feat: plugin analytics avec custom field kirbyup + Chart.js
Refactoring complet du plugin analytics : remplacement de la section avec template Vue inline par un custom field compilé avec kirbyup. Dashboard avec KPIs, line chart Chart.js et filtres par date. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
7371e66ec1
commit
8a73da920f
15 changed files with 873 additions and 0 deletions
37
public/site/plugins/analytics/classes/AnalyticsPage.php
Normal file
37
public/site/plugins/analytics/classes/AnalyticsPage.php
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace adrienpayet\analytics;
|
||||
|
||||
use Kirby\Cms\Page;
|
||||
|
||||
class AnalyticsPage extends Page
|
||||
{
|
||||
public function getAnalyticsData(array $filters = []): array
|
||||
{
|
||||
$user = kirby()->user();
|
||||
|
||||
if (!$user) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($user->isAdmin()) {
|
||||
return AnalyticsStore::getAggregatedData($filters);
|
||||
}
|
||||
|
||||
$allowedProjects = $user->currentProjects();
|
||||
$allowedEmails = [];
|
||||
foreach ($allowedProjects as $project) {
|
||||
$users = kirby()->users();
|
||||
foreach ($users as $u) {
|
||||
if ($u->currentProjects()->has($project)) {
|
||||
$allowedEmails[] = $u->email()->value();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$filters['emails'] = array_unique($allowedEmails);
|
||||
|
||||
return AnalyticsStore::getAggregatedData($filters);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue