Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Actions/GetOoklaSpeedtestServers.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function handle(): array

return $response->mapWithKeys(function (array $item, int $key) {
return [
$item['id'] => $item['id'].': '.$item['name'].' ('.$item['sponsor'].')',
$item['id'] => $item['sponsor'].' ('.$item['name'].', '.$item['id'].')',
];
})->toArray();
}
Expand Down
34 changes: 22 additions & 12 deletions app/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace App\Filament\Pages;

use App\Actions\GetOoklaSpeedtestServers;
use App\Actions\Ookla\StartSpeedtest;
use App\Filament\Widgets\RecentDownloadChartWidget;
use App\Filament\Widgets\RecentDownloadLatencyChartWidget;
Expand All @@ -13,7 +14,7 @@
use Carbon\Carbon;
use Cron\CronExpression;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Forms;
use Filament\Notifications\Notification;
use Filament\Pages\Dashboard as BasePage;
use Filament\Support\Enums\IconPosition;
Expand Down Expand Up @@ -49,20 +50,29 @@ protected function getHeaderActions(): array
->color('gray')
->hidden(fn (): bool => ! config('speedtest.public_dashboard'))
->url(shouldOpenInNewTab: true, url: '/'),
ActionGroup::make([
Action::make('ookla speedtest')
->action(function () {
StartSpeedtest::run();
Action::make('ookla_speedtest')
->form([
Forms\Components\Select::make('server_id')
->label('Select Server')
->helperText('Leave blank to run the speedtest without specifying a server.')
->options(fn (callable $get) => app(GetOoklaSpeedtestServers::class)->handle($get('server_search')))
->searchable(),
])
->action(function (array $data) {
$serverId = $data['server_id'] ?? null;

Notification::make()
->title('Ookla speedtest started')
->success()
->send();
}),
])
StartSpeedtest::run(serverId: $serverId);

Notification::make()
->title('Speedtest started')
->success()
->send();
})
->modalHeading('Run Speedtest')
->modalButton('Run Speedtest')
->modalWidth('lg')
->button()
->color('primary')
->dropdownPlacement('bottom-end')
->label('Run Speedtest')
->icon('heroicon-o-rocket-launch')
->iconPosition(IconPosition::Before)
Expand Down