forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInfluxDbPage.php
More file actions
92 lines (81 loc) · 3.99 KB
/
InfluxDbPage.php
File metadata and controls
92 lines (81 loc) · 3.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?php
namespace App\Filament\Pages\Settings;
use App\Settings\InfluxDbSettings;
use Filament\Forms;
use Filament\Forms\Form;
use Filament\Pages\SettingsPage;
class InfluxDbPage extends SettingsPage
{
protected static ?string $navigationIcon = 'heroicon-o-circle-stack';
protected static ?string $navigationGroup = 'Settings';
protected static ?int $navigationSort = 2;
protected static ?string $title = 'InfluxDB';
protected static ?string $navigationLabel = 'InfluxDB';
protected static string $settings = InfluxDbSettings::class;
public static function canAccess(): bool
{
return auth()->user()->is_admin;
}
public static function shouldRegisterNavigation(): bool
{
return auth()->user()->is_admin;
}
public function form(Form $form): Form
{
return $form
->schema([
Forms\Components\Grid::make([
'default' => 1,
])
->schema([
Forms\Components\Section::make('InfluxDB v2 Settings')
->schema([
Forms\Components\Toggle::make('v2_enabled')
->label('Enable')
->reactive()
->columnSpan(2),
Forms\Components\Grid::make([
'default' => 1,
'md' => 3,
])
->hidden(fn (Forms\Get $get) => $get('v2_enabled') !== true)
->schema([
Forms\Components\TextInput::make('v2_url')
->label('URL')
->placeholder('http://your-influxdb-instance')
->maxLength(255)
->required(fn (Forms\Get $get) => $get('v2_enabled') == true)
->columnSpanFull(),
Forms\Components\Checkbox::make('v2_verify_ssl')
->label('Verify SSL')
->columnSpanFull(),
Forms\Components\TextInput::make('v2_org')
->label('Org')
->maxLength(255)
->required(fn (Forms\Get $get) => $get('v2_enabled') == true)
->columnSpan(['md' => 2]),
Forms\Components\TextInput::make('v2_bucket')
->placeholder('speedtest-tracker')
->label('Bucket')
->maxLength(255)
->required(fn (Forms\Get $get) => $get('v2_enabled') == true)
->columnSpan(['md' => 1]),
Forms\Components\TextInput::make('v2_token')
->label('Token')
->maxLength(255)
->password()
->required(fn (Forms\Get $get) => $get('v2_enabled') == true)
->disableAutocomplete()
->columnSpanFull(),
]),
])
->compact()
->columns([
'default' => 1,
'md' => 2,
]),
])
->columnSpan('full'),
]);
}
}