load(); } public function render() { return view('livewire.ui.system.woltguard-card'); } /** Manuelles Refresh aus dem UI */ public function refresh(): void { $this->load(); } /* ---------------- intern ---------------- */ protected function load(): void { // Erwartet: Cache::put('health:services', [['name'=>'postfix','ok'=>true], ...]) $list = Cache::get('health:services', []); $this->services = is_array($list) ? $list : []; $this->totalCount = count($this->services); $this->okCount = collect($this->services)->filter(fn ($s) => (bool)($s['ok'] ?? false))->count(); $this->downCount = $this->totalCount - $this->okCount; $this->guardOk = ($this->totalCount > 0) && ($this->downCount === 0); // Down-Services Namen extrahieren $this->downServices = collect($this->services) ->filter(fn ($s) => !($s['ok'] ?? false)) ->map(fn ($s) => (string)($s['name'] ?? 'unbekannt')) ->values() ->all(); // Badge aufbereiten (Text/Style/Icon) if ($this->totalCount === 0) { $this->badgeText = 'keine Daten'; $this->badgeIcon = 'ph ph-warning-circle'; $this->badgeClass = 'text-amber-300 border-amber-400/30 bg-amber-500/10'; return; } if ($this->guardOk) { $this->badgeText = 'alle Dienste OK'; $this->badgeIcon = 'ph ph-check-circle'; $this->badgeClass = 'text-emerald-300 border-emerald-400/30 bg-emerald-500/10'; } else { // kleine Abstufung je nach Anzahl der Störungen if ($this->downCount >= 3) { $this->badgeText = "{$this->downCount} Dienste down"; $this->badgeIcon = 'ph ph-x-circle'; $this->badgeClass = 'text-rose-300 border-rose-400/30 bg-rose-500/10'; } else { $this->badgeText = 'Störung erkannt'; $this->badgeIcon = 'ph ph-warning-circle'; $this->badgeClass = 'text-amber-300 border-amber-400/30 bg-amber-500/10'; } } } }