22
33namespace App \Filament \Pages ;
44
5- use App \Actions \GetOoklaSpeedtestServers ;
6- use App \Actions \Ookla \StartSpeedtest ;
75use App \Filament \Widgets \RecentDownloadChartWidget ;
86use App \Filament \Widgets \RecentDownloadLatencyChartWidget ;
97use App \Filament \Widgets \RecentJitterChartWidget ;
108use App \Filament \Widgets \RecentPingChartWidget ;
119use App \Filament \Widgets \RecentUploadChartWidget ;
1210use App \Filament \Widgets \RecentUploadLatencyChartWidget ;
1311use App \Filament \Widgets \StatsOverviewWidget ;
14- use App \Helpers \Ookla ;
1512use Carbon \Carbon ;
1613use Cron \CronExpression ;
17- use Filament \Actions \Action ;
18- use Filament \Forms ;
19- use Filament \Notifications \Notification ;
2014use Filament \Pages \Dashboard as BasePage ;
21- use Filament \Support \Enums \IconPosition ;
2215
2316class Dashboard extends BasePage
2417{
@@ -41,55 +34,6 @@ public function getSubheading(): ?string
4134 return 'Next speedtest at: ' .$ nextRunDate ;
4235 }
4336
44- protected function getHeaderActions (): array
45- {
46- return [
47- Action::make ('home ' )
48- ->label ('Public Dashboard ' )
49- ->icon ('heroicon-o-chart-bar ' )
50- ->iconPosition (IconPosition::Before)
51- ->color ('gray ' )
52- ->hidden (fn (): bool => ! config ('speedtest.public_dashboard ' ))
53- ->url (shouldOpenInNewTab: true , url: '/ ' ),
54-
55- Action::make ('speedtest ' )
56- ->form ([
57- Forms \Components \Select::make ('server_id ' )
58- ->label ('Select Server ' )
59- ->helperText ('Leave empty to run the speedtest without specifying a server. ' )
60- ->options (function (): array {
61- return array_filter ([
62- 'Manual servers ' => Ookla::getConfigServers (),
63- 'Closest servers ' => GetOoklaSpeedtestServers::run (),
64- ]);
65- })
66- ->searchable (),
67- ])
68- ->action (function (array $ data ) {
69- $ serverId = $ data ['server_id ' ] ?? null ;
70-
71- StartSpeedtest::run (
72- scheduled: false ,
73- serverId: $ serverId ,
74- );
75-
76- Notification::make ()
77- ->title ('Speedtest started ' )
78- ->success ()
79- ->send ();
80- })
81- ->modalHeading ('Run Speedtest ' )
82- ->modalWidth ('lg ' )
83- ->modalSubmitActionLabel ('Start ' )
84- ->button ()
85- ->color ('primary ' )
86- ->label ('Run Speedtest ' )
87- ->icon ('heroicon-o-rocket-launch ' )
88- ->iconPosition (IconPosition::Before)
89- ->hidden (! auth ()->user ()->is_admin ),
90- ];
91- }
92-
9337 protected function getHeaderWidgets (): array
9438 {
9539 return [
0 commit comments