diff --git a/app/Filament/App/Widgets/ServerListEntryWidget.php b/app/Filament/App/Widgets/ServerListEntryWidget.php index c29cf77d7c..9bd51c977c 100644 --- a/app/Filament/App/Widgets/ServerListEntryWidget.php +++ b/app/Filament/App/Widgets/ServerListEntryWidget.php @@ -62,9 +62,15 @@ private function memory(): string ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; - $total = config('panel.use_binary_prefix') - ? 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'; + if ($totalMemory === 0) { + $total = config('panel.use_binary_prefix') + ? Number::format($this->server->memory / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' + : Number::format($this->server->memory / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; + } else { + $total = config('panel.use_binary_prefix') + ? 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 $used . ($this->server->memory > 0 ? ' Of ' . $total : ''); } diff --git a/app/Filament/Server/Widgets/ServerMemoryChart.php b/app/Filament/Server/Widgets/ServerMemoryChart.php index 9b5c72d697..4cd9525c6e 100644 --- a/app/Filament/Server/Widgets/ServerMemoryChart.php +++ b/app/Filament/Server/Widgets/ServerMemoryChart.php @@ -75,9 +75,15 @@ public function getHeading(): string ? Number::format($latestMemoryUsed / 1024 / 1024 / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' : Number::format($latestMemoryUsed / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; - $total = config('panel.use_binary_prefix') - ? 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'; + if ($totalMemory === 0) { + $total = config('panel.use_binary_prefix') + ? Number::format($this->server->memory / 1024, maxPrecision: 2, locale: auth()->user()->language) .' GiB' + : Number::format($this->server->memory / 1000, maxPrecision: 2, locale: auth()->user()->language) . ' GB'; + } else { + $total = config('panel.use_binary_prefix') + ? 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 . ($this->server->memory > 0 ? ' Of ' . $total : ''); }