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
7 changes: 7 additions & 0 deletions app/Filament/Pages/Dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use App\Filament\Widgets\RecentUploadChartWidget;
use App\Filament\Widgets\RecentUploadLatencyChartWidget;
use App\Filament\Widgets\StatsOverviewWidget;
use App\Helpers\Ookla;
use Carbon\Carbon;
use Cron\CronExpression;
use Filament\Actions\Action;
Expand Down Expand Up @@ -57,6 +58,12 @@ protected function getHeaderActions(): array
->label('Select Server')
->helperText('Leave empty to run the speedtest without specifying a server.')
->options(fn (): array => GetOoklaSpeedtestServers::run())
->options(function (): array {
return array_filter([
'Manual servers' => Ookla::getConfigServers(),
'Closest servers' => GetOoklaSpeedtestServers::run(),
]);
})
->searchable(),
])
->action(function (array $data) {
Expand Down
24 changes: 24 additions & 0 deletions app/Helpers/Ookla.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,28 @@ public static function getErrorMessage(ProcessFailedException $exception): strin

return $errorMessage;
}

public static function getConfigServers(): ?array
{
$list = [];

if (blank(config('speedtest.servers'))) {
return null;
}

$servers = collect(array_map(
'trim',
explode(',', config('speedtest.servers'))
));

if (! count($servers)) {
return null;
}

$list = $servers->mapWithKeys(function ($serverId) {
return [$serverId => $serverId.' (Config server)'];
})->sort()->toArray();

return $list;
}
}
2 changes: 1 addition & 1 deletion config/speedtest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
*/
'schedule' => env('SPEEDTEST_SCHEDULE', false),

'servers' => env('SPEEDTEST_SERVERS', ''),
'servers' => env('SPEEDTEST_SERVERS'),

/**
* IP filtering settings.
Expand Down