feat: add PopularNewsChart to dashboard and implement ContentAdminStats with updated Shield permissions
This commit is contained in:
parent
ddfd1ab340
commit
3b286cbc7a
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Filament\Widgets\Charts\BudgetRealizationChart;
|
||||
use App\Filament\Widgets\Charts\CooperationStatusChart;
|
||||
use App\Filament\Widgets\Charts\PopularNewsChart;
|
||||
use App\Filament\Widgets\Stats\OverviewStats;
|
||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||
use Filament\Pages\Dashboard as BaseDashboard;
|
||||
@ -26,6 +27,7 @@ public function getWidgets(): array
|
||||
return [
|
||||
OverviewStats::class,
|
||||
BudgetRealizationChart::class,
|
||||
PopularNewsChart::class,
|
||||
CooperationStatusChart::class,
|
||||
];
|
||||
}
|
||||
|
||||
@ -6,12 +6,14 @@
|
||||
use App\Enums\IssueSentiment;
|
||||
use App\Enums\RoleEnum;
|
||||
use App\Models\Classification;
|
||||
use App\Models\ContentRecap;
|
||||
use App\Models\CooperationPayment;
|
||||
use App\Models\DataChangeRequest;
|
||||
use App\Models\Department;
|
||||
use App\Models\IssueManagement;
|
||||
use App\Models\Journalist;
|
||||
use App\Models\Location;
|
||||
use App\Models\News;
|
||||
use App\Models\PartnerMedia;
|
||||
use App\Models\Theme;
|
||||
use App\Models\VerificationRequest;
|
||||
@ -42,6 +44,10 @@ protected function getStats(): array
|
||||
return $this->getFinanceStats();
|
||||
}
|
||||
|
||||
if ($user && $user->hasRole(RoleEnum::ADMIN_KONTEN->value)) {
|
||||
return $this->getContentAdminStats();
|
||||
}
|
||||
|
||||
$totalJournalists = Journalist::count();
|
||||
$totalMedia = PartnerMedia::count();
|
||||
$average = $totalMedia > 0 ? round($totalJournalists / $totalMedia, 1) : 0;
|
||||
@ -197,4 +203,29 @@ private function getFinanceStats(): array
|
||||
->color('danger'),
|
||||
];
|
||||
}
|
||||
|
||||
private function getContentAdminStats(): array
|
||||
{
|
||||
return [
|
||||
Stat::make('Total Klasifikasi', Classification::active()->count())
|
||||
->description('Klasifikasi aktif')
|
||||
->descriptionIcon('heroicon-o-book-open')
|
||||
->color($this->getRandomColor()),
|
||||
|
||||
Stat::make('Total Rekap Konten', ContentRecap::count())
|
||||
->description('Konten direkap')
|
||||
->descriptionIcon('heroicon-o-document-duplicate')
|
||||
->color($this->getRandomColor()),
|
||||
|
||||
Stat::make('Total Berita', News::count())
|
||||
->description('Berita dipublikasikan')
|
||||
->descriptionIcon('heroicon-o-newspaper')
|
||||
->color($this->getRandomColor()),
|
||||
|
||||
Stat::make('Berita Terpopuler', number_format(News::max('views') ?? 0, 0, ',', '.'))
|
||||
->description('Views tertinggi')
|
||||
->descriptionIcon('heroicon-o-star')
|
||||
->color('warning'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@ -635,8 +635,6 @@ public function run(): void
|
||||
"name": "Admin Konten",
|
||||
"guard_name": "web",
|
||||
"permissions": [
|
||||
"View:Analytic",
|
||||
|
||||
"ViewAny:Classification",
|
||||
"View:Classification",
|
||||
"Create:Classification",
|
||||
@ -673,7 +671,23 @@ public function run(): void
|
||||
"ForceDeleteAny:News",
|
||||
"RestoreAny:News",
|
||||
"Replicate:News",
|
||||
"Reorder:News"
|
||||
"Reorder:News",
|
||||
|
||||
"View:OverviewStats",
|
||||
|
||||
"View:PopularNewsChart",
|
||||
|
||||
"ViewAny:SubClassification",
|
||||
"View:SubClassification",
|
||||
"Create:SubClassification",
|
||||
"Update:SubClassification",
|
||||
"Delete:SubClassification",
|
||||
"Restore:SubClassification",
|
||||
"ForceDelete:SubClassification",
|
||||
"ForceDeleteAny:SubClassification",
|
||||
"RestoreAny:SubClassification",
|
||||
"Replicate:SubClassification",
|
||||
"Reorder:SubClassification"
|
||||
]
|
||||
},
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user