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\BudgetRealizationChart;
|
||||||
use App\Filament\Widgets\Charts\CooperationStatusChart;
|
use App\Filament\Widgets\Charts\CooperationStatusChart;
|
||||||
|
use App\Filament\Widgets\Charts\PopularNewsChart;
|
||||||
use App\Filament\Widgets\Stats\OverviewStats;
|
use App\Filament\Widgets\Stats\OverviewStats;
|
||||||
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
use BezhanSalleh\FilamentShield\Traits\HasPageShield;
|
||||||
use Filament\Pages\Dashboard as BaseDashboard;
|
use Filament\Pages\Dashboard as BaseDashboard;
|
||||||
@ -26,6 +27,7 @@ public function getWidgets(): array
|
|||||||
return [
|
return [
|
||||||
OverviewStats::class,
|
OverviewStats::class,
|
||||||
BudgetRealizationChart::class,
|
BudgetRealizationChart::class,
|
||||||
|
PopularNewsChart::class,
|
||||||
CooperationStatusChart::class,
|
CooperationStatusChart::class,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,14 @@
|
|||||||
use App\Enums\IssueSentiment;
|
use App\Enums\IssueSentiment;
|
||||||
use App\Enums\RoleEnum;
|
use App\Enums\RoleEnum;
|
||||||
use App\Models\Classification;
|
use App\Models\Classification;
|
||||||
|
use App\Models\ContentRecap;
|
||||||
use App\Models\CooperationPayment;
|
use App\Models\CooperationPayment;
|
||||||
use App\Models\DataChangeRequest;
|
use App\Models\DataChangeRequest;
|
||||||
use App\Models\Department;
|
use App\Models\Department;
|
||||||
use App\Models\IssueManagement;
|
use App\Models\IssueManagement;
|
||||||
use App\Models\Journalist;
|
use App\Models\Journalist;
|
||||||
use App\Models\Location;
|
use App\Models\Location;
|
||||||
|
use App\Models\News;
|
||||||
use App\Models\PartnerMedia;
|
use App\Models\PartnerMedia;
|
||||||
use App\Models\Theme;
|
use App\Models\Theme;
|
||||||
use App\Models\VerificationRequest;
|
use App\Models\VerificationRequest;
|
||||||
@ -42,6 +44,10 @@ protected function getStats(): array
|
|||||||
return $this->getFinanceStats();
|
return $this->getFinanceStats();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($user && $user->hasRole(RoleEnum::ADMIN_KONTEN->value)) {
|
||||||
|
return $this->getContentAdminStats();
|
||||||
|
}
|
||||||
|
|
||||||
$totalJournalists = Journalist::count();
|
$totalJournalists = Journalist::count();
|
||||||
$totalMedia = PartnerMedia::count();
|
$totalMedia = PartnerMedia::count();
|
||||||
$average = $totalMedia > 0 ? round($totalJournalists / $totalMedia, 1) : 0;
|
$average = $totalMedia > 0 ? round($totalJournalists / $totalMedia, 1) : 0;
|
||||||
@ -197,4 +203,29 @@ private function getFinanceStats(): array
|
|||||||
->color('danger'),
|
->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",
|
"name": "Admin Konten",
|
||||||
"guard_name": "web",
|
"guard_name": "web",
|
||||||
"permissions": [
|
"permissions": [
|
||||||
"View:Analytic",
|
|
||||||
|
|
||||||
"ViewAny:Classification",
|
"ViewAny:Classification",
|
||||||
"View:Classification",
|
"View:Classification",
|
||||||
"Create:Classification",
|
"Create:Classification",
|
||||||
@ -673,7 +671,23 @@ public function run(): void
|
|||||||
"ForceDeleteAny:News",
|
"ForceDeleteAny:News",
|
||||||
"RestoreAny:News",
|
"RestoreAny:News",
|
||||||
"Replicate: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