@page "/events" @attribute [Authorize] @layout MainLayout @inject HeimdallApiClient Api @inject ISnackbar Snackbar @inject NavigationManager Nav Événements Filtres Actualiser @if (_loading) { } else if (_events is null || _events.Count == 0) { Aucun événement trouvé. } else { Horodatage Caméra Type Confiance Label Actions @context.OccurredAt.ToLocalTime().ToString("g") @context.CameraId.ToString()[..8] @FormatEventType(context.Type) @($"{context.Confidence:P0}") @context.Label } @if (_showSnapshotEvent is not null) { Snapshot — @FormatEventType(_showSnapshotEvent.Type) Snapshot Fermer } @code { private List? _events; private bool _loading; private bool _showSnapshot; private EventItem? _showSnapshotEvent; private readonly DialogOptions _dialogOptions = new() { FullWidth = true, MaxWidth = MaxWidth.Large, CloseButton = true }; protected override async Task OnInitializedAsync() => await LoadEvents(); private async Task LoadEvents() { _loading = true; try { var result = await Api.GetEventsAsync(null, null, 1); _events = result?.Items ?? []; } catch (Exception ex) { Snackbar.Add($"Erreur: {ex.Message}", Severity.Error); } finally { _loading = false; } } private void ShowSnapshot(EventItem ev) { _showSnapshotEvent = ev; _showSnapshot = true; } private static string FormatEventType(string type) => type switch { "MotionDetected" => "Mouvement", "PersonDetected" => "Personne", "VehicleDetected" => "Véhicule", "FaceRecognized" => "Visage", "CameraOffline" => "Hors ligne", _ => type }; private static Color GetEventColor(string type) => type switch { "MotionDetected" => Color.Warning, "PersonDetected" => Color.Error, "VehicleDetected" => Color.Info, "FaceRecognized" => Color.Success, _ => Color.Default }; }