mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 08:44:46 +02:00
Combine status & uptime, add address on ServerOverview (#739)
This commit is contained in:
parent
4fd1937c54
commit
355810c549
@ -19,19 +19,22 @@ class ServerOverview extends StatsOverviewWidget
|
||||
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)";
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
* @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
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user