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 { $list = Cache::get(CacheVer::k('health:services')); if (empty($list)) { // Fallback: persistierter Wert aus DB/Redis $list = \App\Support\Setting::get('woltguard.services', []); } $rows = []; if (is_array($list)) { $rows = isset($list['rows']) && is_array($list['rows']) ? $list['rows'] // neues Format : (isset($list[0]) && is_array($list[0]) ? $list : []); // altes Format } $this->services = $rows; $this->totalCount = count($rows); $this->okCount = collect($rows)->where('ok', true)->count(); $this->downCount = $this->totalCount - $this->okCount; $this->guardOk = $this->totalCount > 0 && $this->downCount === 0; $this->downServices = collect($rows) ->filter(fn($s) => !($s['ok'] ?? false)) ->map(fn($s) => (string)($s['name'] ?? 'unbekannt')) ->values()->all(); // Badge 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 { $this->badgeText = $this->downCount >= 3 ? "{$this->downCount} Dienste down" : 'Störung erkannt'; $this->badgeIcon = $this->downCount >= 3 ? 'ph ph-x-circle' : 'ph ph-warning-circle'; $this->badgeClass = $this->downCount >= 3 ? 'text-rose-300 border-rose-400/30 bg-rose-500/10' : 'text-amber-300 border-amber-400/30 bg-amber-500/10'; } } }