@extends('layouts.front') @section('title', 'Statut des services') @section('styles') @endsection @section('content') @php $slotClass = function(string $s) { return match($s) { 'ok' => 'bg-emerald-500', 'degraded' => 'bg-amber-400', 'maintenance' => 'bg-sky-500', 'down' => 'bg-rose-500', default => 'bg-slate-400', }; }; $pill = function(string $s) { return match($s) { 'ok' => 'bg-emerald-500 text-white', 'degraded' => 'bg-amber-400 text-slate-900', 'maintenance' => 'bg-sky-500 text-white', 'down' => 'bg-rose-500 text-white', default => 'bg-slate-500 text-white', }; }; $label = function(string $s) { return match($s) { 'ok' => 'Opérationnel', 'degraded' => 'Dégradé', 'maintenance' => 'Maintenance', 'down' => 'Incident', default => 'Inconnu', }; }; $maintenanceBox = function(?string $severity) { return match($severity) { 'yellow' => 'border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-100', 'orange' => 'border-orange-200 bg-orange-50 text-orange-950 dark:border-orange-900/60 dark:bg-orange-950/20 dark:text-orange-100', 'red' => 'border-rose-200 bg-rose-50 text-rose-950 dark:border-rose-900/60 dark:bg-rose-950/20 dark:text-rose-100', default => 'border-amber-200 bg-amber-50 text-amber-950 dark:border-amber-900/60 dark:bg-amber-950/20 dark:text-amber-100', }; }; $maintenancePill = function(?string $severity) { return match($severity) { 'yellow' => 'bg-amber-200 text-amber-950 dark:bg-amber-900/50 dark:text-amber-100', 'orange' => 'bg-orange-200 text-orange-950 dark:bg-orange-900/50 dark:text-orange-100', 'red' => 'bg-rose-200 text-rose-950 dark:bg-rose-900/50 dark:text-rose-100', default => 'bg-amber-200 text-amber-950 dark:bg-amber-900/50 dark:text-amber-100', }; }; $isMonitorAffected = function(int $monitorId) use ($activeMessage, $affectedMonitorIds) { if (empty($activeMessage)) return false; if (empty($affectedMonitorIds)) return true; return in_array($monitorId, $affectedMonitorIds, true); }; $effectiveStatus = function($m) use ($isMonitorAffected) { if ($isMonitorAffected((int)$m->id)) { return 'maintenance'; } return $m->forced_status ?: ($m->last_status ?: 'down'); }; $allMonitors = collect(); foreach ($monitorsByCategory as $group) { $allMonitors = $allMonitors->merge($group); } $countTotal = $allMonitors->count(); $countDown = $allMonitors->filter(fn($m) => ($effectiveStatus($m) === 'down'))->count(); $countDegraded = $allMonitors->filter(fn($m) => ($effectiveStatus($m) === 'degraded'))->count(); $countMaint = $allMonitors->filter(fn($m) => ($effectiveStatus($m) === 'maintenance'))->count(); $countOk = $allMonitors->filter(fn($m) => ($effectiveStatus($m) === 'ok'))->count(); $globalState = 'ok'; if ($countDown > 0) $globalState = 'down'; elseif ($countDegraded > 0) $globalState = 'degraded'; elseif ($countMaint > 0) $globalState = 'maintenance'; $stateText = match($globalState) { 'ok' => 'Tous les systèmes sont opérationnels.', 'degraded' => 'Certains services sont dégradés.', 'maintenance' => 'Maintenance en cours sur certains services.', 'down' => 'Incident en cours : certains services sont indisponibles.', default => 'Statut inconnu.', }; @endphp
{{-- HERO (safe, no absolute positioning) --}}

Statut des services

{{ $stateText }}

OK: {{ $countOk }} Dégradé: {{ $countDegraded }} Maintenance: {{ $countMaint }} Incident: {{ $countDown }}
{{-- Maintenance banner --}} @if(!empty($activeMessage)) @php $sev = $activeMessage->severity ?: 'yellow'; @endphp
{{ $activeMessage->title }}
Maintenance
@if($activeMessage->description)
{{ $activeMessage->description }}
@endif
@if($activeMessage->starts_at) Début : {{ $activeMessage->starts_at }} @endif @if($activeMessage->ends_at) @if($activeMessage->starts_at) • @endif Fin : {{ $activeMessage->ends_at }} @endif @if(empty($affectedMonitorIds)) • Portée : globale @else • Portée : {{ count($affectedMonitorIds) }} sonde(s) @endif
@endif {{-- Categories --}} @forelse($categories as $cat) @php $monitors = $monitorsByCategory->get($cat->id, collect()); @endphp
{{ $cat->name }}
@if($cat->description)
{{ $cat->description }}
@endif
{{ $monitors->count() }} sonde(s)
@forelse($monitors as $m) @php $affected = $isMonitorAffected((int)$m->id); $status = $affected ? 'maintenance' : ($m->forced_status ?: ($m->last_status ?: 'down')); $slots = $slotsByMonitor[$m->id] ?? []; $meta = []; if ($m->last_response_time_ms) $meta[] = $m->last_response_time_ms.'ms'; if ($m->last_http_code) $meta[] = 'HTTP '.$m->last_http_code; @endphp
{{ $m->name }}
@if($affected) Maintenance @endif
{{ strtoupper($m->type) }} @if(count($meta)) • {{ implode(' • ', $meta) }} @endif
@if($m->description)
{{ $m->description }}
@endif
{{ $label($status) }}
▾
@foreach($slots as $slot)
@endforeach
1h Maintenant
Vérifier toutes les {{ (int)$m->interval_sec }} secondes ({{ max(1, (int) round($m->interval_sec / 60)) }} minutes)
{{ $label($status) }}
Dernier check
@if($m->last_checked_at)
{{ $m->last_checked_at->diffForHumans() }}
{{ $m->last_checked_at }}
@else
Jamais
@endif
Mesures
Réponse : {{ $m->last_response_time_ms ? $m->last_response_time_ms.'ms' : '-' }}
HTTP : {{ $m->last_http_code ?: '-' }}
Type : {{ $m->type }}
Informations
Catégorie : {{ $cat->name }}
@if($activeMessage && $affected)
Maintenance en cours (message d’information)
@endif @if($m->last_error && ($status === 'down'))
Erreur : {{ $m->last_error }}
@endif
@empty
Aucune sonde dans cette catégorie.
@endforelse
@empty
Aucune catégorie/sonde active n’est configurée.
@endforelse
@endsection