diff --git a/src/Heimdall.Web/Components/Layout/MainLayout.razor b/src/Heimdall.Web/Components/Layout/MainLayout.razor
index fdaee26..8d5ada2 100644
--- a/src/Heimdall.Web/Components/Layout/MainLayout.razor
+++ b/src/Heimdall.Web/Components/Layout/MainLayout.razor
@@ -67,6 +67,9 @@
Matrice des permissions
+
+ Événements
+
Journal d'audit
diff --git a/src/Heimdall.Web/Components/Pages/CameraDetail.razor b/src/Heimdall.Web/Components/Pages/CameraDetail.razor
index ba12c1f..03bb11b 100644
--- a/src/Heimdall.Web/Components/Pages/CameraDetail.razor
+++ b/src/Heimdall.Web/Components/Pages/CameraDetail.razor
@@ -66,18 +66,81 @@ else
← Retour aux caméras
+
+ @* Recent Events *@
+
+ Événements récents
+
+
+ @if (_eventsLoading)
+ {
+
+ }
+ else if (_events is { Count: > 0 })
+ {
+
+
+ Horodatage
+ Type
+ Confiance
+ Label
+
+
+
+ @context.OccurredAt.ToLocalTime().ToString("g")
+ @context.Type
+ @($"{context.Confidence:P0}")
+ @context.Label
+
+
+
+
+
+
+ Voir tous les événements →
+
+ }
+ else
+ {
+ Aucun événement récent.
+ }
+
+ @if (_showSnapshotUrl is not null)
+ {
+
+
+
+
+
+ Fermer
+
+
+ }
}
@code {
[Parameter] public Guid Id { get; set; }
private CameraItem? _camera;
- private bool _loading = true;
- private bool _saving;
private string _editName = "";
private string? _editRtspUrl;
private string _editError = "";
private string _editSuccess = "";
+ private bool _loading = true;
+ private bool _saving;
+
+ private List? _events;
+ private bool _eventsLoading;
+ private string? _showSnapshotUrl;
+ private bool _showSnapshotDialog;
+ private readonly DialogOptions _snapshotOptions = new()
+ {
+ FullWidth = true,
+ MaxWidth = MaxWidth.Large,
+ CloseButton = true
+ };
protected override async Task OnInitializedAsync()
{
@@ -92,6 +155,10 @@ else
}
catch (Exception ex) { Snackbar.Add($"Erreur : {ex.Message}", Severity.Error); }
finally { _loading = false; }
+
+ try { _eventsLoading = true; _events = await Api.GetRecentEventsAsync(Id, 10); }
+ catch { }
+ finally { _eventsLoading = false; }
}
private async Task SaveCamera()
diff --git a/src/Heimdall.Web/Components/Pages/EventsPage.razor b/src/Heimdall.Web/Components/Pages/EventsPage.razor
new file mode 100644
index 0000000..e7dfcad
--- /dev/null
+++ b/src/Heimdall.Web/Components/Pages/EventsPage.razor
@@ -0,0 +1,135 @@
+@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)
+
+
+
+
+
+ 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
+ };
+}
diff --git a/src/Heimdall.Web/Services/HeimdallApiClient.cs b/src/Heimdall.Web/Services/HeimdallApiClient.cs
index e82659f..e18d107 100644
--- a/src/Heimdall.Web/Services/HeimdallApiClient.cs
+++ b/src/Heimdall.Web/Services/HeimdallApiClient.cs
@@ -402,6 +402,29 @@ public class HeimdallApiClient
return await client.GetFromJsonAsync>(
$"api/settings/agent/{agentId}") ?? [];
}
+
+ // ─── Events ────────────────────────────────────────────────────────
+
+ public async Task GetEventsAsync(Guid? cameraId, Guid? siteId, int page = 1, int pageSize = 50)
+ {
+ var client = CreateClient();
+ var query = $"page={page}&pageSize={pageSize}";
+ if (cameraId.HasValue) query += $"&cameraId={cameraId}";
+ if (siteId.HasValue) query += $"&siteId={siteId}";
+ return await client.GetFromJsonAsync($"api/events?{query}", Json);
+ }
+
+ public async Task?> GetRecentEventsAsync(Guid cameraId, int count = 20)
+ {
+ var client = CreateClient();
+ return await client.GetFromJsonAsync>($"api/events/camera/{cameraId}?count={count}", Json);
+ }
+
+ public async Task GetEventAsync(Guid eventId)
+ {
+ var client = CreateClient();
+ return await client.GetFromJsonAsync($"api/events/{eventId}", Json);
+ }
}
public class CameraItem
@@ -507,6 +530,23 @@ public record SetAgentSettingRequest(
[property: JsonPropertyName("value")] string Value
);
+public record EventItem(
+ [property: JsonPropertyName("id")] Guid Id,
+ [property: JsonPropertyName("cameraId")] Guid CameraId,
+ [property: JsonPropertyName("type")] string Type,
+ [property: JsonPropertyName("confidence")] double Confidence,
+ [property: JsonPropertyName("label")] string? Label,
+ [property: JsonPropertyName("snapshotUrl")] string? SnapshotUrl,
+ [property: JsonPropertyName("snapshotThumbUrl")] string? SnapshotThumbUrl,
+ [property: JsonPropertyName("occurredAt")] DateTime OccurredAt,
+ [property: JsonPropertyName("createdAt")] DateTime CreatedAt);
+
+public record EventPageResult(
+ [property: JsonPropertyName("items")] List Items,
+ [property: JsonPropertyName("totalCount")] int TotalCount,
+ [property: JsonPropertyName("page")] int Page,
+ [property: JsonPropertyName("pageSize")] int PageSize);
+
// ─── Roles & Permissions DTOs ──────────────────────────────────────
public record RoleItem(