diff --git a/src/Heimdall.Agent/Services/AgentRegistrationService.cs b/src/Heimdall.Agent/Services/AgentRegistrationService.cs
index d94427c..57bcbe2 100644
--- a/src/Heimdall.Agent/Services/AgentRegistrationService.cs
+++ b/src/Heimdall.Agent/Services/AgentRegistrationService.cs
@@ -52,6 +52,10 @@ public class AgentRegistrationService : BackgroundService
_state.ApiKey = result.ApiKey;
_state.ApiKeyPrefix = result.ApiKeyPrefix;
+ // Set API Key header for subsequent requests
+ client.DefaultRequestHeaders.Remove("Authorization");
+ client.DefaultRequestHeaders.Add("Authorization", $"Bearer {result.ApiKey}");
+
_logger.LogInformation(
"Agent registered successfully. ID: {AgentId}, Key prefix: {Prefix}",
result.AgentId, result.ApiKeyPrefix);
diff --git a/src/Heimdall.Web/Components/Pages/CamerasPage.razor b/src/Heimdall.Web/Components/Pages/CamerasPage.razor
new file mode 100644
index 0000000..eb30aba
--- /dev/null
+++ b/src/Heimdall.Web/Components/Pages/CamerasPage.razor
@@ -0,0 +1,157 @@
+@page "/sites/{SiteId:guid}/cameras"
+@attribute [Authorize]
+@layout MainLayout
+@inject HeimdallApiClient Api
+@inject ISnackbar Snackbar
+@inject NavigationManager Nav
+
+
+
+ Caméras du site
+
+
+
+ Ajouter une caméra
+
+
+
+ ← Retour aux sites
+
+
+@if (_loading)
+{
+
+}
+else
+{
+
+
+ Nom
+ Fabricant
+ Modèle
+ RTSP
+ Statut
+ Actions
+
+
+ @context.Name
+ @context.Manufacturer
+ @context.Model
+
+ @context.RtspUrl
+
+
+
+ @context.Status
+
+
+
+
+
+
+
+ Aucune caméra. Cliquez sur "Ajouter une caméra".
+
+
+}
+
+@if (_showCreate)
+{
+
+
+ Ajouter une caméra
+
+
+
+
+
+ @if (!string.IsNullOrEmpty(_error))
+ {
+ @_error
+ }
+
+
+ Annuler
+
+ @if (_saving) { }
+ Ajouter
+
+
+
+}
+
+@code {
+ [Parameter] public Guid SiteId { get; set; }
+
+ private IReadOnlyList? _cameras;
+ private bool _loading = true;
+ private bool _showCreate;
+ private bool _saving;
+ private string _error = "";
+
+ private string _newName = "";
+ private string? _newManufacturer;
+ private string? _newModel;
+ private string? _newRtspUrl;
+
+ protected override async Task OnInitializedAsync() => await LoadCameras();
+
+ private async Task LoadCameras()
+ {
+ _loading = true;
+ try
+ {
+ var result = await Api.GetCamerasBySiteAsync(SiteId);
+ _cameras = result?.Items;
+ }
+ catch (Exception ex) { Snackbar.Add($"Erreur : {ex.Message}", Severity.Error); }
+ finally { _loading = false; }
+ }
+
+ private async Task CreateCamera()
+ {
+ if (string.IsNullOrWhiteSpace(_newName)) { _error = "Le nom est requis"; return; }
+ _saving = true;
+ _error = "";
+ try
+ {
+ var result = await Api.CreateCameraAsync(SiteId, _newName, _newRtspUrl, _newManufacturer, _newModel);
+ if (result is null) { _error = "Erreur lors de la création"; return; }
+ _showCreate = false;
+ ResetForm();
+ Snackbar.Add("Caméra ajoutée", Severity.Success);
+ await LoadCameras();
+ }
+ catch (Exception ex) { _error = $"Erreur : {ex.Message}"; }
+ finally { _saving = false; }
+ }
+
+ private async Task DeleteCamera(Guid id, string name)
+ {
+ if (await Api.DeleteCameraAsync(id))
+ {
+ Snackbar.Add($"Caméra \"{name}\" supprimée", Severity.Success);
+ await LoadCameras();
+ }
+ else Snackbar.Add("Erreur", Severity.Error);
+ }
+
+ private void ResetForm()
+ {
+ _newName = "";
+ _newManufacturer = null;
+ _newModel = null;
+ _newRtspUrl = null;
+ }
+
+ private static Color GetStatusColor(string status) => status switch
+ {
+ "Online" => Color.Success,
+ "Offline" => Color.Error,
+ "Disabled" => Color.Default,
+ _ => Color.Warning
+ };
+}
diff --git a/src/Heimdall.Web/Services/HeimdallApiClient.cs b/src/Heimdall.Web/Services/HeimdallApiClient.cs
index 54f2e13..66d32b8 100644
--- a/src/Heimdall.Web/Services/HeimdallApiClient.cs
+++ b/src/Heimdall.Web/Services/HeimdallApiClient.cs
@@ -148,4 +148,41 @@ public class HeimdallApiClient
var response = await client.DeleteAsync($"api/sites/{id}");
return response.IsSuccessStatusCode;
}
+
+ // ─── Cameras ────────────────────────────────────────────────────
+
+ public async Task?> GetCamerasBySiteAsync(Guid siteId, int page = 1, int pageSize = 20)
+ {
+ var client = CreateClient();
+ return await client.GetFromJsonAsync>(
+ $"api/cameras/by-site/{siteId}?page={page}&pageSize={pageSize}", Json);
+ }
+
+ public async Task CreateCameraAsync(Guid siteId, string name, string? rtspUrl, string? manufacturer, string? model)
+ {
+ var client = CreateClient();
+ var response = await client.PostAsJsonAsync("api/cameras",
+ new { siteId, name, rtspUrl, manufacturer, model }, Json);
+ if (!response.IsSuccessStatusCode) return null;
+ return await response.Content.ReadFromJsonAsync(Json);
+ }
+
+ public async Task DeleteCameraAsync(Guid id)
+ {
+ var client = CreateClient();
+ var response = await client.DeleteAsync($"api/cameras/{id}");
+ return response.IsSuccessStatusCode;
+ }
+}
+
+public class CameraItem
+{
+ public Guid Id { get; set; }
+ public Guid SiteId { get; set; }
+ public string Name { get; set; } = "";
+ public string? Manufacturer { get; set; }
+ public string? Model { get; set; }
+ public string? RtspUrl { get; set; }
+ public string Status { get; set; } = "Unknown";
+ public DateTime CreatedAt { get; set; }
}