forked from alexjustesen/speedtest-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathThresholds.php
More file actions
114 lines (103 loc) · 5.26 KB
/
Thresholds.php
File metadata and controls
114 lines (103 loc) · 5.26 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
<?php
namespace App\Filament\Pages\Settings;
use App\Settings\ThresholdSettings;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Components\Toggle;
use Filament\Pages\SettingsPage;
use Filament\Schemas\Components\Fieldset;
use Filament\Schemas\Components\Grid;
use Filament\Schemas\Components\Section;
use Filament\Schemas\Components\Utilities\Get;
use Filament\Schemas\Schema;
use Illuminate\Support\Facades\Auth;
class Thresholds extends SettingsPage
{
protected static string|\BackedEnum|null $navigationIcon = 'tabler-alert-triangle';
protected static string|\UnitEnum|null $navigationGroup = 'Settings';
protected static ?int $navigationSort = 4;
public function getTitle(): string
{
return __('settings/thresholds.title');
}
public static function getNavigationLabel(): string
{
return __('settings/thresholds.label');
}
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(Schema $schema): Schema
{
return $schema
->components([
Grid::make([
'default' => 1,
'md' => 3,
])
->columnSpan('full')
->schema([
Grid::make([
'default' => 1,
])
->schema([
Section::make(__('settings/thresholds.absolute'))
->description(__('settings/thresholds.absolute_description'))
->schema([
Toggle::make('absolute_enabled')
->label(__('settings/thresholds.absolute_enabled'))
->reactive()
->columnSpan(2),
Grid::make([
'default' => 1,
])
->hidden(fn (Get $get) => $get('absolute_enabled') !== true)
->schema([
Fieldset::make(__('settings/thresholds.metrics'))
->schema([
TextInput::make('absolute_download')
->label(__('general.download'))
->hint(__('general.mbps'))
->helperText(__('settings/thresholds.metrics_helper_text'))
->default(0)
->minValue(0)
->numeric()
->required(),
TextInput::make('absolute_upload')
->label(__('general.upload'))
->hint(__('general.mbps'))
->helperText(__('settings/thresholds.metrics_helper_text'))
->default(0)
->minValue(0)
->numeric()
->required(),
TextInput::make('absolute_ping')
->label(__('general.ping'))
->hint(__('general.ms'))
->helperText(__('settings/thresholds.metrics_helper_text'))
->default(0)
->minValue(0)
->numeric()
->required(),
])
->columns([
'default' => 1,
'md' => 2,
]),
]),
])
->compact()
->columnSpan('full'),
])
->columnSpan([
'md' => 2,
]),
]),
]);
}
}