diff --git a/app/Filament/Pages/Dashboard.php b/app/Filament/Pages/Dashboard.php index a0819609e..5b5b43b66 100644 --- a/app/Filament/Pages/Dashboard.php +++ b/app/Filament/Pages/Dashboard.php @@ -20,8 +20,6 @@ class Dashboard extends BasePage { protected static ?string $navigationIcon = 'heroicon-o-chart-bar'; - protected static ?int $navigationSort = 1; - protected static string $view = 'filament.pages.dashboard'; protected function getHeaderActions(): array diff --git a/app/Filament/Pages/Settings/GeneralPage.php b/app/Filament/Pages/Settings/GeneralPage.php index 498c91f66..67efcf6f0 100644 --- a/app/Filament/Pages/Settings/GeneralPage.php +++ b/app/Filament/Pages/Settings/GeneralPage.php @@ -26,11 +26,9 @@ class GeneralPage extends SettingsPage protected static string $settings = GeneralSettings::class; - public function mount(): void + public static function canAccess(): bool { - parent::mount(); - - abort_unless(auth()->user()->is_admin, 403); + return auth()->user()->is_admin; } public static function shouldRegisterNavigation(): bool diff --git a/app/Filament/Pages/Settings/InfluxDbPage.php b/app/Filament/Pages/Settings/InfluxDbPage.php index 62f51f062..1c0d495e7 100644 --- a/app/Filament/Pages/Settings/InfluxDbPage.php +++ b/app/Filament/Pages/Settings/InfluxDbPage.php @@ -21,11 +21,9 @@ class InfluxDbPage extends SettingsPage protected static string $settings = InfluxDbSettings::class; - public function mount(): void + public static function canAccess(): bool { - parent::mount(); - - abort_unless(auth()->user()->is_admin, 403); + return auth()->user()->is_admin; } public static function shouldRegisterNavigation(): bool diff --git a/app/Filament/Pages/Settings/NotificationPage.php b/app/Filament/Pages/Settings/NotificationPage.php index 3e79b3acd..a40a5e080 100755 --- a/app/Filament/Pages/Settings/NotificationPage.php +++ b/app/Filament/Pages/Settings/NotificationPage.php @@ -27,11 +27,9 @@ class NotificationPage extends SettingsPage protected static string $settings = NotificationSettings::class; - public function mount(): void + public static function canAccess(): bool { - parent::mount(); - - abort_unless(auth()->user()->is_admin, 403); + return auth()->user()->is_admin; } public static function shouldRegisterNavigation(): bool diff --git a/app/Filament/Pages/Settings/ThresholdsPage.php b/app/Filament/Pages/Settings/ThresholdsPage.php index d3dae2076..7f60ba5f5 100644 --- a/app/Filament/Pages/Settings/ThresholdsPage.php +++ b/app/Filament/Pages/Settings/ThresholdsPage.php @@ -21,11 +21,9 @@ class ThresholdsPage extends SettingsPage protected static string $settings = ThresholdSettings::class; - public function mount(): void + public static function canAccess(): bool { - parent::mount(); - - abort_unless(auth()->user()->is_admin, 403); + return auth()->user()->is_admin; } public static function shouldRegisterNavigation(): bool diff --git a/app/Filament/Resources/ResultResource.php b/app/Filament/Resources/ResultResource.php index 345af681e..14101f699 100644 --- a/app/Filament/Resources/ResultResource.php +++ b/app/Filament/Resources/ResultResource.php @@ -31,8 +31,6 @@ class ResultResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-table-cells'; - protected static ?int $navigationSort = 2; - public static function form(Form $form): Form { $settings = new GeneralSettings(); diff --git a/app/Filament/Resources/UserResource.php b/app/Filament/Resources/UserResource.php index 1da51f592..3d034555b 100644 --- a/app/Filament/Resources/UserResource.php +++ b/app/Filament/Resources/UserResource.php @@ -21,8 +21,6 @@ class UserResource extends Resource protected static ?string $navigationIcon = 'heroicon-o-users'; - protected static ?int $navigationSort = 3; - public static function form(Form $form): Form { return $form diff --git a/app/Helpers/Number.php b/app/Helpers/Number.php index 4ad6fc51e..c565eebe3 100644 --- a/app/Helpers/Number.php +++ b/app/Helpers/Number.php @@ -35,6 +35,10 @@ public static function bitsToHuman(int|float $bits, int $precision = 0, ?int $ma { $units = ['B', 'Kb', 'Mb', 'Gb', 'Tb', 'Pb', 'Eb', 'Zb', 'Yb']; + if ($bits === 0) { + return '0 B'; + } + for ($i = 0; ($bits / 1000) > 0.99 && ($i < count($units) - 1); $i++) { $bits /= 1000; } @@ -51,6 +55,10 @@ public static function toBitRate(int|float $bits, int $precision = 0, ?int $maxP { $units = ['Bps', 'Kbps', 'Mbps', 'Gbps', 'Tbps', 'Pbps', 'Ebps', 'Zbps', 'Ybps']; + if ($bits === 0) { + return '0 B'; + } + for ($i = 0; ($bits / 1000) > 0.99 && ($i < count($units) - 1); $i++) { $bits /= 1000; } diff --git a/app/helpers.php b/app/helpers.php index 8684022ce..b70141cb9 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -27,6 +27,10 @@ function toBits(float $size, int $precision = 4): float if (! function_exists('percentChange')) { function percentChange(float $dividend, float $divisor, int $precision = 0): string { + if ($dividend === 0 || $divisor === 0) { + return 0; + } + $quotient = ($dividend - $divisor) / $divisor; return number_format(round($quotient * 100, $precision), $precision); diff --git a/config/speedtest.php b/config/speedtest.php index 3c2796be4..1fb3bdbd5 100644 --- a/config/speedtest.php +++ b/config/speedtest.php @@ -6,9 +6,9 @@ /** * Build information */ - 'build_date' => Carbon::parse('2024-03-30'), + 'build_date' => Carbon::parse('2024-04-01'), - 'build_version' => 'v0.18.4', + 'build_version' => 'v0.18.5', /** * General