diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index 03d38937c..301063e65 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -41,6 +41,13 @@ public function render(): View ->layout(static::$layout, $this->getLayoutData()); } + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getActions(): array { return [ diff --git a/app/Filament/Pages/Settings/GeneralPage.php b/app/Filament/Pages/Settings/GeneralPage.php index 27ccc2ebf..d1ae4fc51 100644 --- a/app/Filament/Pages/Settings/GeneralPage.php +++ b/app/Filament/Pages/Settings/GeneralPage.php @@ -26,6 +26,13 @@ class GeneralPage extends SettingsPage protected static string $settings = GeneralSettings::class; + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getFormSchema(): array { return [ @@ -53,6 +60,11 @@ protected function getFormSchema(): array ->placeholder('M j, Y G:i:s') ->maxLength(25) ->required(), + Select::make('content_width') + ->options([ + '7xl' => 'Default width', + 'full' => 'Full width', + ]), ]) ->compact() ->columns([ diff --git a/app/Filament/Pages/Settings/InfluxDbPage.php b/app/Filament/Pages/Settings/InfluxDbPage.php index e0789ea9a..1c8937db4 100644 --- a/app/Filament/Pages/Settings/InfluxDbPage.php +++ b/app/Filament/Pages/Settings/InfluxDbPage.php @@ -2,6 +2,7 @@ namespace App\Filament\Pages\Settings; +use App\Settings\GeneralSettings; use App\Settings\InfluxDbSettings; use Closure; use Filament\Forms\Components\Grid; @@ -24,6 +25,13 @@ class InfluxDbPage extends SettingsPage protected static string $settings = InfluxDbSettings::class; + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getFormSchema(): array { return [ diff --git a/app/Filament/Pages/Settings/NotificationPage.php b/app/Filament/Pages/Settings/NotificationPage.php index 155ce86f7..0b4300700 100755 --- a/app/Filament/Pages/Settings/NotificationPage.php +++ b/app/Filament/Pages/Settings/NotificationPage.php @@ -6,6 +6,7 @@ use App\Forms\Components\TestMailNotification; use App\Forms\Components\TestTelegramNotification; use App\Mail\Test; +use App\Settings\GeneralSettings; use App\Settings\NotificationSettings; use App\Telegram\TelegramNotification; use Closure; @@ -35,6 +36,13 @@ class NotificationPage extends SettingsPage protected static string $settings = NotificationSettings::class; + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getFormSchema(): array { return [ diff --git a/app/Filament/Pages/Settings/ThresholdsPage.php b/app/Filament/Pages/Settings/ThresholdsPage.php index 192784c70..5e7790ac9 100644 --- a/app/Filament/Pages/Settings/ThresholdsPage.php +++ b/app/Filament/Pages/Settings/ThresholdsPage.php @@ -27,6 +27,13 @@ class ThresholdsPage extends SettingsPage protected static string $settings = ThresholdSettings::class; + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getFormSchema(): array { return [ diff --git a/app/Filament/Resources/ResultResource/Pages/ListResults.php b/app/Filament/Resources/ResultResource/Pages/ListResults.php index 6e7dc9cc8..fd954e20a 100644 --- a/app/Filament/Resources/ResultResource/Pages/ListResults.php +++ b/app/Filament/Resources/ResultResource/Pages/ListResults.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\ResultResource\Pages; use App\Filament\Resources\ResultResource; +use App\Settings\GeneralSettings; use Filament\Resources\Pages\ListRecords; class ListResults extends ListRecords @@ -14,6 +15,13 @@ protected function getTablePollingInterval(): ?string return '5s'; } + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getHeaderWidgets(): array { return ResultResource::getWidgets(); diff --git a/app/Filament/Resources/UserResource/Pages/CreateUser.php b/app/Filament/Resources/UserResource/Pages/CreateUser.php index 78a389490..28ffe65b3 100644 --- a/app/Filament/Resources/UserResource/Pages/CreateUser.php +++ b/app/Filament/Resources/UserResource/Pages/CreateUser.php @@ -3,9 +3,17 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource; +use App\Settings\GeneralSettings; use Filament\Resources\Pages\CreateRecord; class CreateUser extends CreateRecord { protected static string $resource = UserResource::class; + + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } } diff --git a/app/Filament/Resources/UserResource/Pages/EditUser.php b/app/Filament/Resources/UserResource/Pages/EditUser.php index 7fc2e871c..821933578 100644 --- a/app/Filament/Resources/UserResource/Pages/EditUser.php +++ b/app/Filament/Resources/UserResource/Pages/EditUser.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource; +use App\Settings\GeneralSettings; use Filament\Pages\Actions; use Filament\Resources\Pages\EditRecord; use Illuminate\Support\Facades\Hash; @@ -11,6 +12,13 @@ class EditUser extends EditRecord { protected static string $resource = UserResource::class; + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getActions(): array { return [ diff --git a/app/Filament/Resources/UserResource/Pages/ListUsers.php b/app/Filament/Resources/UserResource/Pages/ListUsers.php index 54c3be834..30c1f6238 100644 --- a/app/Filament/Resources/UserResource/Pages/ListUsers.php +++ b/app/Filament/Resources/UserResource/Pages/ListUsers.php @@ -3,6 +3,7 @@ namespace App\Filament\Resources\UserResource\Pages; use App\Filament\Resources\UserResource; +use App\Settings\GeneralSettings; use Filament\Pages\Actions; use Filament\Resources\Pages\ListRecords; @@ -10,6 +11,13 @@ class ListUsers extends ListRecords { protected static string $resource = UserResource::class; + protected function getMaxContentWidth(): string + { + $settings = new GeneralSettings(); + + return $settings->content_width; + } + protected function getActions(): array { return [ diff --git a/app/Settings/GeneralSettings.php b/app/Settings/GeneralSettings.php index ee48bc82b..6c1e6a11e 100644 --- a/app/Settings/GeneralSettings.php +++ b/app/Settings/GeneralSettings.php @@ -8,6 +8,8 @@ class GeneralSettings extends Settings { public bool $auth_enabled; + public string $content_width; + public ?string $speedtest_schedule; /** @var string[] */ diff --git a/database/migrations/2022_12_16_164913_transform_speedtest_server_id.php b/database/migrations/2022_12_16_164913_transform_speedtest_server_id.php index 58059f8ca..4f9cd414f 100644 --- a/database/migrations/2022_12_16_164913_transform_speedtest_server_id.php +++ b/database/migrations/2022_12_16_164913_transform_speedtest_server_id.php @@ -12,9 +12,13 @@ */ public function up() { - $settings = new GeneralSettings(); + try { + $settings = new GeneralSettings(); - $settings->speedtest_server = [$settings->speedtest_server]; - $settings->save(); + $settings->speedtest_server = [$settings->speedtest_server]; + $settings->save(); + } catch (\Throwable $th) { + // This code is short lived as it'll be replaced with a jobs table... + } } }; diff --git a/database/settings/2023_03_05_233042_add_content_width_to_general_settings.php b/database/settings/2023_03_05_233042_add_content_width_to_general_settings.php new file mode 100644 index 000000000..22e74b349 --- /dev/null +++ b/database/settings/2023_03_05_233042_add_content_width_to_general_settings.php @@ -0,0 +1,11 @@ +migrator->add('general.content_width', '7xl'); + } +};