Skip to content

Commit 4723309

Browse files
[Feature] Server selection for manual tests (alexjustesen#1763)
* Add pop up * White line * swap name and sponsor, add id * Use GetOoklaSpeedtestServers * Make it Server selection optional * Update Dashboard.php * removed spaces --------- Co-authored-by: Alex Justesen <[email protected]>
1 parent 59677db commit 4723309

File tree

2 files changed

+23
-13
lines changed

2 files changed

+23
-13
lines changed

app/Actions/GetOoklaSpeedtestServers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function handle(): array
3434

3535
return $response->mapWithKeys(function (array $item, int $key) {
3636
return [
37-
$item['id'] => $item['id'].': '.$item['name'].' ('.$item['sponsor'].')',
37+
$item['id'] => $item['sponsor'].' ('.$item['name'].', '.$item['id'].')',
3838
];
3939
})->toArray();
4040
}

app/Filament/Pages/Dashboard.php

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Filament\Pages;
44

5+
use App\Actions\GetOoklaSpeedtestServers;
56
use App\Actions\Ookla\StartSpeedtest;
67
use App\Filament\Widgets\RecentDownloadChartWidget;
78
use App\Filament\Widgets\RecentDownloadLatencyChartWidget;
@@ -13,7 +14,7 @@
1314
use Carbon\Carbon;
1415
use Cron\CronExpression;
1516
use Filament\Actions\Action;
16-
use Filament\Actions\ActionGroup;
17+
use Filament\Forms;
1718
use Filament\Notifications\Notification;
1819
use Filament\Pages\Dashboard as BasePage;
1920
use Filament\Support\Enums\IconPosition;
@@ -49,20 +50,29 @@ protected function getHeaderActions(): array
4950
->color('gray')
5051
->hidden(fn (): bool => ! config('speedtest.public_dashboard'))
5152
->url(shouldOpenInNewTab: true, url: '/'),
52-
ActionGroup::make([
53-
Action::make('ookla speedtest')
54-
->action(function () {
55-
StartSpeedtest::run();
53+
Action::make('ookla_speedtest')
54+
->form([
55+
Forms\Components\Select::make('server_id')
56+
->label('Select Server')
57+
->helperText('Leave blank to run the speedtest without specifying a server.')
58+
->options(fn (callable $get) => app(GetOoklaSpeedtestServers::class)->handle($get('server_search')))
59+
->searchable(),
60+
])
61+
->action(function (array $data) {
62+
$serverId = $data['server_id'] ?? null;
5663

57-
Notification::make()
58-
->title('Ookla speedtest started')
59-
->success()
60-
->send();
61-
}),
62-
])
64+
StartSpeedtest::run(serverId: $serverId);
65+
66+
Notification::make()
67+
->title('Speedtest started')
68+
->success()
69+
->send();
70+
})
71+
->modalHeading('Run Speedtest')
72+
->modalButton('Run Speedtest')
73+
->modalWidth('lg')
6374
->button()
6475
->color('primary')
65-
->dropdownPlacement('bottom-end')
6676
->label('Run Speedtest')
6777
->icon('heroicon-o-rocket-launch')
6878
->iconPosition(IconPosition::Before)

0 commit comments

Comments
 (0)