NodeStorageChart: Format data after math (#931)

This commit is contained in:
Boy132 2025-01-19 01:09:54 +01:00 committed by GitHub
parent 7e6769c96e
commit 3411e5e65c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -39,15 +39,18 @@ class NodeStorageChart extends ChartWidget
protected function getData(): array protected function getData(): array
{ {
$total = Number::format(config('panel.use_binary_prefix') $total = config('panel.use_binary_prefix')
? ($this->node->statistics()['disk_total'] ?? 0) / 1024 / 1024 / 1024 ? ($this->node->statistics()['disk_total'] ?? 0) / 1024 / 1024 / 1024
: ($this->node->statistics()['disk_total'] ?? 0) / 1000 / 1000 / 1000, maxPrecision: 2); : ($this->node->statistics()['disk_total'] ?? 0) / 1000 / 1000 / 1000;
$used = Number::format(config('panel.use_binary_prefix') $used = config('panel.use_binary_prefix')
? ($this->node->statistics()['disk_used'] ?? 0) / 1024 / 1024 / 1024 ? ($this->node->statistics()['disk_used'] ?? 0) / 1024 / 1024 / 1024
: ($this->node->statistics()['disk_used'] ?? 0) / 1000 / 1000 / 1000, maxPrecision: 2); : ($this->node->statistics()['disk_used'] ?? 0) / 1000 / 1000 / 1000;
$unused = $total - $used; $unused = $total - $used;
$used = Number::format($used, maxPrecision: 2);
$unused = Number::format($unused, maxPrecision: 2);
return [ return [
'datasets' => [ 'datasets' => [
[ [