34 lines
809 B
PHP
34 lines
809 B
PHP
<?php
|
|
|
|
namespace App\Livewire\Widgets;
|
|
|
|
use App\Services\SystemStatsService;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Component;
|
|
|
|
class SystemStats extends Component
|
|
{
|
|
public array $stats = [];
|
|
|
|
public function mount(SystemStatsService $service): void
|
|
{
|
|
// Erstwert beim Page-Load - danach kommen Updates per Reverb-Push.
|
|
$this->stats = $service->collect();
|
|
}
|
|
|
|
/**
|
|
* Wird vom Reverb-Broadcast (fox:broadcast-stats Command) gefeuert.
|
|
* payload kommt direkt aus SystemStatsBroadcast::broadcastWith().
|
|
*/
|
|
#[On('echo:fox,.stats.system')]
|
|
public function onStats(array $payload): void
|
|
{
|
|
$this->stats = $payload;
|
|
}
|
|
|
|
public function render()
|
|
{
|
|
return view('livewire.widgets.system-stats', ['stats' => $this->stats]);
|
|
}
|
|
}
|