feat: add monitoring dashboard stats and charts with updated role permissions
This commit is contained in:
parent
3b286cbc7a
commit
1bc2528256
@ -4,7 +4,10 @@
|
||||
|
||||
use App\Filament\Widgets\Charts\BudgetRealizationChart;
|
||||
use App\Filament\Widgets\Charts\CooperationStatusChart;
|
||||
use App\Filament\Widgets\Charts\IssueLocationChart;
|
||||
use App\Filament\Widgets\Charts\IssueSentimentByDepartmentChart;
|
||||
use App\Filament\Widgets\Charts\PopularNewsChart;
|
||||
use App\Filament\Widgets\Charts\SentimentTrendChart;
|
||||
use App\Filament\Widgets\Stats\OverviewStats;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
use Filament\Pages\Dashboard as BaseDashboard;
|
||||
@ -28,6 +31,9 @@ public function getWidgets(): array
|
||||
OverviewStats::class,
|
||||
BudgetRealizationChart::class,
|
||||
PopularNewsChart::class,
|
||||
SentimentTrendChart::class,
|
||||
IssueSentimentByDepartmentChart::class,
|
||||
IssueLocationChart::class,
|
||||
CooperationStatusChart::class,
|
||||
];
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Journalist;
|
||||
use App\Models\Location;
|
||||
use App\Models\MediaMonitoring;
|
||||
use App\Models\News;
|
||||
use App\Models\PartnerMedia;
|
||||
use App\Models\Theme;
|
||||
@ -48,6 +49,10 @@ protected function getStats(): array
|
||||
return $this->getContentAdminStats();
|
||||
}
|
||||
|
||||
if ($user && $user->hasRole(RoleEnum::ADMIN_MONITORING->value)) {
|
||||
return $this->getMonitoringStats();
|
||||
}
|
||||
|
||||
$totalJournalists = Journalist::count();
|
||||
$totalMedia = PartnerMedia::count();
|
||||
$average = $totalMedia > 0 ? round($totalJournalists / $totalMedia, 1) : 0;
|
||||
@ -228,4 +233,29 @@ private function getContentAdminStats(): array
|
||||
->color('warning'),
|
||||
];
|
||||
}
|
||||
|
||||
private function getMonitoringStats(): array
|
||||
{
|
||||
return [
|
||||
Stat::make('Total Isu (Masalah)', IssueManagement::count())
|
||||
->description('Manajemen Isu')
|
||||
->descriptionIcon('heroicon-o-exclamation-circle')
|
||||
->color('primary'),
|
||||
|
||||
Stat::make('Isu Kritis / Negatif', IssueManagement::whereIn('issue', [IssueSentiment::NEGATIVE, IssueSentiment::CRISIS])->count())
|
||||
->description('Perhatian Khusus')
|
||||
->descriptionIcon('heroicon-o-exclamation-triangle')
|
||||
->color('danger'),
|
||||
|
||||
Stat::make('Total Media Monitoring', MediaMonitoring::count())
|
||||
->description('Berita terpantau')
|
||||
->descriptionIcon('heroicon-o-globe-alt')
|
||||
->color($this->getRandomColor()),
|
||||
|
||||
Stat::make('Total Lokus', Location::active()->count())
|
||||
->description('Lokus aktif')
|
||||
->descriptionIcon('heroicon-o-map-pin')
|
||||
->color($this->getRandomColor()),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,8 +530,6 @@ public function run(): void
|
||||
"name": "Admin Monitoring",
|
||||
"guard_name": "web",
|
||||
"permissions": [
|
||||
"View:Analytic",
|
||||
|
||||
"ViewAny:Classification",
|
||||
"View:Classification",
|
||||
"Create:Classification",
|
||||
@ -546,6 +544,8 @@ public function run(): void
|
||||
|
||||
"View:Dashboard",
|
||||
|
||||
"View:IssueLocationChart",
|
||||
|
||||
"ViewAny:IssueManagement",
|
||||
"View:IssueManagement",
|
||||
"Create:IssueManagement",
|
||||
@ -558,6 +558,8 @@ public function run(): void
|
||||
"Replicate:IssueManagement",
|
||||
"Reorder:IssueManagement",
|
||||
|
||||
"View:IssueSentimentByDepartmentChart",
|
||||
|
||||
"ViewAny:Location",
|
||||
"View:Location",
|
||||
"Create:Location",
|
||||
@ -582,6 +584,10 @@ public function run(): void
|
||||
"Replicate:MediaMonitoring",
|
||||
"Reorder:MediaMonitoring",
|
||||
|
||||
"View:OverviewStats",
|
||||
|
||||
"View:SentimentTrendChart",
|
||||
|
||||
"ViewAny:SubClassification",
|
||||
"View:SubClassification",
|
||||
"Create:SubClassification",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user