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
154 changes: 79 additions & 75 deletions app/Filament/Pages/Settings/DataIntegrationPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
]);
}
}
Loading