From 4c514c1a1de36b070be857a0eb8497f367568989 Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Thu, 6 Feb 2025 19:43:34 -0500 Subject: [PATCH 1/2] removed polling config --- app/Filament/Resources/ResultResource.php | 4 +++- .../Resources/ResultResource/Pages/ListResults.php | 5 ----- app/Filament/Widgets/RecentDownloadChartWidget.php | 7 ++----- .../Widgets/RecentDownloadLatencyChartWidget.php | 7 ++----- app/Filament/Widgets/RecentJitterChartWidget.php | 7 ++----- app/Filament/Widgets/RecentPingChartWidget.php | 7 ++----- app/Filament/Widgets/RecentUploadChartWidget.php | 7 ++----- app/Filament/Widgets/RecentUploadLatencyChartWidget.php | 7 ++----- app/Filament/Widgets/StatsOverviewWidget.php | 5 +---- app/Providers/Filament/AdminPanelProvider.php | 1 - config/speedtest.php | 9 --------- 11 files changed, 16 insertions(+), 50 deletions(-) diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index b8edbe82d..2707e2b87 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -438,7 +438,9 @@ public static function table(Table $table): Table ]) ->defaultSort('created_at', 'desc') ->paginated([5, 15, 25, 50, 100]) - ->defaultPaginationPageOption(15); + ->defaultPaginationPageOption(15) + ->deferLoading() + ->poll('60s'); } public static function getPages(): array diff --git a/app/Filament/Resources/ResultResource/Pages/ListResults.php b/app/Filament/Resources/ResultResource/Pages/ListResults.php index c139b6748..80e77d588 100644 --- a/app/Filament/Resources/ResultResource/Pages/ListResults.php +++ b/app/Filament/Resources/ResultResource/Pages/ListResults.php @@ -9,11 +9,6 @@ class ListResults extends ListRecords { protected static string $resource = ResultResource::class; - protected function getTablePollingInterval(): ?string - { - return config('speedtest.results_polling'); - } - protected function getHeaderWidgets(): array { return ResultResource::getWidgets(); diff --git a/app/Filament/Widgets/RecentDownloadChartWidget.php b/app/Filament/Widgets/RecentDownloadChartWidget.php index 3094287ad..53feffba4 100644 --- a/app/Filament/Widgets/RecentDownloadChartWidget.php +++ b/app/Filament/Widgets/RecentDownloadChartWidget.php @@ -16,12 +16,9 @@ class RecentDownloadChartWidget extends ChartWidget protected static ?string $maxHeight = '250px'; - public ?string $filter = '24h'; + protected static ?string $pollingInterval = '60s'; - protected function getPollingInterval(): ?string - { - return config('speedtest.dashboard_polling'); - } + public ?string $filter = '24h'; protected function getFilters(): ?array { diff --git a/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php index 3fbe67d9a..6b75ffc97 100644 --- a/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php +++ b/app/Filament/Widgets/RecentDownloadLatencyChartWidget.php @@ -14,12 +14,9 @@ class RecentDownloadLatencyChartWidget extends ChartWidget protected static ?string $maxHeight = '250px'; - public ?string $filter = '24h'; + protected static ?string $pollingInterval = '60s'; - protected function getPollingInterval(): ?string - { - return config('speedtest.dashboard_polling'); - } + public ?string $filter = '24h'; protected function getFilters(): ?array { diff --git a/app/Filament/Widgets/RecentJitterChartWidget.php b/app/Filament/Widgets/RecentJitterChartWidget.php index 5db523eca..0c88525d6 100644 --- a/app/Filament/Widgets/RecentJitterChartWidget.php +++ b/app/Filament/Widgets/RecentJitterChartWidget.php @@ -14,12 +14,9 @@ class RecentJitterChartWidget extends ChartWidget protected static ?string $maxHeight = '250px'; - public ?string $filter = '24h'; + protected static ?string $pollingInterval = '60s'; - protected function getPollingInterval(): ?string - { - return config('speedtest.dashboard_polling'); - } + public ?string $filter = '24h'; protected function getFilters(): ?array { diff --git a/app/Filament/Widgets/RecentPingChartWidget.php b/app/Filament/Widgets/RecentPingChartWidget.php index 715eddb0e..5077cc6be 100644 --- a/app/Filament/Widgets/RecentPingChartWidget.php +++ b/app/Filament/Widgets/RecentPingChartWidget.php @@ -15,12 +15,9 @@ class RecentPingChartWidget extends ChartWidget protected static ?string $maxHeight = '250px'; - public ?string $filter = '24h'; + protected static ?string $pollingInterval = '60s'; - protected function getPollingInterval(): ?string - { - return config('speedtest.dashboard_polling'); - } + public ?string $filter = '24h'; protected function getFilters(): ?array { diff --git a/app/Filament/Widgets/RecentUploadChartWidget.php b/app/Filament/Widgets/RecentUploadChartWidget.php index 1997ece1e..d58d5c38e 100644 --- a/app/Filament/Widgets/RecentUploadChartWidget.php +++ b/app/Filament/Widgets/RecentUploadChartWidget.php @@ -16,12 +16,9 @@ class RecentUploadChartWidget extends ChartWidget protected static ?string $maxHeight = '250px'; - public ?string $filter = '24h'; + protected static ?string $pollingInterval = '60s'; - protected function getPollingInterval(): ?string - { - return config('speedtest.dashboard_polling'); - } + public ?string $filter = '24h'; protected function getFilters(): ?array { diff --git a/app/Filament/Widgets/RecentUploadLatencyChartWidget.php b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php index c6625cf89..08f2808b4 100644 --- a/app/Filament/Widgets/RecentUploadLatencyChartWidget.php +++ b/app/Filament/Widgets/RecentUploadLatencyChartWidget.php @@ -14,12 +14,9 @@ class RecentUploadLatencyChartWidget extends ChartWidget protected static ?string $maxHeight = '250px'; - public ?string $filter = '24h'; + protected static ?string $pollingInterval = '60s'; - protected function getPollingInterval(): ?string - { - return config('speedtest.dashboard_polling'); - } + public ?string $filter = '24h'; protected function getFilters(): ?array { diff --git a/app/Filament/Widgets/StatsOverviewWidget.php b/app/Filament/Widgets/StatsOverviewWidget.php index 6a7721147..5aaf55e85 100644 --- a/app/Filament/Widgets/StatsOverviewWidget.php +++ b/app/Filament/Widgets/StatsOverviewWidget.php @@ -12,10 +12,7 @@ class StatsOverviewWidget extends BaseWidget { public ?Result $result = null; - protected function getPollingInterval(): ?string - { - return config('speedtest.dashboard_polling'); - } + protected static ?string $pollingInterval = '60s'; protected function getCards(): array { diff --git a/app/Providers/Filament/AdminPanelProvider.php b/app/Providers/Filament/AdminPanelProvider.php index a2202042e..1fcd9a08f 100644 --- a/app/Providers/Filament/AdminPanelProvider.php +++ b/app/Providers/Filament/AdminPanelProvider.php @@ -54,7 +54,6 @@ public function panel(Panel $panel): Panel ->discoverWidgets(in: app_path('Filament/Widgets'), for: 'App\\Filament\\Widgets') ->widgets([]) ->databaseNotifications() - ->databaseNotificationsPolling(config('speedtest.notification_polling')) ->maxContentWidth(config('speedtest.content_width')) ->spa() ->middleware([ diff --git a/config/speedtest.php b/config/speedtest.php index 209a2f6cb..92795cc02 100644 --- a/config/speedtest.php +++ b/config/speedtest.php @@ -17,15 +17,6 @@ 'public_dashboard' => env('PUBLIC_DASHBOARD', false), - /** - * Polling settings. - */ - 'dashboard_polling' => env('DASHBOARD_POLLING', '60s'), - - 'notification_polling' => env('NOTIFICATION_POLLING', '60s'), - - 'results_polling' => env('RESULTS_POLLING', null), - /** * Speedtest settings. */ From ed952b503bba234fff79d35a8b4b474d19d1058b Mon Sep 17 00:00:00 2001 From: Alex Justesen Date: Thu, 6 Feb 2025 20:08:07 -0500 Subject: [PATCH 2/2] Changed default sorting from 'created_at' to 'id' in ResultResource table --- app/Filament/Resources/ResultResource.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index 2707e2b87..f17c0572c 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -436,9 +436,7 @@ public static function table(Table $table): Table ->hidden(fn (): bool => ! Auth::user()->is_admin), ])->dropdownPlacement('bottom-end'), ]) - ->defaultSort('created_at', 'desc') - ->paginated([5, 15, 25, 50, 100]) - ->defaultPaginationPageOption(15) + ->defaultSort('id', 'desc') ->deferLoading() ->poll('60s'); }