diff --git a/app/Filament/Resources/NodeResource/Pages/ListNodes.php b/app/Filament/Resources/NodeResource/Pages/ListNodes.php index 2313df6a4..ab794ca29 100644 --- a/app/Filament/Resources/NodeResource/Pages/ListNodes.php +++ b/app/Filament/Resources/NodeResource/Pages/ListNodes.php @@ -13,6 +13,7 @@ use Filament\Tables\Actions\EditAction; use Filament\Tables\Columns\IconColumn; use Filament\Tables\Columns\TextColumn; use Filament\Tables\Table; +use Illuminate\Support\Number; class ListNodes extends ListRecords { @@ -47,14 +48,14 @@ class ListNodes extends ListRecords ->icon('tabler-device-desktop-analytics') ->numeric() ->suffix(config('panel.use_binary_prefix') ? ' GiB' : ' GB') - ->formatStateUsing(fn ($state) => number_format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), 2)) + ->formatStateUsing(fn ($state) => Number::format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), maxPrecision: 2, locale: auth()->user()->language)) ->sortable(), TextColumn::make('disk') ->visibleFrom('sm') ->icon('tabler-file') ->numeric() ->suffix(config('panel.use_binary_prefix') ? ' GiB' : ' GB') - ->formatStateUsing(fn ($state) => number_format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), 2)) + ->formatStateUsing(fn ($state) => Number::format($state / (config('panel.use_binary_prefix') ? 1024 : 1000), maxPrecision: 2, locale: auth()->user()->language)) ->sortable(), TextColumn::make('cpu') ->visibleFrom('sm') diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php index 45d18fc90..476b8b533 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeCpuChart.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Number; class NodeCpuChart extends ChartWidget { @@ -24,7 +25,7 @@ class NodeCpuChart extends ChartWidget $cpu = collect(cache()->get("nodes.$node->id.cpu_percent")) ->slice(-10) ->map(fn ($value, $key) => [ - 'cpu' => number_format($value * $threads, 2), + 'cpu' => Number::format($value * $threads, maxPrecision: 2, locale: auth()->user()->language), 'timestamp' => Carbon::createFromTimestamp($key, (auth()->user()->timezone ?? 'UTC'))->format('H:i:s'), ]) ->all(); @@ -73,8 +74,8 @@ class NodeCpuChart extends ChartWidget $node = $this->record; $threads = $node->systemInformation()['cpu_count'] ?? 0; - $cpu = number_format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, 2); - $max = number_format($threads * 100) . '%'; + $cpu = Number::format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, maxPrecision: 2, locale: auth()->user()->language); + $max = Number::format($threads * 100, locale: auth()->user()->language) . '%'; return 'CPU - ' . $cpu . '% Of ' . $max; } diff --git a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php index 3d8762447..9d75fd116 100644 --- a/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php +++ b/app/Filament/Resources/NodeResource/Widgets/NodeMemoryChart.php @@ -7,6 +7,7 @@ use Carbon\Carbon; use Filament\Support\RawJs; use Filament\Widgets\ChartWidget; use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Number; class NodeMemoryChart extends ChartWidget { @@ -22,7 +23,7 @@ class NodeMemoryChart extends ChartWidget $memUsed = collect(cache()->get("nodes.$node->id.memory_used"))->slice(-10) ->map(fn ($value, $key) => [ - 'memory' => config('panel.use_binary_prefix') ? $value / 1024 / 1024 / 1024 : $value / 1000 / 1000 / 1000, + 'memory' => Number::format(config('panel.use_binary_prefix') ? $value / 1024 / 1024 / 1024 : $value / 1000 / 1000 / 1000, maxPrecision: 2, locale: auth()->user()->language), 'timestamp' => Carbon::createFromTimestamp($key, (auth()->user()->timezone ?? 'UTC'))->format('H:i:s'), ]) ->all(); @@ -73,12 +74,12 @@ class NodeMemoryChart extends ChartWidget $totalMemory = collect(cache()->get("nodes.$node->id.memory_total"))->last(); $used = config('panel.use_binary_prefix') - ? number_format($latestMemoryUsed / 1024 / 1024 / 1024, 2) .' GiB' - : number_format($latestMemoryUsed / 1000 / 1000 / 1000, 2) . ' GB'; + ? 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, 2) .' GiB' - : number_format($totalMemory / 1000 / 1000 / 1000, 2) . ' GB'; + ? 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; }