feat(i18n): apply saved language to shell and profile
Heimdall Gitea / Build and tests (pull_request) Failing after 7m21s
Heimdall Gitea / Build and scan server image (pull_request) Skipped
Heimdall Gitea / Build and scan agent image (pull_request) Skipped
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Publish versioned release (pull_request) Skipped

This commit is contained in:
Arnaud Dartois committed 2026-10-25 04:19:19 +01:00
1 parent 199a9c24d9
commit 96af711eac
12 files changed
+1048 -191

No files matched your search

+1
View File
@@ -44,6 +44,7 @@
<script src="@Assets["_framework/blazor.web.js"]"></script>
<script src="@Assets["_content/MudBlazor/MudBlazor.min.js"]"></script>
<script src="@Assets["js/auth.js"]"></script>
<script src="@Assets["js/localization.js"]"></script>
<script src="@Assets["js/theme.js"]"></script>
<script src="@Assets["js/pwa-register.js"]"></script>
</body>
@@ -1,7 +1,11 @@
@inherits LayoutComponentBase
@implements IDisposable
@inject AuthState Auth
@inject NavigationManager Navigation
@inject HeimdallApiClient Api
@inject HeimdallAuthStateProvider AuthStateProvider
@inject UiLanguageService Language
@inject UiText Text
@inject IJSRuntime JsRuntime
@using Heimdall.Web.Theme
@@ -10,18 +14,18 @@
<MudDialogProvider />
<MudSnackbarProvider />
<a href="#main-content" class="skip-link">Aller au contenu principal</a>
<a href="#main-content" class="skip-link">@Text["SkipToContent"]</a>
<MudLayout>
<MudAppBar Elevation="1">
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" aria-label="Menu"
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" aria-label="@Text["Menu"]"
@onclick="@(() => _drawerOpen = !_drawerOpen)" />
<MudText Typo="Typo.h6" Class="ml-2 d-flex align-center gap-2">
<i class="fas fa-eye"></i> Heimdall
</MudText>
@* Global Search *@
<MudTextField @bind-Value="_searchQuery" Placeholder="Rechercher..." Variant="Variant.Outlined"
<MudTextField @bind-Value="_searchQuery" Placeholder="@Text["Search"]" Variant="Variant.Outlined"
Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search"
OnAdornmentClick="@DoSearch" OnKeyDown="@HandleSearchKey"
Class="ml-4" Style="max-width:320px;" Margin="Margin.Dense" />
@@ -30,12 +34,12 @@
@if (Auth.IsLoggedIn)
{
<MudIconButton Icon="@(_darkMode ? Icons.Material.Filled.LightMode : Icons.Material.Filled.DarkMode)"
Color="Color.Inherit" aria-label="Basculer le thème"
Color="Color.Inherit" aria-label="@Text["ToggleTheme"]"
OnClick="@ToggleDarkMode" />
<NotificationBadge />
<MudMenu AnchorOrigin="Origin.BottomRight">
<ActivatorContent>
<MudIconButton Icon="@Icons.Material.Filled.AccountCircle" Color="Color.Inherit" aria-label="Profil" OnClick="@context.ToggleAsync" />
<MudIconButton Icon="@Icons.Material.Filled.AccountCircle" Color="Color.Inherit" aria-label="@Text["Profile"]" OnClick="@context.ToggleAsync" />
</ActivatorContent>
<ChildContent>
<MudMenuItem>
@@ -43,10 +47,10 @@
<MudText Typo="Typo.body2" Color="Color.Secondary">@Auth.User?.Email</MudText>
</MudMenuItem>
<MudMenuItem OnClick="@(() => Navigation.NavigateTo("/profile"))">
<MudIcon Icon="@Icons.Material.Filled.Person" Size="Size.Small" Class="mr-2" /> Mon profil
<MudIcon Icon="@Icons.Material.Filled.Person" Size="Size.Small" Class="mr-2" /> @Text["Profile"]
</MudMenuItem>
<MudDivider />
<MudMenuItem OnClick="@Logout">Déconnexion</MudMenuItem>
<MudMenuItem OnClick="@Logout">@Text["Logout"]</MudMenuItem>
</ChildContent>
</MudMenu>
}
@@ -57,59 +61,59 @@
<MudNavMenu>
@if (Auth.IsLoggedIn)
{
<MudText Typo="Typo.overline" Color="Color.Secondary" Class="px-4 py-2">Navigation</MudText>
<MudText Typo="Typo.overline" Color="Color.Secondary" Class="px-4 py-2">@Text["Navigation"]</MudText>
<MudNavLink Href="/dashboard" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Dashboard">
Dashboard
@Text["Dashboard"]
</MudNavLink>
<MudNavLink Href="/sites" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Videocam">
Sites &amp; Caméras
@Text["SitesAndCameras"]
</MudNavLink>
<MudNavLink Href="/events" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Notifications">
Événements
@Text["Events"]
</MudNavLink>
<MudNavLink Href="/snapshots" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.PhotoLibrary">
Snapshots
@Text["Snapshots"]
</MudNavLink>
<MudNavLink Href="/persons" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.People">
Personnes
@Text["People"]
</MudNavLink>
@if (Auth.HasPermission("Admin.Users") || Auth.HasPermission("Admin.Manage"))
{
<MudText Typo="Typo.overline" Color="Color.Secondary" Class="px-4 py-2 mt-2">Administration</MudText>
<MudText Typo="Typo.overline" Color="Color.Secondary" Class="px-4 py-2 mt-2">@Text["Administration"]</MudText>
<MudNavGroup Title="Gestion des utilisateurs"
<MudNavGroup Title="@Text["UserManagement"]"
Icon="@Icons.Material.Filled.People"
Expanded="_usersMenuOpen" ExpandedChanged="@(v => _usersMenuOpen = v)">
@if (Auth.HasPermission("Admin.Users"))
{
<MudNavLink Href="/users" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Person">
Utilisateurs
@Text["Users"]
</MudNavLink>
<MudNavLink Href="/admin/groups" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Group">
Groupes
@Text["Groups"]
</MudNavLink>
<MudNavLink Href="/admin/roles" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.ManageAccounts">
Rôles &amp; Permissions
@Text["RolesAndPermissions"]
</MudNavLink>
}
@if (Auth.HasPermission("Admin.Manage"))
{
<MudNavLink Href="/admin/claims" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Policy">
Matrice des permissions
@Text["PermissionMatrix"]
</MudNavLink>
}
</MudNavGroup>
<MudNavLink Href="/admin/agents" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Memory">
Agents
@Text["Agents"]
</MudNavLink>
<MudNavLink Href="/audit-logs" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.History">
Journal d'audit
@Text["AuditLog"]
</MudNavLink>
<MudNavLink Href="/settings" Match="NavLinkMatch.Prefix" Icon="@Icons.Material.Filled.Settings">
Configuration
@Text["Settings"]
</MudNavLink>
}
@@ -118,7 +122,7 @@
else
{
<MudNavLink Href="/login" Match="NavLinkMatch.Prefix">
<MudIcon Icon="@Icons.Material.Filled.Login" /> Connexion
<MudIcon Icon="@Icons.Material.Filled.Login" /> @Text["Login"]
</MudNavLink>
}
</MudNavMenu>
@@ -143,16 +147,34 @@
protected override void OnInitialized()
{
Language.LanguageChanged += OnLanguageChanged;
_usersMenuOpen = Navigation.Uri.Contains("/users", StringComparison.OrdinalIgnoreCase)
|| Navigation.Uri.Contains("/admin/groups", StringComparison.OrdinalIgnoreCase)
|| Navigation.Uri.Contains("/admin/roles", StringComparison.OrdinalIgnoreCase)
|| Navigation.Uri.Contains("/admin/claims", StringComparison.OrdinalIgnoreCase);
}
protected override async Task OnInitializedAsync()
{
if (!Auth.IsLoggedIn) return;
try
{
var profile = await Api.GetMyProfileAsync();
if (profile is not null) Language.SetLanguage(profile.Language);
}
catch { /* Keep the request culture when the profile endpoint is unavailable. */ }
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
try
{
await JsRuntime.InvokeVoidAsync("heimdallLocalization.setLanguage", Language.Language);
}
catch { /* UI localization is still applied by the circuit service. */ }
try
{
// Restaure la préférence thème persistée (partagée avec les pages
@@ -214,4 +236,8 @@
if (e.Key == "Enter")
await DoSearch();
}
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
}
@@ -5,51 +5,53 @@
@inject HeimdallApiClient Api
@inject AuthState Auth
@inject ISnackbar Snackbar
@inject UiLanguageService Language
@inject UiText Text
<MudText Typo="Typo.h1" Class="mb-1">
Dashboard
@Text["Dashboard"]
</MudText>
<MudText Typo="Typo.body1" Class="mb-2">
Bienvenue, <strong>@Auth.User?.DisplayName</strong>
@Text["WelcomeUser"], <strong>@Auth.User?.DisplayName</strong>
</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-6">
<MudIcon Icon="@Icons.Material.Filled.Update" Size="Size.Small" Class="mr-1" />
Dernière mise à jour : @_lastRefresh.ToString("T")
@Text["LastUpdated"] @_lastRefresh.ToString("T", Language.Culture)
</MudText>
@* Stats Cards Row — tuiles uniformes (StatTile, hauteur 100%) *@
<MudGrid>
<MudItem xs="12" sm="6" lg="3" Class="d-flex">
<StatTile Label="Caméras"
<StatTile Label="@Text["CameraCount"]"
Value="@(_stats?.TotalCameras.ToString() ?? "—")"
Icon="@Icons.Material.Filled.Videocam"
IconColor="Color.Primary"
Loading="@_loading">
<Footer>
<MudText Typo="Typo.caption" Color="Color.Success">@(_stats?.CamerasOnline ?? 0) en ligne</MudText>
<MudText Typo="Typo.caption" Color="Color.Error">@(_stats?.CamerasOffline ?? 0) hors ligne</MudText>
<MudText Typo="Typo.caption" Color="Color.Success">@(_stats?.CamerasOnline ?? 0) @Text["Online"]</MudText>
<MudText Typo="Typo.caption" Color="Color.Error">@(_stats?.CamerasOffline ?? 0) @Text["Offline"]</MudText>
</Footer>
</StatTile>
</MudItem>
<MudItem xs="12" sm="6" lg="3" Class="d-flex">
<StatTile Label="Agents en ligne"
<StatTile Label="@Text["OnlineAgents"]"
Value="@(_stats?.OnlineAgents.ToString() ?? "—")"
Icon="@Icons.Material.Filled.Memory"
IconColor="Color.Success"
Loading="@_loading">
<Footer>
<MudText Typo="Typo.caption" Color="Color.Secondary">@(_stats?.TotalAgents ?? 0) total</MudText>
<MudText Typo="Typo.caption" Color="Color.Secondary">@(_stats?.TotalAgents ?? 0) @Text["Total"]</MudText>
</Footer>
</StatTile>
</MudItem>
<MudItem xs="12" sm="6" lg="3" Class="d-flex">
<StatTile Label="Événements (24h)"
<StatTile Label="@Text["Events24h"]"
Value="@(_eventCount24h.ToString())"
Icon="@Icons.Material.Filled.Notifications"
IconColor="Color.Warning"
Loading="@_loading">
<Footer>
<MudLink Href="/events" Typo="Typo.caption">Voir tous →</MudLink>
<MudLink Href="/events" Typo="Typo.caption">@Text["ViewAll"] →</MudLink>
</Footer>
</StatTile>
</MudItem>
@@ -60,7 +62,7 @@
IconColor="Color.Info"
Loading="@_loading">
<Footer>
<MudLink Href="/sites" Typo="Typo.caption">Gérer →</MudLink>
<MudLink Href="/sites" Typo="Typo.caption">@Text["Manage"] →</MudLink>
</Footer>
</StatTile>
</MudItem>
@@ -70,13 +72,13 @@
<MudGrid Class="mt-4">
@* Camera Status Breakdown *@
<MudItem xs="12" md="6">
<SectionCard Title="État des caméras" Icon="@Icons.Material.Filled.Videocam">
<SectionCard Title="@Text["CameraStatusSection"]" Icon="@Icons.Material.Filled.Videocam">
@if (_cameraStatusData is not null)
{
<MudTable Items="@_cameraStatusData" Hover="false" Elevation="0">
<HeaderContent>
<MudTh>Statut</MudTh>
<MudTh>Nombre</MudTh>
<MudTh>@Text["Status"]</MudTh>
<MudTh>@Text["Count"]</MudTh>
<MudTh></MudTh>
</HeaderContent>
<RowTemplate>
@@ -98,7 +100,7 @@
@* Recent Events *@
<MudItem xs="12" md="6">
<SectionCard Title="Derniers événements" Icon="@Icons.Material.Filled.Notifications">
<SectionCard Title="@Text["RecentEvents"]" Icon="@Icons.Material.Filled.Notifications">
<ChildContent>
@if (_recentEventsLoading)
{
@@ -109,12 +111,12 @@
{
<MudTable Items="@_recentEvents" Hover="true" Elevation="0">
<HeaderContent>
<MudTh>Heure</MudTh>
<MudTh>Type</MudTh>
<MudTh>Confiance</MudTh>
<MudTh>@Text["Time"]</MudTh>
<MudTh>@Text["Type"]</MudTh>
<MudTh>@Text["Confidence"]</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd><MudText Typo="Typo.body2">@context.OccurredAt.ToLocalTime().ToString("HH:mm")</MudText></MudTd>
<MudTd><MudText Typo="Typo.body2">@context.OccurredAt.ToLocalTime().ToString("t", Language.Culture)</MudText></MudTd>
<MudTd><MudText Color="@GetEventColor(context.Type)">@FormatEventType(context.Type)</MudText></MudTd>
<MudTd><MudText>@($"{context.Confidence:P0}")</MudText></MudTd>
</RowTemplate>
@@ -122,11 +124,11 @@
}
else
{
<MudText Typo="Typo.body2" Color="Color.Secondary">Aucun événement récent.</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["NoRecentEvents"]</MudText>
}
</ChildContent>
<Actions>
<MudLink Href="/events" Typo="Typo.caption">Voir tout →</MudLink>
<MudLink Href="/events" Typo="Typo.caption">@Text["ViewAll"] →</MudLink>
</Actions>
</SectionCard>
</MudItem>
@@ -136,7 +138,7 @@
<MudGrid Class="mt-4">
@* Agent Workload *@
<MudItem xs="12" md="6">
<SectionCard Title="Charge des agents" Icon="@Icons.Material.Filled.Memory">
<SectionCard Title="@Text["AgentLoad"]" Icon="@Icons.Material.Filled.Memory">
@if (_agentsLoading)
{
<MudGrid>
@@ -160,24 +162,24 @@
</MudItem>
}
</MudGrid>
<MudLink Href="/admin/agents" Typo="Typo.caption" Class="mt-2 d-block">Tous les agents →</MudLink>
<MudLink Href="/admin/agents" Typo="Typo.caption" Class="mt-2 d-block">@Text["AllAgents"] →</MudLink>
}
else
{
<MudText Typo="Typo.body2" Color="Color.Secondary">Aucun agent enregistré.</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["NoAgentsRegistered"]</MudText>
}
</SectionCard>
</MudItem>
@* Quick Actions *@
<MudItem xs="12" md="6">
<SectionCard Title="Actions rapides" Icon="@Icons.Material.Filled.FlashOn">
<SectionCard Title="@Text["QuickActions"]" Icon="@Icons.Material.Filled.FlashOn">
<MudGrid>
<MudItem xs="6">
<MudButton FullWidth="true" Variant="Variant.Outlined" Color="Color.Primary" Href="/events" Class="mb-4" Style="height:80px;">
<div class="d-flex flex-column align-center">
<MudIcon Icon="@Icons.Material.Filled.Notifications" />
<MudText Typo="Typo.body2">Événements</MudText>
<MudText Typo="Typo.body2">@Text["Events"]</MudText>
</div>
</MudButton>
</MudItem>
@@ -185,7 +187,7 @@
<MudButton FullWidth="true" Variant="Variant.Outlined" Color="Color.Secondary" Href="/sites" Class="mb-4" Style="height:80px;">
<div class="d-flex flex-column align-center">
<MudIcon Icon="@Icons.Material.Filled.Add" />
<MudText Typo="Typo.body2">Nouveau site</MudText>
<MudText Typo="Typo.body2">@Text["NewSite"]</MudText>
</div>
</MudButton>
</MudItem>
@@ -193,7 +195,7 @@
<MudButton FullWidth="true" Variant="Variant.Outlined" Color="Color.Warning" Href="/admin/agents" Class="mb-4" Style="height:80px;">
<div class="d-flex flex-column align-center">
<MudIcon Icon="@Icons.Material.Filled.Memory" />
<MudText Typo="Typo.body2">Agents</MudText>
<MudText Typo="Typo.body2">@Text["Agents"]</MudText>
</div>
</MudButton>
</MudItem>
@@ -201,7 +203,7 @@
<MudButton FullWidth="true" Variant="Variant.Outlined" Color="Color.Info" Href="/audit-logs" Class="mb-4" Style="height:80px;">
<div class="d-flex flex-column align-center">
<MudIcon Icon="@Icons.Material.Filled.History" />
<MudText Typo="Typo.body2">Audit</MudText>
<MudText Typo="Typo.body2">@Text["Audit"]</MudText>
</div>
</MudButton>
</MudItem>
@@ -213,23 +215,23 @@
@* Sites Table *@
<MudGrid Class="mt-4">
<MudItem xs="12">
<SectionCard Title="Sites" Icon="@Icons.Material.Filled.Business">
<SectionCard Title="@Text["Sites"]" Icon="@Icons.Material.Filled.Business">
<ChildContent>
@if (_loading) { for (int i = 0; i < 3; i++) { <MudSkeleton Width="100%" Height="40px" Class="mt-1" /> } }
else if (_sites?.Count > 0)
{
<MudTable Items="@_sites" Hover="true" Striped="true" Elevation="0">
<HeaderContent>
<MudTh>Nom</MudTh>
<MudTh>Adresse</MudTh>
<MudTh>Statut</MudTh>
<MudTh>Créé le</MudTh>
<MudTh>@Text["Name"]</MudTh>
<MudTh>@Text["Address"]</MudTh>
<MudTh>@Text["Status"]</MudTh>
<MudTh>@Text["CreatedAt"]</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd><MudLink Href="@($"/sites/{context.Id}")">@context.Name</MudLink></MudTd>
<MudTd>@(context.Address ?? "—")</MudTd>
<MudTd><MudText Color="@(context.Enabled ? Color.Success : Color.Default)">@(context.Enabled ? "Actif" : "Inactif")</MudText></MudTd>
<MudTd>@context.CreatedAt.ToString("g")</MudTd>
<MudTd><MudText Color="@(context.Enabled ? Color.Success : Color.Default)">@(context.Enabled ? Text["Active"] : Text["Inactive"])</MudText></MudTd>
<MudTd>@context.CreatedAt.ToString("g", Language.Culture)</MudTd>
</RowTemplate>
</MudTable>
}
@@ -237,19 +239,19 @@
{
<div class="pa-8 text-center">
<MudIcon Icon="@Icons.Material.Filled.Business" Size="Size.Large" Color="Color.Secondary" />
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">Aucun site configuré</MudText>
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">@Text["NoSiteConfigured"]</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
Commencez par créer un site pour déployer vos agents de surveillance.
@Text["CreateSitePrompt"]
</MudText>
<MudButton Variant="Variant.Filled" Color="Color.Primary" Href="/sites">
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Créer un site
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["CreateSite"]
</MudButton>
</div>
}
</ChildContent>
<Actions>
<MudTooltip Text="Rafraîchir">
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Size="Size.Small" OnClick="@(async () => await LoadData())" aria-label="Actualiser le tableau de bord" />
<MudTooltip Text="@Text["Refresh"]">
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Size="Size.Small" OnClick="@(async () => await LoadData())" aria-label="@Text["RefreshDashboard"]" />
</MudTooltip>
</Actions>
</SectionCard>
@@ -268,15 +270,9 @@
private List<AgentItem>? _agents;
private List<CameraStatusEntry>? _cameraStatusData;
private readonly List<CameraStatusEntry> _defaultCameraStatus =
[
new("En ligne", 0, Color.Success, 0),
new("Hors ligne", 0, Color.Error, 0),
new("Désactivée", 0, Color.Default, 0),
];
protected override async Task OnInitializedAsync()
{
Language.LanguageChanged += OnLanguageChanged;
await LoadData();
}
@@ -333,16 +329,7 @@
// Stats
_stats = await Api.GetStatsAsync();
if (_stats is not null)
{
var total = _stats.CamerasOnline + _stats.CamerasOffline + (_stats.TotalCameras - _stats.CamerasOnline - _stats.CamerasOffline);
total = total > 0 ? total : 1;
_cameraStatusData =
[
new("En ligne", _stats.CamerasOnline, Color.Success, (int)(_stats.CamerasOnline * 100.0 / total)),
new("Hors ligne", _stats.CamerasOffline, Color.Error, (int)(_stats.CamerasOffline * 100.0 / total)),
new("Autre", _stats.TotalCameras - _stats.CamerasOnline - _stats.CamerasOffline, Color.Default, (int)((_stats.TotalCameras - _stats.CamerasOnline - _stats.CamerasOffline) * 100.0 / total)),
];
}
UpdateCameraStatusData();
// Sites
var sitesResult = await Api.GetSitesAsync(1, 5);
@@ -370,13 +357,13 @@
finally { _loading = false; }
}
private static string FormatEventType(string type) => type switch
private string FormatEventType(string type) => type switch
{
"MotionDetected" => "Mouvement",
"PersonDetected" => "Personne",
"VehicleDetected" => "Véhicule",
"FaceRecognized" => "Visage",
"CameraOffline" => "Hors ligne",
"MotionDetected" => Text["MotionDetected"],
"PersonDetected" => Text["PersonDetected"],
"VehicleDetected" => Text["VehicleDetected"],
"FaceRecognized" => Text["FaceRecognized"],
"CameraOffline" => Text["CameraOffline"],
_ => type
};
@@ -391,9 +378,30 @@
private record CameraStatusEntry(string Label, int Count, Color Color, int Percent);
private void UpdateCameraStatusData()
{
if (_stats is null) return;
var other = _stats.TotalCameras - _stats.CamerasOnline - _stats.CamerasOffline;
var total = Math.Max(_stats.TotalCameras, 1);
_cameraStatusData =
[
new(Text["Online"], _stats.CamerasOnline, Color.Success, (int)(_stats.CamerasOnline * 100.0 / total)),
new(Text["Offline"], _stats.CamerasOffline, Color.Error, (int)(_stats.CamerasOffline * 100.0 / total)),
new(Text["Other"], other, Color.Default, (int)(other * 100.0 / total)),
];
}
private void OnLanguageChanged()
{
UpdateCameraStatusData();
_ = InvokeAsync(StateHasChanged);
}
public void Dispose()
{
_disposed = true;
Language.LanguageChanged -= OnLanguageChanged;
_refreshCts?.Cancel();
_refreshCts?.Dispose();
}
+112 -102
View File
@@ -1,15 +1,19 @@
@page "/profile"
@attribute [Authorize]
@layout MainLayout
@implements IDisposable
@using Enable2faResponse = Heimdall.Application.DTOs.Enable2faResponse
@inject HeimdallApiClient Api
@inject AuthState Auth
@inject UiLanguageService Language
@inject UiText Text
@inject ISnackbar Snackbar
@inject HeimdallAuthStateProvider AuthProvider
@inject IJSRuntime JS
<MudText Typo="Typo.h1" Class="mb-6">
<i class="fas fa-user-circle mr-2"></i>
Mon profil
@Text["Profile"]
</MudText>
@if (_loading)
@@ -19,9 +23,9 @@
else if (_error)
{
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
<MudText>Erreur lors du chargement du profil.</MudText>
<MudText>@Text["ProfileLoadFailed"]</MudText>
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadProfile" Class="mt-2">
<MudIcon Icon="@Icons.Material.Filled.Refresh" Class="mr-1" Size="Size.Small" /> Réessayer
<MudIcon Icon="@Icons.Material.Filled.Refresh" Class="mr-1" Size="Size.Small" /> @Text["Retry"]
</MudButton>
</MudAlert>
}
@@ -31,7 +35,7 @@ else if (_profile is not null)
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
<MudText Typo="Typo.h5" Class="mb-4">
<MudIcon Icon="@Icons.Material.Filled.Person" Class="mr-1" Size="Size.Small" />
Informations personnelles
@Text["PersonalInformation"]
</MudText>
@if (!string.IsNullOrEmpty(_profileError))
@@ -40,29 +44,29 @@ else if (_profile is not null)
}
<form @onsubmit="SaveProfile">
<MudTextField @bind-Value="_displayName" Label="Nom d'affichage" Variant="Variant.Outlined"
<MudTextField @bind-Value="_displayName" Label="@Text["DisplayName"]" Variant="Variant.Outlined"
Class="mb-4" Required="true" Immediate="true" />
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-1">Email</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-1">@Text["Email"]</MudText>
<MudText Typo="Typo.body1" Class="mb-4">@_profile.Email</MudText>
<MudText Typo="Typo.body2" Class="mb-2">Thème</MudText>
<MudSelect @bind-Value="_theme" Label="Thème" Variant="Variant.Outlined" Class="mb-4">
<MudSelectItem Value="@("Auto")">Auto</MudSelectItem>
<MudSelectItem Value="@("Light")">Light</MudSelectItem>
<MudSelectItem Value="@("Dark")">Dark</MudSelectItem>
<MudText Typo="Typo.body2" Class="mb-2">@Text["Theme"]</MudText>
<MudSelect @bind-Value="_theme" Label="@Text["Theme"]" Variant="Variant.Outlined" Class="mb-4">
<MudSelectItem Value="@("Auto")">@Text["Auto"]</MudSelectItem>
<MudSelectItem Value="@("Light")">@Text["Light"]</MudSelectItem>
<MudSelectItem Value="@("Dark")">@Text["Dark"]</MudSelectItem>
</MudSelect>
<MudText Typo="Typo.body2" Class="mb-2">Langue</MudText>
<MudSelect @bind-Value="_language" Label="Langue" Variant="Variant.Outlined" Class="mb-4">
<MudSelectItem Value="@("fr")">Français</MudSelectItem>
<MudSelectItem Value="@("en")">English</MudSelectItem>
<MudText Typo="Typo.body2" Class="mb-2">@Text["Language"]</MudText>
<MudSelect @bind-Value="_language" Label="@Text["Language"]" Variant="Variant.Outlined" Class="mb-4">
<MudSelectItem Value="@("fr")">@Text["French"]</MudSelectItem>
<MudSelectItem Value="@("en")">@Text["English"]</MudSelectItem>
</MudSelect>
<MudButton Variant="Variant.Filled" Color="Color.Primary" ButtonType="ButtonType.Submit"
Disabled="@_saving" FullWidth="true">
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
<MudIcon Icon="@Icons.Material.Filled.Save" Class="mr-1" /> Enregistrer
<MudIcon Icon="@Icons.Material.Filled.Save" Class="mr-1" /> @Text["Save"]
</MudButton>
</form>
</MudPaper>
@@ -76,30 +80,30 @@ else if (_profile is not null)
<MudGrid>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.body2" Color="Color.Secondary">Date d'inscription</MudText>
<MudText Typo="Typo.body1" Class="mb-3">@_profile.CreatedAt.ToString("g")</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["RegisteredAt"]</MudText>
<MudText Typo="Typo.body1" Class="mb-3">@_profile.CreatedAt.ToString("g", Language.Culture)</MudText>
</MudItem>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.body2" Color="Color.Secondary">Email confirmé</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["EmailConfirmed"]</MudText>
<MudText Typo="Typo.body1" Class="mb-3">
<MudIcon Icon="@(_profile.EmailConfirmed ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Cancel)"
Color="@(_profile.EmailConfirmed ? Color.Success : Color.Default)" Size="Size.Small" />
@(_profile.EmailConfirmed ? "Oui" : "Non")
@(_profile.EmailConfirmed ? Text["Yes"] : Text["No"])
</MudText>
</MudItem>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.body2" Color="Color.Secondary">2FA</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["TwoFactor"]</MudText>
<MudText Typo="Typo.body1" Class="mb-1">
<MudIcon Icon="@(_profile.TwoFactorEnabled ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Cancel)"
Color="@(_profile.TwoFactorEnabled ? Color.Success : Color.Default)" Size="Size.Small" />
@(_profile.TwoFactorEnabled ? "Activé" : "Désactivé")
@(_profile.TwoFactorEnabled ? Text["TwoFactorEnabled"] : Text["TwoFactorDisabled"])
</MudText>
@if (_profile.TwoFactorEnabled)
{
<MudButton Variant="Variant.Outlined" Color="Color.Error" Size="Size.Small" Class="mt-1"
OnClick="Disable2fa" Disabled="@_toggling2fa">
@if (_toggling2fa) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
Désactiver la 2FA
@Text["DisableTwoFactor"]
</MudButton>
}
else
@@ -107,12 +111,12 @@ else if (_profile is not null)
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small" Class="mt-1"
OnClick="Enable2fa" Disabled="@_toggling2fa">
@if (_toggling2fa) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
Activer la 2FA
@Text["EnableTwoFactor"]
</MudButton>
}
</MudItem>
<MudItem xs="12" sm="6">
<MudText Typo="Typo.body2" Color="Color.Secondary">Rôles</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["Roles"]</MudText>
<MudText Typo="Typo.body1" Class="mb-3">
@if (_profile.Roles is not null && _profile.Roles.Count > 0)
{
@@ -126,7 +130,7 @@ else if (_profile is not null)
}
else
{
<MudText Typo="Typo.body2" Color="Color.Secondary">Aucun rôle</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["NoRoles"]</MudText>
}
</MudText>
</MudItem>
@@ -137,7 +141,7 @@ else if (_profile is not null)
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
<MudText Typo="Typo.h5" Class="mb-4">
<MudIcon Icon="@Icons.Material.Filled.Lock" Class="mr-1" Size="Size.Small" />
Changer le mot de passe
@Text["ChangePassword"]
</MudText>
@if (!string.IsNullOrEmpty(_passwordError))
@@ -146,21 +150,21 @@ else if (_profile is not null)
}
<form @onsubmit="ChangePassword">
<MudTextField @bind-Value="_currentPassword" Label="Mot de passe actuel" Variant="Variant.Outlined"
<MudTextField @bind-Value="_currentPassword" Label="@Text["CurrentPassword"]" Variant="Variant.Outlined"
InputType="InputType.Password" Class="mb-4" Required="true" Immediate="true"
Autocomplete="current-password" />
<MudTextField @bind-Value="_newPassword" Label="Nouveau mot de passe" Variant="Variant.Outlined"
<MudTextField @bind-Value="_newPassword" Label="@Text["NewPassword"]" Variant="Variant.Outlined"
InputType="InputType.Password" Class="mb-4" Required="true" Immediate="true"
HelperText="Minimum 12 caractères"
HelperText="@Text["PasswordMinimum"]"
Autocomplete="new-password" />
<MudTextField @bind-Value="_confirmPassword" Label="Confirmer le mot de passe" Variant="Variant.Outlined"
<MudTextField @bind-Value="_confirmPassword" Label="@Text["ConfirmPassword"]" Variant="Variant.Outlined"
InputType="InputType.Password" Class="mb-4" Required="true" Immediate="true"
Autocomplete="new-password" />
<MudButton Variant="Variant.Filled" Color="Color.Warning" ButtonType="ButtonType.Submit"
Disabled="@_changingPassword" FullWidth="true">
@if (_changingPassword) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
<MudIcon Icon="@Icons.Material.Filled.LockReset" Class="mr-1" /> Changer le mot de passe
<MudIcon Icon="@Icons.Material.Filled.LockReset" Class="mr-1" /> @Text["ChangePassword"]
</MudButton>
</form>
</MudPaper>
@@ -169,7 +173,7 @@ else if (_profile is not null)
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
<MudText Typo="Typo.h5" Class="mb-4">
<MudIcon Icon="@Icons.Material.Filled.Notifications" Class="mr-1" Size="Size.Small" />
Notifications
@Text["Notifications"]
</MudText>
@if (!string.IsNullOrEmpty(_notifError))
@@ -179,45 +183,43 @@ else if (_profile is not null)
<MudAlert Severity="Severity.Info" Class="mb-4" Variant="Variant.Outlined">
<MudText Typo="Typo.body2" Class="mb-1">
Les notifications push utilisent <strong>ntfy</strong> (serveur auto-hébergé).
Installez l'app ntfy et abonnez-vous au topic ci-dessous pour recevoir les notifications.
@Text["PushSetupInstructions"]
</MudText>
<MudText Typo="Typo.body2" Class="mb-1">
<strong>Votre topic :</strong> <code>@(!string.IsNullOrWhiteSpace(_ntfyTopic) ? _ntfyTopic : $"heimdall_{_profile?.Id}")</code>
<strong>@Text["YourTopic"]</strong> <code>@(!string.IsNullOrWhiteSpace(_ntfyTopic) ? _ntfyTopic : $"heimdall_{_profile?.Id}")</code>
</MudText>
<MudText Typo="Typo.caption" Color="Color.Secondary">
Personnalisez le champ "Topic ntfy" ci-dessous pour utiliser un topic différent.
@Text["CustomizeTopic"]
</MudText>
</MudAlert>
<MudForm @ref="_notifForm">
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">Canal Email</MudText>
<MudSwitch @bind-Value="_emailEnabled" Label="Notifications par email" Color="Color.Primary" Class="mb-2" />
<MudTextField @bind-Value="_emailAddress" Label="Adresse email de notification"
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">@Text["EmailChannel"]</MudText>
<MudSwitch @bind-Value="_emailEnabled" Label="@Text["EmailNotifications"]" Color="Color.Primary" Class="mb-2" />
<MudTextField @bind-Value="_emailAddress" Label="@Text["NotificationEmailAddress"]"
Variant="Variant.Outlined" Class="mb-4" Disabled="@(!_emailEnabled)"
Placeholder="notification@exemple.com" />
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">Canal Push (ntfy)</MudText>
<MudSwitch @bind-Value="_ntfyEnabled" Label="Notifications push (ntfy)" Color="Color.Secondary" Class="mb-2" />
<MudTextField @bind-Value="_ntfyUrl" Label="URL du serveur ntfy (optionnel)"
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">@Text["PushChannel"]</MudText>
<MudSwitch @bind-Value="_ntfyEnabled" Label="@Text["PushNotifications"]" Color="Color.Secondary" Class="mb-2" />
<MudTextField @bind-Value="_ntfyUrl" Label="@Text["NtfyServerUrl"]"
Variant="Variant.Outlined" Class="mb-4" Disabled="@(!_ntfyEnabled)"
Placeholder="http://ntfy:80 (défaut)" HelperText="Laisser vide pour utiliser le serveur global" />
<MudTextField @bind-Value="_ntfyTopic" Label="Topic ntfy (optionnel)"
Placeholder="@Text["DefaultNtfyUrl"]" HelperText="@Text["UseGlobalServer"]" />
<MudTextField @bind-Value="_ntfyTopic" Label="@Text["NtfyTopicOptional"]"
Variant="Variant.Outlined" Class="mb-4" Disabled="@(!_ntfyEnabled)"
Placeholder="@($"heimdall_{_profile?.Id}")"
HelperText="Personnalisez le topic de réception. Défaut : heimdall_{votre-id}" />
HelperText="@Text["CustomizeTopicHelper"]" />
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">Résumés</MudText>
<MudSwitch @bind-Value="_dailyDigest" Label="Résumé quotidien (8h)" Color="Color.Tertiary" Class="mb-2" />
<MudSwitch @bind-Value="_weeklyDigest" Label="Résumé hebdomadaire (lundi 8h)" Color="Color.Tertiary" Class="mb-4" />
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">@Text["Summaries"]</MudText>
<MudSwitch @bind-Value="_dailyDigest" Label="@Text["DailySummary"]" Color="Color.Tertiary" Class="mb-2" />
<MudSwitch @bind-Value="_weeklyDigest" Label="@Text["WeeklySummary"]" Color="Color.Tertiary" Class="mb-4" />
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">Types d'événements</MudText>
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-4">@Text["EventTypes"]</MudText>
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-2">
Sélectionnez les types d'événements pour lesquels vous souhaitez recevoir des notifications push et email.
Si aucun n'est sélectionné, tous les événements sont notifiés.
@Text["SelectNotificationEventTypes"] @Text["AllEventsIfNone"]
</MudText>
<MudGrid Class="mb-4">
@foreach (var et in _eventTypes)
@foreach (var et in EventTypes)
{
<MudItem xs="12" sm="6">
<MudCheckBox T="bool"
@@ -233,13 +235,13 @@ else if (_profile is not null)
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveNotificationConfig"
Disabled="@_savingNotif" FullWidth="true">
@if (_savingNotif) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
<MudIcon Icon="@Icons.Material.Filled.Save" Class="mr-1" /> Enregistrer
<MudIcon Icon="@Icons.Material.Filled.Save" Class="mr-1" /> @Text["Save"]
</MudButton>
<div class="d-flex align-center mt-3">
<MudButton Variant="Variant.Outlined" Color="Color.Info" StartIcon="@Icons.Material.Filled.Send"
OnClick="TestNtfyForUserAsync" Disabled="@(_testingNtfy || !_ntfyEnabled)">
@(_testingNtfy ? "Test en cours…" : "Tester ntfy")
@(_testingNtfy ? Text["TestRunning"] : Text["TestNtfy"])
</MudButton>
</div>
@if (_ntfyTestResult is not null)
@@ -258,7 +260,7 @@ else if (_profile is not null)
<TitleContent>
<MudText Typo="Typo.h6">
<MudIcon Icon="@Icons.Material.Filled.Security" Class="mr-1" Size="Size.Small" />
Activer la double authentification (2FA)
@Text["EnableTwoFactor"]
</MudText>
</TitleContent>
<DialogContent>
@@ -270,16 +272,15 @@ else if (_profile is not null)
{
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined" Class="mb-4">
<MudText Typo="Typo.body2" Class="mb-1">
Scannez le code QR avec votre application d'authentification (Google Authenticator, Authy…)
ou saisissez la clé manuellement.
@Text["ScanQrInstructions"]
</MudText>
<MudText Typo="Typo.body2" Class="mb-1">
<strong>Clé :</strong> <code>@_2faSetup.SharedKey</code>
<strong>@Text["TwoFactorKey"]</strong> <code>@_2faSetup.SharedKey</code>
</MudText>
@if (!string.IsNullOrEmpty(_2faSetup.QrCodeUri))
{
<MudText Typo="Typo.caption" Color="Color.Secondary">
Lien de configuration : <a href="@_2faSetup.QrCodeUri" target="_blank">ouvrir dans l'app</a>
@Text["SetupLink"] <a href="@_2faSetup.QrCodeUri" target="_blank">@Text["OpenInApp"]</a>
</MudText>
}
</MudAlert>
@@ -288,9 +289,8 @@ else if (_profile is not null)
{
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Class="mb-2">
<MudText Typo="Typo.body2" Class="mb-1">
<strong>Codes de récupération</strong> — conservez-les précieusement.
Ils permettent de vous connecter si vous perdez votre application d'authentification.
Chaque code ne peut être utilisé qu'une seule fois.
<strong>@Text["RecoveryCodes"]</strong> — @Text["KeepRecoveryCodes"]
@Text["RecoveryCodesInstructions"] @Text["RecoveryCodeOneUse"]
</MudText>
</MudAlert>
<MudPaper Elevation="0" Class="pa-3 mb-4" Style="border: 1px dashed #f0ad4e; border-radius: 8px;">
@@ -303,12 +303,12 @@ else if (_profile is not null)
}
</div>
</MudPaper>
<MudCheckBox T="bool" @bind-Value="_recoveryCodesConfirmed" Label="J'ai sauvegardé mes codes de récupération" Class="mb-2" />
<MudCheckBox T="bool" @bind-Value="_recoveryCodesConfirmed" Label="@Text["RecoveryCodesSaved"]" Class="mb-2" />
}
}
</DialogContent>
<DialogActions>
<MudButton Variant="Variant.Text" OnClick="@(() => _show2faDialog = false)">Fermer</MudButton>
<MudButton Variant="Variant.Text" OnClick="@(() => _show2faDialog = false)">@Text["Close"]</MudButton>
</DialogActions>
</MudDialog>
@@ -340,6 +340,7 @@ else if (_profile is not null)
protected override async Task OnInitializedAsync()
{
Language.LanguageChanged += OnLanguageChanged;
await LoadProfile();
await LoadNotificationConfig();
}
@@ -356,12 +357,13 @@ else if (_profile is not null)
_profile = result;
_displayName = result.DisplayName;
_theme = result.Theme ?? "Auto";
_language = result.Language;
_language = UiLanguageService.Normalize(result.Language);
Language.SetLanguage(_language);
}
}
catch {
_error = true;
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
Snackbar.Add(Text["OperationFailed"], Severity.Error);
}
finally { _loading = false; }
}
@@ -372,7 +374,7 @@ else if (_profile is not null)
{
if (string.IsNullOrWhiteSpace(_displayName))
{
_profileError = "Le nom d'affichage est requis";
_profileError = Text["DisplayNameRequired"];
return;
}
@@ -383,15 +385,19 @@ else if (_profile is not null)
var success = await Api.UpdateMyProfileAsync(_displayName.Trim(), _theme, _language);
if (success)
{
Snackbar.Add("Profil mis à jour avec succès", Severity.Success);
_language = UiLanguageService.Normalize(_language);
Language.SetLanguage(_language);
try { await JS.InvokeVoidAsync("heimdallLocalization.setLanguage", _language); }
catch (JSException) { /* The saved preference still applies to this circuit. */ }
Snackbar.Add(Text["ProfileUpdated"], Severity.Success);
}
else
{
_profileError = "Erreur lors de la mise à jour du profil";
_profileError = Text["ProfileUpdateFailed"];
}
}
catch {
_profileError = UiErrors.OperationFailed();
_profileError = Text["OperationFailed"];
}
finally { _saving = false; }
}
@@ -409,7 +415,7 @@ else if (_profile is not null)
var setup = await Api.Enable2faAsync();
if (setup is null)
{
_2faError = "Échec de l'activation de la 2FA. Réessayez.";
_2faError = Text["OperationFailed"];
_show2faDialog = true;
return;
}
@@ -418,7 +424,7 @@ else if (_profile is not null)
}
catch
{
_2faError = UiErrors.OperationFailed();
_2faError = Text["OperationFailed"];
_show2faDialog = true;
}
finally
@@ -436,16 +442,16 @@ else if (_profile is not null)
var ok = await Api.Disable2faAsync();
if (ok)
{
Snackbar.Add("Double authentification désactivée", Severity.Success);
Snackbar.Add(Text["TwoFactorDisabled"], Severity.Success);
}
else
{
Snackbar.Add("Échec de la désactivation de la 2FA", Severity.Error);
Snackbar.Add(Text["TwoFactorDisableFailed"], Severity.Error);
}
}
catch
{
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
Snackbar.Add(Text["OperationFailed"], Severity.Error);
}
finally
{
@@ -458,22 +464,22 @@ else if (_profile is not null)
{
if (string.IsNullOrWhiteSpace(_currentPassword))
{
_passwordError = "Le mot de passe actuel est requis";
_passwordError = Text["CurrentPasswordRequired"];
return;
}
if (string.IsNullOrWhiteSpace(_newPassword))
{
_passwordError = "Le nouveau mot de passe est requis";
_passwordError = Text["NewPasswordRequired"];
return;
}
if (_newPassword.Length < 12)
{
_passwordError = "Le nouveau mot de passe doit contenir au moins 12 caractères";
_passwordError = Text["PasswordTooShort"];
return;
}
if (_newPassword != _confirmPassword)
{
_passwordError = "Les mots de passe ne correspondent pas";
_passwordError = Text["PasswordsMismatch"];
return;
}
@@ -487,15 +493,15 @@ else if (_profile is not null)
_currentPassword = "";
_newPassword = "";
_confirmPassword = "";
Snackbar.Add("Mot de passe changé avec succès", Severity.Success);
Snackbar.Add(Text["PasswordChanged"], Severity.Success);
}
else
{
_passwordError = "Erreur lors du changement de mot de passe. Vérifiez votre mot de passe actuel.";
_passwordError = Text["PasswordChangeFailed"];
}
}
catch {
_passwordError = UiErrors.OperationFailed();
_passwordError = Text["OperationFailed"];
}
finally { _changingPassword = false; }
}
@@ -516,21 +522,25 @@ else if (_profile is not null)
private TestActionResult? _ntfyTestResult;
// Event type subscription checkboxes
private readonly List<EventTypeOption> _eventTypes = new()
{
new("MotionDetected", "Mouvement détecté", Icons.Material.Filled.NearMe),
new("PersonDetected", "Personne détectée", Icons.Material.Filled.Person),
new("VehicleDetected", "Véhicule détecté", Icons.Material.Filled.DirectionsCar),
new("UnknownPerson", "Personne inconnue", Icons.Material.Filled.HelpOutline),
new("FaceRecognized", "Visage reconnu", Icons.Material.Filled.Face),
new("LicensePlateDetected", "Plaque détectée", Icons.Material.Filled.Pin),
new("CameraOffline", "Caméra hors ligne", Icons.Material.Filled.VideocamOff),
new("CameraOnline", "Caméra en ligne", Icons.Material.Filled.Videocam),
};
private IReadOnlyList<EventTypeOption> EventTypes =>
[
new("MotionDetected", Text["MotionDetected"], Icons.Material.Filled.NearMe),
new("PersonDetected", Text["PersonDetected"], Icons.Material.Filled.Person),
new("VehicleDetected", Text["VehicleDetected"], Icons.Material.Filled.DirectionsCar),
new("UnknownPerson", Text["UnknownPerson"], Icons.Material.Filled.HelpOutline),
new("FaceRecognized", Text["FaceRecognized"], Icons.Material.Filled.Face),
new("LicensePlateDetected", Text["LicensePlateDetected"], Icons.Material.Filled.Pin),
new("CameraOffline", Text["CameraOffline"], Icons.Material.Filled.VideocamOff),
new("CameraOnline", Text["CameraOnline"], Icons.Material.Filled.Videocam),
];
private HashSet<string> _subscribedEvents = new();
private sealed record EventTypeOption(string Value, string Label, string Icon);
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
private void ToggleEventType(string value, bool selected)
{
if (selected)
@@ -558,9 +568,9 @@ else if (_profile is not null)
: new HashSet<string>();
}
}
catch (Exception ex)
catch (Exception)
{
_notifError = $"Erreur chargement config notifications : {ex.Message}";
_notifError = Text["NotificationConfigLoadFailed"];
}
}
@@ -583,15 +593,15 @@ else if (_profile is not null)
var success = await Api.UpdateNotificationConfigAsync(request);
if (success)
{
Snackbar.Add("Configuration notifications mise à jour", Severity.Success);
Snackbar.Add(Text["NotificationConfigUpdated"], Severity.Success);
}
else
{
_notifError = "Erreur lors de la mise à jour";
_notifError = Text["NotificationConfigUpdateFailed"];
}
}
catch {
_notifError = UiErrors.OperationFailed();
_notifError = Text["OperationFailed"];
}
finally { _savingNotif = false; }
}
@@ -612,11 +622,11 @@ else if (_profile is not null)
var topic = ResolveNtfyTopic();
var baseUrl = string.IsNullOrWhiteSpace(_ntfyUrl) ? null : _ntfyUrl.Trim();
_ntfyTestResult = await Api.TestNtfyAsync(topic, baseUrl)
?? new TestActionResult(false, "Test impossible (API indisponible).");
?? new TestActionResult(false, Text["TestUnavailable"]);
}
catch (Exception ex)
catch (Exception)
{
_ntfyTestResult = new TestActionResult(false, $"Test impossible : {ex.Message}");
_ntfyTestResult = new TestActionResult(false, Text["OperationFailed"]);
}
finally
{