forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThresholdsPage.php
More file actions
119 lines (107 loc) · 5.43 KB
/
ThresholdsPage.php
File metadata and controls
119 lines (107 loc) · 5.43 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
namespace App\Filament\Pages\Settings;
use App\Settings\ThresholdSettings;
use Filament\Forms;
use Filament\Forms\Components\Fieldset;
use Filament\Forms\Components\Grid;
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 Illuminate\Support\Facades\Auth;
class ThresholdsPage extends SettingsPage
{
protected static ?string $navigationIcon = 'heroicon-o-exclamation-triangle';
protected static ?string $navigationGroup = 'Settings';
protected static ?int $navigationSort = 4;
protected static ?string $title = 'Thresholds';
protected static ?string $navigationLabel = 'Thresholds';
protected static string $settings = ThresholdSettings::class;
public static function canAccess(): bool
{
return Auth::check() && Auth::user()->is_admin;
}
public static function shouldRegisterNavigation(): bool
{
return Auth::check() && Auth::user()->is_admin;
}
public function form(Form $form): Form
{
return $form
->schema([
Grid::make([
'default' => 1,
'md' => 3,
])
->schema([
Grid::make([
'default' => 1,
])
->schema([
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([
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,
]),
]),
])
->compact()
->columns([
'default' => 1,
'md' => 2,
]),
])
->columnSpan([
'md' => 2,
]),
Section::make()
->schema([
View::make('filament.forms.thresholds-helptext'),
])
->columnSpan([
'md' => 1,
]),
]),
]);
}
}