39 lines
730 B
PHP
Raw Normal View History

2024-06-17 14:21:27 +02:00
<?php
namespace App\Livewire\Charts;
use App\Models\Server as ModelsServer;
use Livewire\Component;
class Server extends Component
{
public ModelsServer $server;
2024-06-17 12:22:17 +00:00
2024-06-17 14:21:27 +02:00
public $chartId = 'server';
2024-06-17 12:22:17 +00:00
2024-06-17 14:21:27 +02:00
public $data;
2024-06-17 12:22:17 +00:00
2024-06-17 14:21:27 +02:00
public $categories;
public function render()
{
return view('livewire.charts.server');
}
2024-06-17 12:22:17 +00:00
2024-06-17 14:21:27 +02:00
public function mount()
{
$this->loadData();
}
2024-06-17 12:22:17 +00:00
2024-06-17 14:21:27 +02:00
public function loadData()
{
$metrics = $this->server->getMetrics();
$metrics = collect($metrics)->map(function ($metric) {
return [$metric[0], $metric[1]];
});
$this->dispatch("refreshChartData-{$this->chartId}", [
'seriesData' => $metrics,
]);
}
}