@inherits LayoutComponentBase @inject AuthState Auth @inject NavigationManager Navigation @inject HeimdallAuthStateProvider AuthStateProvider @inject IJSRuntime JsRuntime Heimdall @* Global Search *@ @if (Auth.IsLoggedIn) { @Auth.User?.DisplayName @Auth.User?.Email Mon profil Déconnexion } @if (Auth.IsLoggedIn) { Navigation Dashboard Sites & Caméras @if (Auth.HasPermission("Admin.Users") || Auth.HasPermission("Admin.Manage")) { Administration Utilisateurs Agents Rôles & Permissions Groupes Matrice des permissions Événements Snapshots Journal d'audit Configuration } } else { Connexion } @Body @code { private bool _drawerOpen = true; private string _searchQuery = ""; private readonly MudTheme _theme = new() { PaletteLight = new PaletteLight { Primary = "#1976D2", Secondary = "#9E9E9E", Tertiary = "#009688", AppbarBackground = "#1565C0", AppbarText = "#FFFFFF", Background = "#F5F5F5", Surface = "#FFFFFF", DrawerBackground = "#FFFFFF", DrawerText = "#424242", TextPrimary = "#212121", TextSecondary = "#616161", TextDisabled = "#BDBDBD", Dark = "#0D47A1", DarkLighten = "#1976D2", Info = "#42A5F5", Warning = "#FF9800", Error = "#F44336", Success = "#4CAF50", }, PaletteDark = new PaletteDark { Primary = "#64B5F6", Secondary = "#BDBDBD", Tertiary = "#80CBC4", AppbarBackground = "#212121", AppbarText = "#FFFFFF", Background = "#121212", Surface = "#424242", DrawerBackground = "#424242", DrawerText = "#BDBDBD", TextPrimary = "#E0E0E0", TextSecondary = "#BDBDBD", TextDisabled = "#757575", Dark = "#1A237E", DarkLighten = "#1976D2", Info = "#42A5F5", Warning = "#FFA726", Error = "#EF5350", Success = "#66BB6A", } }; private async Task Logout() { await AuthStateProvider.NotifyLogoutAsync(); await JsRuntime.InvokeVoidAsync("heimdallAuth.signOut"); Navigation.NavigateTo("/login", true); } private async Task DoSearch() { var q = _searchQuery?.Trim(); if (string.IsNullOrEmpty(q)) return; // Route search to the most relevant page based on the query if (Guid.TryParse(q, out var _)) { // It looks like a GUID — try cameras, events, persons Navigation.NavigateTo($"/cameras/{q}"); } else if (q.Contains(' ')) { // Multi-word: search events by type/label Navigation.NavigateTo($"/events?q={Uri.EscapeDataString(q)}"); } else { // Default: search events Navigation.NavigateTo($"/events?q={Uri.EscapeDataString(q)}"); } await Task.CompletedTask; } private async Task HandleSearchKey(KeyboardEventArgs e) { if (e.Key == "Enter") await DoSearch(); } }