55use App \Settings \GeneralSettings ;
66use BackedEnum ;
77use CodeWithDennis \SimpleAlert \Components \SimpleAlert ;
8+ use Filament \Forms \Components \Radio ;
89use Filament \Forms \Components \Select ;
910use Filament \Forms \Components \TextInput ;
1011use Filament \Forms \Components \Toggle ;
1112use Filament \Pages \SettingsPage ;
12- use Filament \Schemas \Components \Fieldset ;
1313use Filament \Schemas \Components \Grid ;
1414use Filament \Schemas \Components \Tabs ;
1515use Filament \Schemas \Components \Tabs \Tab ;
1616use Filament \Schemas \Components \Utilities \Get ;
1717use Filament \Schemas \Schema ;
1818use Illuminate \Support \Facades \Auth ;
19+ use Illuminate \Support \HtmlString ;
1920
2021class General extends SettingsPage
2122{
@@ -44,7 +45,7 @@ public function form(Schema $schema): Schema
4445 ->components ([
4546 Tabs::make ()
4647 ->schema ([
47- Tab::make ('Bandwidth ' )
48+ Tab::make ('Data Usage ' )
4849 ->icon ('tabler-cloud-data-connection ' )
4950 ->columns ([
5051 'default ' => 1 ,
@@ -53,11 +54,11 @@ public function form(Schema $schema): Schema
5354 ->schema ([
5455 SimpleAlert::make ('data_usage_note ' )
5556 ->info ()
56- ->description ('Data usage is calculated based on the total downloaded and uploaded data from Ookla Speedtests only. ' )
57+ ->description (new HtmlString ( 'Data usage is calculated on the total downloaded and uploaded data from Ookla Speedtests <u> only</u>. ' ) )
5758 ->columnSpanFull (),
5859
59- Toggle::make ('data_cap_enabled ' )
60- ->label ('Enable bandwidth data cap ' )
60+ Toggle::make ('data_usage_enabled ' )
61+ ->label ('Enable data usage limit ' )
6162 ->reactive ()
6263 ->columnSpanFull (),
6364
@@ -66,28 +67,30 @@ public function form(Schema $schema): Schema
6667 'md ' => 2 ,
6768 ])
6869 ->schema ([
69- TextInput::make ('data_cap_data_limit ' )
70- ->label ('Data limit ' )
70+ TextInput::make ('data_usage_limit ' )
71+ ->label ('Usage limit ' )
7172 ->placeholder ('e.g., 500GB, 1TB ' )
72- ->required (fn (Get $ get ) => $ get ('data_cap_enabled ' ))
73+ ->required (fn (Get $ get ) => $ get ('data_usage_enabled ' ))
7374 ->columnSpanFull (),
7475
75- TextInput::make ('data_cap_warning_threshold ' )
76- ->label ('Warning threshold ' )
77- ->numeric ()
78- ->integer ()
79- ->minValue (1 )
80- ->maxValue (100 )
81- ->required ()
82- ->suffix ('% ' ),
83-
84- Select::make ('data_cap_action ' )
85- ->label ('Action on limit reached ' )
76+ Select::make ('data_usage_period ' )
77+ ->label ('Period ' )
8678 ->options ([
87- 'notify ' => 'Notify admin(s) ' ,
88- 'block ' => 'Block and notify admin(s) ' ,
79+ 'day ' => 'Day ' ,
80+ 'week ' => 'Week ' ,
81+ 'month ' => 'Month ' ,
8982 ])
9083 ->required (),
84+
85+ TextInput::make ('data_usage_reset_day ' )
86+ ->label ('Reset day ' )
87+ ->helperText ('Which day of the month or week (Sunday=0, Monday=1 etc.) should the data usage reset? ' )
88+ ->numeric ()
89+ ->integer ()
90+ ->step (1 )
91+ ->minValue (0 )
92+ ->maxValue (31 )
93+ ->required (),
9194 ])
9295 ->columnSpan ([
9396 'default ' => 1 ,
@@ -98,27 +101,16 @@ public function form(Schema $schema): Schema
98101 'default ' => 1 ,
99102 ])
100103 ->schema ([
101- Fieldset::make ('period_settings ' )
102- ->label ('Period settings ' )
103- ->schema ([
104- Select::make ('data_cap_period ' )
105- ->label ('Period ' )
106- ->options ([
107- 'day ' => 'Day ' ,
108- 'week ' => 'Week ' ,
109- 'month ' => 'Month ' ,
110- ])
111- ->required (),
112-
113- TextInput::make ('data_cap_reset_day ' )
114- ->label ('Reset day ' )
115- ->numeric ()
116- ->integer ()
117- ->minValue (0 )
118- ->maxValue (31 )
119- ->required (),
104+ Radio::make ('data_usage_action ' )
105+ ->label ('Action on limit reached ' )
106+ ->options ([
107+ 'notify ' => 'Notify ' ,
108+ 'block ' => 'Block and notify ' ,
120109 ])
121- ->columns (1 ),
110+ ->descriptions ([
111+ 'notify ' => 'Allow speed tests but notify the admin user(s) when the limit is reached. ' ,
112+ 'block ' => 'Block further speed tests and notify the admin user(s) when the limit is reached. ' ,
113+ ]),
122114 ])
123115 ->columnSpan ([
124116 'default ' => 1 ,
0 commit comments