Files
Heimdall/src/Heimdall.Web/Components/Shared/NotificationBadge.razor
T
Arnaud Dartois 17ed0a19a1 feat(web): navigation & layout responsive — drawer adaptatif, badge notif, dark toggle (Fixes #33)
- Drawer : Breakpoint.Sm + mini-variant (64px) — responsive mobile/desktop.
- Nav restructurée : Événements et Snapshots SORTIS de la section
  Administration (bug d'accès : masqués aux non-admin alors que les pages
  sont autorisées) — section Navigation pour tous les connectés.
- Badge notifications temps réel : NotificationsHubClient (SignalR,
  access_token JWT, reconnexion auto, fallback silencieux) +
  NotificationBadge dans l'AppBar (compteur non lues, clic → /events).
- Toggle clair/sombre dans l'AppBar (IsDarkMode du MudThemeProvider).
- PageTestBase : enregistre NotificationsHubClient pour les tests bUnit.
172 tests Web verts.
2026-08-10 22:49:37 +02:00

31 lines
971 B
Plaintext

@* NotificationBadge.razor — cloche avec badge compteur temps réel (SignalR). *@
@implements IAsyncDisposable
@inject NotificationsHubClient Hub
@inject NavigationManager Navigation
<MudTooltip Text="Notifications">
<MudIconButton Icon="@Icons.Material.Filled.Notifications" Color="Color.Inherit" aria-label="Notifications"
OnClick="@(() => Navigation.NavigateTo("/events"))">
@if (Hub.UnreadCount > 0)
{
<MudBadge Color="Color.Error" Overlap="true" Bordered="true" Content="@Hub.UnreadCount" />
}
</MudIconButton>
</MudTooltip>
@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();
}
}