fix 500 when node is not reachable

This commit is contained in:
Boy132 2025-05-16 08:43:17 +02:00
parent 8c52209d5f
commit 28f971b26e

View File

@ -23,7 +23,7 @@ class NodeCpuChart extends ChartWidget
protected function getData(): array protected function getData(): array
{ {
$data = $this->node->statistics(); $data = $this->node->statistics();
$threads = $this->node->systemInformation()['cpu_count']; $threads = $this->node->systemInformation()['cpu_count'] ?? 0;
$this->cpuHistory = session()->get('cpuHistory', []); $this->cpuHistory = session()->get('cpuHistory', []);
$this->cpuHistory[] = [ $this->cpuHistory[] = [
@ -75,7 +75,7 @@ class NodeCpuChart extends ChartWidget
public function getHeading(): string public function getHeading(): string
{ {
$threads = $this->node->systemInformation()['cpu_count']; $threads = $this->node->systemInformation()['cpu_count'] ?? 0;
$data = array_slice(end($this->cpuHistory), -60); $data = array_slice(end($this->cpuHistory), -60);
$cpu = Number::format($data['cpu'], maxPrecision: 2, locale: auth()->user()->language); $cpu = Number::format($data['cpu'], maxPrecision: 2, locale: auth()->user()->language);