* Fix #489

* Update app/Filament/Resources/NodeResource/Pages/EditNode.php

Co-authored-by: Boy132 <Boy132@users.noreply.github.com>

* Update app/Filament/Resources/NodeResource/Pages/EditNode.php

Co-authored-by: Boy132 <Boy132@users.noreply.github.com>

* Update app/Filament/Resources/NodeResource/Pages/EditNode.php

Co-authored-by: Boy132 <Boy132@users.noreply.github.com>

---------

Co-authored-by: Boy132 <Boy132@users.noreply.github.com>
This commit is contained in:
MartinOscar 2024-07-17 22:22:12 +02:00 committed by GitHub
parent 10806d6d6b
commit 56b4938dc2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -52,16 +52,16 @@ class EditNode extends EditRecord
->schema([ ->schema([
Placeholder::make('') Placeholder::make('')
->label('Wings Version') ->label('Wings Version')
->content(fn (Node $node) => $node->systemInformation()['version']), ->content(fn (Node $node) => $node->systemInformation()['version'] ?? 'Unknown'),
Placeholder::make('') Placeholder::make('')
->label('CPU Threads') ->label('CPU Threads')
->content(fn (Node $node) => $node->systemInformation()['cpu_count']), ->content(fn (Node $node) => $node->systemInformation()['cpu_count'] ?? 0),
Placeholder::make('') Placeholder::make('')
->label('Architecture') ->label('Architecture')
->content(fn (Node $node) => $node->systemInformation()['architecture']), ->content(fn (Node $node) => $node->systemInformation()['architecture'] ?? 'Unknown'),
Placeholder::make('') Placeholder::make('')
->label('Kernel') ->label('Kernel')
->content(fn (Node $node) => $node->systemInformation()['kernel_version']), ->content(fn (Node $node) => $node->systemInformation()['kernel_version'] ?? 'Unknown'),
]), ]),
View::make('filament.components.node-cpu-chart')->columnSpan(3), View::make('filament.components.node-cpu-chart')->columnSpan(3),
View::make('filament.components.node-memory-chart')->columnSpan(3), View::make('filament.components.node-memory-chart')->columnSpan(3),

View File

@ -19,7 +19,7 @@ class NodeCpuChart extends ChartWidget
{ {
/** @var Node $node */ /** @var Node $node */
$node = $this->record; $node = $this->record;
$threads = $node->systemInformation()['cpu_count']; $threads = $node->systemInformation()['cpu_count'] ?? 0;
$cpu = collect(cache()->get("nodes.$node->id.cpu_percent")) $cpu = collect(cache()->get("nodes.$node->id.cpu_percent"))
->slice(-10) ->slice(-10)
@ -71,7 +71,7 @@ class NodeCpuChart extends ChartWidget
{ {
/** @var Node $node */ /** @var Node $node */
$node = $this->record; $node = $this->record;
$threads = $node->systemInformation()['cpu_count']; $threads = $node->systemInformation()['cpu_count'] ?? 0;
$cpu = number_format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, 2); $cpu = number_format(collect(cache()->get("nodes.$node->id.cpu_percent"))->last() * $threads, 2);
$max = number_format($threads * 100) . '%'; $max = number_format($threads * 100) . '%';