Skip to content

Commit

Permalink
hide "0" cpu/ memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy132 committed Oct 19, 2024
1 parent 17d2609 commit 9e7ada1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions app/Filament/App/Widgets/ServerCpuChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ protected function getOptions(): RawJs

public function getHeading(): string
{
$cpu = Number::format(collect(cache()->get("servers.{$this->server->id}.cpu_absolute"))->last() ?? 0, maxPrecision: 2, locale: auth()->user()->language);
$cpu = Number::format(collect(cache()->get("servers.{$this->server->id}.cpu_absolute"))->last() ?? 0, maxPrecision: 2, locale: auth()->user()->language) . '%';
$max = Number::format($this->server->cpu, locale: auth()->user()->language) . '%';

return 'CPU - ' . $cpu . '% Of ' . $max;
return 'CPU - ' . $cpu . ($this->server->cpu > 0 ? ' Of ' . $max : '');
}
}
2 changes: 1 addition & 1 deletion app/Filament/App/Widgets/ServerMemoryChart.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ public function getHeading(): string
? Number::format($totalMemory / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB'
: Number::format($totalMemory / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB';

return 'Memory - ' . $used . ' Of ' . $total;
return 'Memory - ' . $used . ($this->server->memory > 0 ? ' Of ' . $total : '');
}
}

0 comments on commit 9e7ada1

Please sign in to comment.