/
dimamir
/
coolify
Обзор
Документация
Войти
/
dimamir
/
coolify
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
app/Livewire/Server/Charts.php
64 строки
1 KB
Lucas Michot
Get rid of many useless blank lines
31 окт 2024, 19:44
31 окт 2024, 19:44
8e1444e
Код
Авторство
О чём код?
<?php namespace App\Livewire\Server; use App\Models\Server; use Livewire\Component; class Charts extends Component { public Server $server; public $chartId = 'server'; public $data; public $categories; public int $interval = 5; public bool $poll = true; public function mount(string $server_uuid) { try { $this->server = Server::ownedByCurrentTeam()->whereUuid($server_uuid)->firstOrFail(); } catch (\Throwable $e) { return handleError($e, $this); } } public function pollData() { if ($this->poll || $this->interval <= 10) { $this->loadData(); if ($this->interval > 10) { $this->poll = false; } } } public function loadData() { try { $cpuMetrics = $this->server->getCpuMetrics($this->interval); $memoryMetrics = $this->server->getMemoryMetrics($this->interval); $this->dispatch("refreshChartData-{$this->chartId}-cpu", [ 'seriesData' => $cpuMetrics, ]); $this->dispatch("refreshChartData-{$this->chartId}-memory", [ 'seriesData' => $memoryMetrics, ]); } catch (\Throwable $e) { return handleError($e, $this); } } public function setInterval() { if ($this->interval <= 10) { $this->poll = true; } $this->loadData(); } }