diff --git a/src/Heimdall.Web/Components/Layout/MainLayout.razor b/src/Heimdall.Web/Components/Layout/MainLayout.razor
index bd068e5..bd8ca6d 100644
--- a/src/Heimdall.Web/Components/Layout/MainLayout.razor
+++ b/src/Heimdall.Web/Components/Layout/MainLayout.razor
@@ -5,7 +5,7 @@
@inject IJSRuntime JsRuntime
@using Heimdall.Web.Theme
-
+
@@ -29,8 +29,10 @@
@if (Auth.IsLoggedIn)
{
-
+
+
@@ -50,7 +52,8 @@
}
-
+
@if (Auth.IsLoggedIn)
{
@@ -62,6 +65,12 @@
Sites & Caméras
+
+ Événements
+
+
+ Snapshots
+
@if (Auth.HasPermission("Admin.Users") || Auth.HasPermission("Admin.Manage"))
{
@@ -81,12 +90,6 @@
Matrice des permissions
-
- Événements
-
-
- Snapshots
-
Journal d'audit
@@ -115,8 +118,16 @@
@code {
private bool _drawerOpen = true;
+ private bool _miniVariant;
+ private bool _darkMode = true;
private string _searchQuery = "";
+ private void ToggleDarkMode()
+ {
+ _darkMode = !_darkMode;
+ StateHasChanged();
+ }
+
private async Task Logout()
{
await AuthStateProvider.NotifyLogoutAsync();
diff --git a/src/Heimdall.Web/Components/Shared/NotificationBadge.razor b/src/Heimdall.Web/Components/Shared/NotificationBadge.razor
new file mode 100644
index 0000000..e907199
--- /dev/null
+++ b/src/Heimdall.Web/Components/Shared/NotificationBadge.razor
@@ -0,0 +1,30 @@
+@* NotificationBadge.razor — cloche avec badge compteur temps réel (SignalR). *@
+@implements IAsyncDisposable
+@inject NotificationsHubClient Hub
+@inject NavigationManager Navigation
+
+
+
+ @if (Hub.UnreadCount > 0)
+ {
+
+ }
+
+
+
+@code {
+ protected override async Task OnInitializedAsync()
+ {
+ Hub.UnreadCountChanged += OnUnreadChanged;
+ await Hub.StartAsync();
+ }
+
+ private void OnUnreadChanged(int _) => InvokeAsync(StateHasChanged);
+
+ public async ValueTask DisposeAsync()
+ {
+ Hub.UnreadCountChanged -= OnUnreadChanged;
+ await Hub.DisposeAsync();
+ }
+}
diff --git a/src/Heimdall.Web/Heimdall.Web.csproj b/src/Heimdall.Web/Heimdall.Web.csproj
index 3bfb779..8409db7 100644
--- a/src/Heimdall.Web/Heimdall.Web.csproj
+++ b/src/Heimdall.Web/Heimdall.Web.csproj
@@ -24,6 +24,7 @@
+
diff --git a/src/Heimdall.Web/Program.cs b/src/Heimdall.Web/Program.cs
index 3d5624e..b1a31ae 100644
--- a/src/Heimdall.Web/Program.cs
+++ b/src/Heimdall.Web/Program.cs
@@ -510,6 +510,7 @@ public partial class Program {
// explicit ApiBaseUrl (config/env) overrides that for external APIs.
builder.Services.AddHttpContextAccessor();
builder.Services.AddScoped();
+ builder.Services.AddScoped();
builder.Services.AddTransient();
builder.Services.AddTransient();
var apiBaseUrlConfigured = ApiBaseUrlResolver.IsConfigured(builder.Configuration);
diff --git a/src/Heimdall.Web/Services/NotificationsHubClient.cs b/src/Heimdall.Web/Services/NotificationsHubClient.cs
new file mode 100644
index 0000000..fef44e2
--- /dev/null
+++ b/src/Heimdall.Web/Services/NotificationsHubClient.cs
@@ -0,0 +1,111 @@
+using Microsoft.AspNetCore.Components;
+using Microsoft.AspNetCore.SignalR.Client;
+
+namespace Heimdall.Web.Services;
+
+///
+/// Client hub SignalR pour les notifications temps réel (badge compteur).
+/// S'abonne au groupe personnel "notif_{userId}" et expose l'événement
+/// . Le polling est le fallback : si la
+/// connexion échoue (pas de JWT en session cookie, hub indisponible), le
+/// badge reste silencieux sans casser l'UI.
+///
+public class NotificationsHubClient : IAsyncDisposable, IDisposable
+{
+ private readonly AuthState _authState;
+ private readonly NavigationManager _navigation;
+ private readonly ILogger _logger;
+ private HubConnection? _connection;
+ private bool _started;
+
+ public NotificationsHubClient(
+ AuthState authState,
+ NavigationManager navigation,
+ ILogger logger)
+ {
+ _authState = authState;
+ _navigation = navigation;
+ _logger = logger;
+ }
+
+ /// Compteur de notifications non lues (mis à jour par le hub).
+ public int UnreadCount { get; private set; }
+
+ public event Action? UnreadCountChanged;
+
+ public async Task StartAsync()
+ {
+ if (_started || !_authState.IsLoggedIn)
+ return;
+
+ try
+ {
+ var accessToken = _authState.AccessToken;
+ if (string.IsNullOrEmpty(accessToken))
+ return; // session cookie (SSR/reload) : pas de JWT → pas de hub, fallback silencieux
+
+ _connection = new HubConnectionBuilder()
+ .WithUrl($"{_navigation.BaseUri}hubs/notifications", options =>
+ {
+ options.AccessTokenProvider = GetAccessTokenAsync;
+ })
+ .WithAutomaticReconnect()
+ .Build();
+
+ _connection.On