Charles f8ad720f52
Admin Area Translations (#965)
* Init

* Health Page

* Admin API Keys

* Update API Keys

* Database Hosts

* Mounts

* remove `s`

* Users

* Webhooks

* Server

never again...

* Fix Server

* Settings

* Update Mounts

* Update Databasehost

* Update Server

* Oops, Update Server

* Nodes

* Update User

* Dashboard

* Update Server

* Profile

* Egg

* Role & Update Egg

* Add base Laravel lang files

* update apikey

* remove html back to settings, remove comment

* add `:resource` to create_action

* Update Egg

* Update Egg v2

* Update 1

* trans cf info label

* Update charts

* more trans

* Update Webhook

* update Health

* Update Server

* Update Role

* Fixes

* Bulk Update

* AnotherOne

* Fix relation button label

* rename `admin1` to `admin`

Leftover from testing... oops

* More Translations

* Updates

* `pint` + Relation Manager Titles
2025-02-08 23:16:54 -05:00

81 lines
2.3 KiB
PHP

<?php
namespace App\Filament\Admin\Resources\NodeResource\Widgets;
use App\Models\Node;
use Filament\Widgets\ChartWidget;
use Illuminate\Support\Number;
class NodeStorageChart extends ChartWidget
{
protected static ?string $pollingInterval = '360s';
protected static ?string $maxHeight = '200px';
public Node $node;
protected static ?array $options = [
'scales' => [
'x' => [
'grid' => [
'display' => false,
],
'ticks' => [
'display' => false,
],
],
'y' => [
'grid' => [
'display' => false,
],
'ticks' => [
'display' => false,
],
],
],
];
protected function getData(): array
{
$total = config('panel.use_binary_prefix')
? ($this->node->statistics()['disk_total'] ?? 0) / 1024 / 1024 / 1024
: ($this->node->statistics()['disk_total'] ?? 0) / 1000 / 1000 / 1000;
$used = config('panel.use_binary_prefix')
? ($this->node->statistics()['disk_used'] ?? 0) / 1024 / 1024 / 1024
: ($this->node->statistics()['disk_used'] ?? 0) / 1000 / 1000 / 1000;
$unused = $total - $used;
$used = Number::format($used, maxPrecision: 2);
$unused = Number::format($unused, maxPrecision: 2);
return [
'datasets' => [
[
'data' => [$used, $unused],
'backgroundColor' => [
'rgb(59, 130, 246)',
'rgb(74, 222, 128)',
'rgb(255, 205, 86)',
],
],
],
'labels' => [trans('admin/node.used'), trans('admin/node.unused')],
'locale' => auth()->user()->language ?? 'en',
];
}
protected function getType(): string
{
return 'pie';
}
public function getHeading(): string
{
$used = convert_bytes_to_readable($this->node->statistics()['disk_used'] ?? 0);
$total = convert_bytes_to_readable($this->node->statistics()['disk_total'] ?? 0);
return trans('admin/node.disk_chart', ['used' => $used, 'total' => $total]);
}
}