Skip to content

Commit 8ee65d8

Browse files
committed
Updating dashboard layout and adding footer info
Update dashboard widgets to be scoped by user id
1 parent 6dd91a6 commit 8ee65d8

File tree

11 files changed

+341
-16
lines changed

11 files changed

+341
-16
lines changed
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace App\Filament\Widgets;
4+
5+
use Filament\Widgets\Widget;
6+
7+
class DiscordWidget extends Widget
8+
{
9+
protected static string $view = 'filament.widgets.discord-widget';
10+
}

app/Filament/Widgets/StatsOverview.php

+19-11
Original file line numberDiff line numberDiff line change
@@ -15,24 +15,32 @@ class StatsOverview extends BaseWidget
1515
{
1616
protected function getStats(): array
1717
{
18-
$lastSynced = Carbon::parse(Playlist::max('synced'));
18+
$lastSynced = Carbon::parse(Playlist::where('user_id', auth()->id())->max('synced'));
1919
$relative = $lastSynced ? $lastSynced->diffForHumans() : null;
20-
21-
$lastSyncedEpg = Carbon::parse(Epg::max('synced'));
20+
$lastSyncedEpg = Carbon::parse(Epg::where('user_id', auth()->id())->max('synced'));
2221
$epgRelative = $lastSyncedEpg ? $lastSyncedEpg->diffForHumans() : null;
2322
return [
24-
Stat::make('Playlists', Playlist::count())
23+
Stat::make('Playlists', Playlist::where('user_id', auth()->id())->count())
2524
->description($relative ? "Last sync $relative" : 'No syncs yet')
2625
->descriptionIcon('heroicon-m-calendar-days'),
27-
Stat::make('Groups', Group::count()),
28-
Stat::make('Total Channels', Channel::count()),
29-
Stat::make('Enabled Channels', Channel::where('enabled', true)->count()),
30-
31-
Stat::make('EPGs', Epg::count())
26+
Stat::make('Groups', Group::where('user_id', auth()->id())->count()),
27+
Stat::make('Total Channels', Channel::where('user_id', auth()->id())->count()),
28+
Stat::make('Enabled Channels', Channel::where(
29+
[
30+
['user_id', auth()->id()],
31+
['enabled', true]
32+
]
33+
)->count()),
34+
Stat::make('EPGs', Epg::where('user_id', auth()->id())->count())
3235
->description($epgRelative ? "Last sync $epgRelative" : 'No syncs yet')
3336
->descriptionIcon('heroicon-m-calendar-days'),
34-
Stat::make('Total EPG Channels', EpgChannel::count()),
35-
Stat::make('EPG Mapped Channels', Channel::where('epg_channel_id', '!=', null)->count()),
37+
Stat::make('Total EPG Channels', EpgChannel::where('user_id', auth()->id())->count()),
38+
Stat::make('EPG Mapped Channels', Channel::where(
39+
[
40+
['user_id', auth()->id()],
41+
['epg_channel_id', '!=', null]
42+
]
43+
)->count()),
3644
];
3745
}
3846
}

app/Providers/Filament/AdminPanelProvider.php

+12-4
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
namespace App\Providers\Filament;
44

5+
use Exception;
56
use App\Filament\Auth\Login;
67
use App\Filament\Auth\EditProfile;
8+
use App\Filament\Widgets\DiscordWidget;
79
use App\Settings\GeneralSettings;
810
use Filament\Http\Middleware\Authenticate;
911
use Filament\Http\Middleware\AuthenticateSession;
@@ -24,9 +26,9 @@
2426
use Illuminate\View\Middleware\ShareErrorsFromSession;
2527
use \Croustibat\FilamentJobsMonitor\FilamentJobsMonitorPlugin;
2628
use Doctrine\DBAL\Query\QueryException;
27-
use Exception;
2829
use Filament\Support\Enums\MaxWidth;
2930
use Hydrat\TableLayoutToggle\TableLayoutTogglePlugin;
31+
use Devonab\FilamentEasyFooter\EasyFooterPlugin;
3032

3133
class AdminPanelProvider extends PanelProvider
3234
{
@@ -79,16 +81,22 @@ public function panel(Panel $panel): Panel
7981
->breadcrumbs($settings['show_breadcrumbs'])
8082
->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets')
8183
->widgets([
82-
// Widgets\AccountWidget::class,
83-
// Widgets\FilamentInfoWidget::class,
84+
Widgets\AccountWidget::class,
85+
DiscordWidget::class,
8486
])
8587
->plugins([
8688
FilamentJobsMonitorPlugin::make()
8789
->enableNavigation($settings['show_jobs_navigation'] ?? false),
8890
TableLayoutTogglePlugin::make(),
91+
EasyFooterPlugin::make()
92+
->withBorder()
93+
->withGithub(showLogo: true, showUrl: true)
94+
->withLogo('/images/logo-mark.svg', 'https://brightmindedmedia.com', 30)
95+
// ->withLinks([
96+
// ['title' => 'Join us on discord', 'url' => 'https://discord.gg/szPUzZT6'],
97+
// ]),
8998
])
9099
->maxContentWidth($settings['content_width'])
91-
// ->simplePageMaxContentWidth(MaxWidth::Small) // Login, sign in, etc.
92100
->middleware([
93101
EncryptCookies::class,
94102
AddQueuedCookiesToResponse::class,

composer.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"require": {
99
"php": "^8.2",
1010
"croustibat/filament-jobs-monitor": "^2.5",
11+
"devonab/filament-easy-footer": "^1.0",
1112
"dragonmantank/cron-expression": "^3.4",
1213
"filament/filament": "^3.2",
1314
"filament/spatie-laravel-settings-plugin": "^3.2",

composer.lock

+80-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/filament-easy-footer.php

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
return [
4+
'app_name' => 'm3u editor',
5+
'github' => [
6+
'repository' => 'sparkison/m3u-editor',
7+
'token' => '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',
8+
'cache_ttl' => 3600,
9+
],
10+
];

0 commit comments

Comments
 (0)