diff --git a/app/Filament/Pages/Settings/DataIntegrationPage.php b/app/Filament/Pages/Settings/DataIntegrationPage.php index 391577432..16a48284e 100644 --- a/app/Filament/Pages/Settings/DataIntegrationPage.php +++ b/app/Filament/Pages/Settings/DataIntegrationPage.php @@ -15,6 +15,7 @@ use Filament\Forms\Form; use Filament\Notifications\Notification; use Filament\Pages\SettingsPage; +use Filament\Support\Enums\MaxWidth; use Illuminate\Support\Facades\Auth; class DataIntegrationPage extends SettingsPage @@ -41,92 +42,95 @@ public static function shouldRegisterNavigation(): bool return Auth::check() && Auth::user()->is_admin; } + public function getMaxContentWidth(): MaxWidth + { + return MaxWidth::ThreeExtraLarge; + } + public function form(Form $form): Form { return $form ->schema([ - Grid::make([ - 'default' => 1, - 'md' => 3, - ]) + Section::make('InfluxDB v2') + ->description('When enabled, all new Speedtest results will also be sent to InfluxDB.') ->schema([ - Section::make('InfluxDB v2') - ->description('When enabled, all new Speedtest results will also be sent to InfluxDB.') + Forms\Components\Toggle::make('influxdb_v2_enabled') + ->label('Enable') + ->reactive() + ->columnSpanFull(), + + Grid::make(['default' => 1, 'md' => 2]) + ->hidden(fn (Forms\Get $get) => $get('influxdb_v2_enabled') !== true) ->schema([ - Forms\Components\Toggle::make('influxdb_v2_enabled') - ->label('Enable') - ->reactive() + TextInput::make('influxdb_v2_url') + ->label('URL') + ->placeholder('http://your-influxdb-instance') + ->maxLength(255) + ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) + ->columnSpan(['md' => 1]), + TextInput::make('influxdb_v2_org') + ->label('Org') + ->maxLength(255) + ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) + ->columnSpan(['md' => 1]), + TextInput::make('influxdb_v2_bucket') + ->placeholder('speedtest-tracker') + ->label('Bucket') + ->maxLength(255) + ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) + ->columnSpan(['md' => 2]), + TextInput::make('influxdb_v2_token') + ->label('Token') + ->maxLength(255) + ->password() + ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) + ->autocomplete(false) + ->columnSpan(['md' => 2]), + Checkbox::make('influxdb_v2_verify_ssl') + ->label('Verify SSL') ->columnSpanFull(), - Grid::make(['default' => 1, 'md' => 3]) - ->hidden(fn (Forms\Get $get) => $get('influxdb_v2_enabled') !== true) - ->schema([ - TextInput::make('influxdb_v2_url') - ->label('URL') - ->placeholder('http://your-influxdb-instance') - ->maxLength(255) - ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) - ->columnSpan(['md' => 1]), - TextInput::make('influxdb_v2_org') - ->label('Org') - ->maxLength(255) - ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) - ->columnSpan(['md' => 1]), - TextInput::make('influxdb_v2_bucket') - ->placeholder('speedtest-tracker') - ->label('Bucket') - ->maxLength(255) - ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) - ->columnSpan(['md' => 2]), - TextInput::make('influxdb_v2_token') - ->label('Token') - ->maxLength(255) - ->password() - ->required(fn (Forms\Get $get) => $get('influxdb_v2_enabled') === true) - ->disableAutocomplete() - ->columnSpan(['md' => 2]), - Checkbox::make('influxdb_v2_verify_ssl') - ->label('Verify SSL') - ->columnSpanFull(), - // Button to send old data to InfluxDB - Actions::make([ - Action::make('Export current results') - ->label('Export current results') - ->action(function () { - Notification::make() - ->title('Starting bulk data write to Influxdb') - ->info() - ->send(); + // Button to send old data to InfluxDB + Actions::make([ + Action::make('Export current results') + ->label('Export current results') + ->action(function () { + Notification::make() + ->title('Starting bulk data write to Influxdb') + ->info() + ->send(); - BulkWriteResults::dispatch(Auth::user()); - }) - ->color('primary') - ->icon('heroicon-o-cloud-arrow-up') - ->visible(fn (): bool => app(DataIntegrationSettings::class)->influxdb_v2_enabled), - ]), - // Button to test InfluxDB connection - Actions::make([ - Action::make('Test connection') - ->label('Test connection') - ->action(function () { - Notification::make() - ->title('Sending test data to Influxdb') - ->info() - ->send(); + BulkWriteResults::dispatch(Auth::user()); + }) + ->color('primary') + ->icon('heroicon-o-cloud-arrow-up') + ->visible(fn (): bool => app(DataIntegrationSettings::class)->influxdb_v2_enabled), + ]), + // Button to test InfluxDB connection + Actions::make([ + Action::make('Test connection') + ->label('Test connection') + ->action(function () { + Notification::make() + ->title('Sending test data to Influxdb') + ->info() + ->send(); - TestConnectionJob::dispatch(Auth::user()); - }) - ->color('primary') - ->icon('heroicon-o-check-circle') - ->visible(fn (): bool => app(DataIntegrationSettings::class)->influxdb_v2_enabled), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, + TestConnectionJob::dispatch(Auth::user()); + }) + ->color('primary') + ->icon('heroicon-o-check-circle') + ->visible(fn (): bool => app(DataIntegrationSettings::class)->influxdb_v2_enabled), + ]), ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, ]), + ]) + ->columns([ + 'default' => 1, ]); } } diff --git a/app/Filament/Pages/Settings/NotificationPage.php b/app/Filament/Pages/Settings/NotificationPage.php index 59b63dd8a..83f8e03ca 100755 --- a/app/Filament/Pages/Settings/NotificationPage.php +++ b/app/Filament/Pages/Settings/NotificationPage.php @@ -23,6 +23,7 @@ use Filament\Forms\Components\Toggle; use Filament\Forms\Form; use Filament\Pages\SettingsPage; +use Filament\Support\Enums\MaxWidth; use Illuminate\Support\Facades\Auth; class NotificationPage extends SettingsPage @@ -49,501 +50,480 @@ public static function shouldRegisterNavigation(): bool return Auth::check() && Auth::user()->is_admin; } + public function getMaxContentWidth(): MaxWidth + { + return MaxWidth::ThreeExtraLarge; + } + public function form(Form $form): Form { return $form ->schema([ - Grid::make([ - 'default' => 1, - 'md' => 3, - ]) + Section::make('Database') + ->description('Notifications sent to this channel will show up under the 🔔 icon in the header.') ->schema([ + Toggle::make('database_enabled') + ->label('Enable database notifications') + ->reactive() + ->columnSpanFull(), Grid::make([ 'default' => 1, ]) + ->hidden(fn (Forms\Get $get) => $get('database_enabled') !== true) ->schema([ - Section::make('Database') - ->description('Notifications sent to this channel will show up under the 🔔 icon in the header.') + Fieldset::make('Triggers') ->schema([ - Toggle::make('database_enabled') - ->label('Enable database notifications') - ->reactive() + Toggle::make('database_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('database_on_threshold_failure') + ->label('Notify on threshold failures') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('database_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('database_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('database_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Actions::make([ - Action::make('test database') - ->label('Test database channel') - ->action(fn () => SendDatabaseTestNotification::run(user: Auth::user())), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), + Actions::make([ + Action::make('test database') + ->label('Test database channel') + ->action(fn () => SendDatabaseTestNotification::run(user: Auth::user())), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Mail') + Section::make('Mail') + ->schema([ + Toggle::make('mail_enabled') + ->label('Enable mail notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('mail_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('mail_enabled') - ->label('Enable mail notifications') - ->reactive() + Toggle::make('mail_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('mail_on_threshold_failure') + ->label('Notify on threshold failures') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('mail_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('mail_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('mail_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Repeater::make('mail_recipients') - ->label('Recipients') - ->schema([ - Forms\Components\TextInput::make('email_address') - ->placeholder('your@email.com') - ->email() - ->required(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test mail') - ->label('Test mail channel') - ->action(fn (Forms\Get $get) => SendMailTestNotification::run(recipients: $get('mail_recipients'))) - ->hidden(fn (Forms\Get $get) => ! count($get('mail_recipients'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), - - Section::make('Webhook') + Repeater::make('mail_recipients') + ->label('Recipients') ->schema([ - Toggle::make('webhook_enabled') - ->label('Enable webhook notifications') - ->reactive() - ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('webhook_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('webhook_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpan(2), - Toggle::make('webhook_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpan(2), - ]), - Repeater::make('webhook_urls') - ->label('Recipients') - ->schema([ - Forms\Components\TextInput::make('url') - ->placeholder('https://webhook.site/longstringofcharacters') - ->maxLength(2000) - ->required() - ->url(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test webhook') - ->label('Test webhook channel') - ->action(fn (Forms\Get $get) => SendWebhookTestNotification::run(webhooks: $get('webhook_urls'))) - ->hidden(fn (Forms\Get $get) => ! count($get('webhook_urls'))), - ]), - ]), + Forms\Components\TextInput::make('email_address') + ->placeholder('your@email.com') + ->email() + ->required(), ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, - ]), + ->columnSpanFull(), + Actions::make([ + Action::make('test mail') + ->label('Test mail channel') + ->action(fn (Forms\Get $get) => SendMailTestNotification::run(recipients: $get('mail_recipients'))) + ->hidden(fn (Forms\Get $get) => ! count($get('mail_recipients'))), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Pushover') - ->description('⚠️ Pushover is deprecated and will be removed in a future release.') + Section::make('Webhook') + ->schema([ + Toggle::make('webhook_enabled') + ->label('Enable webhook notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('webhook_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('pushover_enabled') - ->label('Enable Pushover webhook notifications') - ->reactive() - ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('pushover_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('pushover_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('pushover_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Repeater::make('pushover_webhooks') - ->label('Pushover Webhooks') - ->schema([ - Forms\Components\TextInput::make('url') - ->label('URL') - ->placeholder('http://api.pushover.net/1/messages.json') - ->maxLength(2000) - ->required() - ->url(), - Forms\Components\TextInput::make('user_key') - ->label('User Key') - ->placeholder('Your Pushover User Key') - ->maxLength(200) - ->required(), - Forms\Components\TextInput::make('api_token') - ->label('API Token') - ->placeholder('Your Pushover API Token') - ->maxLength(200) - ->required(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test pushover') - ->label('Test Pushover webhook') - ->action(fn (Forms\Get $get) => SendPushoverTestNotification::run( - webhooks: $get('pushover_webhooks') - )) - ->hidden(fn (Forms\Get $get) => ! count($get('pushover_webhooks'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, + Toggle::make('webhook_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpan(2), + Toggle::make('webhook_on_threshold_failure') + ->label('Notify on threshold failures') + ->columnSpan(2), ]), + Repeater::make('webhook_urls') + ->label('Recipients') + ->schema([ + Forms\Components\TextInput::make('url') + ->placeholder('https://webhook.site/longstringofcharacters') + ->maxLength(2000) + ->required() + ->url(), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test webhook') + ->label('Test webhook channel') + ->action(fn (Forms\Get $get) => SendWebhookTestNotification::run(webhooks: $get('webhook_urls'))) + ->hidden(fn (Forms\Get $get) => ! count($get('webhook_urls'))), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Discord') - ->description('⚠️ Discord is deprecated and will be removed in a future release.') + Section::make('Pushover') + ->schema([ + Toggle::make('pushover_enabled') + ->label('Enable Pushover webhook notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('pushover_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('discord_enabled') - ->label('Enable Discord webhook notifications') - ->reactive() + Toggle::make('pushover_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('pushover_on_threshold_failure') + ->label('Notify on threshold failures') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('discord_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('discord_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('discord_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Repeater::make('discord_webhooks') - ->label('Webhooks') - ->schema([ - Forms\Components\TextInput::make('url') - ->placeholder('https://discord.com/api/webhooks/longstringofcharacters') - ->maxLength(2000) - ->required() - ->url(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test discord') - ->label('Test Discord webhook') - ->action(fn (Forms\Get $get) => SendDiscordTestNotification::run(webhooks: $get('discord_webhooks'))) - ->hidden(fn (Forms\Get $get) => ! count($get('discord_webhooks'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), + Repeater::make('pushover_webhooks') + ->label('Pushover Webhooks') + ->schema([ + Forms\Components\TextInput::make('url') + ->label('URL') + ->placeholder('http://api.pushover.net/1/messages.json') + ->maxLength(2000) + ->required() + ->url(), + Forms\Components\TextInput::make('user_key') + ->label('User Key') + ->placeholder('Your Pushover User Key') + ->maxLength(200) + ->required(), + Forms\Components\TextInput::make('api_token') + ->label('API Token') + ->placeholder('Your Pushover API Token') + ->maxLength(200) + ->required(), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test pushover') + ->label('Test Pushover webhook') + ->action(fn (Forms\Get $get) => SendPushoverTestNotification::run( + webhooks: $get('pushover_webhooks') + )) + ->hidden(fn (Forms\Get $get) => ! count($get('pushover_webhooks'))), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Gotify') - ->description('⚠️ Gotify is deprecated and will be removed in a future release.') + Section::make('Discord') + ->schema([ + Toggle::make('discord_enabled') + ->label('Enable Discord webhook notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('discord_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('gotify_enabled') - ->label('Enable Gotify webhook notifications') - ->reactive() + Toggle::make('discord_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('discord_on_threshold_failure') + ->label('Notify on threshold failures') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('gotify_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('gotify_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('gotify_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Repeater::make('gotify_webhooks') - ->label('Webhooks') - ->schema([ - Forms\Components\TextInput::make('url') - ->placeholder('https://example.com/message?token=') - ->maxLength(2000) - ->required() - ->url(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test gotify') - ->label('Test Gotify webhook') - ->action(fn (Forms\Get $get) => SendgotifyTestNotification::run(webhooks: $get('gotify_webhooks'))) - ->hidden(fn (Forms\Get $get) => ! count($get('gotify_webhooks'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), + Repeater::make('discord_webhooks') + ->label('Webhooks') + ->schema([ + Forms\Components\TextInput::make('url') + ->placeholder('https://discord.com/api/webhooks/longstringofcharacters') + ->maxLength(2000) + ->required() + ->url(), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test discord') + ->label('Test Discord webhook') + ->action(fn (Forms\Get $get) => SendDiscordTestNotification::run(webhooks: $get('discord_webhooks'))) + ->hidden(fn (Forms\Get $get) => ! count($get('discord_webhooks'))), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Slack') - ->description('⚠️ Slack is deprecated and will be removed in a future release.') + Section::make('Gotify') + ->schema([ + Toggle::make('gotify_enabled') + ->label('Enable Gotify webhook notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('gotify_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('slack_enabled') - ->label('Enable Slack webhook notifications') - ->reactive() + Toggle::make('gotify_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('gotify_on_threshold_failure') + ->label('Notify on threshold failures') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('slack_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('slack_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('slack_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Repeater::make('slack_webhooks') - ->label('Webhooks') - ->schema([ - Forms\Components\TextInput::make('url') - ->placeholder('https://hooks.slack.com/services/abc/xyz') - ->maxLength(2000) - ->required() - ->url(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test Slack') - ->label('Test slack webhook') - ->action(fn (Forms\Get $get) => SendSlackTestNotification::run(webhooks: $get('slack_webhooks'))) - ->hidden(fn (Forms\Get $get) => ! count($get('slack_webhooks'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), + Repeater::make('gotify_webhooks') + ->label('Webhooks') + ->schema([ + Forms\Components\TextInput::make('url') + ->placeholder('https://example.com/message?token=') + ->maxLength(2000) + ->required() + ->url(), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test gotify') + ->label('Test Gotify webhook') + ->action(fn (Forms\Get $get) => SendgotifyTestNotification::run(webhooks: $get('gotify_webhooks'))) + ->hidden(fn (Forms\Get $get) => ! count($get('gotify_webhooks'))), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Ntfy') - ->description('⚠️ Ntfy is deprecated and will be removed in a future release.') + Section::make('Slack') + ->schema([ + Toggle::make('slack_enabled') + ->label('Enable Slack webhook notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('slack_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('ntfy_enabled') - ->label('Enable Ntfy webhook notifications') - ->reactive() + Toggle::make('slack_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('slack_on_threshold_failure') + ->label('Notify on threshold failures') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('ntfy_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('ntfy_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('ntfy_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Repeater::make('ntfy_webhooks') - ->label('Webhooks') - ->schema([ - Forms\Components\TextInput::make('url') - ->maxLength(2000) - ->placeholder('Your ntfy server url') - ->required() - ->url(), - Forms\Components\TextInput::make('topic') - ->label('Topic') - ->placeholder('Your ntfy Topic') - ->maxLength(200) - ->required(), - Forms\Components\TextInput::make('username') - ->label('Username') - ->placeholder('Username for Basic Auth (optional)') - ->maxLength(200), - Forms\Components\TextInput::make('password') - ->label('Password') - ->placeholder('Password for Basic Auth (optional)') - ->password() - ->maxLength(200), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test ntfy') - ->label('Test Ntfy webhook') - ->action(fn (Forms\Get $get) => SendNtfyTestNotification::run(webhooks: $get('ntfy_webhooks'))) - ->hidden(fn (Forms\Get $get) => ! count($get('ntfy_webhooks'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), + Repeater::make('slack_webhooks') + ->label('Webhooks') + ->schema([ + Forms\Components\TextInput::make('url') + ->placeholder('https://hooks.slack.com/services/abc/xyz') + ->maxLength(2000) + ->required() + ->url(), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test Slack') + ->label('Test slack webhook') + ->action(fn (Forms\Get $get) => SendSlackTestNotification::run(webhooks: $get('slack_webhooks'))) + ->hidden(fn (Forms\Get $get) => ! count($get('slack_webhooks'))), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Healthcheck.io') - ->description('⚠️ Healthcheck.io is deprecated and will be removed in a future release.') + Section::make('Ntfy') + ->schema([ + Toggle::make('ntfy_enabled') + ->label('Enable Ntfy webhook notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('ntfy_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('healthcheck_enabled') - ->label('Enable healthcheck.io webhook notifications') - ->reactive() + Toggle::make('ntfy_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('ntfy_on_threshold_failure') + ->label('Notify on threshold failures') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('healthcheck_enabled') !== true) - ->schema([ - Fieldset::make('Triggers') - ->schema([ - Toggle::make('healthcheck_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('healthcheck_on_threshold_failure') - ->label('Notify on threshold failures') - ->helperText('Threshold notifications will be sent to the /fail path of the URL.') - ->columnSpanFull(), - ]), - Repeater::make('healthcheck_webhooks') - ->label('webhooks') - ->schema([ - Forms\Components\TextInput::make('url') - ->placeholder('https://hc-ping.com/your-uuid-here') - ->maxLength(2000) - ->required() - ->url(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test healthcheck') - ->label('Test healthcheck.io webhook') - ->action(fn (Forms\Get $get) => SendHealthCheckTestNotification::run(webhooks: $get('healthcheck_webhooks'))) - ->hidden(fn (Forms\Get $get) => ! count($get('healthcheck_webhooks'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), + Repeater::make('ntfy_webhooks') + ->label('Webhooks') + ->schema([ + Forms\Components\TextInput::make('url') + ->maxLength(2000) + ->placeholder('Your ntfy server url') + ->required() + ->url(), + Forms\Components\TextInput::make('topic') + ->label('Topic') + ->placeholder('Your ntfy Topic') + ->maxLength(200) + ->required(), + Forms\Components\TextInput::make('username') + ->label('Username') + ->placeholder('Username for Basic Auth (optional)') + ->maxLength(200), + Forms\Components\TextInput::make('password') + ->label('Password') + ->placeholder('Password for Basic Auth (optional)') + ->password() + ->maxLength(200), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test ntfy') + ->label('Test Ntfy webhook') + ->action(fn (Forms\Get $get) => SendNtfyTestNotification::run(webhooks: $get('ntfy_webhooks'))) + ->hidden(fn (Forms\Get $get) => ! count($get('ntfy_webhooks'))), + ]), + ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make('Telegram') - ->description('⚠️ Telegram is deprecated and will be removed in a future release.') + Section::make('Healthcheck.io') + ->schema([ + Toggle::make('healthcheck_enabled') + ->label('Enable healthcheck.io webhook notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('healthcheck_enabled') !== true) + ->schema([ + Fieldset::make('Triggers') ->schema([ - Toggle::make('telegram_enabled') - ->label('Enable telegram notifications') - ->reactive() + Toggle::make('healthcheck_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('healthcheck_on_threshold_failure') + ->label('Notify on threshold failures') + ->helperText('Threshold notifications will be sent to the /fail path of the URL.') ->columnSpanFull(), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('telegram_enabled') !== true) - ->schema([ - Fieldset::make('Options') - ->schema([ - Toggle::make('telegram_disable_notification') - ->label('Send the message silently to the user') - ->columnSpanFull(), - ]), - Fieldset::make('Triggers') - ->schema([ - Toggle::make('telegram_on_speedtest_run') - ->label('Notify on every speedtest run') - ->columnSpanFull(), - Toggle::make('telegram_on_threshold_failure') - ->label('Notify on threshold failures') - ->columnSpanFull(), - ]), - Repeater::make('telegram_recipients') - ->label('Recipients') - ->schema([ - Forms\Components\TextInput::make('telegram_chat_id') - ->placeholder('12345678910') - ->label('Telegram Chat ID') - ->maxLength(50) - ->required(), - ]) - ->columnSpanFull(), - Actions::make([ - Action::make('test telegram') - ->label('Test Telegram channel') - ->action(fn (Forms\Get $get) => SendTelegramTestNotification::run(recipients: $get('telegram_recipients'))) - ->hidden(fn (Forms\Get $get) => ! count($get('telegram_recipients')) || blank(config('telegram.bot'))), - ]), - ]), - ]) - ->compact() - ->columns([ - 'default' => 1, - 'md' => 2, ]), - ]) - ->columnSpan([ - 'md' => 2, + Repeater::make('healthcheck_webhooks') + ->label('webhooks') + ->schema([ + Forms\Components\TextInput::make('url') + ->placeholder('https://hc-ping.com/your-uuid-here') + ->maxLength(2000) + ->required() + ->url(), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test healthcheck') + ->label('Test healthcheck.io webhook') + ->action(fn (Forms\Get $get) => SendHealthCheckTestNotification::run(webhooks: $get('healthcheck_webhooks'))) + ->hidden(fn (Forms\Get $get) => ! count($get('healthcheck_webhooks'))), + ]), ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, + ]), - Section::make() + Section::make('Telegram') + ->schema([ + Toggle::make('telegram_enabled') + ->label('Enable telegram notifications') + ->reactive() + ->columnSpanFull(), + Grid::make([ + 'default' => 1, + ]) + ->hidden(fn (Forms\Get $get) => $get('telegram_enabled') !== true) ->schema([ - Forms\Components\View::make('filament.forms.notifications-helptext'), - ]) - ->columnSpan([ - 'md' => 1, + Fieldset::make('Options') + ->schema([ + Toggle::make('telegram_disable_notification') + ->label('Send the message silently to the user') + ->columnSpanFull(), + ]), + Fieldset::make('Triggers') + ->schema([ + Toggle::make('telegram_on_speedtest_run') + ->label('Notify on every speedtest run') + ->columnSpanFull(), + Toggle::make('telegram_on_threshold_failure') + ->label('Notify on threshold failures') + ->columnSpanFull(), + ]), + Repeater::make('telegram_recipients') + ->label('Recipients') + ->schema([ + Forms\Components\TextInput::make('telegram_chat_id') + ->placeholder('12345678910') + ->label('Telegram Chat ID') + ->maxLength(50) + ->required(), + ]) + ->columnSpanFull(), + Actions::make([ + Action::make('test telegram') + ->label('Test Telegram channel') + ->action(fn (Forms\Get $get) => SendTelegramTestNotification::run(recipients: $get('telegram_recipients'))) + ->hidden(fn (Forms\Get $get) => ! count($get('telegram_recipients')) || blank(config('telegram.bot'))), + ]), ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, ]), + ]) + ->columns([ + 'default' => 1, ]); } } diff --git a/app/Filament/Pages/Settings/ThresholdsPage.php b/app/Filament/Pages/Settings/ThresholdsPage.php index 3dc749bd7..e6d5b4f1c 100644 --- a/app/Filament/Pages/Settings/ThresholdsPage.php +++ b/app/Filament/Pages/Settings/ThresholdsPage.php @@ -9,9 +9,9 @@ use Filament\Forms\Components\Section; use Filament\Forms\Components\TextInput; use Filament\Forms\Components\Toggle; -use Filament\Forms\Components\View; use Filament\Forms\Form; use Filament\Pages\SettingsPage; +use Filament\Support\Enums\MaxWidth; use Illuminate\Support\Facades\Auth; class ThresholdsPage extends SettingsPage @@ -38,82 +38,70 @@ public static function shouldRegisterNavigation(): bool return Auth::check() && Auth::user()->is_admin; } + public function getMaxContentWidth(): MaxWidth + { + return MaxWidth::ThreeExtraLarge; + } + public function form(Form $form): Form { return $form ->schema([ - Grid::make([ - 'default' => 1, - 'md' => 3, - ]) + Section::make('Absolute') + ->description('Absolute thresholds do not take into account previous history and could be triggered on each test.') ->schema([ + Toggle::make('absolute_enabled') + ->label('Enable absolute thresholds') + ->reactive() + ->columnSpan(2), Grid::make([ 'default' => 1, ]) + ->hidden(fn (Forms\Get $get) => $get('absolute_enabled') !== true) ->schema([ - Section::make('Absolute') - ->description('Absolute thresholds do not take into account previous history and could be triggered on each test.') + Fieldset::make('Metrics') ->schema([ - Toggle::make('absolute_enabled') - ->label('Enable absolute thresholds') - ->reactive() - ->columnSpan(2), - Grid::make([ - 'default' => 1, - ]) - ->hidden(fn (Forms\Get $get) => $get('absolute_enabled') !== true) - ->schema([ - Fieldset::make('Metrics') - ->schema([ - TextInput::make('absolute_download') - ->label('Download') - ->hint('Mbps') - ->helperText('Set to zero to disable this metric.') - ->default(0) - ->minValue(0) - ->numeric() - ->required(), - TextInput::make('absolute_upload') - ->label('Upload') - ->hint('Mbps') - ->helperText('Set to zero to disable this metric.') - ->default(0) - ->minValue(0) - ->numeric() - ->required(), - TextInput::make('absolute_ping') - ->label('Ping') - ->hint('ms') - ->helperText('Set to zero to disable this metric.') - ->default(0) - ->minValue(0) - ->numeric() - ->required(), - ]) - ->columns([ - 'default' => 1, - 'md' => 2, - ]), - ]), + TextInput::make('absolute_download') + ->label('Download') + ->hint('Mbps') + ->helperText('Set to zero to disable this metric.') + ->default(0) + ->minValue(0) + ->numeric() + ->required(), + + TextInput::make('absolute_upload') + ->label('Upload') + ->hint('Mbps') + ->helperText('Set to zero to disable this metric.') + ->default(0) + ->minValue(0) + ->numeric() + ->required(), + + TextInput::make('absolute_ping') + ->label('Ping') + ->hint('ms') + ->helperText('Set to zero to disable this metric.') + ->default(0) + ->minValue(0) + ->numeric() + ->required(), ]) - ->compact() ->columns([ 'default' => 1, 'md' => 2, ]), - ]) - ->columnSpan([ - 'md' => 2, - ]), - - Section::make() - ->schema([ - View::make('filament.forms.thresholds-helptext'), - ]) - ->columnSpan([ - 'md' => 1, ]), + ]) + ->compact() + ->columns([ + 'default' => 1, + 'md' => 2, ]), + ]) + ->columns([ + 'default' => 1, ]); } } diff --git a/resources/views/filament/forms/notifications-helptext.blade.php b/resources/views/filament/forms/notifications-helptext.blade.php deleted file mode 100644 index 88ac268d3..000000000 --- a/resources/views/filament/forms/notifications-helptext.blade.php +++ /dev/null @@ -1,11 +0,0 @@ -
-

- ⚠️ Deprecated Channels -

- -

- Database, mail and webhook channels are considered core notification channels. - - All other channels should be considered deprecated and will be replaced by Apprise in a future release. -

-
diff --git a/resources/views/filament/forms/thresholds-helptext.blade.php b/resources/views/filament/forms/thresholds-helptext.blade.php deleted file mode 100644 index 1c0624afd..000000000 --- a/resources/views/filament/forms/thresholds-helptext.blade.php +++ /dev/null @@ -1,6 +0,0 @@ -
-

- 💡 Did you know, when a threshold is triggered it's sent to notification channels. - Each channel can be configured separately to have the notification sent to a specific destination. -

-