diff --git a/app/Console/Commands/UpdateGeneralSettings.php b/app/Console/Commands/UpdateGeneralSettings.php
index c9031268f..efd4ee0ac 100644
--- a/app/Console/Commands/UpdateGeneralSettings.php
+++ b/app/Console/Commands/UpdateGeneralSettings.php
@@ -8,6 +8,7 @@
use Illuminate\Console\Command;
use function Laravel\Prompts\confirm;
+use function Laravel\Prompts\select;
use function Laravel\Prompts\text;
class UpdateGeneralSettings extends Command
@@ -34,6 +35,7 @@ public function handle()
$settings = new GeneralSettings();
$this->updateSiteName($settings);
+ $this->updatePublicDashboard($settings);
$this->updateTimeZone($settings);
$this->updateSchedule($settings);
$this->resetSevers($settings);
@@ -57,12 +59,32 @@ protected function resetSevers($settings): void
}
}
+ protected function updatePublicDashboard($settings): void
+ {
+ $publicDashboard = select(
+ label: 'Make the dashboard public?',
+ options: ['Yes', 'No'],
+ default: 'Yes',
+ required: true,
+ );
+
+ if ($publicDashboard == 'Yes') {
+ $settings->public_dashboard_enabled = true;
+
+ $settings->save();
+ } else {
+ $settings->public_dashboard_enabled = false;
+ }
+
+ $settings->save();
+ }
+
protected function updateSchedule($settings): void
{
$cron = text(
label: 'What is the schedule?',
placeholder: '0 * * * *',
- default: $settings->speedtest_schedule,
+ default: $settings->speedtest_schedule ?? '0 * * * *',
required: true,
validate: fn (string $value) => match (true) {
! CronExpression::isValidExpression($value) => 'The schedule expression is invalid.',
diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php
index 5d1427b1c..a0819609e 100644
--- a/app/Filament/Pages/Dashboard.php
+++ b/app/Filament/Pages/Dashboard.php
@@ -13,7 +13,6 @@
use Filament\Actions\ActionGroup;
use Filament\Notifications\Notification;
use Filament\Pages\Dashboard as BasePage;
-use Filament\Support\Enums\ActionSize;
use Filament\Support\Enums\IconPosition;
use Illuminate\Support\Arr;
@@ -30,9 +29,11 @@ protected function getHeaderActions(): array
return [
Action::make('home')
->label('Public Dashboard')
+ ->icon('heroicon-o-chart-bar')
+ ->iconPosition(IconPosition::Before)
->color('gray')
- ->hidden(fn (GeneralSettings $settings): bool => ! $settings->public_dashboard_enabled)
- ->url('/'),
+ ->hidden(fn (): bool => ! config('speedtest.public_dashboard'))
+ ->url(shouldOpenInNewTab: true, url: '/'),
ActionGroup::make([
Action::make('ookla speedtest')
->action(function (GeneralSettings $settings) {
@@ -55,9 +56,8 @@ protected function getHeaderActions(): array
->dropdownPlacement('bottom-end')
->label('Run Speedtest')
->icon('heroicon-o-rocket-launch')
- ->iconPosition(IconPosition::After)
- ->hidden(! auth()->user()->is_admin)
- ->size(ActionSize::Small),
+ ->iconPosition(IconPosition::Before)
+ ->hidden(! auth()->user()->is_admin),
];
}
diff --git a/app/Filament/Pages/Settings/GeneralPage.php b/app/Filament/Pages/Settings/GeneralPage.php
index 3ca1bae59..498c91f66 100644
--- a/app/Filament/Pages/Settings/GeneralPage.php
+++ b/app/Filament/Pages/Settings/GeneralPage.php
@@ -49,11 +49,13 @@ public function form(Form $form): Form
Forms\Components\Section::make('Site Settings')
->schema([
Forms\Components\TextInput::make('site_name')
- ->maxLength(50)
- ->required()
+ ->disabled()
+ ->helperText(new HtmlString('⚠️ DEPRECATED: Use APP_NAME environment variable.'))
->columnSpanFull(),
Forms\Components\Toggle::make('public_dashboard_enabled')
- ->label('Public dashboard'),
+ ->label('Public dashboard')
+ ->disabled()
+ ->helperText(new HtmlString('⚠️ DEPRECATED: Use PUBLIC_DASHBOARD environment variable.')),
])
->compact()
->columns([
diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php
index 7ea5aa13f..3f1219c55 100644
--- a/app/Http/Controllers/HomeController.php
+++ b/app/Http/Controllers/HomeController.php
@@ -16,7 +16,7 @@ public function __invoke(Request $request)
{
$settings = new GeneralSettings();
- if (! $settings->public_dashboard_enabled) {
+ if (! config('speedtest.public_dashboard')) {
return redirect()->route('filament.admin.auth.login');
}
diff --git a/app/Listeners/Webhook/SendSpeedtestCompletedNotification.php b/app/Listeners/Webhook/SendSpeedtestCompletedNotification.php
index 9000464d5..262a18525 100644
--- a/app/Listeners/Webhook/SendSpeedtestCompletedNotification.php
+++ b/app/Listeners/Webhook/SendSpeedtestCompletedNotification.php
@@ -3,7 +3,6 @@
namespace App\Listeners\Webhook;
use App\Events\SpeedtestCompleted;
-use App\Settings\GeneralSettings;
use App\Settings\NotificationSettings;
use Illuminate\Support\Facades\Log;
use Spatie\WebhookServer\WebhookCall;
@@ -15,8 +14,6 @@ class SendSpeedtestCompletedNotification
*/
public function handle(SpeedtestCompleted $event): void
{
- $generalSettings = new GeneralSettings();
-
$notificationSettings = new NotificationSettings();
if (! $notificationSettings->webhook_enabled) {
@@ -38,7 +35,7 @@ public function handle(SpeedtestCompleted $event): void
->url($url['url'])
->payload([
'result_id' => $event->result->id,
- 'site_name' => $generalSettings->site_name,
+ 'site_name' => config('app.name'),
'ping' => $event->result->ping,
'download' => $event->result->downloadBits,
'upload' => $event->result->uploadBits,
diff --git a/app/Listeners/Webhook/SendSpeedtestThresholdNotification.php b/app/Listeners/Webhook/SendSpeedtestThresholdNotification.php
index 6af4d5bda..11b46d2df 100644
--- a/app/Listeners/Webhook/SendSpeedtestThresholdNotification.php
+++ b/app/Listeners/Webhook/SendSpeedtestThresholdNotification.php
@@ -4,7 +4,6 @@
use App\Events\SpeedtestCompleted;
use App\Helpers\Number;
-use App\Settings\GeneralSettings;
use App\Settings\NotificationSettings;
use App\Settings\ThresholdSettings;
use Illuminate\Support\Facades\Log;
@@ -33,8 +32,6 @@ public function handle(SpeedtestCompleted $event): void
return;
}
- $generalSettings = new GeneralSettings();
-
$thresholdSettings = new ThresholdSettings();
if (! $thresholdSettings->absolute_enabled) {
@@ -68,7 +65,7 @@ public function handle(SpeedtestCompleted $event): void
->url($url['url'])
->payload([
'result_id' => $event->result->id,
- 'site_name' => $generalSettings->site_name,
+ 'site_name' => config('app.name'),
'metrics' => $failed,
])
->doNotSign()
diff --git a/app/Settings/GeneralSettings.php b/app/Settings/GeneralSettings.php
index 234bf6f4b..3e5b6ae3c 100644
--- a/app/Settings/GeneralSettings.php
+++ b/app/Settings/GeneralSettings.php
@@ -15,6 +15,9 @@ class GeneralSettings extends Settings
/** @var string[] */
public $speedtest_server;
+ /**
+ * @deprecated Use APP_NAME environment variable.
+ */
public string $site_name;
public string $time_format;
@@ -23,6 +26,9 @@ class GeneralSettings extends Settings
public bool $db_has_timezone;
+ /**
+ * @deprecated Use PUBLIC_DASHBOARD environment variable.
+ */
public bool $public_dashboard_enabled;
public static function group(): string
diff --git a/app/helpers.php b/app/helpers.php
index 068e47a29..8684022ce 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -62,7 +62,7 @@ function absolutePingThresholdFailed(float $threshold, float $ping): bool
* @deprecated
*
* @param string $data
- * @return bool
+ * @return bool
*/
if (! function_exists('json_validate')) {
function json_validate($data)
diff --git a/config/speedtest.php b/config/speedtest.php
index 7bb679e7d..3c2796be4 100644
--- a/config/speedtest.php
+++ b/config/speedtest.php
@@ -6,15 +6,17 @@
/**
* Build information
*/
- 'build_date' => Carbon::parse('2024-03-14'),
+ 'build_date' => Carbon::parse('2024-03-30'),
- 'build_version' => 'v0.18.3',
+ 'build_version' => 'v0.18.4',
/**
* General
*/
'content_width' => env('CONTENT_WIDTH', '7xl'),
+ 'public_dashboard' => env('PUBLIC_DASHBOARD', false),
+
/**
* Polling
*/
diff --git a/database/migrations/2022_08_31_202106_create_results_table.php b/database/migrations/2022_08_31_202106_create_results_table.php
index 682125f34..4b8429117 100644
--- a/database/migrations/2022_08_31_202106_create_results_table.php
+++ b/database/migrations/2022_08_31_202106_create_results_table.php
@@ -32,6 +32,6 @@ public function up(): void
*/
public function down(): void
{
- //
+ Schema::dropIfExists('results');
}
};