From 355810c549b0e5456edc11ed0f2a414c20caa101 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Sun, 1 Dec 2024 18:12:28 +0100 Subject: [PATCH] Combine status & uptime, add address on ServerOverview (#739) --- app/Filament/Server/Widgets/ServerOverview.php | 13 ++++++++----- app/Models/Allocation.php | 1 + 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/Filament/Server/Widgets/ServerOverview.php b/app/Filament/Server/Widgets/ServerOverview.php index e11b7a4be9..0d23404e88 100644 --- a/app/Filament/Server/Widgets/ServerOverview.php +++ b/app/Filament/Server/Widgets/ServerOverview.php @@ -19,19 +19,22 @@ protected function getStats(): array return [ Stat::make('Name', $this->server->name) ->description($this->server->description), - Stat::make('Status', Str::title($this->server->condition)), - Stat::make('Uptime', $this->uptime()), + Stat::make('Status', $this->status()), + Stat::make('Address', $this->server->allocation->address), ]; } - private function uptime(): string + private function status(): string { + $status = Str::title($this->server->condition); $uptime = collect(cache()->get("servers.{$this->server->id}.uptime"))->last() ?? 0; if ($uptime === 0) { - return 'Offline'; + return $status; } - return now()->subMillis($uptime)->diffForHumans(syntax: CarbonInterface::DIFF_ABSOLUTE, short: true, parts: 2); + $uptime = now()->subMillis($uptime)->diffForHumans(syntax: CarbonInterface::DIFF_ABSOLUTE, short: true, parts: 2); + + return "$status ($uptime)"; } } diff --git a/app/Models/Allocation.php b/app/Models/Allocation.php index 4ec50e72d0..b8bbeb571a 100644 --- a/app/Models/Allocation.php +++ b/app/Models/Allocation.php @@ -20,6 +20,7 @@ * @property \Carbon\Carbon|null $updated_at * @property string $alias * @property bool $has_alias + * @property string $address * @property \App\Models\Server|null $server * @property \App\Models\Node $node *