Merge pull request 'feat(i18n): localize remaining UI and server messages' (#93) from feat/i18n-camera-events-pages into main
Heimdall Gitea / Build and tests (push) Successful in 17m42s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Successful in 6m18s
Heimdall Gitea / Build and scan server image (push) Successful in 8m41s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 2m7s
Heimdall Gitea / Build and tests (push) Successful in 17m42s
Heimdall Gitea / Publish versioned release (push) Skipped
Heimdall Gitea / Build and scan agent image (push) Successful in 6m18s
Heimdall Gitea / Build and scan server image (push) Successful in 8m41s
Heimdall Gitea / Publish Docker Hub latest tags (push) Successful in 2m7s
This commit was merged in pull request #93.
This commit is contained in:
commit
6ba31db8fe
77 files changed
+11988
-1477
No files matched your search
@@ -1,4 +1,6 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Application.Localization;
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Domain.Entities;
|
||||
using MediatR;
|
||||
@@ -39,15 +41,18 @@ public class ForgotPasswordHandler : IRequestHandler<ForgotPasswordCommand, Serv
|
||||
var encodedToken = Uri.EscapeDataString(token);
|
||||
|
||||
var resetLink = $"heimdall://reset-password?email={Uri.EscapeDataString(request.Email)}&token={encodedToken}";
|
||||
var language = user.Language;
|
||||
var encodedResetLink = HtmlEncoder.Default.Encode(resetLink);
|
||||
var body = $"""
|
||||
<h2>Réinitialisation de mot de passe</h2>
|
||||
<p>Vous avez demandé la réinitialisation de votre mot de passe Heimdall.</p>
|
||||
<p>Cliquez sur le lien ci-dessous pour le réinitialiser :</p>
|
||||
<p><a href="{resetLink}">Réinitialiser mon mot de passe</a></p>
|
||||
<p>Ce lien est valable 24h. Si vous n'avez pas fait cette demande, ignorez cet email.</p>
|
||||
<h2>{ServerText.Get("Auth.ForgotPassword.Title", language)}</h2>
|
||||
<p>{ServerText.Get("Auth.ForgotPassword.Intro", language)}</p>
|
||||
<p>{ServerText.Get("Auth.ForgotPassword.Instruction", language)}</p>
|
||||
<p><a href="{encodedResetLink}">{ServerText.Get("Auth.ForgotPassword.Link", language)}</a></p>
|
||||
<p>{ServerText.Get("Auth.ForgotPassword.Expiry", language)}</p>
|
||||
""";
|
||||
|
||||
await _emailService.SendEmailAsync(request.Email, "Réinitialisation de mot de passe Heimdall", body, ct).ConfigureAwait(false);
|
||||
await _emailService.SendEmailAsync(request.Email,
|
||||
ServerText.Get("Auth.ForgotPassword.Subject", language), body, ct).ConfigureAwait(false);
|
||||
|
||||
_logger.LogInformation("ForgotPassword: Reset link sent to Email={Email}", request.Email);
|
||||
return ServiceResult.Success();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using System.Text.Encodings.Web;
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Application.DTOs;
|
||||
using Heimdall.Application.Localization;
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Domain.Entities;
|
||||
using MediatR;
|
||||
@@ -161,14 +163,16 @@ public class RegisterHandler : IRequestHandler<RegisterCommand, ServiceResult<Au
|
||||
var userId = Uri.EscapeDataString(user.Id.ToString());
|
||||
|
||||
var confirmLink = $"heimdall://confirm-email?userId={userId}&token={encodedToken}";
|
||||
var encodedConfirmLink = HtmlEncoder.Default.Encode(confirmLink);
|
||||
var body = $"""
|
||||
<h2>Bienvenue sur Heimdall</h2>
|
||||
<p>Merci de vous être inscrit. Veuillez confirmer votre adresse email en cliquant sur le lien ci-dessous :</p>
|
||||
<p><a href="{confirmLink}">Confirmer mon email</a></p>
|
||||
<p>Ce lien est valable 24h.</p>
|
||||
<h2>{ServerText.Get("Auth.Register.Title", user.Language)}</h2>
|
||||
<p>{ServerText.Get("Auth.Register.Intro", user.Language)}</p>
|
||||
<p><a href="{encodedConfirmLink}">{ServerText.Get("Auth.Register.Link", user.Language)}</a></p>
|
||||
<p>{ServerText.Get("Auth.Register.Expiry", user.Language)}</p>
|
||||
""";
|
||||
|
||||
await _emailService.SendEmailAsync(user.Email!, "Confirmez votre email - Heimdall", body, ct).ConfigureAwait(false);
|
||||
await _emailService.SendEmailAsync(user.Email!,
|
||||
ServerText.Get("Auth.Register.Subject", user.Language), body, ct).ConfigureAwait(false);
|
||||
_logger.LogInformation("Register: Confirmation email sent to {Email}", user.Email);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Application.Localization;
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Domain.Enums;
|
||||
using MediatR;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Heimdall.Application.Events.Notifications;
|
||||
|
||||
@@ -9,15 +12,26 @@ public class EventCreatedNotificationHandler : INotificationHandler<EventCreated
|
||||
private readonly IEventBroadcastService _broadcast;
|
||||
private readonly ICameraAccessService _cameraAccess;
|
||||
private readonly INotificationService _notifications;
|
||||
private readonly IApplicationDbContext? _context;
|
||||
|
||||
public EventCreatedNotificationHandler(
|
||||
IEventBroadcastService broadcast,
|
||||
ICameraAccessService cameraAccess,
|
||||
INotificationService notifications)
|
||||
: this(broadcast, cameraAccess, notifications, null)
|
||||
{
|
||||
}
|
||||
|
||||
public EventCreatedNotificationHandler(
|
||||
IEventBroadcastService broadcast,
|
||||
ICameraAccessService cameraAccess,
|
||||
INotificationService notifications,
|
||||
IApplicationDbContext? context)
|
||||
{
|
||||
_broadcast = broadcast;
|
||||
_cameraAccess = cameraAccess;
|
||||
_notifications = notifications;
|
||||
_context = context;
|
||||
}
|
||||
|
||||
public async Task Handle(EventCreatedNotification notification, CancellationToken ct)
|
||||
@@ -28,20 +42,26 @@ public class EventCreatedNotificationHandler : INotificationHandler<EventCreated
|
||||
if (cameraEvent.Type == EventType.ManualSnapshot) return;
|
||||
var recipients = await _cameraAccess.GetUserIdsWithCameraAccessAsync(cameraEvent.CameraId, ct)
|
||||
.ConfigureAwait(false);
|
||||
var title = cameraEvent.Type switch
|
||||
|
||||
var languages = _context is null || recipients.Count == 0
|
||||
? new Dictionary<Guid, string>()
|
||||
: await _context.Users.AsNoTracking()
|
||||
.Where(user => recipients.Contains(user.Id))
|
||||
.Select(user => new { user.Id, user.Language })
|
||||
.ToDictionaryAsync(user => user.Id, user => user.Language, ct)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
var titleKey = cameraEvent.Type switch
|
||||
{
|
||||
EventType.PersonDetected => "Personne détectée",
|
||||
EventType.VehicleDetected => "Véhicule détecté",
|
||||
EventType.UnknownPerson => "Personne inconnue détectée",
|
||||
EventType.FaceRecognized => "Visage reconnu",
|
||||
EventType.LicensePlateDetected => "Plaque détectée",
|
||||
EventType.CameraOffline => "Caméra hors ligne",
|
||||
EventType.CameraOnline => "Caméra en ligne",
|
||||
_ => "Mouvement détecté"
|
||||
EventType.PersonDetected => "Notification.Event.PersonDetected",
|
||||
EventType.VehicleDetected => "Notification.Event.VehicleDetected",
|
||||
EventType.UnknownPerson => "Notification.Event.UnknownPerson",
|
||||
EventType.FaceRecognized => "Notification.Event.FaceRecognized",
|
||||
EventType.LicensePlateDetected => "Notification.Event.LicensePlateDetected",
|
||||
EventType.CameraOffline => "Notification.Event.CameraOffline",
|
||||
EventType.CameraOnline => "Notification.Event.CameraOnline",
|
||||
_ => "Notification.Event.MotionDetected"
|
||||
};
|
||||
var message = string.IsNullOrWhiteSpace(cameraEvent.Label)
|
||||
? $"{title} sur la caméra {cameraEvent.CameraId}."
|
||||
: $"{title} sur la caméra {cameraEvent.CameraId} : {cameraEvent.Label}.";
|
||||
var type = cameraEvent.Type is EventType.UnknownPerson or EventType.CameraOffline
|
||||
? NotificationType.Alert
|
||||
: cameraEvent.Type == EventType.CameraOnline
|
||||
@@ -50,6 +70,11 @@ public class EventCreatedNotificationHandler : INotificationHandler<EventCreated
|
||||
|
||||
foreach (var userId in recipients)
|
||||
{
|
||||
languages.TryGetValue(userId, out var language);
|
||||
var title = ServerText.Get(titleKey, language);
|
||||
var message = string.IsNullOrWhiteSpace(cameraEvent.Label)
|
||||
? ServerText.Format("Notification.Event.NoLabel", language, title, cameraEvent.CameraId)
|
||||
: ServerText.Format("Notification.Event.WithLabel", language, title, cameraEvent.CameraId, cameraEvent.Label);
|
||||
var result = await _notifications.CreateNotificationAsync(
|
||||
userId, title, message, type, cameraEvent.Type, cameraEvent.CameraId,
|
||||
cameraEvent.SiteId, cameraEvent.SnapshotUrl,
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<data name="Auth.ForgotPassword.Subject" xml:space="preserve">
|
||||
<value>Reset your Heimdall password</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Title" xml:space="preserve">
|
||||
<value>Password reset</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Intro" xml:space="preserve">
|
||||
<value>You requested a reset of your Heimdall password.</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Instruction" xml:space="preserve">
|
||||
<value>Click the link below to reset it:</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Link" xml:space="preserve">
|
||||
<value>Reset my password</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Expiry" xml:space="preserve">
|
||||
<value>This link is valid for 24 hours. If you did not request it, ignore this email.</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Subject" xml:space="preserve">
|
||||
<value>Confirm your email address - Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Title" xml:space="preserve">
|
||||
<value>Welcome to Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Intro" xml:space="preserve">
|
||||
<value>Thank you for registering. Please confirm your email address by clicking the link below:</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Link" xml:space="preserve">
|
||||
<value>Confirm my email</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Expiry" xml:space="preserve">
|
||||
<value>This link is valid for 24 hours.</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Subject" xml:space="preserve">
|
||||
<value>Heimdall — Daily digest</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Title" xml:space="preserve">
|
||||
<value>Heimdall daily digest</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Subject" xml:space="preserve">
|
||||
<value>Heimdall — Weekly digest</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Title" xml:space="preserve">
|
||||
<value>Heimdall weekly digest</value>
|
||||
</data>
|
||||
<data name="Digest.Greeting" xml:space="preserve">
|
||||
<value>Hello,</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Events" xml:space="preserve">
|
||||
<value>Events detected today (UTC):</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Events" xml:space="preserve">
|
||||
<value>Events detected in the last 7 days (UTC):</value>
|
||||
</data>
|
||||
<data name="Digest.UnreadNotifications" xml:space="preserve">
|
||||
<value>Unread notifications:</value>
|
||||
</data>
|
||||
<data name="Digest.Signoff" xml:space="preserve">
|
||||
<value>Regards,<br/>The Heimdall team</value>
|
||||
</data>
|
||||
<data name="Notification.Event.PersonDetected" xml:space="preserve">
|
||||
<value>Person detected</value>
|
||||
</data>
|
||||
<data name="Notification.Event.VehicleDetected" xml:space="preserve">
|
||||
<value>Vehicle detected</value>
|
||||
</data>
|
||||
<data name="Notification.Event.UnknownPerson" xml:space="preserve">
|
||||
<value>Unknown person detected</value>
|
||||
</data>
|
||||
<data name="Notification.Event.FaceRecognized" xml:space="preserve">
|
||||
<value>Face recognized</value>
|
||||
</data>
|
||||
<data name="Notification.Event.LicensePlateDetected" xml:space="preserve">
|
||||
<value>License plate detected</value>
|
||||
</data>
|
||||
<data name="Notification.Event.CameraOffline" xml:space="preserve">
|
||||
<value>Camera offline</value>
|
||||
</data>
|
||||
<data name="Notification.Event.CameraOnline" xml:space="preserve">
|
||||
<value>Camera online</value>
|
||||
</data>
|
||||
<data name="Notification.Event.MotionDetected" xml:space="preserve">
|
||||
<value>Motion detected</value>
|
||||
</data>
|
||||
<data name="Notification.Event.NoLabel" xml:space="preserve">
|
||||
<value>{0} on camera {1}.</value>
|
||||
</data>
|
||||
<data name="Notification.Event.WithLabel" xml:space="preserve">
|
||||
<value>{0} on camera {1}: {2}.</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Subject" xml:space="preserve">
|
||||
<value>Heimdall — configuration test</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Title" xml:space="preserve">
|
||||
<value>✅ Email configuration OK</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Body" xml:space="preserve">
|
||||
<value>This message confirms that the SMTP server is reachable and authentication works.</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.NotConfigured" xml:space="preserve">
|
||||
<value>Sender address is not configured (email.fromaddress).</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Sent" xml:space="preserve">
|
||||
<value>Test email sent to {0}</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Failed" xml:space="preserve">
|
||||
<value>Sending failed: {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<data name="Auth.ForgotPassword.Subject" xml:space="preserve">
|
||||
<value>Réinitialisation du mot de passe Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Title" xml:space="preserve">
|
||||
<value>Réinitialisation de mot de passe</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Intro" xml:space="preserve">
|
||||
<value>Vous avez demandé la réinitialisation de votre mot de passe Heimdall.</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Instruction" xml:space="preserve">
|
||||
<value>Cliquez sur le lien ci-dessous pour le réinitialiser :</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Link" xml:space="preserve">
|
||||
<value>Réinitialiser mon mot de passe</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Expiry" xml:space="preserve">
|
||||
<value>Ce lien est valable 24 h. Si vous n'avez pas fait cette demande, ignorez cet email.</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Subject" xml:space="preserve">
|
||||
<value>Confirmez votre adresse email - Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Title" xml:space="preserve">
|
||||
<value>Bienvenue sur Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Intro" xml:space="preserve">
|
||||
<value>Merci de vous être inscrit. Veuillez confirmer votre adresse email en cliquant sur le lien ci-dessous :</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Link" xml:space="preserve">
|
||||
<value>Confirmer mon email</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Expiry" xml:space="preserve">
|
||||
<value>Ce lien est valable 24 h.</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Subject" xml:space="preserve">
|
||||
<value>Heimdall — Résumé quotidien</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Title" xml:space="preserve">
|
||||
<value>Résumé quotidien Heimdall</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Subject" xml:space="preserve">
|
||||
<value>Heimdall — Résumé hebdomadaire</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Title" xml:space="preserve">
|
||||
<value>Résumé hebdomadaire Heimdall</value>
|
||||
</data>
|
||||
<data name="Digest.Greeting" xml:space="preserve">
|
||||
<value>Bonjour,</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Events" xml:space="preserve">
|
||||
<value>Événements détectés aujourd'hui (UTC) :</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Events" xml:space="preserve">
|
||||
<value>Événements détectés sur les 7 derniers jours (UTC) :</value>
|
||||
</data>
|
||||
<data name="Digest.UnreadNotifications" xml:space="preserve">
|
||||
<value>Notifications non lues :</value>
|
||||
</data>
|
||||
<data name="Digest.Signoff" xml:space="preserve">
|
||||
<value>Cordialement,<br/>L'équipe Heimdall</value>
|
||||
</data>
|
||||
<data name="Notification.Event.PersonDetected" xml:space="preserve">
|
||||
<value>Personne détectée</value>
|
||||
</data>
|
||||
<data name="Notification.Event.VehicleDetected" xml:space="preserve">
|
||||
<value>Véhicule détecté</value>
|
||||
</data>
|
||||
<data name="Notification.Event.UnknownPerson" xml:space="preserve">
|
||||
<value>Personne inconnue détectée</value>
|
||||
</data>
|
||||
<data name="Notification.Event.FaceRecognized" xml:space="preserve">
|
||||
<value>Visage reconnu</value>
|
||||
</data>
|
||||
<data name="Notification.Event.LicensePlateDetected" xml:space="preserve">
|
||||
<value>Plaque détectée</value>
|
||||
</data>
|
||||
<data name="Notification.Event.CameraOffline" xml:space="preserve">
|
||||
<value>Caméra hors ligne</value>
|
||||
</data>
|
||||
<data name="Notification.Event.CameraOnline" xml:space="preserve">
|
||||
<value>Caméra en ligne</value>
|
||||
</data>
|
||||
<data name="Notification.Event.MotionDetected" xml:space="preserve">
|
||||
<value>Mouvement détecté</value>
|
||||
</data>
|
||||
<data name="Notification.Event.NoLabel" xml:space="preserve">
|
||||
<value>{0} sur la caméra {1}.</value>
|
||||
</data>
|
||||
<data name="Notification.Event.WithLabel" xml:space="preserve">
|
||||
<value>{0} sur la caméra {1} : {2}.</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Subject" xml:space="preserve">
|
||||
<value>Heimdall — test de configuration</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Title" xml:space="preserve">
|
||||
<value>✅ Configuration email OK</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Body" xml:space="preserve">
|
||||
<value>Ce message confirme que le serveur SMTP est joignable et que l'authentification fonctionne.</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.NotConfigured" xml:space="preserve">
|
||||
<value>Adresse expéditrice non configurée (email.fromaddress).</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Sent" xml:space="preserve">
|
||||
<value>Email de test envoyé à {0}</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Failed" xml:space="preserve">
|
||||
<value>Échec de l’envoi : {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,111 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<data name="Auth.ForgotPassword.Subject" xml:space="preserve">
|
||||
<value>Réinitialisation du mot de passe Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Title" xml:space="preserve">
|
||||
<value>Réinitialisation de mot de passe</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Intro" xml:space="preserve">
|
||||
<value>Vous avez demandé la réinitialisation de votre mot de passe Heimdall.</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Instruction" xml:space="preserve">
|
||||
<value>Cliquez sur le lien ci-dessous pour le réinitialiser :</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Link" xml:space="preserve">
|
||||
<value>Réinitialiser mon mot de passe</value>
|
||||
</data>
|
||||
<data name="Auth.ForgotPassword.Expiry" xml:space="preserve">
|
||||
<value>Ce lien est valable 24 h. Si vous n'avez pas fait cette demande, ignorez cet email.</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Subject" xml:space="preserve">
|
||||
<value>Confirmez votre adresse email - Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Title" xml:space="preserve">
|
||||
<value>Bienvenue sur Heimdall</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Intro" xml:space="preserve">
|
||||
<value>Merci de vous être inscrit. Veuillez confirmer votre adresse email en cliquant sur le lien ci-dessous :</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Link" xml:space="preserve">
|
||||
<value>Confirmer mon email</value>
|
||||
</data>
|
||||
<data name="Auth.Register.Expiry" xml:space="preserve">
|
||||
<value>Ce lien est valable 24 h.</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Subject" xml:space="preserve">
|
||||
<value>Heimdall — Résumé quotidien</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Title" xml:space="preserve">
|
||||
<value>Résumé quotidien Heimdall</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Subject" xml:space="preserve">
|
||||
<value>Heimdall — Résumé hebdomadaire</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Title" xml:space="preserve">
|
||||
<value>Résumé hebdomadaire Heimdall</value>
|
||||
</data>
|
||||
<data name="Digest.Greeting" xml:space="preserve">
|
||||
<value>Bonjour,</value>
|
||||
</data>
|
||||
<data name="Digest.Daily.Events" xml:space="preserve">
|
||||
<value>Événements détectés aujourd'hui (UTC) :</value>
|
||||
</data>
|
||||
<data name="Digest.Weekly.Events" xml:space="preserve">
|
||||
<value>Événements détectés sur les 7 derniers jours (UTC) :</value>
|
||||
</data>
|
||||
<data name="Digest.UnreadNotifications" xml:space="preserve">
|
||||
<value>Notifications non lues :</value>
|
||||
</data>
|
||||
<data name="Digest.Signoff" xml:space="preserve">
|
||||
<value>Cordialement,<br/>L'équipe Heimdall</value>
|
||||
</data>
|
||||
<data name="Notification.Event.PersonDetected" xml:space="preserve">
|
||||
<value>Personne détectée</value>
|
||||
</data>
|
||||
<data name="Notification.Event.VehicleDetected" xml:space="preserve">
|
||||
<value>Véhicule détecté</value>
|
||||
</data>
|
||||
<data name="Notification.Event.UnknownPerson" xml:space="preserve">
|
||||
<value>Personne inconnue détectée</value>
|
||||
</data>
|
||||
<data name="Notification.Event.FaceRecognized" xml:space="preserve">
|
||||
<value>Visage reconnu</value>
|
||||
</data>
|
||||
<data name="Notification.Event.LicensePlateDetected" xml:space="preserve">
|
||||
<value>Plaque détectée</value>
|
||||
</data>
|
||||
<data name="Notification.Event.CameraOffline" xml:space="preserve">
|
||||
<value>Caméra hors ligne</value>
|
||||
</data>
|
||||
<data name="Notification.Event.CameraOnline" xml:space="preserve">
|
||||
<value>Caméra en ligne</value>
|
||||
</data>
|
||||
<data name="Notification.Event.MotionDetected" xml:space="preserve">
|
||||
<value>Mouvement détecté</value>
|
||||
</data>
|
||||
<data name="Notification.Event.NoLabel" xml:space="preserve">
|
||||
<value>{0} sur la caméra {1}.</value>
|
||||
</data>
|
||||
<data name="Notification.Event.WithLabel" xml:space="preserve">
|
||||
<value>{0} sur la caméra {1} : {2}.</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Subject" xml:space="preserve">
|
||||
<value>Heimdall — test de configuration</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Title" xml:space="preserve">
|
||||
<value>✅ Configuration email OK</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Body" xml:space="preserve">
|
||||
<value>Ce message confirme que le serveur SMTP est joignable et que l'authentification fonctionne.</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.NotConfigured" xml:space="preserve">
|
||||
<value>Adresse expéditrice non configurée (email.fromaddress).</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Sent" xml:space="preserve">
|
||||
<value>Email de test envoyé à {0}</value>
|
||||
</data>
|
||||
<data name="Settings.EmailTest.Failed" xml:space="preserve">
|
||||
<value>Échec de l’envoi : {0}</value>
|
||||
</data>
|
||||
</root>
|
||||
@@ -0,0 +1,30 @@
|
||||
using System.Globalization;
|
||||
using System.Resources;
|
||||
|
||||
namespace Heimdall.Application.Localization;
|
||||
|
||||
/// <summary>Resolves server generated email and notification text in French or English.</summary>
|
||||
public static class ServerText
|
||||
{
|
||||
private static readonly ResourceManager Resources = new(
|
||||
"Heimdall.Application.Localization.ServerResources",
|
||||
typeof(ServerText).Assembly);
|
||||
|
||||
public static CultureInfo Culture(string? language)
|
||||
=> CultureInfo.GetCultureInfo(Normalize(language));
|
||||
|
||||
public static string Get(string key, string? language = null)
|
||||
=> Resources.GetString(key, Culture(language)) ?? Resources.GetString(key, CultureInfo.GetCultureInfo("fr")) ?? key;
|
||||
|
||||
public static string Format(string key, string? language = null, params object?[] args)
|
||||
=> string.Format(Culture(language), Get(key, language), args);
|
||||
|
||||
private static string Normalize(string? language)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(language)) return "fr";
|
||||
return language.Equals("en", StringComparison.OrdinalIgnoreCase)
|
||||
|| language.StartsWith("en-", StringComparison.OrdinalIgnoreCase)
|
||||
? "en"
|
||||
: "fr";
|
||||
}
|
||||
}
|
||||
+4
-2
@@ -20,6 +20,8 @@ public class UpdateNotificationConfigHandler : IRequestHandler<UpdateNotificatio
|
||||
|
||||
public async Task<ServiceResult<UserNotificationConfigDto>> Handle(UpdateNotificationConfigCommand request, CancellationToken ct)
|
||||
{
|
||||
var language = request.Language?.Trim().ToLowerInvariant();
|
||||
|
||||
var config = await _context.UserNotificationConfigs
|
||||
.FirstOrDefaultAsync(c => c.UserId == request.UserId, ct);
|
||||
|
||||
@@ -41,8 +43,8 @@ public class UpdateNotificationConfigHandler : IRequestHandler<UpdateNotificatio
|
||||
if (request.SubscribedEvents is not null)
|
||||
config.SetSubscribedEvents(System.Text.Json.JsonSerializer.Serialize(request.SubscribedEvents));
|
||||
|
||||
if (request.Language is not null)
|
||||
config.SetLanguage(request.Language);
|
||||
if (language is not null)
|
||||
config.SetLanguage(language);
|
||||
|
||||
await _context.SaveChangesWithRetryAsync(ct: ct).ConfigureAwait(false);
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Application.Localization;
|
||||
using Heimdall.Infrastructure.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -38,6 +39,10 @@ public class DailyDigestJob
|
||||
var configs = await db.UserNotificationConfigs
|
||||
.Where(c => c.DailyDigest && c.EmailEnabled && c.EmailAddress != null)
|
||||
.ToListAsync(ct);
|
||||
var userIds = configs.Select(config => config.UserId).Distinct().ToArray();
|
||||
var languages = await db.Users.AsNoTracking()
|
||||
.Where(user => userIds.Contains(user.Id))
|
||||
.ToDictionaryAsync(user => user.Id, user => user.Language, ct);
|
||||
|
||||
var now = DateTime.UtcNow;
|
||||
var from = now.Date;
|
||||
@@ -58,15 +63,16 @@ public class DailyDigestJob
|
||||
var unreadNotifications = await db.Notifications
|
||||
.CountAsync(n => n.UserId == config.UserId && !n.IsRead, ct);
|
||||
|
||||
var subject = "Heimdall — Résumé quotidien";
|
||||
var language = languages.GetValueOrDefault(config.UserId, config.Language);
|
||||
var subject = ServerText.Get("Digest.Daily.Subject", language);
|
||||
var body = $"""
|
||||
<h2>Résumé quotidien Heimdall</h2>
|
||||
<p>Bonjour,</p>
|
||||
<h2>{ServerText.Get("Digest.Daily.Title", language)}</h2>
|
||||
<p>{ServerText.Get("Digest.Greeting", language)}</p>
|
||||
<ul>
|
||||
<li>Événements détectés aujourd'hui (UTC) : <strong>{eventCount}</strong></li>
|
||||
<li>Notifications non lues : <strong>{unreadNotifications}</strong></li>
|
||||
<li>{ServerText.Get("Digest.Daily.Events", language)} <strong>{eventCount}</strong></li>
|
||||
<li>{ServerText.Get("Digest.UnreadNotifications", language)} <strong>{unreadNotifications}</strong></li>
|
||||
</ul>
|
||||
<p>Cordialement,<br/>L'équipe Heimdall</p>
|
||||
<p>{ServerText.Get("Digest.Signoff", language)}</p>
|
||||
""";
|
||||
|
||||
await _emailService.SendEmailAsync(config.EmailAddress!, subject, body, ct).ConfigureAwait(false);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Application.Localization;
|
||||
using Heimdall.Infrastructure.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@@ -38,6 +39,10 @@ public class WeeklyDigestJob
|
||||
var configs = await db.UserNotificationConfigs
|
||||
.Where(c => c.WeeklyDigest && c.EmailEnabled && c.EmailAddress != null)
|
||||
.ToListAsync(ct);
|
||||
var userIds = configs.Select(config => config.UserId).Distinct().ToArray();
|
||||
var languages = await db.Users.AsNoTracking()
|
||||
.Where(user => userIds.Contains(user.Id))
|
||||
.ToDictionaryAsync(user => user.Id, user => user.Language, ct);
|
||||
|
||||
var to = DateTime.UtcNow;
|
||||
var from = to.AddDays(-7);
|
||||
@@ -58,15 +63,16 @@ public class WeeklyDigestJob
|
||||
var unreadNotifications = await db.Notifications
|
||||
.CountAsync(n => n.UserId == config.UserId && !n.IsRead, ct);
|
||||
|
||||
var subject = "Heimdall — Résumé hebdomadaire";
|
||||
var language = languages.GetValueOrDefault(config.UserId, config.Language);
|
||||
var subject = ServerText.Get("Digest.Weekly.Subject", language);
|
||||
var body = $"""
|
||||
<h2>Résumé hebdomadaire Heimdall</h2>
|
||||
<p>Bonjour,</p>
|
||||
<h2>{ServerText.Get("Digest.Weekly.Title", language)}</h2>
|
||||
<p>{ServerText.Get("Digest.Greeting", language)}</p>
|
||||
<ul>
|
||||
<li>Événements détectés sur les 7 derniers jours (UTC) : <strong>{eventCount}</strong></li>
|
||||
<li>Notifications non lues : <strong>{unreadNotifications}</strong></li>
|
||||
<li>{ServerText.Get("Digest.Weekly.Events", language)} <strong>{eventCount}</strong></li>
|
||||
<li>{ServerText.Get("Digest.UnreadNotifications", language)} <strong>{unreadNotifications}</strong></li>
|
||||
</ul>
|
||||
<p>Cordialement,<br/>L'équipe Heimdall</p>
|
||||
<p>{ServerText.Get("Digest.Signoff", language)}</p>
|
||||
""";
|
||||
|
||||
await _emailService.SendEmailAsync(config.EmailAddress!, subject, body, ct).ConfigureAwait(false);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
@* AgentCard.razor — carte agent avec jauges live CPU/RAM/Disque/Uptime.
|
||||
Seuils : CPU/RAM > 90 % → warning, > 95 % → error. Hors ligne → jauges grisées. *@
|
||||
@using Heimdall.Web.Services
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<MudPaper Elevation="1" Class="pa-4 hmd-tile" Style="border-radius: var(--hmd-radius-md); height: 100%; display:flex; flex-direction:column;">
|
||||
@@ -41,12 +43,12 @@
|
||||
<div class="d-flex align-center justify-center flex-column" style="flex:1; min-height: 120px;">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CloudOff" Size="Size.Large" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-2">
|
||||
@(Agent.Status == "Offline" ? "Agent hors ligne" : "Agent en erreur")
|
||||
@(Agent.Status == "Offline" ? Text["AgentCard_Offline"] : Text["AgentCard_Error"])
|
||||
</MudText>
|
||||
@if (Agent.LastHeartbeat is { } hb)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
Dernier contact : @hb.ToLocalTime().ToString("g")
|
||||
@Text["AgentCard_LastContact"] : @hb.ToLocalTime().ToString("g", Language.Culture)
|
||||
</MudText>
|
||||
}
|
||||
</div>
|
||||
@@ -65,7 +67,7 @@
|
||||
@* RAM *@
|
||||
<div>
|
||||
<div class="d-flex justify-space-between">
|
||||
<MudText Typo="Typo.caption">Mémoire</MudText>
|
||||
<MudText Typo="Typo.caption">@Text["AgentCard_Memory"]</MudText>
|
||||
<MudText Typo="Typo.caption" Color="@GetMetricColor(MemoryPercent)">@FormatPercent(MemoryPercent)</MudText>
|
||||
</div>
|
||||
<MudProgressLinear Value="@(MemoryPercent ?? 0)" Color="@GetMetricColor(MemoryPercent)" Rounded="true" Size="Size.Small" />
|
||||
@@ -73,14 +75,14 @@
|
||||
@* Disque *@
|
||||
<div>
|
||||
<div class="d-flex justify-space-between">
|
||||
<MudText Typo="Typo.caption">Disque</MudText>
|
||||
<MudText Typo="Typo.caption">@Text["AgentCard_Disk"]</MudText>
|
||||
<MudText Typo="Typo.caption" Color="@GetMetricColor(DiskPercent)">@FormatPercent(DiskPercent)</MudText>
|
||||
</div>
|
||||
<MudProgressLinear Value="@(DiskPercent ?? 0)" Color="@GetMetricColor(DiskPercent)" Rounded="true" Size="Size.Small" />
|
||||
</div>
|
||||
@* Uptime *@
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Schedule" Size="Size.Small" Class="mr-1" /> Uptime : @FormatUptime()
|
||||
<MudIcon Icon="@Icons.Material.Filled.Schedule" Size="Size.Small" Class="mr-1" /> @Text["AgentCard_Uptime"] : @FormatUptime()
|
||||
</MudText>
|
||||
|
||||
@* GPU Live Metrics *@
|
||||
@@ -158,11 +160,11 @@
|
||||
_ => Icons.Material.Filled.Help
|
||||
};
|
||||
|
||||
private static string FormatStatus(string status) => status switch
|
||||
private string FormatStatus(string status) => status switch
|
||||
{
|
||||
"Online" => "En ligne",
|
||||
"Offline" => "Hors ligne",
|
||||
"Error" => "Erreur",
|
||||
"Online" => Text["AgentCard_Online"],
|
||||
"Offline" => Text["AgentCard_OfflineStatus"],
|
||||
"Error" => Text["AgentCard_Error"],
|
||||
_ => status
|
||||
};
|
||||
|
||||
@@ -195,6 +197,6 @@
|
||||
{
|
||||
if (Agent.UptimeSeconds is not { } s) return "—";
|
||||
var t = TimeSpan.FromSeconds(s);
|
||||
return t.TotalDays >= 1 ? $"{(int)t.TotalDays}j {t.Hours}h" : $"{t.Hours}h {t.Minutes}min";
|
||||
return t.TotalDays >= 1 ? string.Format(Text["AgentCard_UptimeDays"], (int)t.TotalDays, t.Hours) : string.Format(Text["AgentCard_UptimeHours"], t.Hours, t.Minutes);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,11 @@
|
||||
@* AgentMetrics.razor — jauge CPU / RAM / disque + uptime d'un agent.
|
||||
Affiche les métriques live remontées par le heartbeat (nullable). *@
|
||||
@using Heimdall.Web.Services
|
||||
@inject UiText Text
|
||||
|
||||
@if (Agent is null)
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Aucune métrique disponible.</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["AgentMetrics_NoMetrics"]</MudText>
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,15 +15,15 @@
|
||||
Progress="@CpuPercent" ProgressColor="Color.Primary" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MetricTile Label="Mémoire" Value="@FormatMemory()" Color="Color.Info"
|
||||
<MetricTile Label="@Text["AgentMetrics_Memory"]" Value="@FormatMemory()" Color="Color.Info"
|
||||
Progress="@MemoryPercent" ProgressColor="Color.Info" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MetricTile Label="Disque" Value="@FormatDisk()" Color="Color.Warning"
|
||||
<MetricTile Label="@Text["AgentMetrics_Disk"]" Value="@FormatDisk()" Color="Color.Warning"
|
||||
Progress="@DiskPercent" ProgressColor="Color.Warning" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MetricTile Label="Uptime" Value="@FormatUptime()" Color="Color.Success"
|
||||
<MetricTile Label="@Text["AgentMetrics_Uptime"]" Value="@FormatUptime()" Color="Color.Success"
|
||||
Icon="@Icons.Material.Filled.Schedule" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -63,11 +64,11 @@
|
||||
{
|
||||
if (Agent?.UptimeSeconds is not { } s) return "—";
|
||||
var t = TimeSpan.FromSeconds(s);
|
||||
return t.TotalDays >= 1 ? $"{(int)t.TotalDays}j {t.Hours}h" : $"{t.Hours}h {t.Minutes}min";
|
||||
return t.TotalDays >= 1 ? string.Format(Text["AgentMetrics_UptimeDays"], (int)t.TotalDays, t.Hours) : string.Format(Text["AgentMetrics_UptimeHours"], t.Hours, t.Minutes);
|
||||
}
|
||||
|
||||
private static string FormatMb(long bytes)
|
||||
private string FormatMb(long bytes)
|
||||
=> bytes >= 1024 * 1024 * 1024 ? $"{bytes / 1024.0 / 1024.0 / 1024.0:F1} Go"
|
||||
: bytes >= 1024 * 1024 ? $"{bytes / 1024.0 / 1024.0:F0} Mo"
|
||||
: $"{bytes / 1024.0:F0} Ko";
|
||||
: bytes >= 1024 * 1024 ? string.Format(Text["AgentMetrics_Megabytes"], bytes / 1024.0 / 1024.0)
|
||||
: string.Format(Text["AgentMetrics_Kilobytes"], bytes / 1024.0);
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
@inject UiText Text
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
|
||||
@@ -27,8 +29,8 @@
|
||||
<div class="auth-card">
|
||||
<div class="auth-header">
|
||||
<i class="fas fa-exclamation-triangle fa-2x" style="color: var(--auth-primary);"></i>
|
||||
<h1>Une erreur est survenue</h1>
|
||||
<p>L'application a rencontré une erreur. <a href="">Recharger la page</a> pour réessayer.</p>
|
||||
<h1>@Text["App_ErrorTitle"]</h1>
|
||||
<p>@Text["App_ErrorBody"] <a href="">@Text["App_Reload"]</a> @Text["App_TryAgain"]</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,9 +38,9 @@
|
||||
</ErrorBoundary>
|
||||
|
||||
<div id="blazor-error-ui">
|
||||
<p>Une erreur réseau est survenue. Tentative de reconnexion...</p>
|
||||
<a href="" class="reconnect">Reconnecter</a>
|
||||
<a href="" class="dismiss">Ignorer</a>
|
||||
<p>@Text["App_ReconnectBody"]</p>
|
||||
<a href="" class="reconnect">@Text["App_Reconnect"]</a>
|
||||
<a href="" class="dismiss">@Text["App_Dismiss"]</a>
|
||||
</div>
|
||||
|
||||
<script src="@Assets["_framework/blazor.web.js"]"></script>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@* CameraTile.razor — tuile caméra live : vignette snapshot, statut, actions. *@
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@inject UiText Text
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-0 hmd-tile" Style="border-radius: var(--hmd-radius-lg); overflow: hidden; height: 100%; display: flex; flex-direction: column;">
|
||||
@* ─── Vignette / placeholder ─── *@
|
||||
@@ -11,7 +12,7 @@
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(SnapshotUrl))
|
||||
{
|
||||
<img src="@SnapshotUrl" alt="Vignette de @Camera.Name" style="width:100%; height:100%; object-fit:cover;"
|
||||
<img src="@SnapshotUrl" alt="@string.Format(Text["CameraTile_SnapshotAlt"], Camera.Name)" style="width:100%; height:100%; object-fit:cover;"
|
||||
loading="lazy" />
|
||||
@if (Camera.Status == "Online")
|
||||
{
|
||||
@@ -48,23 +49,23 @@
|
||||
|
||||
@* ─── Actions ─── *@
|
||||
<div class="d-flex justify-end">
|
||||
<MudTooltip Text="Voir la caméra">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Visibility" Size="Size.Small" aria-label="Voir la caméra"
|
||||
<MudTooltip Text="@Text["CameraTile_View"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Visibility" Size="Size.Small" aria-label="@Text["CameraTile_View"]"
|
||||
OnClick="@(() => Nav.NavigateTo($"/cameras/{Camera.Id}"))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="@(Camera.Status == "Disabled" ? "Activer la caméra" : "Désactiver la caméra")">
|
||||
<MudTooltip Text="@(Camera.Status == "Disabled" ? Text["CameraTile_Enable"] : Text["CameraTile_Disable"])">
|
||||
<MudIconButton Icon="@(Camera.Status == "Disabled" ? Icons.Material.Filled.PlayArrow : Icons.Material.Filled.Stop)"
|
||||
Size="Size.Small" Color="@(Camera.Status == "Disabled" ? Color.Success : Color.Default)"
|
||||
aria-label="@(Camera.Status == "Disabled" ? "Activer la caméra" : "Désactiver la caméra")"
|
||||
aria-label="@(Camera.Status == "Disabled" ? Text["CameraTile_Enable"] : Text["CameraTile_Disable"])"
|
||||
OnClick="@OnToggleStatus" Disabled="@_toggling" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Prendre un snapshot">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.PhotoCamera" Size="Size.Small" aria-label="Prendre un snapshot"
|
||||
<MudTooltip Text="@Text["CameraTile_Snapshot"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.PhotoCamera" Size="Size.Small" aria-label="@Text["CameraTile_Snapshot"]"
|
||||
Disabled="@(Camera.Status != "Online" || LoadingSnapshot || SnapshotRequesting)" OnClick="@OnSnapshot" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Supprimer la caméra">
|
||||
<MudTooltip Text="@Text["CameraTile_Delete"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
|
||||
aria-label="Supprimer la caméra" OnClick="@OnDelete" />
|
||||
aria-label="@Text["CameraTile_Delete"]" OnClick="@OnDelete" />
|
||||
</MudTooltip>
|
||||
</div>
|
||||
</div>
|
||||
@@ -94,11 +95,11 @@
|
||||
_ => Color.Warning
|
||||
};
|
||||
|
||||
private static string GetStatusLabel(string? status) => status switch
|
||||
private string GetStatusLabel(string? status) => status switch
|
||||
{
|
||||
"Online" => "En ligne",
|
||||
"Disabled" => "Désactivée",
|
||||
"Offline" => "Hors ligne",
|
||||
"Online" => Text["CameraTile_StatusOnline"],
|
||||
"Disabled" => Text["CameraTile_StatusDisabled"],
|
||||
"Offline" => Text["CameraTile_StatusOffline"],
|
||||
_ => status ?? "—"
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,8 @@
|
||||
<script type="module" src="@Assets["Components/Layout/ReconnectModal.razor.js"]"></script>
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<script type="module" src="@Assets["Components/Layout/ReconnectModal.razor.js"]"></script>
|
||||
|
||||
<dialog id="components-reconnect-modal" data-nosnippet>
|
||||
<div class="components-reconnect-container">
|
||||
@@ -7,25 +11,33 @@
|
||||
<div></div>
|
||||
</div>
|
||||
<p class="components-reconnect-first-attempt-visible">
|
||||
Rejoining the server...
|
||||
@Text["ReconnectModal_Rejoining"]
|
||||
</p>
|
||||
<p class="components-reconnect-repeated-attempt-visible">
|
||||
Rejoin failed... trying again in <span id="components-seconds-to-next-attempt"></span> seconds.
|
||||
@Text["ReconnectModal_RetryCountdownPrefix"] <span id="components-seconds-to-next-attempt"></span> @Text["ReconnectModal_RetryCountdownSuffix"]
|
||||
</p>
|
||||
<p class="components-reconnect-failed-visible">
|
||||
Failed to rejoin.<br />Please retry or reload the page.
|
||||
@Text["ReconnectModal_RejoinFailed"]<br />@Text["ReconnectModal_RetryOrReload"]
|
||||
</p>
|
||||
<button id="components-reconnect-button" class="components-reconnect-failed-visible">
|
||||
Retry
|
||||
@Text["ReconnectModal_Retry"]
|
||||
</button>
|
||||
<p class="components-pause-visible">
|
||||
The session has been paused by the server.
|
||||
@Text["ReconnectModal_Paused"]
|
||||
</p>
|
||||
<p class="components-resume-failed-visible">
|
||||
Failed to resume the session.<br />Please retry or reload the page.
|
||||
@Text["ReconnectModal_ResumeFailed"]<br />@Text["ReconnectModal_RetryOrReload"]
|
||||
</p>
|
||||
<button id="components-resume-button" class="components-pause-visible components-resume-failed-visible">
|
||||
Resume
|
||||
@Text["ReconnectModal_Resume"]
|
||||
</button>
|
||||
</div>
|
||||
</dialog>
|
||||
|
||||
@code {
|
||||
protected override void OnInitialized() => Language.LanguageChanged += OnLanguageChanged;
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
@page "/admin/agents"
|
||||
@attribute [Authorize(Policy = "Admin.Users")]
|
||||
@layout MainLayout
|
||||
@implements IDisposable
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-microchip mr-2"></i>
|
||||
Agents
|
||||
@Text["AdminAllAgents_Title"]
|
||||
</MudText>
|
||||
|
||||
@if (_loading)
|
||||
@@ -16,9 +19,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des agents.</MudText>
|
||||
<MudText>@Text["AdminAllAgents_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadData" 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["AdminAllAgents_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -29,7 +32,7 @@ else
|
||||
@foreach (var stat in _agentStats)
|
||||
{
|
||||
<MudItem xs="12" sm="6" md="3" @key="stat.Label" Class="d-flex">
|
||||
<StatTile Label="@stat.Label"
|
||||
<StatTile Label="@GetStatLabel(stat.StatType)"
|
||||
Value="@stat.Value.ToString()"
|
||||
Icon="@GetStatIcon(stat.StatType)"
|
||||
IconColor="Color.Secondary"
|
||||
@@ -39,7 +42,7 @@ else
|
||||
</MudGrid>
|
||||
|
||||
@* ─── Filter Bar ─── *@
|
||||
<FilterBar SearchPlaceholder="Rechercher un agent par nom, hostname ou IP..."
|
||||
<FilterBar SearchPlaceholder="@Text["AdminAllAgents_SearchPlaceholder"]"
|
||||
OnSearch="@(async () => { _page = 1; await LoadData(); })"
|
||||
SearchChanged="@(async (s) => { _search = s; _page = 1; await LoadData(); })"
|
||||
Reset="@(async () => { _search = ""; _page = 1; await LoadData(); })" />
|
||||
@@ -47,12 +50,12 @@ else
|
||||
@if (_agents is null || _agents.Count == 0)
|
||||
{
|
||||
<EmptyState Icon="@Icons.Material.Filled.Memory"
|
||||
Title="Aucun agent déployé"
|
||||
Description="Aucun agent n'est actuellement enregistré sur aucun site. Créez un site et générez un token d'enregistrement pour connecter un agent.">
|
||||
Title="@Text["AdminAllAgents_EmptyTitle"]"
|
||||
Description="@Text["AdminAllAgents_EmptyDescription"]">
|
||||
<ActionContent>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary"
|
||||
OnClick="@(() => Nav.NavigateTo("/sites"))">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Business" Class="mr-1" /> Voir les sites
|
||||
<MudIcon Icon="@Icons.Material.Filled.Business" Class="mr-1" /> @Text["AdminAllAgents_ViewSites"]
|
||||
</MudButton>
|
||||
</ActionContent>
|
||||
</EmptyState>
|
||||
@@ -67,9 +70,9 @@ else
|
||||
<div class="position-relative">
|
||||
<AgentCard Agent="@agent" />
|
||||
<div class="d-flex justify-end pa-1" style="margin-top:-8px;">
|
||||
<MudTooltip Text="Supprimer cet agent">
|
||||
<MudTooltip Text="@Text["AdminAllAgents_DeleteTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small"
|
||||
Color="Color.Error" aria-label="Supprimer l'agent"
|
||||
Color="Color.Error" aria-label="@Text["AdminAllAgents_DeleteAria"]"
|
||||
OnClick="@(() => ConfirmDeleteAgent(agent.Id, agent.Name))" />
|
||||
</MudTooltip>
|
||||
</div>
|
||||
@@ -94,20 +97,20 @@ else
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Warning" Color="Color.Warning" Class="mr-2" />
|
||||
Confirmer la suppression
|
||||
@Text["AdminAllAgents_ConfirmDelete"]
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudText>Supprimer l'agent <strong>@_confirmDeleteName</strong> ?</MudText>
|
||||
<MudText>@string.Format(Text["AdminAllAgents_DeletePrompt"], _confirmDeleteName)</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-2">
|
||||
Les caméras associées seront désassignées mais pas supprimées.
|
||||
@Text["AdminAllAgents_DeleteConsequences"]
|
||||
</MudText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">@Text["AdminAllAgents_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error"
|
||||
OnClick="@ExecuteDeleteAgentAsync" Loading="@_deleting" Disabled="@_deleting">
|
||||
Supprimer
|
||||
@Text["AdminAllAgents_Delete"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -132,9 +135,12 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadData();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
// ─── Auto-refresh 15s (métriques live) ─────────────────────────
|
||||
// Démarre APRÈS le premier rendu (OnAfterRenderAsync) : une boucle
|
||||
// infinie awaitée dans OnInitializedAsync bloque le rendu initial
|
||||
@@ -201,7 +207,7 @@ else
|
||||
}
|
||||
catch {
|
||||
_error = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally { _loading = false; }
|
||||
}
|
||||
@@ -212,6 +218,14 @@ else
|
||||
await LoadData();
|
||||
}
|
||||
|
||||
private string GetStatLabel(string statType) => statType switch
|
||||
{
|
||||
"AgentsOnline" => Text["AdminAllAgents_Online"],
|
||||
"AgentsOffline" => Text["AdminAllAgents_Offline"],
|
||||
"AgentsError" => Text["AdminAllAgents_Error"],
|
||||
_ => Text["AdminAllAgents_Total"]
|
||||
};
|
||||
|
||||
private static string GetStatIcon(string statType) => statType switch
|
||||
{
|
||||
"AgentsOnline" => Icons.Material.Filled.CheckCircle,
|
||||
@@ -222,6 +236,7 @@ else
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Language.LanguageChanged -= OnLanguageChanged;
|
||||
_disposed = true;
|
||||
_refreshCts?.Cancel();
|
||||
_refreshCts?.Dispose();
|
||||
@@ -245,15 +260,15 @@ else
|
||||
var error = await Api.DeleteAgentAsync(_confirmDeleteId);
|
||||
if (error is null)
|
||||
{
|
||||
Snackbar.Add($"Agent \"{_confirmDeleteName}\" supprimé", Severity.Success);
|
||||
Snackbar.Add(string.Format(Text["AdminAllAgents_DeleteSuccess"], _confirmDeleteName), Severity.Success);
|
||||
await LoadData();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(error, Severity.Error);
|
||||
Snackbar.Add(Text["OperationFailed"], Severity.Error);
|
||||
}
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["OperationFailed"], Severity.Error); }
|
||||
finally { _deleting = false; }
|
||||
}
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
@page "/admin/api-keys"
|
||||
@attribute [Authorize(Policy = "Admin.ApiKeys")]
|
||||
@layout MainLayout
|
||||
@implements IDisposable
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-key mr-2"></i>
|
||||
Clés API
|
||||
@Text["AdminApiKeys_Title"]
|
||||
</MudText>
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreate = true)" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Créer une clé
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["AdminApiKeys_CreateKey"]
|
||||
</MudButton>
|
||||
|
||||
@if (_loading)
|
||||
@@ -20,16 +23,16 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des clés API.</MudText>
|
||||
<MudText>@Text["AdminApiKeys_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadKeys" 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["AdminApiKeys_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
else if (_keys is null || _keys.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Class="mb-4">
|
||||
<MudText>Aucune clé API configurée. Créez une clé pour permettre aux agents de se connecter.</MudText>
|
||||
<MudText>@Text["AdminApiKeys_EmptyDescription"]</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
@@ -39,23 +42,23 @@ else
|
||||
<MudItem xs="12" sm="4">
|
||||
<MudPaper Class="pa-4" Elevation="2" Style="border-radius: 12px;">
|
||||
<MudText Typo="Typo.h3" Color="Color.Primary">@_keys.Count(k => k.Enabled)</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Clés actives</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["AdminApiKeys_ActiveKeys"]</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="4">
|
||||
<MudPaper Class="pa-4" Elevation="2" Style="border-radius: 12px;">
|
||||
<MudText Typo="Typo.h3" Color="Color.Warning">
|
||||
@(_keys.Any(k => k.Enabled && k.ExpiresAt.HasValue)
|
||||
? _keys.Where(k => k.Enabled && k.ExpiresAt.HasValue).Min(k => k.ExpiresAt!.Value).ToString("dd/MM/yyyy")
|
||||
? _keys.Where(k => k.Enabled && k.ExpiresAt.HasValue).Min(k => k.ExpiresAt!.Value).ToString("d", Language.Culture)
|
||||
: "—")
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Expiration la plus proche</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["AdminApiKeys_NextExpiry"]</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="4">
|
||||
<MudPaper Class="pa-4" Elevation="2" Style="border-radius: 12px;">
|
||||
<MudText Typo="Typo.h3" Color="Color.Error">@_keys.Count(k => !k.Enabled)</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Clés révoquées</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["AdminApiKeys_RevokedKeys"]</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -63,47 +66,47 @@ else
|
||||
@* Table *@
|
||||
<MudTable Items="@_keys" Hover="true" Striped="true" Elevation="2">
|
||||
<HeaderContent>
|
||||
<MudTh>Préfixe</MudTh>
|
||||
<MudTh>Site</MudTh>
|
||||
<MudTh>Créée le</MudTh>
|
||||
<MudTh>Expire le</MudTh>
|
||||
<MudTh>Statut</MudTh>
|
||||
<MudTh>Dernière utilisation</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["AdminApiKeys_Prefix"]</MudTh>
|
||||
<MudTh>@Text["AdminApiKeys_Site"]</MudTh>
|
||||
<MudTh>@Text["AdminApiKeys_CreatedAt"]</MudTh>
|
||||
<MudTh>@Text["AdminApiKeys_ExpiresAt"]</MudTh>
|
||||
<MudTh>@Text["AdminApiKeys_Status"]</MudTh>
|
||||
<MudTh>@Text["AdminApiKeys_LastUsed"]</MudTh>
|
||||
<MudTh>@Text["AdminApiKeys_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Préfixe">
|
||||
<MudTd DataLabel="@Text["AdminApiKeys_Prefix"]">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Default" Variant="Variant.Outlined">
|
||||
@context.KeyPrefix
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Site">@(context.SiteName ?? "—")</MudTd>
|
||||
<MudTd DataLabel="Créée le">@context.CreatedAt.ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Expire le">@(context.ExpiresAt?.ToString("g") ?? "—")</MudTd>
|
||||
<MudTd DataLabel="Statut">
|
||||
<MudTd DataLabel="@Text["AdminApiKeys_Site"]">@(context.SiteName ?? "—")</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminApiKeys_CreatedAt"]">@context.CreatedAt.ToString("g", Language.Culture)</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminApiKeys_ExpiresAt"]">@(context.ExpiresAt?.ToString("g", Language.Culture) ?? "—")</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminApiKeys_Status"]">
|
||||
@if (context.Enabled)
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Success">Actif</MudChip>
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Success">@Text["AdminApiKeys_Active"]</MudChip>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Error">Révoquée</MudChip>
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Error">@Text["AdminApiKeys_Revoked"]</MudChip>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Dernière utilisation">@(context.LastUsedAt?.ToString("g") ?? "Jamais")</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTd DataLabel="@Text["AdminApiKeys_LastUsed"]">@(context.LastUsedAt?.ToString("g", Language.Culture) ?? Text["AdminApiKeys_Never"])</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminApiKeys_Actions"]">
|
||||
@if (context.Enabled)
|
||||
{
|
||||
<MudTooltip Text="Révoquer cette clé">
|
||||
<MudTooltip Text="@Text["AdminApiKeys_RevokeTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Block" Size="Size.Small" Color="Color.Error"
|
||||
aria-label="Révoquer la clé"
|
||||
aria-label="@Text["AdminApiKeys_RevokeAria"]"
|
||||
OnClick="@(() => OpenRevoke(context))" />
|
||||
</MudTooltip>
|
||||
}
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Align="Align.Center" Class="py-4">Aucune clé API</MudText>
|
||||
<MudText Align="Align.Center" Class="py-4">@Text["AdminApiKeys_Empty"]</MudText>
|
||||
</NoRecordsContent>
|
||||
</MudTable>
|
||||
}
|
||||
@@ -111,20 +114,20 @@ else
|
||||
@* Dialog: Créer une clé *@
|
||||
<MudOverlay Visible="@_showCreate" OnClick="@(() => _showCreate = false)" />
|
||||
<MudDialog @bind-Visible="_showCreate">
|
||||
<TitleContent><MudText Typo="Typo.h6">Créer une clé API</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["AdminApiKeys_CreateTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudText Typo="Typo.body2" Color="Color.Warning" Class="mb-4">
|
||||
<i class="fas fa-exclamation-triangle mr-1"></i>
|
||||
La clé complète ne sera affichée qu'une seule fois. Copiez-la immédiatement.
|
||||
@Text["AdminApiKeys_KeyShownOnce"]
|
||||
</MudText>
|
||||
|
||||
<MudTextField @bind-Value="_createSiteId" Label="Site ID (optionnel — laisser vide pour clé globale)"
|
||||
<MudTextField @bind-Value="_createSiteId" Label="@Text["AdminApiKeys_SiteIdLabel"]"
|
||||
Variant="Variant.Outlined" Class="mb-4" Immediate="true"
|
||||
HelperText="Si spécifié, l'agent ne pourra accéder qu'à ce site." />
|
||||
HelperText="@Text["AdminApiKeys_SiteIdHelp"]" />
|
||||
|
||||
<MudTextField @bind-Value="_createExpiresAt" Label="Date d'expiration (optionnel — YYYY-MM-DD)"
|
||||
<MudTextField @bind-Value="_createExpiresAt" Label="@Text["AdminApiKeys_ExpiryLabel"]"
|
||||
Variant="Variant.Outlined" Class="mb-4" Immediate="true"
|
||||
HelperText="Si vide, la clé n'expirera jamais." />
|
||||
HelperText="@Text["AdminApiKeys_ExpiryHelp"]" />
|
||||
|
||||
@if (!string.IsNullOrEmpty(_createError))
|
||||
{
|
||||
@@ -132,10 +135,10 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">@Text["AdminApiKeys_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@CreateKey" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Créer
|
||||
@Text["AdminApiKeys_Create"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -143,24 +146,24 @@ else
|
||||
@* Dialog: Clé créée — affichage unique *@
|
||||
<MudOverlay Visible="@_showCreated" OnClick="@(() => _showCreated = false)" />
|
||||
<MudDialog @bind-Visible="_showCreated">
|
||||
<TitleContent><MudText Typo="Typo.h6">Clé créée avec succès</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["AdminApiKeys_CreatedTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
||||
<MudText Typo="Typo.body2">
|
||||
<strong>Copiez cette clé maintenant.</strong> Elle ne sera plus jamais affichée.
|
||||
<strong>@Text["AdminApiKeys_CopyNow"]</strong> @Text["AdminApiKeys_NeverShownAgain"]
|
||||
</MudText>
|
||||
</MudAlert>
|
||||
<MudTextField Value="@_createdPlainKey" Label="Clé API" Variant="Variant.Outlined"
|
||||
<MudTextField Value="@_createdPlainKey" Label="@Text["AdminApiKeys_KeyLabel"]" Variant="Variant.Outlined"
|
||||
ReadOnly="true" Adornment="Adornment.End"
|
||||
AdornmentIcon="@Icons.Material.Filled.ContentCopy"
|
||||
OnAdornmentClick="@CopyToClipboard" />
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-2">
|
||||
Préfixe : <strong>@_createdPrefix</strong>
|
||||
@Text["AdminApiKeys_PrefixLabel"] <strong>@_createdPrefix</strong>
|
||||
</MudText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreated = false)">
|
||||
J'ai copié la clé
|
||||
@Text["AdminApiKeys_Copied"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -168,13 +171,13 @@ else
|
||||
@* Dialog: Confirmer la révocation *@
|
||||
<MudOverlay Visible="@_showRevokeConfirm" OnClick="@(() => _showRevokeConfirm = false)" />
|
||||
<MudDialog @bind-Visible="_showRevokeConfirm">
|
||||
<TitleContent><MudText Typo="Typo.h6">Révoquer la clé API</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["AdminApiKeys_RevokeTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudText Typo="Typo.body1" Class="mb-2">
|
||||
Êtes-vous sûr de vouloir révoquer la clé <strong>@_revokeKey?.KeyPrefix</strong> ?
|
||||
@string.Format(Text["AdminApiKeys_RevokePrompt"], _revokeKey?.KeyPrefix)
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Error">
|
||||
Cette action est immédiate et irréversible. L'agent associé ne pourra plus se connecter.
|
||||
@Text["AdminApiKeys_RevokeWarning"]
|
||||
</MudText>
|
||||
@if (!string.IsNullOrEmpty(_revokeError))
|
||||
{
|
||||
@@ -182,10 +185,10 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showRevokeConfirm = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showRevokeConfirm = false)">@Text["AdminApiKeys_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@RevokeKey" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Révoquer
|
||||
@Text["AdminApiKeys_Revoke"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -212,7 +215,11 @@ else
|
||||
private bool _showRevokeConfirm;
|
||||
private string _revokeError = "";
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadKeys();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadKeys();
|
||||
}
|
||||
|
||||
private async Task LoadKeys()
|
||||
{
|
||||
@@ -225,7 +232,7 @@ else
|
||||
catch
|
||||
{
|
||||
_error = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -246,7 +253,7 @@ else
|
||||
{
|
||||
if (!Guid.TryParse(_createSiteId.Trim(), out var parsed))
|
||||
{
|
||||
_createError = "ID de site invalide";
|
||||
_createError = Text["AdminApiKeys_InvalidSiteId"];
|
||||
return;
|
||||
}
|
||||
siteId = parsed;
|
||||
@@ -257,7 +264,7 @@ else
|
||||
{
|
||||
if (!DateTime.TryParse(_createExpiresAt.Trim(), System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out var parsed))
|
||||
{
|
||||
_createError = "Date d'expiration invalide (format : YYYY-MM-DD)";
|
||||
_createError = Text["AdminApiKeys_InvalidExpiry"];
|
||||
return;
|
||||
}
|
||||
expiresAt = parsed;
|
||||
@@ -266,7 +273,7 @@ else
|
||||
var result = await Api.CreateApiKeyAsync(siteId, expiresAt);
|
||||
if (result is null)
|
||||
{
|
||||
_createError = "Erreur lors de la création de la clé";
|
||||
_createError = Text["AdminApiKeys_CreateError"];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -279,12 +286,12 @@ else
|
||||
_createdPrefix = result.KeyPrefix;
|
||||
_showCreated = true;
|
||||
|
||||
Snackbar.Add("Clé API créée avec succès", Severity.Success);
|
||||
Snackbar.Add(Text["AdminApiKeys_CreateSuccess"], Severity.Success);
|
||||
await LoadKeys();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_createError = UiErrors.OperationFailed();
|
||||
_createError = Text["OperationFailed"];
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -295,7 +302,7 @@ else
|
||||
private void CopyToClipboard()
|
||||
{
|
||||
// JS interop would be needed for clipboard — for now, user can select and copy
|
||||
Snackbar.Add("Sélectionnez et copiez la clé avec Ctrl+C", Severity.Info);
|
||||
Snackbar.Add(Text["AdminApiKeys_CopyInstruction"], Severity.Info);
|
||||
}
|
||||
|
||||
// ─── Revoke ───────────────────────────────────────────────────
|
||||
@@ -317,21 +324,23 @@ else
|
||||
var success = await Api.RevokeApiKeyAsync(_revokeKey.Id);
|
||||
if (!success)
|
||||
{
|
||||
_revokeError = "Erreur lors de la révocation";
|
||||
_revokeError = Text["AdminApiKeys_RevokeError"];
|
||||
return;
|
||||
}
|
||||
_showRevokeConfirm = false;
|
||||
_revokeKey = null;
|
||||
Snackbar.Add("Clé API révoquée", Severity.Success);
|
||||
Snackbar.Add(Text["AdminApiKeys_RevokeSuccess"], Severity.Success);
|
||||
await LoadKeys();
|
||||
}
|
||||
catch
|
||||
{
|
||||
_revokeError = UiErrors.OperationFailed();
|
||||
_revokeError = Text["OperationFailed"];
|
||||
}
|
||||
finally
|
||||
{
|
||||
_saving = false;
|
||||
}
|
||||
}
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
@page "/admin/claims"
|
||||
@attribute [Authorize(Policy = "Admin.Manage")]
|
||||
@layout MainLayout
|
||||
@implements IDisposable
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-shield-halved mr-2"></i>
|
||||
Matrice des permissions
|
||||
@Text["AdminClaims_Title"]
|
||||
</MudText>
|
||||
|
||||
@if (_loading)
|
||||
@@ -16,9 +19,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des permissions.</MudText>
|
||||
<MudText>@Text["AdminClaims_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadData" 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["AdminClaims_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -28,23 +31,23 @@ else
|
||||
{
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4" @key="category.Key">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Folder" Size="Size.Small" Class="mr-1" />
|
||||
@category.Key
|
||||
@GetCategoryLabel(category.Key)
|
||||
</MudText>
|
||||
|
||||
<MudTable Items="@category.Value" Dense="true" Hover="true" Striped="true" Elevation="2" Class="mb-4">
|
||||
<HeaderContent>
|
||||
<MudTh>Permission</MudTh>
|
||||
<MudTh>Description</MudTh>
|
||||
<MudTh>@Text["AdminClaims_Permission"]</MudTh>
|
||||
<MudTh>@Text["AdminClaims_Description"]</MudTh>
|
||||
@foreach (var role in _roles)
|
||||
{
|
||||
<MudTh Class="text-center" @key="role.Name">@role.Name</MudTh>
|
||||
}
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Permission">
|
||||
<MudTd DataLabel="@Text["AdminClaims_Permission"]">
|
||||
<MudText Typo="Typo.body2" Class="font-weight-bold">@context.DisplayName</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Description">
|
||||
<MudTd DataLabel="@Text["AdminClaims_Description"]">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@context.Name</MudText>
|
||||
</MudTd>
|
||||
@foreach (var role in _roles)
|
||||
@@ -58,7 +61,7 @@ else
|
||||
}
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Align="Align.Center" Class="py-4">Aucune permission dans cette catégorie</MudText>
|
||||
<MudText Align="Align.Center" Class="py-4">@Text["AdminClaims_EmptyCategory"]</MudText>
|
||||
</NoRecordsContent>
|
||||
</MudTable>
|
||||
}
|
||||
@@ -71,7 +74,13 @@ else
|
||||
private bool _loading = true;
|
||||
private bool _error;
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadData();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadData();
|
||||
}
|
||||
|
||||
private string GetCategoryLabel(string category) => category == "General" ? Text["AdminClaims_General"] : category;
|
||||
|
||||
private async Task LoadData()
|
||||
{
|
||||
@@ -94,8 +103,10 @@ else
|
||||
}
|
||||
catch {
|
||||
_error = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally { _loading = false; }
|
||||
}
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
@@ -1,16 +1,19 @@
|
||||
@page "/admin/groups"
|
||||
@attribute [Authorize(Policy = "Admin.Users")]
|
||||
@layout MainLayout
|
||||
@implements IDisposable
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-user-group mr-2"></i>
|
||||
Groupes
|
||||
@Text["AdminGroups_Title"]
|
||||
</MudText>
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreate = true)" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Nouveau groupe
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["AdminGroups_NewGroup"]
|
||||
</MudButton>
|
||||
|
||||
@if (_loading)
|
||||
@@ -20,9 +23,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des groupes.</MudText>
|
||||
<MudText>@Text["AdminGroups_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadGroups" 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["AdminGroups_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -30,47 +33,47 @@ else
|
||||
{
|
||||
<MudTable Items="@_groups" Hover="true" Striped="true" Elevation="2">
|
||||
<HeaderContent>
|
||||
<MudTh>Nom</MudTh>
|
||||
<MudTh>Description</MudTh>
|
||||
<MudTh>Membres</MudTh>
|
||||
<MudTh>Créé le</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["AdminGroups_Name"]</MudTh>
|
||||
<MudTh>@Text["AdminGroups_Description"]</MudTh>
|
||||
<MudTh>@Text["AdminGroups_Members"]</MudTh>
|
||||
<MudTh>@Text["AdminGroups_CreatedAt"]</MudTh>
|
||||
<MudTh>@Text["AdminGroups_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Nom">@context.Name</MudTd>
|
||||
<MudTd DataLabel="Description">
|
||||
<MudTd DataLabel="@Text["AdminGroups_Name"]">@context.Name</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminGroups_Description"]">
|
||||
@(string.IsNullOrEmpty(context.Description) ? "—" : context.Description)
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Membres">@context.MemberCount</MudTd>
|
||||
<MudTd DataLabel="Créé le">@context.CreatedAt.ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTooltip Text="Modifier ce groupe et gérer ses membres">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" aria-label="Modifier le groupe"
|
||||
<MudTd DataLabel="@Text["AdminGroups_Members"]">@context.MemberCount</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminGroups_CreatedAt"]">@context.CreatedAt.ToString("g", Language.Culture)</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminGroups_Actions"]">
|
||||
<MudTooltip Text="@Text["AdminGroups_EditTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" aria-label="@Text["AdminGroups_EditAria"]"
|
||||
OnClick="@(() => OpenEdit(context))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Supprimer ce groupe">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error" aria-label="Supprimer le groupe"
|
||||
<MudTooltip Text="@Text["AdminGroups_DeleteTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error" aria-label="@Text["AdminGroups_DeleteAria"]"
|
||||
OnClick="@(() => OpenDelete(context))" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Align="Align.Center" Class="py-4">Aucun groupe</MudText>
|
||||
<MudText Align="Align.Center" Class="py-4">@Text["AdminGroups_Empty"]</MudText>
|
||||
</NoRecordsContent>
|
||||
</MudTable>
|
||||
|
||||
@* Pagination *@
|
||||
<MudPaper Class="d-flex align-center pa-4 mt-4">
|
||||
<MudText Typo="Typo.body2" Class="mr-4">
|
||||
Page @_page sur @_totalPages (@_total groupes)
|
||||
@string.Format(Text["AdminGroups_Pagination"], _page, _totalPages, _total)
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Class="mr-2"
|
||||
Disabled="@(_page <= 1)" OnClick="@(() => GoToPage(_page - 1))">
|
||||
← Précédent
|
||||
@Text["AdminGroups_Previous"]
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small"
|
||||
Disabled="@(_page >= _totalPages)" OnClick="@(() => GoToPage(_page + 1))">
|
||||
Suivant →
|
||||
@Text["AdminGroups_Next"]
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -78,12 +81,12 @@ else
|
||||
@* Dialog: Créer un groupe *@
|
||||
<MudOverlay Visible="@_showCreate" OnClick="@(() => _showCreate = false)" />
|
||||
<MudDialog @bind-Visible="_showCreate">
|
||||
<TitleContent><MudText Typo="Typo.h6">Nouveau groupe</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["AdminGroups_NewGroup"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_createName" Label="Nom *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_createName" Label="@Text["AdminGroups_NameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true"
|
||||
Autocomplete="organization" />
|
||||
<MudTextField @bind-Value="_createDescription" Label="Description" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_createDescription" Label="@Text["AdminGroups_Description"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" Lines="3"
|
||||
Autocomplete="off" />
|
||||
@if (!string.IsNullOrEmpty(_createError))
|
||||
@@ -92,10 +95,10 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">@Text["AdminGroups_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@CreateGroup" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Créer
|
||||
@Text["AdminGroups_Create"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -103,32 +106,32 @@ else
|
||||
@* Dialog: Modifier un groupe *@
|
||||
<MudOverlay Visible="@_showEdit" OnClick="@(() => _showEdit = false)" />
|
||||
<MudDialog @bind-Visible="_showEdit">
|
||||
<TitleContent><MudText Typo="Typo.h6">Groupe : @_editGroup!.Name</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@string.Format(Text["AdminGroups_EditTitle"], _editGroup!.Name)</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
@* Section: Informations *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">Informations</MudText>
|
||||
<MudTextField @bind-Value="_editName" Label="Nom *" Variant="Variant.Outlined"
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">@Text["AdminGroups_Information"]</MudText>
|
||||
<MudTextField @bind-Value="_editName" Label="@Text["AdminGroups_NameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true"
|
||||
Autocomplete="organization" />
|
||||
<MudTextField @bind-Value="_editDescription" Label="Description" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_editDescription" Label="@Text["AdminGroups_Description"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" Lines="3"
|
||||
Autocomplete="off" />
|
||||
|
||||
@* Section: Gérer les membres *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">Membres</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">@Text["AdminGroups_Members"]</MudText>
|
||||
<MudPaper Class="pa-4 mb-4" Elevation="0">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-3">
|
||||
@_editGroup!.MemberCount membre(s) dans ce groupe
|
||||
@string.Format(Text["AdminGroups_MemberCount"], _editGroup!.MemberCount)
|
||||
</MudText>
|
||||
|
||||
<MudText Typo="Typo.body2" Class="mb-2">Ajouter un membre</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mb-2">@Text["AdminGroups_AddMember"]</MudText>
|
||||
<div class="d-flex align-center mb-3">
|
||||
<MudTextField @bind-Value="_memberUserId" Label="ID de l'utilisateur" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_memberUserId" Label="@Text["AdminGroups_UserId"]" Variant="Variant.Outlined"
|
||||
Immediate="true" Class="flex-grow-1 mr-2" />
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@AddMember"
|
||||
Disabled="@(DisabledAddMember)">
|
||||
@if (_savingMember) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Ajouter
|
||||
@Text["AdminGroups_Add"]
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@@ -137,13 +140,13 @@ else
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Error" Size="Size.Small"
|
||||
OnClick="@RemoveMember" Disabled="@_savingMember">
|
||||
@if (_savingMember) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Retirer le membre
|
||||
@Text["AdminGroups_RemoveMember"]
|
||||
</MudButton>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
@* Section: Gérer les caméras *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">Caméras accessibles au groupe</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">@Text["AdminGroups_GroupCameras"]</MudText>
|
||||
@if (_loadingGroupCameras)
|
||||
{
|
||||
<MudProgressCircular Indeterminate="true" Class="my-3" />
|
||||
@@ -151,24 +154,24 @@ else
|
||||
else if (_groupCameraError)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-3">
|
||||
Impossible de charger les caméras du groupe.
|
||||
<MudButton Variant="Variant.Text" OnClick="@LoadGroupCameraDataAsync">Réessayer</MudButton>
|
||||
@Text["AdminGroups_CamerasLoadError"]
|
||||
<MudButton Variant="Variant.Text" OnClick="@LoadGroupCameraDataAsync">@Text["AdminGroups_Retry"]</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudPaper Class="pa-4 mb-4" Elevation="0">
|
||||
<MudText Typo="Typo.body2" Class="mb-2">Ajouter une caméra</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mb-2">@Text["AdminGroups_AddCamera"]</MudText>
|
||||
@if (_availableGroupCameras.Count == 0)
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-3">
|
||||
Aucune caméra disponible sur les sites.
|
||||
@Text["AdminGroups_NoAvailableCameras"]
|
||||
</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="d-flex align-center mb-3">
|
||||
<MudSelect T="Guid?" @bind-Value="_selectedGroupCameraId" Label="Caméra" Variant="Variant.Outlined"
|
||||
<MudSelect T="Guid?" @bind-Value="_selectedGroupCameraId" Label="@Text["AdminGroups_Camera"]" Variant="Variant.Outlined"
|
||||
Class="flex-grow-1 mr-2" Disabled="@_savingGroupCamera">
|
||||
@foreach (var camera in _availableGroupCameras)
|
||||
{
|
||||
@@ -180,31 +183,31 @@ else
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@AddCameraToGroup"
|
||||
Disabled="@(_savingGroupCamera || _selectedGroupCameraId is null)">
|
||||
@if (_savingGroupCamera) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Ajouter
|
||||
@Text["AdminGroups_Add"]
|
||||
</MudButton>
|
||||
</div>
|
||||
}
|
||||
|
||||
<MudText Typo="Typo.body2" Class="mb-2 mt-4">Caméras accordées (@_groupCameras.Count)</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mb-2 mt-4">@string.Format(Text["AdminGroups_GrantedCameras"], _groupCameras.Count)</MudText>
|
||||
<MudTable Items="@_groupCameras" Hover="true" Dense="true" Striped="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Site</MudTh>
|
||||
<MudTh>Caméra</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["AdminGroups_Site"]</MudTh>
|
||||
<MudTh>@Text["AdminGroups_Camera"]</MudTh>
|
||||
<MudTh>@Text["AdminGroups_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Site">@GetSiteName(context.SiteId)</MudTd>
|
||||
<MudTd DataLabel="Caméra">@context.Name</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTd DataLabel="@Text["AdminGroups_Site"]">@GetSiteName(context.SiteId)</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminGroups_Camera"]">@context.Name</MudTd>
|
||||
<MudTd DataLabel="@Text["AdminGroups_Actions"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
|
||||
Title="Retirer l'accès caméra du groupe"
|
||||
Title="@Text["AdminGroups_RemoveCameraTitle"]"
|
||||
Disabled="@_savingGroupCamera"
|
||||
OnClick="@(() => RemoveCameraFromGroup(context.Id))" />
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="pa-3">
|
||||
Aucune caméra n'est directement accordée à ce groupe.
|
||||
@Text["AdminGroups_NoGrantedCameras"]
|
||||
</MudText>
|
||||
</NoRecordsContent>
|
||||
</MudTable>
|
||||
@@ -217,10 +220,10 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@CloseEdit">Fermer</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@CloseEdit">@Text["AdminGroups_Close"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveEdit" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Enregistrer
|
||||
@Text["AdminGroups_Save"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -228,13 +231,13 @@ else
|
||||
@* Dialog: Confirmer la suppression *@
|
||||
<MudOverlay Visible="@_showDeleteConfirm" OnClick="@(() => _showDeleteConfirm = false)" />
|
||||
<MudDialog @bind-Visible="_showDeleteConfirm">
|
||||
<TitleContent><MudText Typo="Typo.h6">Supprimer le groupe</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["AdminGroups_DeleteTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudText Typo="Typo.body1" Class="mb-2">
|
||||
Êtes-vous sûr de vouloir supprimer le groupe <strong>@_deleteGroup!.Name</strong> ?
|
||||
@string.Format(Text["AdminGroups_DeletePrompt"], _deleteGroup!.Name)
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Error">
|
||||
Cette action est irréversible. Le groupe sera définitivement supprimé.
|
||||
@Text["AdminGroups_DeleteWarning"]
|
||||
</MudText>
|
||||
@if (!string.IsNullOrEmpty(_deleteError))
|
||||
{
|
||||
@@ -242,10 +245,10 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showDeleteConfirm = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showDeleteConfirm = false)">@Text["AdminGroups_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@DeleteGroup" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Supprimer
|
||||
@Text["AdminGroups_Delete"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -291,7 +294,11 @@ else
|
||||
private bool _showDeleteConfirm;
|
||||
private string _deleteError = "";
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadGroups();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadGroups();
|
||||
}
|
||||
|
||||
private async Task LoadGroups()
|
||||
{
|
||||
@@ -309,7 +316,7 @@ else
|
||||
}
|
||||
catch {
|
||||
_error = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally { _loading = false; }
|
||||
}
|
||||
@@ -325,21 +332,21 @@ else
|
||||
private async Task CreateGroup()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_createName))
|
||||
{ _createError = "Le nom est requis"; return; }
|
||||
{ _createError = Text["AdminGroups_NameRequiredError"]; return; }
|
||||
_saving = true;
|
||||
_createError = "";
|
||||
try
|
||||
{
|
||||
var result = await Api.CreateGroupAsync(_createName,
|
||||
string.IsNullOrWhiteSpace(_createDescription) ? null : _createDescription);
|
||||
if (result is null) { _createError = "Erreur lors de la création"; return; }
|
||||
if (result is null) { _createError = Text["AdminGroups_CreateError"]; return; }
|
||||
_showCreate = false;
|
||||
_createName = "";
|
||||
_createDescription = "";
|
||||
Snackbar.Add("Groupe créé avec succès", Severity.Success);
|
||||
Snackbar.Add(Text["AdminGroups_CreateSuccess"], Severity.Success);
|
||||
await LoadGroups();
|
||||
}
|
||||
catch { _createError = UiErrors.OperationFailed(); }
|
||||
catch { _createError = Text["OperationFailed"]; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
@@ -404,12 +411,12 @@ else
|
||||
catch
|
||||
{
|
||||
_groupCameraError = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally { _loadingGroupCameras = false; }
|
||||
}
|
||||
|
||||
private string GetSiteName(Guid siteId) => _sites.FirstOrDefault(site => site.Id == siteId)?.Name ?? "Site inconnu";
|
||||
private string GetSiteName(Guid siteId) => _sites.FirstOrDefault(site => site.Id == siteId)?.Name ?? Text["AdminGroups_UnknownSite"];
|
||||
|
||||
private void UpdateAvailableGroupCameras()
|
||||
{
|
||||
@@ -426,15 +433,15 @@ else
|
||||
{
|
||||
if (!await Api.AddCameraToGroupAsync(_editGroup.Id, cameraId))
|
||||
{
|
||||
Snackbar.Add("Erreur lors de l'ajout de la caméra au groupe", Severity.Error);
|
||||
Snackbar.Add(Text["AdminGroups_AddCameraError"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
var camera = _availableGroupCameras.FirstOrDefault(item => item.Id == cameraId);
|
||||
if (camera is not null) _groupCameras.Add(camera);
|
||||
UpdateAvailableGroupCameras();
|
||||
Snackbar.Add("Caméra ajoutée au groupe", Severity.Success);
|
||||
Snackbar.Add(Text["AdminGroups_AddCameraSuccess"], Severity.Success);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["OperationFailed"], Severity.Error); }
|
||||
finally { _savingGroupCamera = false; }
|
||||
}
|
||||
|
||||
@@ -446,7 +453,7 @@ else
|
||||
{
|
||||
if (!await Api.RemoveCameraFromGroupAsync(_editGroup.Id, cameraId))
|
||||
{
|
||||
Snackbar.Add("Erreur lors du retrait de la caméra du groupe", Severity.Error);
|
||||
Snackbar.Add(Text["AdminGroups_RemoveCameraError"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
var camera = _groupCameras.FirstOrDefault(item => item.Id == cameraId);
|
||||
@@ -454,9 +461,9 @@ else
|
||||
if (camera is not null) _availableGroupCameras.Add(camera);
|
||||
_availableGroupCameras = _availableGroupCameras.OrderBy(item => GetSiteName(item.SiteId)).ThenBy(item => item.Name).ToList();
|
||||
_selectedGroupCameraId ??= _availableGroupCameras.FirstOrDefault()?.Id;
|
||||
Snackbar.Add("Accès caméra retiré du groupe", Severity.Success);
|
||||
Snackbar.Add(Text["AdminGroups_RemoveCameraSuccess"], Severity.Success);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["OperationFailed"], Severity.Error); }
|
||||
finally { _savingGroupCamera = false; }
|
||||
}
|
||||
|
||||
@@ -475,12 +482,12 @@ else
|
||||
{
|
||||
var success = await Api.UpdateGroupAsync(_editGroup.Id, _editName,
|
||||
string.IsNullOrWhiteSpace(_editDescription) ? null : _editDescription);
|
||||
if (!success) { _editError = "Erreur lors de la mise à jour"; return; }
|
||||
Snackbar.Add("Groupe mis à jour", Severity.Success);
|
||||
if (!success) { _editError = Text["AdminGroups_UpdateError"]; return; }
|
||||
Snackbar.Add(Text["AdminGroups_UpdateSuccess"], Severity.Success);
|
||||
CloseEdit();
|
||||
await LoadGroups();
|
||||
}
|
||||
catch { _editError = UiErrors.OperationFailed(); }
|
||||
catch { _editError = Text["OperationFailed"]; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
@@ -494,7 +501,7 @@ else
|
||||
{
|
||||
if (!Guid.TryParse(_memberUserId.Trim(), out var userId))
|
||||
{
|
||||
Snackbar.Add("ID utilisateur invalide", Severity.Error);
|
||||
Snackbar.Add(Text["AdminGroups_InvalidUserId"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
var success = await Api.AddUserToGroupAsync(_editGroup.Id, userId);
|
||||
@@ -502,14 +509,14 @@ else
|
||||
{
|
||||
_editGroup!.MemberCount++;
|
||||
_memberUserId = "";
|
||||
Snackbar.Add("Membre ajouté au groupe", Severity.Success);
|
||||
Snackbar.Add(Text["AdminGroups_AddMemberSuccess"], Severity.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add("Erreur lors de l'ajout du membre", Severity.Error);
|
||||
Snackbar.Add(Text["AdminGroups_AddMemberError"], Severity.Error);
|
||||
}
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["OperationFailed"], Severity.Error); }
|
||||
finally { _savingMember = false; }
|
||||
}
|
||||
|
||||
@@ -521,7 +528,7 @@ else
|
||||
{
|
||||
if (!Guid.TryParse(_memberUserId.Trim(), out var userId))
|
||||
{
|
||||
Snackbar.Add("ID utilisateur invalide", Severity.Error);
|
||||
Snackbar.Add(Text["AdminGroups_InvalidUserId"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
var success = await Api.RemoveUserFromGroupAsync(_editGroup.Id, userId);
|
||||
@@ -529,14 +536,14 @@ else
|
||||
{
|
||||
_editGroup!.MemberCount = Math.Max(0, _editGroup!.MemberCount - 1);
|
||||
_memberUserId = "";
|
||||
Snackbar.Add("Membre retiré du groupe", Severity.Success);
|
||||
Snackbar.Add(Text["AdminGroups_RemoveMemberSuccess"], Severity.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add("Erreur lors du retrait du membre", Severity.Error);
|
||||
Snackbar.Add(Text["AdminGroups_RemoveMemberError"], Severity.Error);
|
||||
}
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["OperationFailed"], Severity.Error); }
|
||||
finally { _savingMember = false; }
|
||||
}
|
||||
|
||||
@@ -557,13 +564,15 @@ else
|
||||
try
|
||||
{
|
||||
var success = await Api.DeleteGroupAsync(_deleteGroup.Id);
|
||||
if (!success) { _deleteError = "Erreur lors de la suppression"; return; }
|
||||
if (!success) { _deleteError = Text["AdminGroups_DeleteError"]; return; }
|
||||
_showDeleteConfirm = false;
|
||||
_deleteGroup = null;
|
||||
Snackbar.Add("Groupe supprimé avec succès", Severity.Success);
|
||||
Snackbar.Add(Text["AdminGroups_DeleteSuccess"], Severity.Success);
|
||||
await LoadGroups();
|
||||
}
|
||||
catch { _deleteError = UiErrors.OperationFailed(); }
|
||||
catch { _deleteError = Text["OperationFailed"]; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
@page "/admin/roles"
|
||||
@attribute [Authorize(Policy = "Admin.Users")]
|
||||
@layout MainLayout
|
||||
@implements IDisposable
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-user-shield mr-2"></i>
|
||||
Rôles & Permissions
|
||||
@Text["AdminRoles_Title"]
|
||||
</MudText>
|
||||
|
||||
@if (_loading)
|
||||
@@ -16,16 +19,16 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des rôles et permissions.</MudText>
|
||||
<MudText>@Text["AdminRoles_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadRoles" 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["AdminRoles_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
else if (_roles is null || _roles.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
||||
<MudText>Aucun rôle trouvé.</MudText>
|
||||
<MudText>@Text["AdminRoles_Empty"]</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
@@ -43,7 +46,7 @@ else
|
||||
@if (permissionsByCategory.Count == 0)
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
Aucune permission attribuée à ce rôle.
|
||||
@Text["AdminRoles_NoPermissions"]
|
||||
</MudText>
|
||||
}
|
||||
else
|
||||
@@ -55,7 +58,7 @@ else
|
||||
<MudPaper Class="pa-3 h-100" Elevation="0" Style="border: 1px solid var(--mud-palette-lines-default); border-radius: 8px;">
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2 font-weight-bold" Color="@GetCategoryColor(category)">
|
||||
<MudIcon Icon="@GetCategoryIcon(category)" Size="Size.Small" Class="mr-1" />
|
||||
@category
|
||||
@GetCategoryLabel(category)
|
||||
</MudText>
|
||||
<div class="d-flex flex-wrap gap-1">
|
||||
@foreach (var perm in permissions)
|
||||
@@ -80,7 +83,11 @@ else
|
||||
private bool _loading = true;
|
||||
private bool _error;
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadRoles();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadRoles();
|
||||
}
|
||||
|
||||
private async Task LoadRoles()
|
||||
{
|
||||
@@ -92,7 +99,7 @@ else
|
||||
}
|
||||
catch {
|
||||
_error = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -100,6 +107,16 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
private string GetCategoryLabel(string category) => category switch
|
||||
{
|
||||
"Sites" => Text["AdminRoles_Sites"],
|
||||
"Caméras" => Text["AdminRoles_Cameras"],
|
||||
"Événements" => Text["AdminRoles_Events"],
|
||||
"Personnes" => Text["AdminRoles_People"],
|
||||
"Administration" => Text["AdminRoles_Administration"],
|
||||
_ => Text["AdminRoles_Other"]
|
||||
};
|
||||
|
||||
private static Color GetCategoryColor(string category) => category switch
|
||||
{
|
||||
"Sites" => Color.Primary,
|
||||
@@ -156,4 +173,6 @@ else
|
||||
|
||||
return sorted;
|
||||
}
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -4,14 +4,17 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Dns" Class="mr-2" />
|
||||
Agents du site
|
||||
@Text["AgentsPage_Title"]
|
||||
</MudText>
|
||||
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Default" OnClick="@(() => Nav.NavigateTo("/sites"))" Class="mb-4">
|
||||
← Retour aux sites
|
||||
← @Text["AgentsPage_BackToSites"]
|
||||
</MudButton>
|
||||
|
||||
@if (_loading)
|
||||
@@ -21,21 +24,21 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des agents.</MudText>
|
||||
<MudText>@Text["AgentsPage_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadAgents" 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["AgentsPage_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
else if (_agents is null || _agents.Count == 0)
|
||||
{
|
||||
<EmptyState Icon="@Icons.Material.Filled.Dns"
|
||||
Title="Aucun agent enregistré"
|
||||
Description="Utilisez un token d'enregistrement pour connecter un agent à ce site.">
|
||||
Title="@Text["AgentsPage_EmptyTitle"]"
|
||||
Description="@Text["AgentsPage_EmptyDescription"]">
|
||||
<ActionContent>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary"
|
||||
OnClick="@(() => Nav.NavigateTo($"/sites/{SiteId}"))">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Business" Class="mr-1" /> Voir le site
|
||||
<MudIcon Icon="@Icons.Material.Filled.Business" Class="mr-1" /> @Text["AgentsPage_ViewSite"]
|
||||
</MudButton>
|
||||
</ActionContent>
|
||||
</EmptyState>
|
||||
@@ -44,32 +47,32 @@ else
|
||||
{
|
||||
<MudTable Items="@_agents" Hover="true" Striped="true" Elevation="2">
|
||||
<HeaderContent>
|
||||
<MudTh>Nom</MudTh>
|
||||
<MudTh>Hostname</MudTh>
|
||||
<MudTh>Version</MudTh>
|
||||
<MudTh>Statut</MudTh>
|
||||
<MudTh>Dernier heartbeat</MudTh>
|
||||
<MudTh>IP</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["AgentsPage_Name"]</MudTh>
|
||||
<MudTh>@Text["AgentsPage_Hostname"]</MudTh>
|
||||
<MudTh>@Text["AgentsPage_Version"]</MudTh>
|
||||
<MudTh>@Text["AgentsPage_Status"]</MudTh>
|
||||
<MudTh>@Text["AgentsPage_LastHeartbeat"]</MudTh>
|
||||
<MudTh>@Text["AgentsPage_Ip"]</MudTh>
|
||||
<MudTh>@Text["AgentsPage_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Nom">
|
||||
<MudTd DataLabel="@Text["AgentsPage_Name"]">
|
||||
<MudLink Href="@($"/agents/{context.Id}")">@context.Name</MudLink>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Hostname">@context.Hostname</MudTd>
|
||||
<MudTd DataLabel="Version">@context.Version</MudTd>
|
||||
<MudTd DataLabel="Statut">
|
||||
<StatusChip Text="@UiFormat.Status(context.Status)"
|
||||
<MudTd DataLabel="@Text["AgentsPage_Status"]">
|
||||
<StatusChip Text="@GetStatusLabel(context.Status)"
|
||||
Color="@GetStatusColor(context.Status)"
|
||||
Icon="@GetStatusIcon(context.Status)" />
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Dernier heartbeat">
|
||||
@(context.LastHeartbeat?.ToString("g") ?? "Jamais")
|
||||
<MudTd DataLabel="@Text["AgentsPage_LastHeartbeat"]">
|
||||
@(context.LastHeartbeat?.ToString("g", Language.Culture) ?? Text["AgentsPage_Never"])
|
||||
</MudTd>
|
||||
<MudTd DataLabel="IP">@context.PublicIp</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTooltip Text="Voir le détail de l'agent">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Visibility" Size="Size.Small" aria-label="Voir les détails"
|
||||
<MudTd DataLabel="@Text["AgentsPage_Ip"]">@context.PublicIp</MudTd>
|
||||
<MudTd DataLabel="@Text["AgentsPage_Actions"]">
|
||||
<MudTooltip Text="@Text["AgentsPage_ViewDetails"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Visibility" Size="Size.Small" aria-label="@Text["AgentsPage_ViewDetails"]"
|
||||
OnClick="@(() => Nav.NavigateTo($"/agents/{context.Id}"))" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
@@ -94,7 +97,25 @@ else
|
||||
private int _totalPages = 1;
|
||||
private int _total;
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadAgents();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadAgents();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
|
||||
private string GetStatusLabel(string status) => status switch
|
||||
{
|
||||
"Online" => Text["AgentsPage_StatusOnline"],
|
||||
"Offline" => Text["AgentsPage_StatusOffline"],
|
||||
"Disabled" => Text["AgentsPage_StatusDisabled"],
|
||||
"Error" => Text["AgentsPage_StatusError"],
|
||||
"Unknown" => Text["AgentsPage_StatusUnknown"],
|
||||
_ => status
|
||||
};
|
||||
|
||||
private async Task LoadAgents()
|
||||
{
|
||||
|
||||
@@ -4,73 +4,76 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IJSRuntime JS
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-history mr-2"></i>
|
||||
Journal d'audit
|
||||
@Text["AuditLogs_Title"]
|
||||
</MudText>
|
||||
|
||||
<form @onsubmit="ApplyFilters" method="post">
|
||||
<MudPaper Class="pa-4 mb-4" Elevation="1" Style="border-radius: 8px;">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="3">
|
||||
<MudTextField @bind-Value="_filterSearch" Label="Recherche"
|
||||
<MudTextField @bind-Value="_filterSearch" Label="@Text["AuditLogs_Search"]"
|
||||
Variant="Variant.Outlined" Immediate="true" Class="mb-0"
|
||||
Placeholder="Nom, action, ressource..." />
|
||||
Placeholder="@Text["AuditLogs_SearchPlaceholder"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="3">
|
||||
<MudTextField @bind-Value="_filterResourceType" Label="Type de ressource"
|
||||
<MudTextField @bind-Value="_filterResourceType" Label="@Text["AuditLogs_ResourceType"]"
|
||||
Variant="Variant.Outlined" Immediate="true" Class="mb-0"
|
||||
Placeholder="Ex: User, Site, Camera..." />
|
||||
Placeholder="@Text["AuditLogs_ResourceTypePlaceholder"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="3">
|
||||
<MudSelect @bind-Value="_filterAction" Label="Action" Variant="Variant.Outlined"
|
||||
<MudSelect @bind-Value="_filterAction" Label="@Text["AuditLogs_Action"]" Variant="Variant.Outlined"
|
||||
Immediate="true" Class="mb-0" Clearable="true">
|
||||
<MudSelectItem T="string" Value="@null">Toutes les actions</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserCreated")">Création utilisateur</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserRolesUpdated")">Rôles modifiés</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserPasswordReset")">Mot de passe réinitialisé</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserLocked")">Compte verrouillé</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserUnlocked")">Compte déverrouillé</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserDeleted")">Utilisateur supprimé</MudSelectItem>
|
||||
<MudSelectItem Value="@("Site.Created")">Site créé</MudSelectItem>
|
||||
<MudSelectItem Value="@("Site.Updated")">Site modifié</MudSelectItem>
|
||||
<MudSelectItem Value="@("Site.Deleted")">Site supprimé</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.Created")">Caméra créée</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.Updated")">Caméra modifiée</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.Deleted")">Caméra supprimée</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.StatusChanged")">Statut caméra changé</MudSelectItem>
|
||||
<MudSelectItem Value="@("User.Logout")">Déconnexion</MudSelectItem>
|
||||
<MudSelectItem Value="@("Group.Created")">Groupe créé</MudSelectItem>
|
||||
<MudSelectItem Value="@("Group.Updated")">Groupe modifié</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@null">@Text["AuditLogs_AllActions"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserCreated")">@Text["AuditLogs_UserCreated"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserRolesUpdated")">@Text["AuditLogs_UserRolesUpdated"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserPasswordReset")">@Text["AuditLogs_UserPasswordReset"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserLocked")">@Text["AuditLogs_UserLocked"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserUnlocked")">@Text["AuditLogs_UserUnlocked"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("UserDeleted")">@Text["AuditLogs_UserDeleted"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Site.Created")">@Text["AuditLogs_SiteCreated"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Site.Updated")">@Text["AuditLogs_SiteUpdated"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Site.Deleted")">@Text["AuditLogs_SiteDeleted"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.Created")">@Text["AuditLogs_CameraCreated"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.Updated")">@Text["AuditLogs_CameraUpdated"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.Deleted")">@Text["AuditLogs_CameraDeleted"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Camera.StatusChanged")">@Text["AuditLogs_CameraStatusChanged"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("User.Logout")">@Text["AuditLogs_UserLogout"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Group.Created")">@Text["AuditLogs_GroupCreated"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Group.Updated")">@Text["AuditLogs_GroupUpdated"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="1">
|
||||
<MudDatePicker @bind-Date="_filterFromDate" Label="Du" Variant="Variant.Outlined"
|
||||
<MudDatePicker @bind-Date="_filterFromDate" Label="@Text["AuditLogs_From"]" Culture="@Language.Culture" Variant="Variant.Outlined"
|
||||
Class="mb-0" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="1">
|
||||
<MudDatePicker @bind-Date="_filterToDate" Label="Au" Variant="Variant.Outlined"
|
||||
<MudDatePicker @bind-Date="_filterToDate" Label="@Text["AuditLogs_To"]" Culture="@Language.Culture" Variant="Variant.Outlined"
|
||||
Class="mb-0" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="1" Class="d-flex align-center">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" ButtonType="ButtonType.Submit" Class="mr-1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Search" Class="mr-1" Size="Size.Small" />
|
||||
Filtrer
|
||||
@Text["AuditLogs_Filter"]
|
||||
</MudButton>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
<MudGrid Class="mt-1">
|
||||
<MudItem xs="12" Class="d-flex align-center">
|
||||
<MudButton Variant="Variant.Text" OnClick="@ResetFilters">Réinitialiser</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@ResetFilters">@Text["AuditLogs_Reset"]</MudButton>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Secondary" OnClick="@ExportCsv" Class="mr-2"
|
||||
Disabled="@(_logs is null || _logs.Count == 0)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Download" Class="mr-1" Size="Size.Small" />
|
||||
Exporter CSV
|
||||
@Text["AuditLogs_ExportCsv"]
|
||||
</MudButton>
|
||||
<MudTooltip Text="Rafraîchir">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Size="Size.Small" OnClick="@LoadLogs" aria-label="Actualiser les journaux" />
|
||||
<MudTooltip Text="@Text["AuditLogs_Refresh"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Size="Size.Small" OnClick="@LoadLogs" aria-label="@Text["AuditLogs_Refresh"]" />
|
||||
</MudTooltip>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -89,9 +92,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement du journal d'audit.</MudText>
|
||||
<MudText>@Text["AuditLogs_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadLogs" 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["AuditLogs_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -99,32 +102,32 @@ else
|
||||
{
|
||||
<MudTable Items="@_logs" Hover="true" Striped="true" Elevation="2" Dense="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Date</MudTh>
|
||||
<MudTh>Utilisateur</MudTh>
|
||||
<MudTh>Action</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
<MudTh>Ressource</MudTh>
|
||||
<MudTh>Détails</MudTh>
|
||||
<MudTh>IP</MudTh>
|
||||
<MudTh>@Text["AuditLogs_Date"]</MudTh>
|
||||
<MudTh>@Text["AuditLogs_User"]</MudTh>
|
||||
<MudTh>@Text["AuditLogs_Action"]</MudTh>
|
||||
<MudTh>@Text["AuditLogs_Type"]</MudTh>
|
||||
<MudTh>@Text["AuditLogs_Resource"]</MudTh>
|
||||
<MudTh>@Text["AuditLogs_Details"]</MudTh>
|
||||
<MudTh>@Text["AuditLogs_Ip"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Date">
|
||||
<MudTooltip Text="@context.Timestamp.ToString("F")">
|
||||
<MudText Typo="Typo.body2">@context.Timestamp.ToString("g")</MudText>
|
||||
<MudTd DataLabel="@Text["AuditLogs_Date"]">
|
||||
<MudTooltip Text="@context.Timestamp.ToString("F", Language.Culture)">
|
||||
<MudText Typo="Typo.body2">@context.Timestamp.ToString("g", Language.Culture)</MudText>
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Utilisateur">
|
||||
<MudTd DataLabel="@Text["AuditLogs_User"]">
|
||||
<MudText Typo="Typo.body2">@(context.UserEmail ?? "-")</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Action">
|
||||
<MudTd DataLabel="@Text["AuditLogs_Action"]">
|
||||
<MudChip T="string" Size="Size.Small" Color="@GetActionColor(context.Action)">
|
||||
@context.Action
|
||||
@GetActionLabel(context.Action)
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Type">
|
||||
<MudTd DataLabel="@Text["AuditLogs_Type"]">
|
||||
<MudText Typo="Typo.body2">@context.ResourceType</MudText>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Ressource">
|
||||
<MudTd DataLabel="@Text["AuditLogs_Resource"]">
|
||||
@if (!string.IsNullOrEmpty(context.ResourceName))
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@context.ResourceName</MudText>
|
||||
@@ -136,7 +139,7 @@ else
|
||||
</MudText>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Detils">
|
||||
<MudTd DataLabel="@Text["AuditLogs_Details"]">
|
||||
@if (!string.IsNullOrEmpty(context.OldValue) || !string.IsNullOrEmpty(context.NewValue))
|
||||
{
|
||||
<div style="max-width: 320px; overflow: hidden; text-overflow: ellipsis;">
|
||||
@@ -155,16 +158,16 @@ else
|
||||
</div>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="IP">
|
||||
<MudTd DataLabel="@Text["AuditLogs_Ip"]">
|
||||
<MudText Typo="Typo.body2">@(context.IpAddress ?? "-")</MudText>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudPaper Class="pa-8 text-center" Style="border-radius: 12px;">
|
||||
<MudIcon Icon="@Icons.Material.Filled.History" Size="Size.Large" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">Aucune entrée d'audit</MudText>
|
||||
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">@Text["AuditLogs_EmptyTitle"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
Les actions d'administration seront journalisees ici.
|
||||
@Text["AuditLogs_EmptyDescription"]
|
||||
</MudText>
|
||||
</MudPaper>
|
||||
</NoRecordsContent>
|
||||
@@ -172,15 +175,15 @@ else
|
||||
|
||||
<MudPaper Class="d-flex align-center pa-4 mt-4" Style="border-radius: 8px;">
|
||||
<MudText Typo="Typo.body2" Class="mr-4">
|
||||
Page @_page sur @_totalPages (@_total entrees)
|
||||
@string.Format(Language.Culture, Text["AuditLogs_Pagination"], _page, _totalPages, _total)
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Class="mr-2"
|
||||
Disabled="@(_page <= 1)" OnClick="@(() => GoToPage(_page - 1))">
|
||||
← Precedent
|
||||
← @Text["AuditLogs_Previous"]
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small"
|
||||
Disabled="@(_page >= _totalPages)" OnClick="@(() => GoToPage(_page + 1))">
|
||||
Suivant →
|
||||
@Text["AuditLogs_Next"] →
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -198,7 +201,36 @@ else
|
||||
private DateTime? _filterFromDate;
|
||||
private DateTime? _filterToDate;
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadLogs();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadLogs();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
|
||||
private string GetActionLabel(string action) => action switch
|
||||
{
|
||||
"UserCreated" => Text["AuditLogs_UserCreated"],
|
||||
"UserRolesUpdated" => Text["AuditLogs_UserRolesUpdated"],
|
||||
"UserPasswordReset" => Text["AuditLogs_UserPasswordReset"],
|
||||
"UserLocked" => Text["AuditLogs_UserLocked"],
|
||||
"UserUnlocked" => Text["AuditLogs_UserUnlocked"],
|
||||
"UserDeleted" => Text["AuditLogs_UserDeleted"],
|
||||
"Site.Created" => Text["AuditLogs_SiteCreated"],
|
||||
"Site.Updated" => Text["AuditLogs_SiteUpdated"],
|
||||
"Site.Deleted" => Text["AuditLogs_SiteDeleted"],
|
||||
"Camera.Created" => Text["AuditLogs_CameraCreated"],
|
||||
"Camera.Updated" => Text["AuditLogs_CameraUpdated"],
|
||||
"Camera.Deleted" => Text["AuditLogs_CameraDeleted"],
|
||||
"Camera.StatusChanged" => Text["AuditLogs_CameraStatusChanged"],
|
||||
"User.Logout" => Text["AuditLogs_UserLogout"],
|
||||
"Group.Created" => Text["AuditLogs_GroupCreated"],
|
||||
"Group.Updated" => Text["AuditLogs_GroupUpdated"],
|
||||
_ => action
|
||||
};
|
||||
|
||||
private async Task LoadLogs()
|
||||
{
|
||||
@@ -230,14 +262,14 @@ else
|
||||
{
|
||||
if (_logs is null || _logs.Count == 0) return;
|
||||
|
||||
var header = "Date;Utilisateur;Action;Type;Ressource;Nom;Ancien;Nouveau;IP";
|
||||
var header = string.Join(';', Text["AuditLogs_Date"], Text["AuditLogs_User"], Text["AuditLogs_Action"], Text["AuditLogs_Type"], Text["AuditLogs_Resource"], Text["AuditLogs_Name"], Text["AuditLogs_OldValue"], Text["AuditLogs_NewValue"], "IP");
|
||||
var lines = new List<string> { header };
|
||||
foreach (var item in _logs)
|
||||
{
|
||||
var resourceName = item.ResourceName ?? item.ResourceId?[..Math.Min(8, item.ResourceId?.Length ?? 0)] ?? "";
|
||||
var oldVal = EscapeCsv(item.OldValue);
|
||||
var newVal = EscapeCsv(item.NewValue);
|
||||
lines.Add($"{item.Timestamp:yyyy-MM-dd HH:mm:ss};{EscapeCsv(item.UserEmail ?? "-")};{EscapeCsv(item.Action)};{EscapeCsv(item.ResourceType)};{EscapeCsv(item.ResourceId ?? "")};{EscapeCsv(resourceName)};{oldVal};{newVal};{EscapeCsv(item.IpAddress ?? "-")}");
|
||||
lines.Add($"{item.Timestamp.ToString("yyyy-MM-dd HH:mm:ss", Language.Culture)};{EscapeCsv(item.UserEmail ?? "-")};{EscapeCsv(GetActionLabel(item.Action))};{EscapeCsv(item.ResourceType)};{EscapeCsv(item.ResourceId ?? "")};{EscapeCsv(resourceName)};{oldVal};{newVal};{EscapeCsv(item.IpAddress ?? "-")}");
|
||||
}
|
||||
|
||||
var csv = string.Join("\n", lines);
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject IJSRuntime JS
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
@using Heimdall.Web.Services
|
||||
@using Heimdall.Web.Components.Pages
|
||||
@using UserCamAccessResponse = Heimdall.Web.Services.UserCameraAccessResponse
|
||||
@@ -10,8 +13,8 @@
|
||||
{
|
||||
<MudPaper Class="camera-access-panel pa-4 mt-4" Elevation="1">
|
||||
<MudStack Row="true" AlignItems="AlignItems.Center" Justify="Justify.SpaceBetween" Class="mb-2">
|
||||
<MudText Typo="Typo.h6">Gestion des accès caméra : @SelectedUser.DisplayName</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Close" Size="Size.Small" aria-label="Masquer les accès caméra"
|
||||
<MudText Typo="Typo.h6">@Text["CameraAccess_Title"] : @SelectedUser.DisplayName</MudText>
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Close" Size="Size.Small" aria-label="@Text["CameraAccess_Hide"]"
|
||||
OnClick="@CloseCameraAccess" Disabled="@_savingAccess" />
|
||||
</MudStack>
|
||||
<MudDivider Class="mb-3" />
|
||||
@@ -24,8 +27,8 @@
|
||||
else if (_accessError)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4">
|
||||
Erreur lors du chargement des accès caméra.
|
||||
<MudButton Variant="Variant.Text" OnClick="@RetryLoadAccessAsync">Réessayer</MudButton>
|
||||
@Text["CameraAccess_LoadError"]
|
||||
<MudButton Variant="Variant.Text" OnClick="@RetryLoadAccessAsync">@Text["CameraAccess_Retry"]</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
@@ -33,69 +36,69 @@
|
||||
@if (_accessLimitExceeded)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
||||
Cet utilisateur a plus de 500 accès directs. Retirez des accès depuis les lignes ci-dessous; l'ajout et le remplacement complet seront disponibles une fois la liste ramenée à 500.
|
||||
@Text["CameraAccess_OverLimit"]
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
@* Section: Accès site-wide *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">Accès aux sites (toutes caméras)</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">@Text["CameraAccess_SiteWideHeading"]</MudText>
|
||||
<MudTable Items="_siteWideAccess" RowsPerPage="20" Hover="true" Striped="true" Dense="true" Elevation="1">
|
||||
<HeaderContent>
|
||||
<MudTh>Site</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["CameraAccess_Site"]</MudTh>
|
||||
<MudTh>@Text["CameraAccess_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Site">@GetSiteName(context.SiteId)</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTd DataLabel="@Text["CameraAccess_Site"]">@GetSiteName(context.SiteId)</MudTd>
|
||||
<MudTd DataLabel="@Text["CameraAccess_Actions"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
|
||||
Disabled="@(_savingAccess || _revokingAccessIds.Contains(context.Id))"
|
||||
OnClick="@(() => RevokeAccess(context.Id))"
|
||||
Title="Révoquer l'accès site-wide" />
|
||||
Title="@Text["CameraAccess_RevokeSite"]" />
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="p-4">Aucun accès site-wide</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="p-4">@Text["CameraAccess_NoSiteAccess"]</MudText>
|
||||
</NoRecordsContent>
|
||||
<PagerContent><MudTablePager /></PagerContent>
|
||||
</MudTable>
|
||||
|
||||
@* Section: Accès caméra spécifiques *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">Accès aux caméras spécifiques</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">@Text["CameraAccess_CameraHeading"]</MudText>
|
||||
<MudTable Items="_cameraAccess" RowsPerPage="20" Hover="true" Striped="true" Dense="true" Elevation="1">
|
||||
<HeaderContent>
|
||||
<MudTh>Site</MudTh>
|
||||
<MudTh>Caméra</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["CameraAccess_Site"]</MudTh>
|
||||
<MudTh>@Text["CameraAccess_Camera"]</MudTh>
|
||||
<MudTh>@Text["CameraAccess_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Site">@GetSiteName(context.SiteId)</MudTd>
|
||||
<MudTd DataLabel="Caméra">@GetCameraName(context.CameraId!.Value)</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTd DataLabel="@Text["CameraAccess_Site"]">@GetSiteName(context.SiteId)</MudTd>
|
||||
<MudTd DataLabel="@Text["CameraAccess_Camera"]">@GetCameraName(context.CameraId!.Value)</MudTd>
|
||||
<MudTd DataLabel="@Text["CameraAccess_Actions"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
|
||||
Disabled="@(_savingAccess || _revokingAccessIds.Contains(context.Id))"
|
||||
OnClick="@(() => RevokeAccess(context.Id))"
|
||||
Title="Révoquer l'accès caméra" />
|
||||
Title="@Text["CameraAccess_RevokeCamera"]" />
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="p-4">Aucun accès caméra spécifique</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="p-4">@Text["CameraAccess_NoCameraAccess"]</MudText>
|
||||
</NoRecordsContent>
|
||||
<PagerContent><MudTablePager /></PagerContent>
|
||||
</MudTable>
|
||||
|
||||
@* Section: Accorder un nouvel accès *@
|
||||
@* Section: Grant access *@
|
||||
<MudDivider Class="my-4" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">Accorder un nouvel accès</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">@Text["CameraAccess_GrantHeading"]</MudText>
|
||||
|
||||
<MudGrid Class="mb-4">
|
||||
<MudItem xs="12" md="6">
|
||||
<MudSelect @bind-Value="_newAccessType" Label="Type d'accès" Variant="Variant.Outlined" Class="w-100">
|
||||
<MudSelectItem Value="@AccessType.SiteWide">Accès à toutes les caméras d'un site</MudSelectItem>
|
||||
<MudSelectItem Value="@AccessType.CameraSpecific">Accès à une caméra spécifique</MudSelectItem>
|
||||
<MudSelect @bind-Value="_newAccessType" Label="@Text["CameraAccess_Type"]" Variant="Variant.Outlined" Class="w-100">
|
||||
<MudSelectItem Value="@AccessType.SiteWide">@Text["CameraAccess_AllSiteCameras"]</MudSelectItem>
|
||||
<MudSelectItem Value="@AccessType.CameraSpecific">@Text["CameraAccess_SingleCamera"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudSelect @bind-Value="_newAccessSiteId" Label="Site" Variant="Variant.Outlined" Class="w-100">
|
||||
<MudSelect @bind-Value="_newAccessSiteId" Label="@Text["CameraAccess_Site"]" Variant="Variant.Outlined" Class="w-100">
|
||||
@foreach (var site in _availableSites)
|
||||
{
|
||||
<MudSelectItem Value="@site.Id">@site.Name</MudSelectItem>
|
||||
@@ -106,7 +109,7 @@
|
||||
|
||||
@if (_newAccessType == AccessType.CameraSpecific)
|
||||
{
|
||||
<MudSelect @bind-Value="_newAccessCameraId" Label="Caméra" Variant="Variant.Outlined" Class="w-100 mb-4">
|
||||
<MudSelect @bind-Value="_newAccessCameraId" Label="@Text["CameraAccess_Camera"]" Variant="Variant.Outlined" Class="w-100 mb-4">
|
||||
@foreach (var camera in _availableCameras)
|
||||
{
|
||||
<MudSelectItem Value="@camera.Id">@camera.Name (@GetSiteName(camera.SiteId))</MudSelectItem>
|
||||
@@ -121,24 +124,24 @@
|
||||
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary" OnClick="@GrantAccess"
|
||||
Disabled="@(_savingAccess || _accessLimitExceeded)">
|
||||
Ajouter à la liste
|
||||
@Text["CameraAccess_AddToList"]
|
||||
</MudButton>
|
||||
|
||||
@if (HasUnsavedChanges)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Class="mt-4">Les changements ne sont appliqués qu'après l'enregistrement.</MudAlert>
|
||||
<MudAlert Severity="Severity.Info" Class="mt-4">@Text["CameraAccess_UnsavedNotice"]</MudAlert>
|
||||
@if (_draftGrantCount > 500)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mt-2">La limite de 500 accès directs est dépassée. Retirez des accès avant d'enregistrer.</MudAlert>
|
||||
<MudAlert Severity="Severity.Error" Class="mt-2">@Text["CameraAccess_DraftOverLimit"]</MudAlert>
|
||||
}
|
||||
<MudStack Row="true" Spacing="2" Class="mt-3">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveAccessAsync"
|
||||
Disabled="@(_savingAccess || _draftGrantCount > 500)">
|
||||
@if (_savingAccess) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Enregistrer les accès
|
||||
@Text["CameraAccess_Save"]
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@CancelAccessChanges" Disabled="@_savingAccess">
|
||||
Annuler les changements
|
||||
@Text["CameraAccess_CancelChanges"]
|
||||
</MudButton>
|
||||
</MudStack>
|
||||
}
|
||||
@@ -147,6 +150,11 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
protected override void OnInitialized() => Language.LanguageChanged += OnLanguageChanged;
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
[Parameter] public UserItem? SelectedUser { get; set; }
|
||||
[Parameter] public EventCallback OnClose { get; set; }
|
||||
private bool _loadingAccess = true;
|
||||
@@ -211,7 +219,7 @@
|
||||
catch
|
||||
{
|
||||
_accessError = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["CameraAccess_OperationFailed"], Severity.Error);
|
||||
return false;
|
||||
}
|
||||
finally { _loadingAccess = false; }
|
||||
@@ -254,13 +262,13 @@
|
||||
if (_accessLimitExceeded) return;
|
||||
if (SelectedUser == null || _newAccessSiteId == null)
|
||||
{
|
||||
_grantError = "Veuillez sélectionner un site";
|
||||
_grantError = Text["CameraAccess_SelectSite"];
|
||||
return;
|
||||
}
|
||||
|
||||
if (_newAccessType == AccessType.CameraSpecific && _newAccessCameraId == null)
|
||||
{
|
||||
_grantError = "Veuillez sélectionner une caméra";
|
||||
_grantError = Text["CameraAccess_SelectCamera"];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -268,7 +276,7 @@
|
||||
var cameraId = _newAccessType == AccessType.CameraSpecific ? _newAccessCameraId : null;
|
||||
if (CurrentDraftAccess().Any(a => a.SiteId == _newAccessSiteId.Value && a.CameraId == cameraId))
|
||||
{
|
||||
_grantError = "Cet accès figure déjà dans la liste";
|
||||
_grantError = Text["CameraAccess_Duplicate"];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -290,7 +298,7 @@
|
||||
{
|
||||
if (!await Api.DeleteUserCameraAccessAsync(accessId))
|
||||
{
|
||||
Snackbar.Add("Erreur lors de la révocation", Severity.Error);
|
||||
Snackbar.Add(Text["CameraAccess_RevokeError"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -298,11 +306,11 @@
|
||||
_siteWideAccess.RemoveAll(access => access.Id == accessId);
|
||||
_cameraAccess.RemoveAll(access => access.Id == accessId);
|
||||
_accessLimitExceeded = _savedAccess.Count > 500;
|
||||
Snackbar.Add("Accès caméra révoqué", Severity.Success);
|
||||
Snackbar.Add(Text["CameraAccess_Revoked"], Severity.Success);
|
||||
}
|
||||
catch
|
||||
{
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["CameraAccess_OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally { _revokingAccessIds.Remove(accessId); }
|
||||
return;
|
||||
@@ -324,18 +332,18 @@
|
||||
var saved = await Api.ReplaceUserCameraAccessAsync(SelectedUser.Id, grants);
|
||||
if (saved is null)
|
||||
{
|
||||
_grantError = "Erreur lors de l'enregistrement des accès. Vos changements restent disponibles.";
|
||||
_grantError = Text["CameraAccess_SaveError"];
|
||||
return;
|
||||
}
|
||||
|
||||
_savedAccess = saved;
|
||||
_siteWideAccess = saved.Where(access => access.CameraId is null).ToList();
|
||||
_cameraAccess = saved.Where(access => access.CameraId is not null).ToList();
|
||||
Snackbar.Add("Accès caméra enregistrés", Severity.Success);
|
||||
Snackbar.Add(Text["CameraAccess_Saved"], Severity.Success);
|
||||
}
|
||||
catch
|
||||
{
|
||||
_grantError = UiErrors.OperationFailed();
|
||||
_grantError = Text["CameraAccess_OperationFailed"];
|
||||
}
|
||||
finally { _savingAccess = false; }
|
||||
}
|
||||
@@ -359,7 +367,7 @@
|
||||
try
|
||||
{
|
||||
return await JS.InvokeAsync<bool>("confirm",
|
||||
"Abandonner les changements d'accès caméra qui n'ont pas été enregistrés ?");
|
||||
Text["CameraAccess_ConfirmDiscard"]);
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -369,12 +377,12 @@
|
||||
|
||||
private string GetSiteName(Guid siteId)
|
||||
{
|
||||
return _availableSites.FirstOrDefault(s => s.Id == siteId)?.Name ?? "Site inconnu";
|
||||
return _availableSites.FirstOrDefault(s => s.Id == siteId)?.Name ?? Text["CameraAccess_UnknownSite"];
|
||||
}
|
||||
|
||||
private string GetCameraName(Guid cameraId)
|
||||
{
|
||||
return _availableCameras.FirstOrDefault(c => c.Id == cameraId)?.Name ?? "Caméra inconnue";
|
||||
return _availableCameras.FirstOrDefault(c => c.Id == cameraId)?.Name ?? Text["CameraAccess_UnknownCamera"];
|
||||
}
|
||||
|
||||
private async Task CloseCameraAccess()
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-2">
|
||||
<i class="fas fa-camera mr-2"></i>
|
||||
Caméra : @_camera?.Name
|
||||
@Text["CameraDetail_TitlePrefix"] @_camera?.Name
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@if (_camera is not null)
|
||||
@@ -15,7 +18,7 @@
|
||||
<MudBadge Color="@GetStatusColor(_camera.Status)" Variant="Variant.Filled">
|
||||
@GetStatusIcon(_camera.Status) @FormatStatus(_camera.Status)
|
||||
</MudBadge>
|
||||
<span class="ml-2">Créée le @_camera.CreatedAt.ToString("g")</span>
|
||||
<span class="ml-2">@Text["CameraDetail_CreatedAt"] @_camera.CreatedAt.ToString("g", Language.Culture)</span>
|
||||
}
|
||||
</MudText>
|
||||
|
||||
@@ -27,7 +30,7 @@
|
||||
}
|
||||
else if (_camera is null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning">Caméra introuvable</MudAlert>
|
||||
<MudAlert Severity="Severity.Warning">@Text["CameraDetail_NotFound"]</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -40,12 +43,12 @@ else
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_latestSnapshotUrl))
|
||||
{
|
||||
<img src="@_latestSnapshotUrl" alt="Dernière image de @_camera.Name"
|
||||
<img src="@_latestSnapshotUrl" alt="@string.Format(Language.Culture, Text["CameraDetail_LatestImageAlt"], _camera.Name)"
|
||||
style="width:100%; height:100%; object-fit:contain;" />
|
||||
@if (_latestSnapshotAt is DateTime capturedAt)
|
||||
{
|
||||
<span style="position:absolute; top:12px; left:12px; padding:4px 8px; border-radius:4px; background:rgba(0,0,0,0.65); color:white;">
|
||||
Dernière image : @capturedAt.ToLocalTime().ToString("g")
|
||||
@Text["CameraDetail_LatestImage"] @capturedAt.ToLocalTime().ToString("g", Language.Culture)
|
||||
</span>
|
||||
}
|
||||
}
|
||||
@@ -54,21 +57,21 @@ else
|
||||
<div class="d-flex align-center justify-center flex-column" style="height:100%; min-height:240px;">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Videocam" Size="Size.Large" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-2">
|
||||
Aucun flux disponible pour cette caméra
|
||||
@Text["CameraDetail_NoStream"]
|
||||
</MudText>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* Overlay actions live *@
|
||||
<div style="position:absolute; bottom:12px; right:12px;" class="d-flex gap-2">
|
||||
<MudTooltip Text="Prendre un snapshot">
|
||||
<MudTooltip Text="@Text["CameraDetail_TakeSnapshot"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.PhotoCamera" Color="Color.Inherit" Style="background: rgba(0,0,0,0.45);"
|
||||
aria-label="Prendre un snapshot" Disabled="@(_camera.Status != "Online" || _snapshotLoading)"
|
||||
aria-label="@Text["CameraDetail_TakeSnapshot"]" Disabled="@(_camera.Status != "Online" || _snapshotLoading)"
|
||||
OnClick="@TakeSnapshot" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Actualiser le flux">
|
||||
<MudTooltip Text="@Text["CameraDetail_RefreshStream"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Color="Color.Inherit" Style="background: rgba(0,0,0,0.45);"
|
||||
aria-label="Actualiser le flux" OnClick="@RefreshSnapshot" />
|
||||
aria-label="@Text["CameraDetail_RefreshStream"]" OnClick="@RefreshSnapshot" />
|
||||
</MudTooltip>
|
||||
</div>
|
||||
</div>
|
||||
@@ -76,24 +79,24 @@ else
|
||||
|
||||
@* ─── Informations & actions ─── *@
|
||||
<MudPaper Elevation="1" Class="pa-5 mb-6" Style="border-radius: var(--hmd-radius-md);">
|
||||
<MudText Typo="Typo.h6" Class="mb-4">Informations</MudText>
|
||||
<MudText Typo="Typo.h6" Class="mb-4">@Text["CameraDetail_Information"]</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudTextField @bind-Value="_editName" Label="Nom" Variant="Variant.Outlined" Class="mb-4" Immediate="true" />
|
||||
<MudTextField @bind-Value="_editName" Label="@Text["CameraDetail_Name"]" Variant="Variant.Outlined" Class="mb-4" Immediate="true" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudTextField @bind-Value="_editRtspUrl" Label="URL RTSP" Variant="Variant.Outlined" Class="mb-4" Immediate="true"
|
||||
<MudTextField @bind-Value="_editRtspUrl" Label="@Text["CameraDetail_RtspUrl"]" Variant="Variant.Outlined" Class="mb-4" Immediate="true"
|
||||
InputType="@(_showRtsp ? InputType.Text : InputType.Password)"
|
||||
Adornment="Adornment.End"
|
||||
AdornmentIcon="@(_showRtsp ? Icons.Material.Filled.VisibilityOff : Icons.Material.Filled.Visibility)"
|
||||
OnAdornmentClick="@(() => _showRtsp = !_showRtsp)" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Fabricant</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["CameraDetail_Manufacturer"]</MudText>
|
||||
<MudText Typo="Typo.body1">@(_camera.Manufacturer ?? "-")</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Modèle</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["CameraDetail_Model"]</MudText>
|
||||
<MudText Typo="Typo.body1">@(_camera.Model ?? "-")</MudText>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -110,17 +113,17 @@ else
|
||||
<div class="d-flex flex-wrap gap-2 mt-2">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveCamera" Disabled="@_saving">
|
||||
@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["CameraDetail_Save"]
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Color="@(_camera.Status == "Disabled" ? Color.Success : Color.Default)"
|
||||
OnClick="@ToggleCameraStatus" Disabled="@(_saving || _togglingStatus)">
|
||||
@if (_togglingStatus) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
<MudIcon Icon="@(_camera.Status == "Disabled" ? Icons.Material.Filled.PlayArrow : Icons.Material.Filled.Stop)"
|
||||
Class="mr-1" />
|
||||
@(_camera.Status == "Disabled" ? "Activer" : "Désactiver")
|
||||
@(_camera.Status == "Disabled" ? Text["CameraDetail_Enable"] : Text["CameraDetail_Disable"])
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Error" OnClick="@(() => _confirmDeleteShow = true)" aria-label="Supprimer la caméra">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Delete" Class="mr-1" /> Supprimer
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Error" OnClick="@(() => _confirmDeleteShow = true)" aria-label="@Text["CameraDetail_DeleteCamera"]">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Delete" Class="mr-1" /> @Text["CameraDetail_Delete"]
|
||||
</MudButton>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Text" Color="Color.Default" OnClick="@(() => Nav.NavigateTo($"/sites/{_camera.SiteId}/cameras"))">
|
||||
@@ -131,7 +134,7 @@ else
|
||||
|
||||
@* ─── Mini-timeline : événements récents ─── *@
|
||||
<MudText Typo="Typo.h6" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Notifications" Class="mr-1" /> Événements récents
|
||||
<MudIcon Icon="@Icons.Material.Filled.Notifications" Class="mr-1" /> @Text["CameraDetail_RecentEvents"]
|
||||
</MudText>
|
||||
|
||||
@if (_eventsLoading)
|
||||
@@ -144,23 +147,23 @@ else
|
||||
{
|
||||
<MudTable Items="@_events" Hover="true" Elevation="1" Dense="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Horodatage</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
<MudTh>Confiance</MudTh>
|
||||
<MudTh>Label</MudTh>
|
||||
<MudTh>@Text["CameraDetail_Timestamp"]</MudTh>
|
||||
<MudTh>@Text["CameraDetail_Type"]</MudTh>
|
||||
<MudTh>@Text["CameraDetail_Confidence"]</MudTh>
|
||||
<MudTh>@Text["CameraDetail_Label"]</MudTh>
|
||||
<MudTh></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Horodatage">@context.OccurredAt.ToLocalTime().ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Type">
|
||||
<MudTd DataLabel="@Text["CameraDetail_Timestamp"]">@context.OccurredAt.ToLocalTime().ToString("g", Language.Culture)</MudTd>
|
||||
<MudTd DataLabel="@Text["CameraDetail_Type"]">
|
||||
<MudChip T="string" Size="Size.Small" Color="@GetEventColor(context.Type)" Variant="Variant.Outlined">
|
||||
@FormatEventType(context.Type)
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Confiance">@($"{(context.Confidence * 100):0}%")</MudTd>
|
||||
<MudTd DataLabel="Label">@context.Label</MudTd>
|
||||
<MudTd DataLabel="@Text["CameraDetail_Confidence"]">@((context.Confidence * 100).ToString("0", Language.Culture) + "%")</MudTd>
|
||||
<MudTd DataLabel="@Text["CameraDetail_Label"]">@context.Label</MudTd>
|
||||
<MudTd DataLabel="">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Image" Size="Size.Small" aria-label="Voir le snapshot"
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Image" Size="Size.Small" aria-label="@Text["CameraDetail_ViewSnapshot"]"
|
||||
Disabled="@(context.SnapshotUrl is null)"
|
||||
OnClick="@(() => { _showSnapshotUrl = context.SnapshotUrl; _showSnapshotDialog = true; })" />
|
||||
</MudTd>
|
||||
@@ -172,19 +175,19 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Class="mt-2" Typo="Typo.body2" Color="Color.Default">Aucun événement récent.</MudText>
|
||||
<MudText Class="mt-2" Typo="Typo.body2" Color="Color.Default">@Text["CameraDetail_NoRecentEvents"]</MudText>
|
||||
}
|
||||
|
||||
@* ─── Dialogs (toujours rendus, visibilité via @bind-Visible) ─── *@
|
||||
<MudOverlay Visible="@_confirmDeleteShow" OnClick="@(() => _confirmDeleteShow = false)" />
|
||||
<MudDialog @bind-Visible="_confirmDeleteShow">
|
||||
<TitleContent><MudText Typo="Typo.h6">Confirmer la suppression</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["CameraDetail_ConfirmDeleteTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudText>Supprimer la caméra "@_camera.Name" ? Cette action est irréversible.</MudText>
|
||||
<MudText>@string.Format(Language.Culture, Text["CameraDetail_ConfirmDeleteBody"], _camera.Name)</MudText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@DeleteCamera">Supprimer</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">@Text["CameraDetail_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@DeleteCamera">@Text["CameraDetail_Delete"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@@ -192,11 +195,11 @@ else
|
||||
<DialogContent>
|
||||
@if (_showSnapshotUrl is not null)
|
||||
{
|
||||
<img src="@_showSnapshotUrl" alt="Snapshot" style="width:100%;height:auto;" class="rounded-lg" />
|
||||
<img src="@_showSnapshotUrl" alt="@Text["CameraDetail_SnapshotAlt"]" style="width:100%;height:auto;" class="rounded-lg" />
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="@(() => _showSnapshotDialog = false)">Fermer</MudButton>
|
||||
<MudButton OnClick="@(() => _showSnapshotDialog = false)">@Text["CameraDetail_Close"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
}
|
||||
@@ -234,6 +237,7 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
try
|
||||
{
|
||||
_camera = await Api.GetCameraAsync(Id);
|
||||
@@ -243,13 +247,15 @@ else
|
||||
_editRtspUrl = _camera.RtspUrl;
|
||||
}
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["CameraDetail_OperationFailed"], Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
|
||||
await LoadEventsAsync();
|
||||
await LoadLatestSnapshotAsync();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
// L'auto-refresh démarre après le premier rendu : une boucle infinie
|
||||
// awaitée dans OnInitializedAsync bloque le rendu initial (SSR/prerender
|
||||
// attend la fin du cycle de vie) → page lente.
|
||||
@@ -313,18 +319,18 @@ else
|
||||
var request = await Api.RequestCameraSnapshotAsync(Id);
|
||||
if (!request.Succeeded || request.Data == Guid.Empty)
|
||||
{
|
||||
Snackbar.Add(request.ErrorMessage ?? UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(request.ErrorMessage ?? Text["CameraDetail_OperationFailed"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
Snackbar.Add("Capture demandée à l'agent", Severity.Info);
|
||||
Snackbar.Add(Text["CameraDetail_CaptureRequested"], Severity.Info);
|
||||
for (var attempt = 0; attempt < 35 && !_disposed; attempt++)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
var status = await Api.GetCameraSnapshotStatusAsync(Id, request.Data);
|
||||
if (status?.Status is "Failed" or "TimedOut")
|
||||
{
|
||||
Snackbar.Add(status.Reason ?? "La capture a échoué.", Severity.Error);
|
||||
Snackbar.Add(status.Reason ?? Text["CameraDetail_CaptureFailed"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
if (status?.Status != "Completed") continue;
|
||||
@@ -333,12 +339,12 @@ else
|
||||
_latestSnapshotUrl = snapshot.SnapshotThumbUrl ?? snapshot.SnapshotUrl;
|
||||
_latestSnapshotAt = snapshot.OccurredAt;
|
||||
await LoadEventsAsync();
|
||||
Snackbar.Add("Snapshot disponible", Severity.Success);
|
||||
Snackbar.Add(Text["CameraDetail_SnapshotAvailable"], Severity.Success);
|
||||
return;
|
||||
}
|
||||
Snackbar.Add("Le résultat de la capture est encore en attente ; actualisez la page pour le consulter.", Severity.Info);
|
||||
Snackbar.Add(Text["CameraDetail_CapturePending"], Severity.Info);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["CameraDetail_OperationFailed"], Severity.Error); }
|
||||
finally
|
||||
{
|
||||
_snapshotLoading = false;
|
||||
@@ -348,7 +354,7 @@ else
|
||||
|
||||
private async Task SaveCamera()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_editName)) { _editError = "Le nom est requis"; return; }
|
||||
if (string.IsNullOrWhiteSpace(_editName)) { _editError = Text["CameraDetail_NameRequired"]; return; }
|
||||
_saving = true;
|
||||
_editError = "";
|
||||
_editSuccess = "";
|
||||
@@ -356,12 +362,12 @@ else
|
||||
{
|
||||
if (await Api.UpdateCameraAsync(Id, _editName, _editRtspUrl, null))
|
||||
{
|
||||
_editSuccess = "Caméra mise à jour";
|
||||
_editSuccess = Text["CameraDetail_Updated"];
|
||||
if (_camera is not null) _camera.Name = _editName;
|
||||
}
|
||||
else _editError = "Erreur lors de la mise à jour";
|
||||
else _editError = Text["CameraDetail_UpdateError"];
|
||||
}
|
||||
catch { _editError = UiErrors.OperationFailed(); }
|
||||
catch { _editError = Text["CameraDetail_OperationFailed"]; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
@@ -377,11 +383,11 @@ else
|
||||
if (result.Succeeded && result.Data is not null)
|
||||
{
|
||||
_camera.Status = result.Data.Status;
|
||||
Snackbar.Add(result.Data.Status == "Online" ? "Caméra activée" : "Caméra désactivée", Severity.Success);
|
||||
Snackbar.Add(result.Data.Status == "Online" ? Text["CameraDetail_Enabled"] : Text["CameraDetail_Disabled"], Severity.Success);
|
||||
}
|
||||
else _editError = result.ErrorMessage ?? "Erreur lors de la mise à jour du statut";
|
||||
else _editError = result.ErrorMessage ?? Text["CameraDetail_StatusError"];
|
||||
}
|
||||
catch { _editError = UiErrors.OperationFailed(); }
|
||||
catch { _editError = Text["CameraDetail_OperationFailed"]; }
|
||||
finally
|
||||
{
|
||||
_saving = false;
|
||||
@@ -394,10 +400,10 @@ else
|
||||
if (_camera is null) return;
|
||||
if (await Api.DeleteCameraAsync(Id))
|
||||
{
|
||||
Snackbar.Add($"Caméra \"{_camera.Name}\" supprimée", Severity.Success);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["CameraDetail_Deleted"], _camera.Name), Severity.Success);
|
||||
Nav.NavigateTo($"/sites/{_camera.SiteId}/cameras");
|
||||
}
|
||||
else Snackbar.Add("Erreur lors de la suppression", Severity.Error);
|
||||
else Snackbar.Add(Text["CameraDetail_DeleteError"], Severity.Error);
|
||||
}
|
||||
|
||||
private static Color GetStatusColor(string status) => status switch
|
||||
@@ -415,22 +421,22 @@ else
|
||||
_ => "?"
|
||||
};
|
||||
|
||||
private static string FormatStatus(string status) => status switch
|
||||
private string FormatStatus(string status) => status switch
|
||||
{
|
||||
"Online" => "En ligne",
|
||||
"Offline" => "Hors ligne",
|
||||
"Disabled" => "Désactivée",
|
||||
"Online" => Text["CameraDetail_StatusOnline"],
|
||||
"Offline" => Text["CameraDetail_StatusOffline"],
|
||||
"Disabled" => Text["CameraDetail_StatusDisabled"],
|
||||
_ => status
|
||||
};
|
||||
|
||||
private static string FormatEventType(string type) => type switch
|
||||
private string FormatEventType(string type) => type switch
|
||||
{
|
||||
"ManualSnapshot" => "Capture manuelle",
|
||||
"MotionDetected" => "Mouvement",
|
||||
"PersonDetected" => "Personne",
|
||||
"VehicleDetected" => "Véhicule",
|
||||
"FaceRecognized" => "Visage",
|
||||
"CameraOffline" => "Hors ligne",
|
||||
"ManualSnapshot" => Text["CameraDetail_EventManualSnapshot"],
|
||||
"MotionDetected" => Text["CameraDetail_EventMotion"],
|
||||
"PersonDetected" => Text["CameraDetail_EventPerson"],
|
||||
"VehicleDetected" => Text["CameraDetail_EventVehicle"],
|
||||
"FaceRecognized" => Text["CameraDetail_EventFace"],
|
||||
"CameraOffline" => Text["CameraDetail_StatusOffline"],
|
||||
_ => type
|
||||
};
|
||||
|
||||
@@ -445,6 +451,7 @@ else
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Language.LanguageChanged -= OnLanguageChanged;
|
||||
_disposed = true;
|
||||
_refreshCts?.Cancel();
|
||||
_refreshCts?.Dispose();
|
||||
|
||||
@@ -4,16 +4,19 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-2">
|
||||
<i class="fas fa-video mr-2"></i>
|
||||
Caméras du site
|
||||
@Text["CamerasPage_Title"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@if (_cameras is not null)
|
||||
{
|
||||
@($"{_cameras.Count} caméra(s)") <span class="mx-1">·</span>
|
||||
@($"{_cameras.Count(c => c.Status == "Online")} en ligne")
|
||||
@string.Format(Language.Culture, Text["CamerasPage_CameraCount"], _cameras.Count) <span class="mx-1">·</span>
|
||||
@string.Format(Language.Culture, Text["CamerasPage_OnlineCount"], _cameras.Count(c => c.Status == "Online"))
|
||||
}
|
||||
</MudText>
|
||||
|
||||
@@ -21,19 +24,19 @@
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Default" OnClick="@(() => Nav.NavigateTo("/sites"))" Class="mr-2">
|
||||
← Retour aux sites
|
||||
</MudButton>
|
||||
<MudTooltip Text="Actualiser">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Color="Color.Inherit" aria-label="Actualiser"
|
||||
<MudTooltip Text="@Text["CamerasPage_Refresh"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Color="Color.Inherit" aria-label="@Text["CamerasPage_Refresh"]"
|
||||
OnClick="@RefreshCurrentTab" />
|
||||
</MudTooltip>
|
||||
</div>
|
||||
|
||||
<MudTabs Elevation="0" Rounded="true" ApplyEffectsToContainer="true" PanelClass="pa-0" @bind-ActiveIndex="_activeTab">
|
||||
@* ─── Onglet 1 : Caméras ──────────────────────────────────── *@
|
||||
<MudTabPanel Text="Caméras" Icon="@Icons.Material.Filled.Videocam">
|
||||
<MudTabPanel Text="@Text["CamerasPage_CamerasTab"]" Icon="@Icons.Material.Filled.Videocam">
|
||||
<div class="pa-4">
|
||||
<div class="d-flex align-center mb-4">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreate = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Ajouter une caméra
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["CamerasPage_AddCamera"]
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@@ -57,9 +60,9 @@
|
||||
else if (_camerasError)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Class="mt-4">
|
||||
<MudText>Impossible de charger les caméras. Vérifiez votre connexion puis réessayez.</MudText>
|
||||
<MudText>@Text["CamerasPage_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@(() => LoadCameras(silent: false))" 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["CamerasPage_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -67,12 +70,12 @@
|
||||
{
|
||||
<MudPaper Elevation="0" Class="pa-8 text-center" Style="border-radius: var(--hmd-radius-lg); border: 1px dashed var(--mud-palette-lines-default);">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Videocam" Size="Size.Large" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">Aucune caméra configurée</MudText>
|
||||
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">@Text["CamerasPage_NoCameras"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
Ajoutez une caméra ou lancez un scan réseau pour en détecter.
|
||||
@Text["CamerasPage_NoCamerasHelp"]
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreate = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Ajouter une caméra
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["CamerasPage_AddCamera"]
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -99,19 +102,19 @@
|
||||
</MudTabPanel>
|
||||
|
||||
@* ─── Onglet 2 : Découverte ────────────────────────────────── *@
|
||||
<MudTabPanel Text="Découverte" Icon="@Icons.Material.Filled.Radar">
|
||||
<MudTabPanel Text="@Text["CamerasPage_DiscoveryTab"]" Icon="@Icons.Material.Filled.Radar">
|
||||
<div class="pa-4">
|
||||
<div class="d-flex align-center mb-4">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@ScanNow" Disabled="@_scanning">
|
||||
@if (_scanning) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
<MudIcon Icon="@Icons.Material.Filled.Radar" Class="mr-1" /> Scanner maintenant
|
||||
<MudIcon Icon="@Icons.Material.Filled.Radar" Class="mr-1" /> @Text["CamerasPage_ScanNow"]
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@if (_scanning)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Class="mb-4">
|
||||
Scan demandé aux agents du site. Les résultats arrivent dans quelques instants…
|
||||
@Text["CamerasPage_ScanPending"]
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
@@ -123,10 +126,9 @@
|
||||
{
|
||||
<MudPaper Elevation="2" Class="pa-6 text-center" Style="border-radius: 12px;">
|
||||
<MudIcon Icon="@Icons.Material.Filled.VideocamOff" Size="Size.Large" Color="Color.Default" />
|
||||
<MudText Typo="Typo.h6" Class="mt-2">Aucune caméra détectée</MudText>
|
||||
<MudText Typo="Typo.h6" Class="mt-2">@Text["CamerasPage_NoDiscoveries"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
Lancez un scan avec « Scanner maintenant » (les agents doivent être en ligne),
|
||||
ou vérifiez que des identifiants caméras sont déclarés sur le site.
|
||||
@Text["CamerasPage_NoDiscoveriesHelp"]
|
||||
</MudText>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -134,25 +136,25 @@
|
||||
{
|
||||
<MudTable Items="@_discoveries" Hover="true" Striped="true" Elevation="2">
|
||||
<HeaderContent>
|
||||
<MudTh>Adresse IP</MudTh>
|
||||
<MudTh>Marque / Modèle</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
<MudTh>Ports</MudTh>
|
||||
<MudTh>Détecté le</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["CamerasPage_IpAddress"]</MudTh>
|
||||
<MudTh>@Text["CamerasPage_VendorModel"]</MudTh>
|
||||
<MudTh>@Text["CamerasPage_Type"]</MudTh>
|
||||
<MudTh>@Text["CamerasPage_Ports"]</MudTh>
|
||||
<MudTh>@Text["CamerasPage_DetectedAt"]</MudTh>
|
||||
<MudTh>@Text["CamerasPage_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="IP">
|
||||
<MudTd DataLabel="@Text["CamerasPage_IpAddress"]">
|
||||
<strong>@context.IpAddress</strong>
|
||||
@if (!string.IsNullOrEmpty(context.MacAddress))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@context.MacAddress</MudText>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Marque">
|
||||
<MudTd DataLabel="@Text["CamerasPage_VendorModel"]">
|
||||
@if (!string.IsNullOrEmpty(context.Vendor) || !string.IsNullOrEmpty(context.OnvifHardware))
|
||||
{
|
||||
<MudText Typo="Typo.body2">@(context.Vendor ?? "Inconnu")</MudText>
|
||||
<MudText Typo="Typo.body2">@(context.Vendor ?? Text["CamerasPage_Unknown"])</MudText>
|
||||
@if (!string.IsNullOrEmpty(context.OnvifHardware))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@context.OnvifHardware</MudText>
|
||||
@@ -164,14 +166,14 @@
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Inconnue</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["CamerasPage_Unknown"]</MudText>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Type">
|
||||
<MudTd DataLabel="@Text["CamerasPage_Type"]">
|
||||
<StatusChip Text="@FormatType(context.DetectedType)" Color="@TypeColor(context.DetectedType)"
|
||||
Icon="@Icons.Material.Filled.Videocam" />
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Ports">
|
||||
<MudTd DataLabel="@Text["CamerasPage_Ports"]">
|
||||
@if (context.OpenPorts.Length == 0) { <MudText Typo="Typo.body2">-</MudText> }
|
||||
else
|
||||
{
|
||||
@@ -183,16 +185,16 @@
|
||||
</div>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Détecté le">@context.ProbedAt.ToLocalTime().ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTooltip Text="Ajouter cette caméra">
|
||||
<MudTd DataLabel="@Text["CamerasPage_DetectedAt"]">@context.ProbedAt.ToLocalTime().ToString("g", Language.Culture)</MudTd>
|
||||
<MudTd DataLabel="@Text["CamerasPage_Actions"]">
|
||||
<MudTooltip Text="@Text["CamerasPage_AddDiscoveredTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.AddCircle" Color="Color.Success"
|
||||
aria-label="Confirmer la caméra"
|
||||
aria-label="@Text["CamerasPage_ConfirmCamera"]"
|
||||
OnClick="@(() => OpenConfirm(context))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Ignorer cette détection">
|
||||
<MudTooltip Text="@Text["CamerasPage_IgnoreTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Cancel" Color="Color.Default"
|
||||
aria-label="Ignorer la détection"
|
||||
aria-label="@Text["CamerasPage_IgnoreDiscovery"]"
|
||||
OnClick="@(() => Reject(context))" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
@@ -203,17 +205,15 @@
|
||||
</MudTabPanel>
|
||||
|
||||
@* ─── Onglet 3 : Identifiants ──────────────────────────────── *@
|
||||
<MudTabPanel Text="Identifiants" Icon="@Icons.Material.Filled.Lock">
|
||||
<MudTabPanel Text="@Text["CamerasPage_CredentialsTab"]" Icon="@Icons.Material.Filled.Lock">
|
||||
<div class="pa-4">
|
||||
<div class="d-flex justify-space-between align-center mb-4">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
Déclarez les couples login/mot de passe possibles des caméras de ce site.
|
||||
Les agents les utilisent pour authentifier et identifier automatiquement
|
||||
chaque caméra détectée sur le réseau.
|
||||
@Text["CamerasPage_CredentialsDescription"]
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
OnClick="@(() => _showCredentialDialog = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Ajouter
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["CamerasPage_Add"]
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@@ -224,29 +224,28 @@
|
||||
else if (_credentials.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||
Aucun identifiant déclaré. La détection fonctionnera, mais les caméras
|
||||
protégées ne seront pas identifiées automatiquement.
|
||||
@Text["CamerasPage_NoCredentials"]
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTable Items="@_credentials" Hover="true" Dense="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Libellé</MudTh>
|
||||
<MudTh>Utilisateur</MudTh>
|
||||
<MudTh>Dernière utilisation</MudTh>
|
||||
<MudTh>@Text["CamerasPage_Label"]</MudTh>
|
||||
<MudTh>@Text["CamerasPage_Username"]</MudTh>
|
||||
<MudTh>@Text["CamerasPage_LastUsed"]</MudTh>
|
||||
<MudTh></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Libellé">@context.Label</MudTd>
|
||||
<MudTd DataLabel="Utilisateur"><code>@context.Username</code></MudTd>
|
||||
<MudTd DataLabel="Dernière utilisation">
|
||||
@(context.LastUsedAt?.ToString("g") ?? "jamais")
|
||||
<MudTd DataLabel="@Text["CamerasPage_Label"]">@context.Label</MudTd>
|
||||
<MudTd DataLabel="@Text["CamerasPage_Username"]"><code>@context.Username</code></MudTd>
|
||||
<MudTd DataLabel="@Text["CamerasPage_LastUsed"]">
|
||||
@(context.LastUsedAt?.ToString("g", Language.Culture) ?? Text["CamerasPage_Never"])
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTooltip Text="Supprimer cet identifiant">
|
||||
<MudTd DataLabel="@Text["CamerasPage_Actions"]">
|
||||
<MudTooltip Text="@Text["CamerasPage_DeleteCredentialTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small"
|
||||
Color="Color.Error" aria-label="Supprimer l'identifiant"
|
||||
Color="Color.Error" aria-label="@Text["CamerasPage_DeleteCredential"]"
|
||||
OnClick="@(() => DeleteCredential(context))" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
@@ -260,37 +259,37 @@
|
||||
@* ─── Confirm delete dialog ───────────────────────────────── *@
|
||||
<MudOverlay Visible="@_confirmDeleteShow" OnClick="@(() => _confirmDeleteShow = false)" />
|
||||
<MudDialog @bind-Visible="_confirmDeleteShow">
|
||||
<TitleContent><MudText Typo="Typo.h6">Confirmer la suppression</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["CamerasPage_ConfirmDeleteTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudText>Supprimer la caméra "@_confirmDeleteName" ? Cette action est irréversible.</MudText>
|
||||
<MudText>@string.Format(Language.Culture, Text["CamerasPage_ConfirmDeleteBody"], _confirmDeleteName)</MudText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@ExecuteDeleteCamera">Supprimer</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">@Text["CamerasPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@ExecuteDeleteCamera">@Text["CamerasPage_Delete"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@* ─── Create camera dialog ──────────────────────────────────── *@
|
||||
<MudOverlay Visible="@_showCreate" OnClick="@(() => _showCreate = false)" />
|
||||
<MudDialog @bind-Visible="_showCreate">
|
||||
<TitleContent><MudText Typo="Typo.h6">Ajouter une caméra</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["CamerasPage_AddCamera"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_newName" Label="Nom *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_newName" Label="@Text["CamerasPage_NameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true" />
|
||||
<MudTextField @bind-Value="_newManufacturer" Label="Fabricant" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<MudTextField @bind-Value="_newModel" Label="Modèle" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<MudTextField @bind-Value="_newRtspUrl" Label="URL RTSP" Variant="Variant.Outlined" Class="mb-4"
|
||||
HelperText="Ex: rtsp://192.168.1.100:554/stream1" />
|
||||
<MudTextField @bind-Value="_newManufacturer" Label="@Text["CamerasPage_Manufacturer"]" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<MudTextField @bind-Value="_newModel" Label="@Text["CamerasPage_Model"]" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<MudTextField @bind-Value="_newRtspUrl" Label="@Text["CamerasPage_RtspUrl"]" Variant="Variant.Outlined" Class="mb-4"
|
||||
HelperText="@Text["CamerasPage_RtspHint"]" />
|
||||
@if (!string.IsNullOrEmpty(_dialogError))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4">@_dialogError</MudAlert>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">@Text["CamerasPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@CreateCamera" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Ajouter
|
||||
@Text["CamerasPage_Add"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -299,12 +298,12 @@
|
||||
<MudOverlay Visible="@_confirmShow" OnClick="@(() => _confirmShow = false)" />
|
||||
<MudDialog @bind-Visible="_confirmShow" Options="new DialogOptions { MaxWidth = MaxWidth.Medium, FullWidth = true }">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Ajouter la caméra @_confirm?.IpAddress</MudText>
|
||||
<MudText Typo="Typo.h6">@string.Format(Language.Culture, Text["CamerasPage_ConfirmTitle"], _confirm?.IpAddress)</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@if (_confirm is not null)
|
||||
{
|
||||
<MudTextField @bind-Value="_confirmName" Label="Nom de la caméra *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_confirmName" Label="@Text["CamerasPage_CameraNameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" />
|
||||
|
||||
@if (!string.IsNullOrEmpty(_selectedStreamUrl))
|
||||
@@ -312,7 +311,7 @@
|
||||
<MudAlert Severity="Severity.Success" Variant="Variant.Outlined" Class="mb-4">
|
||||
<MudText Typo="Typo.body2" Class="mb-1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.CheckCircle" Class="mr-1" Size="Size.Small" />
|
||||
Flux principal détecté automatiquement
|
||||
@Text["CamerasPage_MainStreamDetected"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2"><code>@_selectedStreamUrl</code></MudText>
|
||||
</MudAlert>
|
||||
@@ -320,12 +319,12 @@
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
||||
Aucun flux n'a pu être détecté pour cette caméra (hors ligne ou protégée ?).
|
||||
@Text["CamerasPage_NoStreamDetected"]
|
||||
</MudAlert>
|
||||
}
|
||||
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mb-4">
|
||||
@(_confirm.Vendor ?? "Marque inconnue")
|
||||
@(_confirm.Vendor ?? Text["CamerasPage_UnknownVendor"])
|
||||
@if (!string.IsNullOrEmpty(_confirm.OnvifHardware)) { <text>· @_confirm.OnvifHardware</text> }
|
||||
@if (!string.IsNullOrEmpty(_confirm.MacAddress)) { <text>· @_confirm.MacAddress</text> }
|
||||
</MudText>
|
||||
@@ -333,10 +332,10 @@
|
||||
@if (_confirm.HasScreenshot)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mb-1">
|
||||
Aperçu du flux (capturé par l'agent)
|
||||
@Text["CamerasPage_StreamPreview"]
|
||||
</MudText>
|
||||
<div class="mb-4" style="border: 1px solid var(--mud-palette-lines-default); border-radius: 8px; overflow: hidden;">
|
||||
<img src="/api/discovery/results/@_confirm.Id/screenshot" alt="Aperçu du flux"
|
||||
<img src="/api/discovery/results/@_confirm.Id/screenshot" alt="@Text["CamerasPage_StreamPreviewAlt"]"
|
||||
style="width: 100%; display: block;" />
|
||||
</div>
|
||||
}
|
||||
@@ -348,11 +347,11 @@
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmShow = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmShow = false)">@Text["CamerasPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Success" OnClick="@ConfirmCamera"
|
||||
Disabled="@(_confirming || string.IsNullOrWhiteSpace(_confirmName) || string.IsNullOrEmpty(_selectedStreamUrl))">
|
||||
@if (_confirming) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Ajouter la caméra
|
||||
@Text["CamerasPage_AddCamera"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -360,14 +359,14 @@
|
||||
@* ─── Add credential dialog ──────────────────────────────────── *@
|
||||
<MudOverlay Visible="@_showCredentialDialog" OnClick="@(() => _showCredentialDialog = false)" />
|
||||
<MudDialog @bind-Visible="_showCredentialDialog">
|
||||
<TitleContent><MudText Typo="Typo.h6">Ajouter un identifiant caméra</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["CamerasPage_AddCredentialTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_newCredLabel" Label="Libellé *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_newCredLabel" Label="@Text["CamerasPage_LabelRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true"
|
||||
HelperText="Ex : admin principal, compte NVR, ..." />
|
||||
<MudTextField @bind-Value="_newCredUsername" Label="Utilisateur *" Variant="Variant.Outlined"
|
||||
HelperText="@Text["CamerasPage_CredentialHint"]" />
|
||||
<MudTextField @bind-Value="_newCredUsername" Label="@Text["CamerasPage_UsernameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" />
|
||||
<MudTextField @bind-Value="_newCredPassword" Label="Mot de passe *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_newCredPassword" Label="@Text["CamerasPage_PasswordRequired"]" Variant="Variant.Outlined"
|
||||
InputType="InputType.Password" Class="mb-4" Immediate="true" />
|
||||
@if (!string.IsNullOrEmpty(_credentialError))
|
||||
{
|
||||
@@ -375,11 +374,11 @@
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCredentialDialog = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCredentialDialog = false)">@Text["CamerasPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@AddCredential"
|
||||
Disabled="@(_savingCredential || string.IsNullOrWhiteSpace(_newCredLabel) || string.IsNullOrWhiteSpace(_newCredUsername) || string.IsNullOrWhiteSpace(_newCredPassword))">
|
||||
@if (_savingCredential) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Ajouter
|
||||
@Text["CamerasPage_Add"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -434,6 +433,7 @@
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
// Load all three tabs data in parallel
|
||||
var tasks = new[]
|
||||
{
|
||||
@@ -445,6 +445,8 @@
|
||||
await Task.WhenAll(tasks);
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private bool _autoRefreshStarted;
|
||||
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
@@ -502,7 +504,7 @@
|
||||
}
|
||||
catch {
|
||||
_camerasError = true;
|
||||
if (!silent) Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
if (!silent) Snackbar.Add(Text["CamerasPage_OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -548,7 +550,7 @@
|
||||
if (status?.Status == "Failed")
|
||||
{
|
||||
_pendingSnapshotRequests.Remove(cameraId);
|
||||
Snackbar.Add(status.Reason ?? "La capture a échoué.", Severity.Error);
|
||||
Snackbar.Add(status.Reason ?? Text["CamerasPage_CaptureFailed"], Severity.Error);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -560,7 +562,7 @@
|
||||
|
||||
_snapshots[cameraId] = snapshot.SnapshotThumbUrl ?? snapshot.SnapshotUrl;
|
||||
_pendingSnapshotRequests.Remove(cameraId);
|
||||
Snackbar.Add("Snapshot disponible", Severity.Success);
|
||||
Snackbar.Add(Text["CamerasPage_SnapshotAvailable"], Severity.Success);
|
||||
}
|
||||
catch { /* Réessayer lors de la prochaine actualisation de la grille. */ }
|
||||
}
|
||||
@@ -577,12 +579,12 @@
|
||||
var request = await Api.RequestCameraSnapshotAsync(camera.Id);
|
||||
if (!request.Succeeded || request.Data == Guid.Empty)
|
||||
{
|
||||
Snackbar.Add(request.ErrorMessage ?? UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(request.ErrorMessage ?? Text["CamerasPage_OperationFailed"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
_pendingSnapshotRequests[camera.Id] = request.Data;
|
||||
Snackbar.Add($"Capture demandée pour {camera.Name}", Severity.Info);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["CamerasPage_CaptureRequested"], camera.Name), Severity.Info);
|
||||
for (var attempt = 0; attempt < 35 && !_disposed; attempt++)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(1));
|
||||
@@ -592,7 +594,7 @@
|
||||
if (status.Status == "Failed")
|
||||
{
|
||||
_pendingSnapshotRequests.Remove(camera.Id);
|
||||
Snackbar.Add(status.Reason ?? "La capture a échoué.", Severity.Error);
|
||||
Snackbar.Add(status.Reason ?? Text["CamerasPage_CaptureFailed"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -607,18 +609,18 @@
|
||||
|
||||
_snapshots[camera.Id] = snapshot.SnapshotThumbUrl ?? snapshot.SnapshotUrl;
|
||||
_pendingSnapshotRequests.Remove(camera.Id);
|
||||
Snackbar.Add("Snapshot disponible", Severity.Success);
|
||||
Snackbar.Add(Text["CamerasPage_SnapshotAvailable"], Severity.Success);
|
||||
return;
|
||||
}
|
||||
|
||||
if (_disposed) return;
|
||||
Snackbar.Add(completedWithoutImage
|
||||
? "La capture est terminée ; l'image sera actualisée dès qu'elle sera disponible."
|
||||
: "La capture prend plus de temps que prévu ; la grille continuera à vérifier sa livraison.",
|
||||
? Text["CamerasPage_CaptureComplete"]
|
||||
: Text["CamerasPage_CaptureSlow"],
|
||||
Severity.Info);
|
||||
}
|
||||
catch {
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["CamerasPage_OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -636,17 +638,17 @@
|
||||
{
|
||||
camera.Status = result.Data.Status;
|
||||
Snackbar.Add(
|
||||
result.Data.Status == "Online" ? $"Caméra \"{camera.Name}\" activée" : $"Caméra \"{camera.Name}\" désactivée",
|
||||
result.Data.Status == "Online" ? string.Format(Language.Culture, Text["CamerasPage_CameraEnabled"], camera.Name) : string.Format(Language.Culture, Text["CamerasPage_CameraDisabled"], camera.Name),
|
||||
Severity.Success);
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add(result.ErrorMessage ?? UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(result.ErrorMessage ?? Text["CamerasPage_OperationFailed"], Severity.Error);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["CamerasPage_OperationFailed"], Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -669,7 +671,7 @@
|
||||
|
||||
private async Task CreateCamera()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_newName)) { _dialogError = "Le nom est requis"; return; }
|
||||
if (string.IsNullOrWhiteSpace(_newName)) { _dialogError = Text["CamerasPage_NameRequiredError"]; return; }
|
||||
_saving = true;
|
||||
_dialogError = "";
|
||||
try
|
||||
@@ -678,16 +680,16 @@
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
_dialogError = string.IsNullOrWhiteSpace(result.ErrorMessage)
|
||||
? UiErrors.OperationFailed("la création de la caméra")
|
||||
? Text["CamerasPage_CreateError"]
|
||||
: result.ErrorMessage;
|
||||
return;
|
||||
}
|
||||
_showCreate = false;
|
||||
ResetForm();
|
||||
Snackbar.Add("Caméra ajoutée", Severity.Success);
|
||||
Snackbar.Add(Text["CamerasPage_CameraAdded"], Severity.Success);
|
||||
await LoadCameras();
|
||||
}
|
||||
catch { _dialogError = UiErrors.OperationFailed(); }
|
||||
catch { _dialogError = Text["CamerasPage_OperationFailed"]; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
@@ -695,10 +697,10 @@
|
||||
{
|
||||
if (await Api.DeleteCameraAsync(id))
|
||||
{
|
||||
Snackbar.Add($"Caméra \"{name}\" supprimée", Severity.Success);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["CamerasPage_CameraDeleted"], name), Severity.Success);
|
||||
await LoadCameras();
|
||||
}
|
||||
else Snackbar.Add("Erreur", Severity.Error);
|
||||
else Snackbar.Add(Text["CamerasPage_Error"], Severity.Error);
|
||||
}
|
||||
|
||||
private void ResetForm()
|
||||
@@ -718,7 +720,7 @@
|
||||
{
|
||||
_discoveries = await Api.GetPendingDiscoveriesAsync(SiteId);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["CamerasPage_OperationFailed"], Severity.Error); }
|
||||
finally { _loadingDiscoveries = false; }
|
||||
}
|
||||
|
||||
@@ -740,13 +742,13 @@
|
||||
var result = await Api.ScanNowAsync(SiteId);
|
||||
Snackbar.Add(
|
||||
result is { AgentsNotified: > 0 }
|
||||
? $"Scan demandé à {result.AgentsNotified} agent(s)"
|
||||
: "Scan demandé (aucun agent en ligne ?)",
|
||||
? string.Format(Language.Culture, Text["CamerasPage_ScanRequested"], result.AgentsNotified)
|
||||
: Text["CamerasPage_ScanNoAgents"],
|
||||
result is { AgentsNotified: > 0 } ? Severity.Success : Severity.Warning);
|
||||
await Task.Delay(TimeSpan.FromSeconds(8));
|
||||
await LoadDiscoveries();
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["CamerasPage_OperationFailed"], Severity.Error); }
|
||||
finally { _scanning = false; }
|
||||
}
|
||||
|
||||
@@ -759,10 +761,10 @@
|
||||
_confirmShow = true;
|
||||
}
|
||||
|
||||
private static string DefaultName(PendingDiscoveryItem item)
|
||||
private string DefaultName(PendingDiscoveryItem item)
|
||||
{
|
||||
var vendor = item.Vendor ?? item.OnvifHardware ?? "Caméra";
|
||||
return $"{vendor} ({item.IpAddress})";
|
||||
var vendor = item.Vendor ?? item.OnvifHardware ?? Text["CamerasPage_Camera"];
|
||||
return string.Format(Language.Culture, Text["CamerasPage_DefaultCameraName"], vendor, item.IpAddress);
|
||||
}
|
||||
|
||||
private async Task ConfirmCamera()
|
||||
@@ -779,17 +781,17 @@
|
||||
if (!result.Succeeded || result.Data is null)
|
||||
{
|
||||
_confirmError = string.IsNullOrWhiteSpace(result.ErrorMessage)
|
||||
? "Impossible d'ajouter la caméra (déjà enregistrée ou erreur)."
|
||||
? Text["CamerasPage_ConfirmError"]
|
||||
: result.ErrorMessage;
|
||||
return;
|
||||
}
|
||||
var camera = result.Data;
|
||||
Snackbar.Add($"Caméra \"{camera.Name}\" ajoutée", Severity.Success);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["CamerasPage_CameraAddedNamed"], camera.Name), Severity.Success);
|
||||
_confirmShow = false;
|
||||
await LoadDiscoveries();
|
||||
await LoadCameras();
|
||||
}
|
||||
catch { _confirmError = UiErrors.OperationFailed(); }
|
||||
catch { _confirmError = Text["CamerasPage_OperationFailed"]; }
|
||||
finally { _confirming = false; }
|
||||
}
|
||||
|
||||
@@ -797,12 +799,12 @@
|
||||
{
|
||||
if (await Api.RejectDiscoveryAsync(item.Id))
|
||||
{
|
||||
Snackbar.Add($"Détection {item.IpAddress} ignorée", Severity.Info);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["CamerasPage_DiscoveryIgnored"], item.IpAddress), Severity.Info);
|
||||
await LoadDiscoveries();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add("Erreur lors de l'ignorance", Severity.Error);
|
||||
Snackbar.Add(Text["CamerasPage_IgnoreError"], Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -822,13 +824,13 @@
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
private static string FormatType(string detectedType) => detectedType switch
|
||||
private string FormatType(string detectedType) => detectedType switch
|
||||
{
|
||||
"Standard" => "Caméra",
|
||||
"Standard" => Text["CamerasPage_Camera"],
|
||||
"Nvr" => "NVR",
|
||||
"HomeKit" => "HomeKit",
|
||||
"Doorbell" => "Sonnette",
|
||||
_ => "Inconnu"
|
||||
"Doorbell" => Text["CamerasPage_Doorbell"],
|
||||
_ => Text["CamerasPage_Unknown"]
|
||||
};
|
||||
|
||||
private static Color TypeColor(string detectedType) => detectedType switch
|
||||
@@ -847,7 +849,7 @@
|
||||
{
|
||||
_credentials = await Api.GetSiteCredentialsAsync(SiteId);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["CamerasPage_OperationFailed"], Severity.Error); }
|
||||
finally { _credentialsLoading = false; }
|
||||
}
|
||||
|
||||
@@ -860,17 +862,17 @@
|
||||
var result = await Api.AddSiteCredentialAsync(SiteId, _newCredLabel, _newCredUsername, _newCredPassword);
|
||||
if (result is null)
|
||||
{
|
||||
_credentialError = "Erreur lors de l'ajout (libellé ou utilisateur déjà utilisé ?)";
|
||||
_credentialError = Text["CamerasPage_CredentialAddError"];
|
||||
return;
|
||||
}
|
||||
Snackbar.Add("Identifiant ajouté", Severity.Success);
|
||||
Snackbar.Add(Text["CamerasPage_CredentialAdded"], Severity.Success);
|
||||
_showCredentialDialog = false;
|
||||
_newCredLabel = "";
|
||||
_newCredUsername = "";
|
||||
_newCredPassword = "";
|
||||
await LoadCredentials();
|
||||
}
|
||||
catch { _credentialError = UiErrors.OperationFailed(); }
|
||||
catch { _credentialError = Text["CamerasPage_OperationFailed"]; }
|
||||
finally { _savingCredential = false; }
|
||||
}
|
||||
|
||||
@@ -878,12 +880,12 @@
|
||||
{
|
||||
if (await Api.DeleteSiteCredentialAsync(SiteId, credential.Id))
|
||||
{
|
||||
Snackbar.Add($"Identifiant \"{credential.Label}\" supprimé", Severity.Success);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["CamerasPage_CredentialDeleted"], credential.Label), Severity.Success);
|
||||
await LoadCredentials();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add("Erreur lors de la suppression", Severity.Error);
|
||||
Snackbar.Add(Text["CamerasPage_DeleteError"], Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -891,6 +893,7 @@
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Language.LanguageChanged -= OnLanguageChanged;
|
||||
_disposed = true;
|
||||
_refreshCts?.Cancel();
|
||||
_refreshCts?.Dispose();
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
@inject ISnackbar Snackbar
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-1">
|
||||
@Text["Dashboard"]
|
||||
@@ -56,7 +57,7 @@
|
||||
</StatTile>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" lg="3" Class="d-flex">
|
||||
<StatTile Label="Sites"
|
||||
<StatTile Label="@Text["Sites"]"
|
||||
Value="@(_stats?.TotalSites.ToString() ?? "—")"
|
||||
Icon="@Icons.Material.Filled.Assignment"
|
||||
IconColor="Color.Info"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@page "/Error"
|
||||
@layout MudBlazorLayout
|
||||
@inject NavigationManager Navigation
|
||||
@inject UiText Text
|
||||
|
||||
<div class="auth-page">
|
||||
<div class="auth-card">
|
||||
@@ -8,8 +9,8 @@
|
||||
<div class="auth-icon">
|
||||
<MudIcon Icon="@Icons.Material.Filled.ErrorOutline" Size="Size.Large" Color="Color.Error" />
|
||||
</div>
|
||||
<h1>Une erreur est survenue</h1>
|
||||
<p>Une erreur inattendue s'est produite. Veuillez réessayer.</p>
|
||||
<h1>@Text["ErrorPage_Title"]</h1>
|
||||
<p>@Text["ErrorPage_Body"]</p>
|
||||
</div>
|
||||
|
||||
<div class="auth-form">
|
||||
@@ -18,14 +19,14 @@
|
||||
FullWidth="true"
|
||||
Class="auth-submit-btn"
|
||||
OnClick="@(() => Navigation.NavigateTo("/dashboard"))">
|
||||
Retour au tableau de bord
|
||||
@Text["ErrorPage_BackToDashboard"]
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@if (Environment.IsDevelopment())
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="mt-4">
|
||||
<MudText>Consultez les logs serveur pour plus de détails sur cette erreur.</MudText>
|
||||
<MudText>@Text["ErrorPage_LogsHint"]</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -4,43 +4,46 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@using Microsoft.AspNetCore.WebUtilities
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-2">
|
||||
<i class="fas fa-bell mr-2"></i>
|
||||
Événements
|
||||
@Text["EventsPage_Title"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@(_total > 0 ? $"{_total} événement(s) trouvé(s)" : "Historique des détections")
|
||||
@(_total > 0 ? string.Format(Text["EventsPage_CountFound"], _total) : Text["EventsPage_History"])
|
||||
</MudText>
|
||||
|
||||
@* ─── Barre de filtres fonctionnelle ─── *@
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4" Style="border-radius: var(--hmd-radius-md);">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="12" md="4">
|
||||
<MudTextField @bind-Value="_search" Label="Rechercher (label, caméra…)" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_search" Label="@Text["EventsPage_SearchLabel"]" Variant="Variant.Outlined"
|
||||
Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search"
|
||||
OnAdornmentClick="@ApplyFilters" OnKeyDown="@HandleSearchKey"
|
||||
Immediate="true" Class="mb-2 mb-md-0" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudSelect T="string" @bind-Value="_selectedType" Label="Type" Variant="Variant.Outlined"
|
||||
<MudSelect T="string" @bind-Value="_selectedType" Label="@Text["EventsPage_Type"]" Variant="Variant.Outlined"
|
||||
Class="mb-2 mb-md-0">
|
||||
<MudSelectItem T="string" Value="@("")">Tous les types</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("MotionDetected")">Mouvement</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("PersonDetected")">Personne</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("VehicleDetected")">Véhicule</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("FaceRecognized")">Visage</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("CameraOffline")">Hors ligne</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("")">@Text["EventsPage_AllTypes"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("MotionDetected")">@Text["EventsPage_Motion"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("PersonDetected")">@Text["EventsPage_Person"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("VehicleDetected")">@Text["EventsPage_Vehicle"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("FaceRecognized")">@Text["EventsPage_Face"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("CameraOffline")">@Text["EventsPage_Offline"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3">
|
||||
<MudDateRangePicker @bind-DateRange="_dateRange" Label="Période" Variant="Variant.Outlined"
|
||||
<MudDateRangePicker @bind-DateRange="_dateRange" Label="@Text["EventsPage_Period"]" Culture="@Language.Culture" Variant="Variant.Outlined"
|
||||
Class="mb-2 mb-md-0" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="2" Class="d-flex align-center justify-end">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@ApplyFilters" Class="w-100">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Search" Class="mr-1" Size="Size.Small" /> Filtrer
|
||||
<MudIcon Icon="@Icons.Material.Filled.Search" Class="mr-1" Size="Size.Small" /> @Text["EventsPage_Filter"]
|
||||
</MudButton>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -58,9 +61,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Class="mt-4">
|
||||
<MudText>Impossible de charger les événements. Réessayez dans un instant.</MudText>
|
||||
<MudText>@Text["EventsPage_LoadFailed"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadEvents" 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["EventsPage_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -68,21 +71,21 @@ else if (_events is null || _events.Count == 0)
|
||||
{
|
||||
<MudPaper Elevation="0" Class="pa-8 text-center" Style="border-radius: var(--hmd-radius-md); border: 1px dashed var(--mud-palette-lines-default);">
|
||||
<MudIcon Icon="@Icons.Material.Filled.NotificationsOff" Size="Size.Large" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">Aucun événement trouvé</MudText>
|
||||
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">@Text["EventsPage_EmptyTitle"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@if (_hasActiveFilters)
|
||||
{
|
||||
<text>Modifiez vos filtres ou</text>
|
||||
<text>@Text["EventsPage_EmptyFiltered"]</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>Les détections apparaîtront ici dès que vos caméras repèrent un mouvement.</text>
|
||||
<text>@Text["EventsPage_EmptyDescription"]</text>
|
||||
}
|
||||
</MudText>
|
||||
@if (_hasActiveFilters)
|
||||
{
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Default" OnClick="@ClearFilters">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Clear" Class="mr-1" /> Effacer les filtres
|
||||
<MudIcon Icon="@Icons.Material.Filled.Clear" Class="mr-1" /> @Text["EventsPage_ClearFilters"]
|
||||
</MudButton>
|
||||
}
|
||||
</MudPaper>
|
||||
@@ -96,10 +99,10 @@ else
|
||||
<div class="d-flex align-center pa-3 event-row" style="border-bottom: 1px solid var(--mud-palette-lines-default);">
|
||||
<div class="d-flex flex-column mr-4" style="min-width: 150px;">
|
||||
<MudText Typo="Typo.body2" Class="font-weight-medium">
|
||||
@ev.OccurredAt.ToLocalTime().ToString("dd/MM HH:mm")
|
||||
@ev.OccurredAt.ToLocalTime().ToString("g", Language.Culture)
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
@ev.OccurredAt.ToLocalTime().ToString("ss") s
|
||||
@string.Format(Text["EventsPage_Seconds"], ev.OccurredAt.ToLocalTime().ToString("ss", Language.Culture))
|
||||
</MudText>
|
||||
</div>
|
||||
|
||||
@@ -110,14 +113,14 @@ else
|
||||
|
||||
<div class="d-flex flex-column" style="flex:1; min-width:0;">
|
||||
<MudLink Href="@($"/cameras/{ev.CameraId}")" Typo="Typo.body2" Class="text-truncate">
|
||||
@ev.Label ?? "Caméra " + ev.CameraId.ToString()[..8]
|
||||
@(ev.Label ?? $"{Text["EventsPage_Camera"]} {ev.CameraId.ToString()[..8]}")
|
||||
</MudLink>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
@($"Confiance {(ev.Confidence * 100):0}%")
|
||||
@string.Format(Text["EventsPage_Confidence"], ev.Confidence.ToString("P0", Language.Culture))
|
||||
</MudText>
|
||||
</div>
|
||||
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Image" Size="Size.Small" aria-label="Voir le snapshot"
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Image" Size="Size.Small" aria-label="@Text["EventsPage_ViewSnapshot"]"
|
||||
Disabled="@(ev.SnapshotUrl is null)"
|
||||
OnClick="@(() => ShowSnapshot(ev))" />
|
||||
</div>
|
||||
@@ -131,13 +134,13 @@ else
|
||||
|
||||
<MudDialog @bind-Visible="_showSnapshot" Options="_dialogOptions">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Snapshot — @FormatEventType(_showSnapshotEvent!.Type)</MudText>
|
||||
<MudText Typo="Typo.h6">@Text["EventsPage_SnapshotTitle"] — @FormatEventType(_showSnapshotEvent!.Type)</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<img src="@_showSnapshotEvent!.SnapshotUrl" alt="Snapshot" style="width:100%" class="rounded-lg" />
|
||||
<img src="@_showSnapshotEvent!.SnapshotUrl" alt="@Text["EventsPage_SnapshotAlt"]" style="width:100%" class="rounded-lg" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showSnapshot = false)">Fermer</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showSnapshot = false)">@Text["EventsPage_Close"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@@ -169,6 +172,7 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
var uri = Nav.Uri;
|
||||
var query = uri.Contains('?') ? uri[(uri.IndexOf('?') + 1)..] : "";
|
||||
var q = QueryHelpers.ParseQuery(query).TryGetValue("q", out var qv) ? qv.ToString() : null;
|
||||
@@ -215,7 +219,7 @@ else
|
||||
}
|
||||
catch {
|
||||
_error = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["EventsPage_LoadFailed"], Severity.Error);
|
||||
}
|
||||
finally { _loading = false; }
|
||||
}
|
||||
@@ -231,14 +235,14 @@ else
|
||||
_showSnapshot = true;
|
||||
}
|
||||
|
||||
private static string FormatEventType(string type) => type switch
|
||||
private string FormatEventType(string type) => type switch
|
||||
{
|
||||
"ManualSnapshot" => "Capture manuelle",
|
||||
"MotionDetected" => "Mouvement",
|
||||
"PersonDetected" => "Personne",
|
||||
"VehicleDetected" => "Véhicule",
|
||||
"FaceRecognized" => "Visage",
|
||||
"CameraOffline" => "Hors ligne",
|
||||
"ManualSnapshot" => Text["EventsPage_ManualSnapshot"],
|
||||
"MotionDetected" => Text["EventsPage_Motion"],
|
||||
"PersonDetected" => Text["EventsPage_Person"],
|
||||
"VehicleDetected" => Text["EventsPage_Vehicle"],
|
||||
"FaceRecognized" => Text["EventsPage_Face"],
|
||||
"CameraOffline" => Text["EventsPage_Offline"],
|
||||
_ => type
|
||||
};
|
||||
|
||||
@@ -250,4 +254,8 @@ else
|
||||
"FaceRecognized" => Color.Success,
|
||||
_ => Color.Default
|
||||
};
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
@page "/login"
|
||||
@layout MudBlazorLayout
|
||||
@inject HeimdallApiClient Api
|
||||
@inject UiText Text
|
||||
@inject AuthState Auth
|
||||
@inject NavigationManager Navigation
|
||||
@inject ISnackbar Snackbar
|
||||
@@ -16,7 +17,7 @@
|
||||
<i class="fas fa-eye"></i>
|
||||
</div>
|
||||
<h1>Heimdall</h1>
|
||||
<p>Plateforme de surveillance vidéo</p>
|
||||
<p>@Text["LoginPage_Subtitle"]</p>
|
||||
</div>
|
||||
|
||||
<div class="auth-form">
|
||||
@@ -24,14 +25,14 @@
|
||||
@if (!_requires2fa)
|
||||
{
|
||||
<MudTextField @bind-Value="_email"
|
||||
Label="Email"
|
||||
Label="@Text["LoginPage_Email"]"
|
||||
Variant="Variant.Outlined"
|
||||
Class="mb-4"
|
||||
Required="true"
|
||||
Immediate="true"
|
||||
Autocomplete="email" />
|
||||
<MudTextField @bind-Value="_password"
|
||||
Label="Mot de passe"
|
||||
Label="@Text["LoginPage_Password"]"
|
||||
Variant="Variant.Outlined"
|
||||
InputType="InputType.Password"
|
||||
Class="mb-4"
|
||||
@@ -42,10 +43,10 @@
|
||||
else
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Class="mb-4">
|
||||
Authentification à deux facteurs requise. Saisissez le code généré par votre application d'authentification.
|
||||
@Text["LoginPage_TwoFactorPrompt"]
|
||||
</MudAlert>
|
||||
<MudTextField @bind-Value="_twoFactorCode"
|
||||
Label="Code 2FA"
|
||||
Label="@Text["LoginPage_TwoFactorCode"]"
|
||||
Variant="Variant.Outlined"
|
||||
Class="mb-4"
|
||||
Required="true"
|
||||
@@ -70,15 +71,15 @@
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Class="mr-2" Color="Color.Inherit" />
|
||||
}
|
||||
@(_loading ? "Connexion en cours…" : (_requires2fa ? "Vérifier" : "Se connecter"))
|
||||
@(_loading ? Text["LoginPage_Loading"] : (_requires2fa ? Text["LoginPage_Verify"] : Text["LoginPage_SignIn"]))
|
||||
</MudButton>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="auth-footer">
|
||||
<p>
|
||||
Pas encore de compte ?
|
||||
<a href="/register">Créer un compte</a>
|
||||
@Text["LoginPage_NoAccount"]
|
||||
<a href="/register">@Text["LoginPage_CreateAccount"]</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -134,7 +135,7 @@
|
||||
if (result is null)
|
||||
{
|
||||
Logger.LogWarning("Login failed: Invalid credentials for {Email}", _email);
|
||||
_errorMessage = "Email ou mot de passe invalide";
|
||||
_errorMessage = Text["LoginPage_InvalidCredentials"];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,7 +167,7 @@
|
||||
if (string.IsNullOrWhiteSpace(_twoFactorCode))
|
||||
{
|
||||
Logger.LogWarning("2FA verification attempted with empty code for {Email}", _email);
|
||||
_errorMessage = "Le code 2FA est requis";
|
||||
_errorMessage = Text["LoginPage_TwoFactorCodeRequired"];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@
|
||||
if (result is null)
|
||||
{
|
||||
Logger.LogWarning("2FA verification failed for {Email}", _email);
|
||||
_errorMessage = "Code 2FA invalide. Veuillez réessayer.";
|
||||
_errorMessage = Text["LoginPage_InvalidTwoFactorCode"];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,12 +219,12 @@
|
||||
if (!cookieOk)
|
||||
{
|
||||
Logger.LogError("Failed to create auth cookie for {Email}", _email);
|
||||
_errorMessage = "Erreur lors de la création de la session. Veuillez réessayer.";
|
||||
_errorMessage = Text["LoginPage_AuthSessionFailed"];
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.LogInformation("Authentication completed successfully for {Email}, redirecting to {ReturnUrl}", _email, _returnUrl);
|
||||
Snackbar.Add("Connexion réussie", Severity.Success);
|
||||
Snackbar.Add(Text["LoginPage_SignInSucceeded"], Severity.Success);
|
||||
Navigation.NavigateTo(_returnUrl);
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,14 @@
|
||||
@page "/not-found"
|
||||
@layout MainLayout
|
||||
@inject UiText Text
|
||||
|
||||
<div class="empty-state" style="min-height: 50vh;">
|
||||
<i class="fas fa-map-signs"></i>
|
||||
<MudText Typo="Typo.h1" Color="Color.Primary" Class="mt-4">Page introuvable</MudText>
|
||||
<MudText Typo="Typo.h1" Color="Color.Primary" Class="mt-4">@Text["NotFoundPage_Title"]</MudText>
|
||||
<MudText Typo="Typo.body1" Color="Color.Secondary" Class="mb-6">
|
||||
Désolé, la page que vous cherchez n'existe pas ou a été déplacée.
|
||||
@Text["NotFoundPage_Body"]
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Href="/dashboard">
|
||||
<i class="fas fa-arrow-left mr-2"></i> Retour au Dashboard
|
||||
<i class="fas fa-arrow-left mr-2"></i> @Text["NotFoundPage_Back"]
|
||||
</MudButton>
|
||||
</div>
|
||||
@@ -6,6 +6,9 @@
|
||||
@inject NavigationManager Nav
|
||||
@using Heimdall.Web.Components.Shared
|
||||
@using Heimdall.Web.Services
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@implements IDisposable
|
||||
|
||||
@if (_loading)
|
||||
{
|
||||
@@ -13,7 +16,7 @@
|
||||
}
|
||||
else if (_person is null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning">Person not found</MudAlert>
|
||||
<MudAlert Severity="Severity.Warning">@Text["PersonDetailPage_NotFound"]</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -34,23 +37,23 @@ else
|
||||
<div>
|
||||
<MudText Typo="Typo.h1" Class="mb-1">@_person.DisplayName</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
@FormatCategory(_person.Category) · Created @_person.CreatedAt.ToString("d")
|
||||
@FormatCategory(_person.Category) · @string.Format(Text["PersonDetailPage_Created"], _person.CreatedAt.ToString("d", Language.Culture))
|
||||
</MudText>
|
||||
@if (_person.IsWatchlisted)
|
||||
{
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Warning"
|
||||
Icon="@Icons.Material.Filled.Warning" Class="mt-2">
|
||||
Watchlisted
|
||||
@Text["PersonDetailPage_Watchlisted"]
|
||||
</MudChip>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex gap-2">
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Default" OnClick="@(() => _showForm = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Edit" Class="mr-1" /> Edit
|
||||
<MudIcon Icon="@Icons.Material.Filled.Edit" Class="mr-1" /> @Text["PersonDetailPage_Edit"]
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Error" OnClick="@ConfirmDelete">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Delete" Class="mr-1" /> Delete
|
||||
<MudIcon Icon="@Icons.Material.Filled.Delete" Class="mr-1" /> @Text["PersonDetailPage_Delete"]
|
||||
</MudButton>
|
||||
</div>
|
||||
</div>
|
||||
@@ -58,7 +61,7 @@ else
|
||||
@if (!string.IsNullOrEmpty(_person.Notes))
|
||||
{
|
||||
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
||||
<MudText Typo="Typo.h6" Class="mb-2">Notes</MudText>
|
||||
<MudText Typo="Typo.h6" Class="mb-2">@Text["PersonDetailPage_Notes"]</MudText>
|
||||
<MudText Typo="Typo.body1">@_person.Notes</MudText>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -70,7 +73,7 @@ else
|
||||
<div class="d-flex justify-space-between align-center mb-4">
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Portrait" Class="mr-1" />
|
||||
Registered faces (@_faces.Count)
|
||||
@string.Format(Text["PersonDetailPage_RegisteredFaces"], _faces.Count)
|
||||
</MudText>
|
||||
</div>
|
||||
|
||||
@@ -81,7 +84,7 @@ else
|
||||
else if (_faces.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||
No face registered. Add a face to improve recognition.
|
||||
@Text["PersonDetailPage_NoFaces"]
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
@@ -93,7 +96,7 @@ else
|
||||
<div class="d-flex flex-column align-center gap-2" style="padding: 16px;">
|
||||
@if (!string.IsNullOrEmpty(face.ThumbnailUrl))
|
||||
{
|
||||
<img src="@face.ThumbnailUrl" alt="Face"
|
||||
<img src="@face.ThumbnailUrl" alt="@Text["PersonDetailPage_FaceAlt"]"
|
||||
style="width: 200px; height: 200px; border-radius: 50%; object-fit:cover;
|
||||
border: 4px solid var(--mud-palette-primary);" />
|
||||
}
|
||||
@@ -108,11 +111,11 @@ else
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
@if (!string.IsNullOrEmpty(face.SourceEventId))
|
||||
{
|
||||
<text>Event: @face.SourceEventId.Substring(0, Math.Min(8, face.SourceEventId.Length))…</text>
|
||||
<text>@Text["PersonDetailPage_Event"]: @face.SourceEventId.Substring(0, Math.Min(8, face.SourceEventId.Length))…</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>Face #@face.Id.ToString()[..8]</text>
|
||||
<text>@Text["PersonDetailPage_FaceNumber"] #@face.Id.ToString()[..8]</text>
|
||||
}
|
||||
</MudText>
|
||||
</div>
|
||||
@@ -139,7 +142,7 @@ else
|
||||
<MudPaper Elevation="2" Class="pa-6" Style="border-radius: 12px; height: 100%;">
|
||||
<MudText Typo="Typo.h6" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.ElectricCar" Class="mr-1" />
|
||||
Associated vehicles (@_vehicles.Count)
|
||||
@string.Format(Text["PersonDetailPage_AssociatedVehicles"], _vehicles.Count)
|
||||
</MudText>
|
||||
|
||||
@if (_vehiclesLoading)
|
||||
@@ -149,25 +152,25 @@ else
|
||||
else if (_vehicles.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||
No vehicle associated with this person.
|
||||
@Text["PersonDetailPage_NoVehicles"]
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTable Items="@_vehicles" Dense="true" Hover="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Plate</MudTh>
|
||||
<MudTh>Make</MudTh>
|
||||
<MudTh>Model</MudTh>
|
||||
<MudTh>Color</MudTh>
|
||||
<MudTh>Events</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Plate"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Make"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Model"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Color"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Events"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Plate"><code>@context.LicensePlate</code></MudTd>
|
||||
<MudTd DataLabel="Make">@context.Make</MudTd>
|
||||
<MudTd DataLabel="Model">@context.Model</MudTd>
|
||||
<MudTd DataLabel="Color">@context.Color</MudTd>
|
||||
<MudTd DataLabel="Events">@context.EventCount</MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Plate"]"><code>@context.LicensePlate</code></MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Make"]">@context.Make</MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Model"]">@context.Model</MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Color"]">@context.Color</MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Events"]">@context.EventCount</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
}
|
||||
@@ -179,7 +182,7 @@ else
|
||||
<MudPaper Elevation="2" Class="pa-6 mt-6" Style="border-radius: 12px;">
|
||||
<MudText Typo="Typo.h6" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.History" Class="mr-1" />
|
||||
Detection history (last 30 days)
|
||||
@Text["PersonDetailPage_DetectionHistory"]
|
||||
</MudText>
|
||||
|
||||
@if (_eventsLoading)
|
||||
@@ -189,33 +192,33 @@ else
|
||||
else if (_events.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||
No face detection for the last 30 days.
|
||||
@Text["PersonDetailPage_NoRecentDetections"]
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTable Items="@_events" Dense="true" Hover="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Date</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
<MudTh>Camera</MudTh>
|
||||
<MudTh>Confidence</MudTh>
|
||||
<MudTh>Snapshot</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Date"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Type"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Camera"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Confidence"]</MudTh>
|
||||
<MudTh>@Text["PersonDetailPage_Snapshot"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Date">@context.OccurredAt.ToLocalTime().ToString("dd/MM HH:mm")</MudTd>
|
||||
<MudTd DataLabel="Type">
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Date"]">@context.OccurredAt.ToLocalTime().ToString("g", Language.Culture)</MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Type"]">
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Success" Variant="Variant.Filled">
|
||||
Face
|
||||
@Text["PersonDetailPage_Face"]
|
||||
</MudChip>
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Camera">@context.Label</MudTd>
|
||||
<MudTd DataLabel="Confidence">@((context.Confidence * 100).ToString("0"))%</MudTd>
|
||||
<MudTd DataLabel="Snapshot">
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Camera"]">@context.Label</MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Confidence"]">@context.Confidence.ToString("P0", Language.Culture)</MudTd>
|
||||
<MudTd DataLabel="@Text["PersonDetailPage_Snapshot"]">
|
||||
@if (!string.IsNullOrEmpty(context.SnapshotUrl))
|
||||
{
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Image" Size="Size.Small"
|
||||
aria-label="View snapshot" OnClick="@(() => ShowSnapshot(context))" />
|
||||
aria-label="@Text["PersonDetailPage_ViewSnapshot"]" OnClick="@(() => ShowSnapshot(context))" />
|
||||
}
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
@@ -224,7 +227,7 @@ else
|
||||
{
|
||||
<MudButton Variant="Variant.Text" Color="Color.Primary" Class="mt-2"
|
||||
Disabled="@_eventsLoading" OnClick="@LoadMoreEvents">
|
||||
Load more (@_events.Count / @_eventsTotalCount)
|
||||
@string.Format(Text["PersonDetailPage_LoadMore"], _events.Count, _eventsTotalCount)
|
||||
</MudButton>
|
||||
}
|
||||
}
|
||||
@@ -232,7 +235,7 @@ else
|
||||
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Default" Class="mt-4"
|
||||
OnClick="@(() => Nav.NavigateTo("/persons"))">
|
||||
← Back to persons
|
||||
← @Text["PersonDetailPage_BackToPersons"]
|
||||
</MudButton>
|
||||
}
|
||||
|
||||
@@ -242,29 +245,29 @@ else
|
||||
@* ─── Confirm delete ─── *@
|
||||
<MudOverlay Visible="_confirmDeleteShow" OnClick="@(() => _confirmDeleteShow = false)" />
|
||||
<MudDialog @bind-Visible="_confirmDeleteShow">
|
||||
<TitleContent><MudText Typo="Typo.h6">Confirm deletion</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["PersonDetailPage_ConfirmDelete"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudText>Delete the person "@_person?.DisplayName" ?</MudText>
|
||||
<MudText>@string.Format(Text["PersonDetailPage_DeletePrompt"], _person?.DisplayName)</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mt-2">
|
||||
This action is irreversible. The @(_person?.FaceCount) registered face(s) will also be deleted.
|
||||
@string.Format(Text["PersonDetailPage_DeleteWarning"], _person?.FaceCount)
|
||||
</MudText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Cancel</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@ExecuteDelete">Delete</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">@Text["PersonDetailPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@ExecuteDelete">@Text["PersonDetailPage_Delete"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@* ─── Snapshot dialog ─── *@
|
||||
<MudDialog @bind-Visible="_showSnapshot" Options="_dialogOptions">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Snapshot — @_showSnapshotEvent?.Label</MudText>
|
||||
<MudText Typo="Typo.h6">@Text["PersonDetailPage_SnapshotTitle"] — @_showSnapshotEvent?.Label</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<img src="@_showSnapshotEvent?.SnapshotUrl" alt="Snapshot" style="width:100%" class="rounded-lg" />
|
||||
<img src="@_showSnapshotEvent?.SnapshotUrl" alt="@Text["PersonDetailPage_SnapshotAlt"]" style="width:100%" class="rounded-lg" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showSnapshot = false)">Close</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showSnapshot = false)">@Text["PersonDetailPage_Close"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@@ -301,11 +304,12 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
try
|
||||
{
|
||||
_person = await Api.GetPersonAsync(Id);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["PersonDetailPage_OperationFailed"], Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
|
||||
await LoadFaces();
|
||||
@@ -320,7 +324,7 @@ else
|
||||
{
|
||||
_faces = (await Api.GetFacesAsync(Id)) ?? [];
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["PersonDetailPage_OperationFailed"], Severity.Error); }
|
||||
finally { _facesLoading = false; }
|
||||
}
|
||||
|
||||
@@ -331,7 +335,7 @@ else
|
||||
{
|
||||
_vehicles = await Api.GetVehiclesAsync(Id) ?? [];
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["PersonDetailPage_OperationFailed"], Severity.Error); }
|
||||
finally { _vehiclesLoading = false; }
|
||||
}
|
||||
|
||||
@@ -354,7 +358,7 @@ else
|
||||
_eventsPage++;
|
||||
}
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["PersonDetailPage_OperationFailed"], Severity.Error); }
|
||||
finally { _eventsLoading = false; }
|
||||
}
|
||||
|
||||
@@ -375,15 +379,15 @@ else
|
||||
{
|
||||
if (await Api.DeletePersonAsync(Id))
|
||||
{
|
||||
Snackbar.Add($"Person \"{_person?.DisplayName}\" deleted", Severity.Success);
|
||||
Snackbar.Add(string.Format(Text["PersonDetailPage_DeleteSuccess"], _person?.DisplayName), Severity.Success);
|
||||
Nav.NavigateTo("/persons");
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add("Failed to delete person", Severity.Error);
|
||||
Snackbar.Add(Text["PersonDetailPage_DeleteFailed"], Severity.Error);
|
||||
}
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["PersonDetailPage_OperationFailed"], Severity.Error); }
|
||||
}
|
||||
|
||||
private void ShowSnapshot(EventItem ev)
|
||||
@@ -392,12 +396,16 @@ else
|
||||
_showSnapshot = true;
|
||||
}
|
||||
|
||||
private static string FormatCategory(string? category) => category switch
|
||||
private string FormatCategory(string? category) => category switch
|
||||
{
|
||||
"family" => "Family",
|
||||
"employee" => "Employee",
|
||||
"watchlist" => "Watchlist",
|
||||
"unknown" => "Unknown",
|
||||
"family" => Text["PersonDetailPage_Family"],
|
||||
"employee" => Text["PersonDetailPage_Employee"],
|
||||
"watchlist" => Text["PersonDetailPage_Watchlist"],
|
||||
"unknown" => Text["PersonDetailPage_Unknown"],
|
||||
_ => "—"
|
||||
};
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
@@ -6,34 +6,37 @@
|
||||
@inject NavigationManager Nav
|
||||
@using Heimdall.Web.Components.Shared
|
||||
@using Heimdall.Web.Services
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-1">
|
||||
<i class="fas fa-users mr-2"></i>
|
||||
Persons
|
||||
@Text["PersonsListPage_Title"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@(_total > 0 ? $"{_total} person(s) registered" : "List of identified persons")
|
||||
@(_total > 0 ? string.Format(Text["PersonsListPage_CountRegistered"], _total) : Text["PersonsListPage_Description"])
|
||||
</MudText>
|
||||
|
||||
@* ─── Filters ─── *@
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4" Style="border-radius: var(--hmd-radius-md);">
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6" md="5">
|
||||
<MudTextField @bind-Value="Search" Label="Search (name...)" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="Search" Label="@Text["PersonsListPage_SearchLabel"]" Variant="Variant.Outlined"
|
||||
Adornment="Adornment.End" AdornmentIcon="@Icons.Material.Filled.Search"
|
||||
Immediate="true" Class="mb-2 mb-md-0" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="4">
|
||||
<MudSelect T="string" @bind-Value="_statusFilter" Label="Status" Variant="Variant.Outlined"
|
||||
<MudSelect T="string" @bind-Value="_statusFilter" Label="@Text["PersonsListPage_Status"]" Variant="Variant.Outlined"
|
||||
Class="mb-2 mb-md-0">
|
||||
<MudSelectItem T="string" Value="@("")">All</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("known")">Known</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("unknown")">Unknown</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("")">@Text["PersonsListPage_All"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("known")">@Text["PersonsListPage_Known"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("unknown")">@Text["PersonsListPage_Unknown"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6" md="3" Class="d-flex align-center">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@ApplyFilters" Class="w-100">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Search" Class="mr-1" Size="Size.Small" /> Filter
|
||||
<MudIcon Icon="@Icons.Material.Filled.Search" Class="mr-1" Size="Size.Small" /> @Text["PersonsListPage_Filter"]
|
||||
</MudButton>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -56,9 +59,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Variant="Variant.Filled" Class="mb-4">
|
||||
<MudText>Unable to load persons.</MudText>
|
||||
<MudText>@Text["PersonsListPage_LoadFailed"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadPersons" Class="mt-2">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Refresh" Class="mr-1" Size="Size.Small" /> Retry
|
||||
<MudIcon Icon="@Icons.Material.Filled.Refresh" Class="mr-1" Size="Size.Small" /> @Text["PersonsListPage_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -68,23 +71,23 @@ else if (_Filtered is null || _Filtered.Count == 0)
|
||||
<MudIcon Icon="@Icons.Material.Filled.PersonSearch" Size="Size.Large" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.h6" Color="Color.Secondary" Class="mt-4">
|
||||
@(_persons is null || _persons.Count == 0
|
||||
? "No person registered"
|
||||
: "No person matches the filters")
|
||||
? Text["PersonsListPage_EmptyTitle"]
|
||||
: Text["PersonsListPage_NoMatches"])
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@if (_persons is null || _persons.Count == 0)
|
||||
{
|
||||
<text>Persons will appear here once the system recognises a face.</text>
|
||||
<text>@Text["PersonsListPage_EmptyDescription"]</text>
|
||||
}
|
||||
else
|
||||
{
|
||||
<text>Adjust your filters or create a new person.</text>
|
||||
<text>@Text["PersonsListPage_NoMatchesDescription"]</text>
|
||||
}
|
||||
</MudText>
|
||||
@if (_persons is null || _persons.Count == 0)
|
||||
{
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showForm = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Add a person
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["PersonsListPage_AddPerson"]
|
||||
</MudButton>
|
||||
}
|
||||
</MudPaper>
|
||||
@@ -93,10 +96,10 @@ else
|
||||
{
|
||||
<div class="d-flex justify-space-between align-center mb-4">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">
|
||||
@_Filtered.Count person(s) shown
|
||||
@string.Format(Text["PersonsListPage_CountShown"], _Filtered.Count)
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showForm = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Add
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["PersonsListPage_Add"]
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@@ -128,17 +131,17 @@ else
|
||||
<MudSpacer />
|
||||
<MudChip T="string" Size="Size.Small" Color="Color.Warning"
|
||||
Icon="@Icons.Material.Filled.Warning">
|
||||
Watchlisted
|
||||
@Text["PersonsListPage_Watchlisted"]
|
||||
</MudChip>
|
||||
}
|
||||
</div>
|
||||
<MudCardActions Justify="Justify.FlexEnd" Class="pa-4 pt-0">
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined"
|
||||
Icon="@Icons.Material.Filled.CollectionsBookmark">
|
||||
@person.FaceCount face(s)
|
||||
@string.Format(Text["PersonsListPage_FaceCount"], person.FaceCount)
|
||||
</MudChip>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
Created @person.CreatedAt.ToString("d")
|
||||
@string.Format(Text["PersonsListPage_Created"], person.CreatedAt.ToString("d", Language.Culture))
|
||||
</MudText>
|
||||
</MudCardActions>
|
||||
</MudCard>
|
||||
@@ -170,7 +173,11 @@ else
|
||||
}
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadPersons();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadPersons();
|
||||
}
|
||||
|
||||
private async Task LoadPersons()
|
||||
{
|
||||
@@ -182,7 +189,7 @@ else
|
||||
_total = _persons?.Count ?? 0;
|
||||
ApplyFilters();
|
||||
}
|
||||
catch { _error = true; Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { _error = true; Snackbar.Add(Text["PersonsListPage_LoadFailed"], Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
}
|
||||
|
||||
@@ -209,12 +216,16 @@ else
|
||||
Nav.NavigateTo($"/persons/{person.Id}");
|
||||
}
|
||||
|
||||
private static string FormatCategory(string? category) => category switch
|
||||
private string FormatCategory(string? category) => category switch
|
||||
{
|
||||
"family" => "Family",
|
||||
"employee" => "Employee",
|
||||
"watchlist" => "Watchlist",
|
||||
"unknown" => "Unknown",
|
||||
"family" => Text["PersonsListPage_Family"],
|
||||
"employee" => Text["PersonsListPage_Employee"],
|
||||
"watchlist" => Text["PersonsListPage_Watchlist"],
|
||||
"unknown" => Text["PersonsListPage_Unknown"],
|
||||
_ => "—"
|
||||
};
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
}
|
||||
@@ -75,7 +75,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.BarChart" Class="mr-1" Size="Size.Small" />
|
||||
Statistiques du compte
|
||||
@Text["Profile_AccountStatistics"]
|
||||
</MudText>
|
||||
|
||||
<MudGrid>
|
||||
@@ -198,7 +198,7 @@ else if (_profile is not null)
|
||||
<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" />
|
||||
Placeholder="@Text["NotificationEmailPlaceholder"]" />
|
||||
|
||||
<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" />
|
||||
@@ -588,7 +588,8 @@ else if (_profile is not null)
|
||||
string.IsNullOrWhiteSpace(_ntfyTopic) ? null : _ntfyTopic.Trim(),
|
||||
_dailyDigest,
|
||||
_weeklyDigest,
|
||||
_subscribedEvents.Count > 0 ? _subscribedEvents.ToList() : null
|
||||
_subscribedEvents.Count > 0 ? _subscribedEvents.ToList() : null,
|
||||
Language: UiLanguageService.Normalize(_language)
|
||||
);
|
||||
var success = await Api.UpdateNotificationConfigAsync(request);
|
||||
if (success)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
@page "/register"
|
||||
@layout MudBlazorLayout
|
||||
@inject HeimdallApiClient Api
|
||||
@inject UiText Text
|
||||
@inject AuthState Auth
|
||||
@inject NavigationManager Navigation
|
||||
@inject ISnackbar Snackbar
|
||||
@@ -13,34 +14,34 @@
|
||||
<div class="auth-icon">
|
||||
<i class="fas fa-user-plus"></i>
|
||||
</div>
|
||||
<h1>Créer un compte</h1>
|
||||
<p>Rejoignez la plateforme Heimdall</p>
|
||||
<h1>@Text["RegisterPage_Title"]</h1>
|
||||
<p>@Text["RegisterPage_Subtitle"]</p>
|
||||
</div>
|
||||
|
||||
<div class="auth-form">
|
||||
<form @onsubmit="RegisterAsync">
|
||||
<MudTextField @bind-Value="_displayName"
|
||||
Label="Nom d'affichage"
|
||||
Label="@Text["RegisterPage_DisplayName"]"
|
||||
Variant="Variant.Outlined"
|
||||
Class="mb-4"
|
||||
Required="true"
|
||||
Immediate="true"
|
||||
Autocomplete="name" />
|
||||
<MudTextField @bind-Value="_email"
|
||||
Label="Email"
|
||||
Label="@Text["LoginPage_Email"]"
|
||||
Variant="Variant.Outlined"
|
||||
Class="mb-4"
|
||||
Required="true"
|
||||
Immediate="true"
|
||||
Autocomplete="email" />
|
||||
<MudTextField @bind-Value="_password"
|
||||
Label="Mot de passe"
|
||||
Label="@Text["LoginPage_Password"]"
|
||||
Variant="Variant.Outlined"
|
||||
InputType="InputType.Password"
|
||||
Class="mb-4"
|
||||
Required="true"
|
||||
Immediate="true"
|
||||
HelperText="Minimum 12 caractères"
|
||||
HelperText="@Text["RegisterPage_PasswordMinimum"]"
|
||||
Autocomplete="new-password" />
|
||||
|
||||
<div class="auth-error">
|
||||
@@ -60,15 +61,15 @@
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Class="mr-2" Color="Color.Inherit" />
|
||||
}
|
||||
@(_loading ? "Création en cours…" : "S'inscrire")
|
||||
@(_loading ? Text["RegisterPage_Loading"] : Text["RegisterPage_Submit"])
|
||||
</MudButton>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div class="auth-footer">
|
||||
<p>
|
||||
Déjà un compte ?
|
||||
<a href="/login">Se connecter</a>
|
||||
@Text["RegisterPage_AlreadyAccount"]
|
||||
<a href="/login">@Text["LoginPage_SignIn"]</a>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -90,7 +91,7 @@
|
||||
var result = await Api.RegisterAsync(_email, _password, _displayName);
|
||||
if (result is null)
|
||||
{
|
||||
_errorMessage = "Erreur lors de l'inscription";
|
||||
_errorMessage = Text["RegisterPage_Failed"];
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -107,11 +108,11 @@
|
||||
|
||||
if (!cookieOk)
|
||||
{
|
||||
_errorMessage = "Compte créé mais échec de connexion automatique. Veuillez vous connecter.";
|
||||
_errorMessage = Text["RegisterPage_AutoLoginFailed"];
|
||||
return;
|
||||
}
|
||||
|
||||
Snackbar.Add("Compte créé avec succès", Severity.Success);
|
||||
Snackbar.Add(Text["RegisterPage_Succeeded"], Severity.Success);
|
||||
Navigation.NavigateTo("/dashboard");
|
||||
}
|
||||
catch {
|
||||
|
||||
@@ -3,21 +3,23 @@
|
||||
@layout MainLayout
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<div class="d-flex align-center mb-4">
|
||||
<MudText Typo="Typo.h1" Class="flex-grow-1">
|
||||
<i class="fas fa-cog mr-2"></i>
|
||||
Configuration
|
||||
@Text["SettingsPage_Title"]
|
||||
</MudText>
|
||||
<MudTooltip Text="Forcer le rechargement de la configuration sur tous les agents">
|
||||
<MudTooltip Text="@Text["SettingsPage_ReloadTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Color="Color.Info" OnClick="ReloadAllConfig"
|
||||
Disabled="@_reloading" aria-label="Recharger la configuration" />
|
||||
Disabled="@_reloading" aria-label="@Text["SettingsPage_Reload"]" />
|
||||
</MudTooltip>
|
||||
</div>
|
||||
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
Chaque domaine est configuré via sa section dédiée. Les modifications sont enregistrées immédiatement
|
||||
et propagées aux agents (bouton <strong>Recharger</strong> en haut à droite pour forcer la notification).
|
||||
@Text["SettingsPage_Description"]
|
||||
</MudText>
|
||||
|
||||
<StorageSettingsSection />
|
||||
@@ -28,17 +30,23 @@
|
||||
@code {
|
||||
private bool _reloading;
|
||||
|
||||
protected override void OnInitialized() => Language.LanguageChanged += OnLanguageChanged;
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
|
||||
private async Task ReloadAllConfig()
|
||||
{
|
||||
_reloading = true;
|
||||
try
|
||||
{
|
||||
await Api.ReloadAllConfigAsync();
|
||||
Snackbar.Add("Configuration rechargée — les agents seront notifiés", Severity.Success);
|
||||
Snackbar.Add(Text["SettingsPage_ReloadSuccess"], Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Échec du rechargement : {ex.Message}", Severity.Error);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["SettingsPage_ReloadError"], ex.Message), Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -5,10 +5,13 @@
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@inject IJSRuntime Js
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-video mr-2"></i>
|
||||
Site : @_site?.Name
|
||||
@Text["SiteDetail_TitlePrefix"] @_site?.Name
|
||||
</MudText>
|
||||
|
||||
@if (_loading)
|
||||
@@ -17,29 +20,29 @@
|
||||
}
|
||||
else if (_site is null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning">Site introuvable</MudAlert>
|
||||
<MudAlert Severity="Severity.Warning">@Text["SiteDetail_NotFound"]</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
||||
<MudText Typo="Typo.h6" Class="mb-4">Informations</MudText>
|
||||
<MudText Typo="Typo.h6" Class="mb-4">@Text["SiteDetail_Information"]</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Nom</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["SiteDetail_Name"]</MudText>
|
||||
<MudText Typo="Typo.body1">@_site.Name</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Adresse</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["SiteDetail_Address"]</MudText>
|
||||
<MudText Typo="Typo.body1">@(_site.Address ?? "-")</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Fuseau horaire</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["SiteDetail_Timezone"]</MudText>
|
||||
<MudText Typo="Typo.body1">@_site.Timezone</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Statut</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["SiteDetail_Status"]</MudText>
|
||||
<MudText Color="@(_site.Enabled ? Color.Success : Color.Default)">
|
||||
@(_site.Enabled ? "● Actif" : "○ Inactif")
|
||||
@(_site.Enabled ? "● " + Text["SiteDetail_Active"] : "○ " + Text["SiteDetail_Inactive"])
|
||||
</MudText>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
@@ -47,10 +50,10 @@ else
|
||||
|
||||
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
||||
<div class="d-flex flex-wrap justify-space-between align-center mb-4">
|
||||
<MudText Typo="Typo.h6">Capacité et ressources du site</MudText>
|
||||
<MudText Typo="Typo.h6">@Text["SiteDetail_CapacityTitle"]</MudText>
|
||||
<MudButtonGroup Variant="Variant.Outlined" Color="Color.Primary">
|
||||
<MudButton OnClick="@(() => LoadCapacityHistoryAsync("24h"))" Disabled="@(_capacityHistoryLoading || _capacityRange == "24h")">24 h</MudButton>
|
||||
<MudButton OnClick="@(() => LoadCapacityHistoryAsync("7d"))" Disabled="@(_capacityHistoryLoading || _capacityRange == "7d")">7 jours</MudButton>
|
||||
<MudButton OnClick="@(() => LoadCapacityHistoryAsync("24h"))" Disabled="@(_capacityHistoryLoading || _capacityRange == "24h")">@Text["SiteDetail_Range24h"]</MudButton>
|
||||
<MudButton OnClick="@(() => LoadCapacityHistoryAsync("7d"))" Disabled="@(_capacityHistoryLoading || _capacityRange == "7d")">@Text["SiteDetail_Range7d"]</MudButton>
|
||||
</MudButtonGroup>
|
||||
</div>
|
||||
@if (_capacityHistoryLoading)
|
||||
@@ -59,11 +62,11 @@ else
|
||||
}
|
||||
else if (_capacityHistoryError)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error">Impossible de charger l’historique de capacité.</MudAlert>
|
||||
<MudAlert Severity="Severity.Error">@Text["SiteDetail_CapacityLoadError"]</MudAlert>
|
||||
}
|
||||
else if (_capacityHistory.Count == 0 || !_capacityHistory.Any(point => point.ReportingAgents > 0))
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">Les données historiques apparaîtront après le premier échantillon d’agent.</MudAlert>
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">@Text["SiteDetail_CapacityEmpty"]</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -73,24 +76,24 @@ else
|
||||
@if (latestCapacity.InventoryObservedAtUtc.HasValue)
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mb-2">
|
||||
Dernier inventaire GPU/température reçu : @latestCapacity.InventoryObservedAtUtc.Value.ToLocalTime().ToString("g").
|
||||
@Text["SiteDetail_LastInventory"] @latestCapacity.InventoryObservedAtUtc.Value.ToLocalTime().ToString("g", Language.Culture).
|
||||
</MudText>
|
||||
}
|
||||
<MudGrid Class="mb-3">
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">Agents échantillonnés</MudText><MudText Typo="Typo.h6">@latestCapacity.ReportingAgents</MudText></MudItem>
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">Cœurs logiques</MudText><MudText Typo="Typo.h6">@(latestCapacity.LogicalCores?.ToString() ?? "—")</MudText></MudItem>
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">RAM totale</MudText><MudText Typo="Typo.h6">@FormatCapacity(latestCapacity.MemoryCapacityBytes)</MudText></MudItem>
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">RAM utilisée</MudText><MudText Typo="Typo.h6">@FormatCapacity(latestCapacity.MemoryUsedBytes)</MudText></MudItem>
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">@Text["SiteDetail_ReportingAgents"]</MudText><MudText Typo="Typo.h6">@latestCapacity.ReportingAgents</MudText></MudItem>
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">@Text["SiteDetail_LogicalCores"]</MudText><MudText Typo="Typo.h6">@(latestCapacity.LogicalCores?.ToString() ?? "—")</MudText></MudItem>
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">@Text["SiteDetail_TotalRam"]</MudText><MudText Typo="Typo.h6">@FormatCapacity(latestCapacity.MemoryCapacityBytes)</MudText></MudItem>
|
||||
<MudItem xs="6" sm="3"><MudText Typo="Typo.caption" Color="Color.Secondary">@Text["SiteDetail_UsedRam"]</MudText><MudText Typo="Typo.h6">@FormatCapacity(latestCapacity.MemoryUsedBytes)</MudText></MudItem>
|
||||
</MudGrid>
|
||||
}
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="CPU moyen utilisé" Points="@CapacitySeries(point => point.AverageCpuUsagePercent)" Minimum="0" Maximum="100" /></MudItem>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="Mémoire système utilisée" Points="@CapacitySeries(MemoryCapacityUsedPercent)" Minimum="0" Maximum="100" /></MudItem>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="Disque moyen utilisé" Points="@CapacitySeries(point => point.AverageDiskUsagePercent)" Minimum="0" Maximum="100" /></MudItem>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="Température GPU moyenne" Points="@CapacitySeries(point => point.AverageGpuTemperatureCelsius)" Unit=" °C" /></MudItem>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="@Text["SiteDetail_AverageCpu"]" Points="@CapacitySeries(point => point.AverageCpuUsagePercent)" Minimum="0" Maximum="100" /></MudItem>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="@Text["SiteDetail_SystemMemory"]" Points="@CapacitySeries(MemoryCapacityUsedPercent)" Minimum="0" Maximum="100" /></MudItem>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="@Text["SiteDetail_AverageDisk"]" Points="@CapacitySeries(point => point.AverageDiskUsagePercent)" Minimum="0" Maximum="100" /></MudItem>
|
||||
<MudItem xs="12" md="6"><MetricHistoryChart Title="@Text["SiteDetail_AverageGpuTemp"]" Points="@CapacitySeries(point => point.AverageGpuTemperatureCelsius)" Unit=" °C" /></MudItem>
|
||||
</MudGrid>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-2">
|
||||
Les trous représentent des périodes sans échantillon en ligne; ils ne comptent pas comme une utilisation nulle.
|
||||
@Text["SiteDetail_MissingSamples"]
|
||||
</MudText>
|
||||
}
|
||||
</MudPaper>
|
||||
@@ -99,21 +102,21 @@ else
|
||||
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
||||
<MudText Typo="Typo.h6" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Key" Class="mr-1" />
|
||||
Token d'enregistrement agent
|
||||
@Text["SiteDetail_RegistrationToken"]
|
||||
</MudText>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_generatedToken))
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
||||
<strong>Token d'enregistrement :</strong><br />
|
||||
<strong>@Text["SiteDetail_RegistrationToken"]</strong><br />
|
||||
<code class="hmd-code-block mt-2">
|
||||
@_generatedToken
|
||||
</code>
|
||||
<MudText Typo="Typo.body2" Color="Color.Warning" Class="mt-2">
|
||||
⚠ Copiez ce token maintenant. Il ne sera plus jamais affiché.
|
||||
⚠ @Text["SiteDetail_TokenCopyWarning"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mt-1">
|
||||
Expire le : @_tokenExpiresAt.ToString("g")
|
||||
@Text["SiteDetail_Expires"] @_tokenExpiresAt.ToString("g", Language.Culture)
|
||||
</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -121,7 +124,7 @@ else
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Warning" OnClick="@GenerateToken" Disabled="@_generating">
|
||||
@if (_generating) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
<MudIcon Icon="@Icons.Material.Filled.Refresh" Class="mr-1" />
|
||||
@(!string.IsNullOrEmpty(_generatedToken) ? "Régénérer" : "Générer un token")
|
||||
@(!string.IsNullOrEmpty(_generatedToken) ? Text["SiteDetail_Regenerate"] : Text["SiteDetail_GenerateToken"])
|
||||
</MudButton>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_generatedToken))
|
||||
@@ -136,17 +139,15 @@ else
|
||||
<div class="d-flex justify-space-between align-center mb-4">
|
||||
<MudText Typo="Typo.h6">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Lock" Class="mr-1" />
|
||||
Identifiants caméras
|
||||
@Text["SiteDetail_Credentials"]
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Size="Size.Small"
|
||||
OnClick="@(() => _showCredentialDialog = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Ajouter
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["SiteDetail_Add"]
|
||||
</MudButton>
|
||||
</div>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
Déclarez les couples login/mot de passe possibles des caméras de ce site.
|
||||
Les agents les utilisent pour authentifier et identifier automatiquement
|
||||
chaque caméra détectée sur le réseau.
|
||||
@Text["SiteDetail_CredentialDescription"]
|
||||
</MudText>
|
||||
|
||||
@if (_credentialsLoading)
|
||||
@@ -156,29 +157,28 @@ else
|
||||
else if (_credentials.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Variant="Variant.Outlined">
|
||||
Aucun identifiant déclaré. La détection fonctionnera, mais les caméras
|
||||
protégées ne seront pas identifiées automatiquement.
|
||||
@Text["SiteDetail_NoCredentials"]
|
||||
</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudTable Items="@_credentials" Hover="true" Dense="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Libellé</MudTh>
|
||||
<MudTh>Utilisateur</MudTh>
|
||||
<MudTh>Dernière utilisation</MudTh>
|
||||
<MudTh>@Text["SiteDetail_Label"]</MudTh>
|
||||
<MudTh>@Text["SiteDetail_Username"]</MudTh>
|
||||
<MudTh>@Text["SiteDetail_LastUsed"]</MudTh>
|
||||
<MudTh></MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Libellé">@context.Label</MudTd>
|
||||
<MudTd DataLabel="Utilisateur"><code>@context.Username</code></MudTd>
|
||||
<MudTd DataLabel="Dernière utilisation">
|
||||
@(context.LastUsedAt?.ToString("g") ?? "jamais")
|
||||
<MudTd DataLabel="@Text["SiteDetail_Label"]">@context.Label</MudTd>
|
||||
<MudTd DataLabel="@Text["SiteDetail_Username"]"><code>@context.Username</code></MudTd>
|
||||
<MudTd DataLabel="@Text["SiteDetail_LastUsed"]">
|
||||
@(context.LastUsedAt?.ToString("g", Language.Culture) ?? Text["SiteDetail_Never"])
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTooltip Text="Supprimer cet identifiant">
|
||||
<MudTd DataLabel="@Text["SiteDetail_Actions"]">
|
||||
<MudTooltip Text="@Text["SiteDetail_DeleteCredentialTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small"
|
||||
Color="Color.Error" aria-label="Supprimer l'identifiant"
|
||||
Color="Color.Error" aria-label="@Text["SiteDetail_DeleteCredential"]"
|
||||
OnClick="@(() => DeleteCredential(context))" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
@@ -188,43 +188,43 @@ else
|
||||
</MudPaper>
|
||||
|
||||
@* Navigation rapide *@
|
||||
<MudText Typo="Typo.h6" Class="mb-4">Gestion</MudText>
|
||||
<MudText Typo="Typo.h6" Class="mb-4">@Text["SiteDetail_Management"]</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudPaper Elevation="3" Class="pa-4 text-center" Style="border-radius: 12px; cursor: pointer;"
|
||||
@onclick="@(() => Nav.NavigateTo($"/sites/{Id}/cameras"))">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Videocam" Size="Size.Large" Color="Color.Primary" />
|
||||
<MudText Typo="Typo.h6" Class="mt-2">Caméras</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Gérer les caméras, détection et identifiants</MudText>
|
||||
<MudText Typo="Typo.h6" Class="mt-2">@Text["SiteDetail_Cameras"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["SiteDetail_ManageCameras"]</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudPaper Elevation="3" Class="pa-4 text-center" Style="border-radius: 12px; cursor: pointer;"
|
||||
@onclick="@(() => Nav.NavigateTo($"/sites/{Id}/agents"))">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Dns" Size="Size.Large" Color="Color.Secondary" />
|
||||
<MudText Typo="Typo.h6" Class="mt-2">Agents</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Voir les agents</MudText>
|
||||
<MudText Typo="Typo.h6" Class="mt-2">@Text["SiteDetail_Agents"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["SiteDetail_ViewAgents"]</MudText>
|
||||
</MudPaper>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Default" Class="mt-4"
|
||||
OnClick="@(() => Nav.NavigateTo("/sites"))">
|
||||
← Retour aux sites
|
||||
@Text["SiteDetail_BackToSites"]
|
||||
</MudButton>
|
||||
}
|
||||
|
||||
@* ─── Ajout d'identifiant caméra ─────────────────────────────────── *@
|
||||
<MudOverlay Visible="@_showCredentialDialog" OnClick="@(() => _showCredentialDialog = false)" />
|
||||
<MudDialog @bind-Visible="_showCredentialDialog">
|
||||
<TitleContent><MudText Typo="Typo.h6">Ajouter un identifiant caméra</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["SiteDetail_AddCredentialTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_newCredLabel" Label="Libellé *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_newCredLabel" Label="@Text["SiteDetail_LabelRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true"
|
||||
HelperText="Ex : admin principal, compte NVR, ..." />
|
||||
<MudTextField @bind-Value="_newCredUsername" Label="Utilisateur *" Variant="Variant.Outlined"
|
||||
HelperText="@Text["SiteDetail_CredentialHint"]" />
|
||||
<MudTextField @bind-Value="_newCredUsername" Label="@Text["SiteDetail_UsernameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" />
|
||||
<MudTextField @bind-Value="_newCredPassword" Label="Mot de passe *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_newCredPassword" Label="@Text["SiteDetail_PasswordRequired"]" Variant="Variant.Outlined"
|
||||
InputType="InputType.Password" Class="mb-4" Immediate="true" />
|
||||
@if (!string.IsNullOrEmpty(_credentialError))
|
||||
{
|
||||
@@ -232,11 +232,11 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCredentialDialog = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCredentialDialog = false)">@Text["SiteDetail_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@AddCredential"
|
||||
Disabled="@(_savingCredential || string.IsNullOrWhiteSpace(_newCredLabel) || string.IsNullOrWhiteSpace(_newCredUsername) || string.IsNullOrWhiteSpace(_newCredPassword))">
|
||||
@if (_savingCredential) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Ajouter
|
||||
@Text["SiteDetail_Add"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -267,18 +267,23 @@ else
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
try
|
||||
{
|
||||
_site = await Api.GetSiteAsync(Id);
|
||||
if (_site is not null)
|
||||
await LoadCapacityHistoryAsync(_capacityRange);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["SiteDetail_OperationFailed"], Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
|
||||
await LoadCredentials();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
|
||||
private async Task LoadCapacityHistoryAsync(string range)
|
||||
{
|
||||
_capacityRange = range;
|
||||
@@ -304,10 +309,10 @@ else
|
||||
? Math.Clamp(100d * used / point.MemoryCapacityBytes.Value, 0, 100)
|
||||
: null;
|
||||
|
||||
private static string FormatCapacity(long? bytes)
|
||||
private string FormatCapacity(long? bytes)
|
||||
=> bytes is { } value ? FormatBytes(value) : "—";
|
||||
|
||||
private static string FormatBytes(long bytes)
|
||||
private string FormatBytes(long bytes)
|
||||
{
|
||||
string[] units = ["B", "KB", "MB", "GB", "TB"];
|
||||
var size = (double)bytes;
|
||||
@@ -317,7 +322,7 @@ else
|
||||
size /= 1024;
|
||||
unit++;
|
||||
}
|
||||
return $"{size:0.#} {units[unit]}";
|
||||
return size.ToString("0.#", Language.Culture) + " " + units[unit];
|
||||
}
|
||||
|
||||
private async Task LoadCredentials()
|
||||
@@ -327,7 +332,7 @@ else
|
||||
{
|
||||
_credentials = await Api.GetSiteCredentialsAsync(Id);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["SiteDetail_OperationFailed"], Severity.Error); }
|
||||
finally { _credentialsLoading = false; }
|
||||
}
|
||||
|
||||
@@ -340,17 +345,17 @@ else
|
||||
var result = await Api.AddSiteCredentialAsync(Id, _newCredLabel, _newCredUsername, _newCredPassword);
|
||||
if (result is null)
|
||||
{
|
||||
_credentialError = "Erreur lors de l'ajout (libellé ou utilisateur déjà utilisé ?)";
|
||||
_credentialError = Text["SiteDetail_CredentialAddError"];
|
||||
return;
|
||||
}
|
||||
Snackbar.Add("Identifiant ajouté", Severity.Success);
|
||||
Snackbar.Add(Text["SiteDetail_CredentialAdded"], Severity.Success);
|
||||
_showCredentialDialog = false;
|
||||
_newCredLabel = "";
|
||||
_newCredUsername = "";
|
||||
_newCredPassword = "";
|
||||
await LoadCredentials();
|
||||
}
|
||||
catch { _credentialError = UiErrors.OperationFailed(); }
|
||||
catch { _credentialError = Text["SiteDetail_OperationFailed"]; }
|
||||
finally { _savingCredential = false; }
|
||||
}
|
||||
|
||||
@@ -358,12 +363,12 @@ else
|
||||
{
|
||||
if (await Api.DeleteSiteCredentialAsync(Id, credential.Id))
|
||||
{
|
||||
Snackbar.Add($"Identifiant \"{credential.Label}\" supprimé", Severity.Success);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["SiteDetail_CredentialDeleted"], credential.Label), Severity.Success);
|
||||
await LoadCredentials();
|
||||
}
|
||||
else
|
||||
{
|
||||
Snackbar.Add("Erreur lors de la suppression", Severity.Error);
|
||||
Snackbar.Add(Text["SiteDetail_DeleteError"], Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -375,15 +380,15 @@ else
|
||||
var result = await Api.GenerateSiteTokenAsync(Id);
|
||||
if (result is null)
|
||||
{
|
||||
Snackbar.Add("Erreur lors de la génération du token", Severity.Error);
|
||||
Snackbar.Add(Text["SiteDetail_TokenError"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
_generatedToken = result.Token;
|
||||
_tokenExpiresAt = result.ExpiresAt;
|
||||
_dockerComposeSnippet = GenerateDockerComposeSnippet(_generatedToken);
|
||||
Snackbar.Add("Token généré ! Copiez le docker-compose ci-dessous.", Severity.Warning);
|
||||
Snackbar.Add(Text["SiteDetail_TokenGenerated"], Severity.Warning);
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["SiteDetail_OperationFailed"], Severity.Error); }
|
||||
finally { _generating = false; }
|
||||
}
|
||||
|
||||
|
||||
@@ -3,18 +3,21 @@
|
||||
@layout MainLayout
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-1">
|
||||
<i class="fas fa-video mr-2"></i>
|
||||
Sites
|
||||
@Text["SitesPage_Title"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
Créez et gérez les sites pour connecter vos agents de surveillance.
|
||||
@Text["SitesPage_Description"]
|
||||
</MudText>
|
||||
|
||||
<div class="d-flex justify-space-between align-center mb-4">
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreate = true)">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> Nouveau site
|
||||
<MudIcon Icon="@Icons.Material.Filled.Add" Class="mr-1" /> @Text["SitesPage_NewSite"]
|
||||
</MudButton>
|
||||
</div>
|
||||
|
||||
@@ -25,9 +28,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des sites.</MudText>
|
||||
<MudText>@Text["SitesPage_LoadError"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadSites" 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["SitesPage_Retry"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -35,53 +38,53 @@ else
|
||||
{
|
||||
<MudTable Items="@_sites" Hover="true" Striped="true" Elevation="2">
|
||||
<HeaderContent>
|
||||
<MudTh>Nom</MudTh>
|
||||
<MudTh>Adresse</MudTh>
|
||||
<MudTh>Fuseau</MudTh>
|
||||
<MudTh>Statut</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["SitesPage_Name"]</MudTh>
|
||||
<MudTh>@Text["SitesPage_Address"]</MudTh>
|
||||
<MudTh>@Text["SitesPage_Timezone"]</MudTh>
|
||||
<MudTh>@Text["SitesPage_Status"]</MudTh>
|
||||
<MudTh>@Text["SitesPage_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Nom"><MudLink Href="@($"/sites/{context.Id}")">@context.Name</MudLink></MudTd>
|
||||
<MudTd DataLabel="Adresse">@context.Address</MudTd>
|
||||
<MudTd DataLabel="Fuseau">@context.Timezone</MudTd>
|
||||
<MudTd DataLabel="Statut">
|
||||
<StatusChip Text="@(context.Enabled ? "Actif" : "Inactif")"
|
||||
<MudTd DataLabel="@Text["SitesPage_Name"]"><MudLink Href="@($"/sites/{context.Id}")">@context.Name</MudLink></MudTd>
|
||||
<MudTd DataLabel="@Text["SitesPage_Address"]">@context.Address</MudTd>
|
||||
<MudTd DataLabel="@Text["SitesPage_Timezone"]">@context.Timezone</MudTd>
|
||||
<MudTd DataLabel="@Text["SitesPage_Status"]">
|
||||
<StatusChip Text="@(context.Enabled ? Text["SitesPage_Active"] : Text["SitesPage_Inactive"])"
|
||||
Color="@(context.Enabled ? Color.Success : Color.Default)"
|
||||
Icon="@(context.Enabled ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Cancel)" />
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTooltip Text="Modifier ce site">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" aria-label="Modifier le site"
|
||||
<MudTd DataLabel="@Text["SitesPage_Actions"]">
|
||||
<MudTooltip Text="@Text["SitesPage_EditTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" aria-label="@Text["SitesPage_EditTitle"]"
|
||||
OnClick="@(() => OpenEdit(context))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Installer un agent sur ce site">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Download" Size="Size.Small" Color="Color.Info" aria-label="Télécharger la configuration"
|
||||
<MudTooltip Text="@Text["SitesPage_InstallTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Download" Size="Size.Small" Color="Color.Info" aria-label="@Text["SitesPage_DownloadConfig"]"
|
||||
OnClick="@(() => CopyToken(context.Id, context.Name))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Supprimer ce site">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error" aria-label="Supprimer le site"
|
||||
<MudTooltip Text="@Text["SitesPage_DeleteTooltip"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error" aria-label="@Text["SitesPage_DeleteSite"]"
|
||||
OnClick="@(() => ConfirmDeleteSite(context.Id, context.Name))" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Align="Align.Center" Class="py-4">Aucun site.</MudText>
|
||||
<MudText Align="Align.Center" Class="py-4">@Text["SitesPage_NoSites"]</MudText>
|
||||
</NoRecordsContent>
|
||||
</MudTable>
|
||||
}
|
||||
|
||||
<MudOverlay Visible="@_showCreate" OnClick="@(() => _showCreate = false)" />
|
||||
<MudDialog @bind-Visible="_showCreate">
|
||||
<TitleContent><MudText Typo="Typo.h6">Nouveau site</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["SitesPage_NewSite"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_newName" Label="Nom du site *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_newName" Label="@Text["SitesPage_NameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true" />
|
||||
<MudTextField @bind-Value="_newAddress" Label="Adresse" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<MudTextField @bind-Value="_newAddress" Label="@Text["SitesPage_Address"]" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<TimezoneAutocomplete @bind-Value="_newTimezone" Class="mb-4"
|
||||
HelperText="Recherche par ville ou identifiant (défaut: UTC)" />
|
||||
<MudTextField @bind-Value="_newNtfyTopic" Label="Topic ntfy (optionnel)" Variant="Variant.Outlined" Class="mb-4"
|
||||
HelperText="Topic dédié pour les notifications de ce site. Vide = topic personnel de l'utilisateur." />
|
||||
HelperText="@Text["SitesPage_TimezoneHelper"]" />
|
||||
<MudTextField @bind-Value="_newNtfyTopic" Label="@Text["SitesPage_NtfyLabel"]" Variant="Variant.Outlined" Class="mb-4"
|
||||
HelperText="@Text["SitesPage_NtfyHelper"]" />
|
||||
@if (!string.IsNullOrEmpty(_creationError))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4">@_creationError</MudAlert>
|
||||
@@ -89,22 +92,22 @@ else
|
||||
@if (!string.IsNullOrEmpty(_createdToken))
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Class="mb-4">
|
||||
<strong>Token d'enregistrement :</strong><br />
|
||||
<strong>@Text["SitesPage_RegistrationToken"]</strong><br />
|
||||
<code class="hmd-code-block mt-2">
|
||||
@_createdToken
|
||||
</code>
|
||||
<MudText Typo="Typo.body2" Color="Color.Warning" Class="mt-2">
|
||||
⚠ Copiez ce token maintenant. Il ne sera plus affiché.
|
||||
⚠ @Text["SitesPage_TokenCopyWarning"]
|
||||
</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@CancelCreate">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@CancelCreate">@Text["SitesPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@ConfirmCreate"
|
||||
Disabled="@IsCreateDisabled">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
@(!string.IsNullOrEmpty(_createdToken) ? "Fermer" : "Créer")
|
||||
@(!string.IsNullOrEmpty(_createdToken) ? Text["SitesPage_Close"] : Text["SitesPage_Create"])
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -112,61 +115,61 @@ else
|
||||
@* ─── Confirm delete dialog ───────────────────────────────── *@
|
||||
<MudOverlay Visible="@_confirmDeleteShow" OnClick="@(() => _confirmDeleteShow = false)" />
|
||||
<MudDialog @bind-Visible="_confirmDeleteShow">
|
||||
<TitleContent><MudText Typo="Typo.h6">Confirmer la suppression</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["SitesPage_ConfirmDeleteTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudText>Supprimer le site "@_confirmDeleteName" ? Cette action est irréversible.</MudText>
|
||||
<MudText>@string.Format(Language.Culture, Text["SitesPage_DeleteConfirm"], _confirmDeleteName)</MudText>
|
||||
@if (_cascadeInfoLoading)
|
||||
{
|
||||
<MudProgressCircular Size="Size.Small" Class="mt-2" />
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="ml-2 d-inline">Chargement du périmètre...</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="ml-2 d-inline">@Text["SitesPage_CascadeLoading"]</MudText>
|
||||
}
|
||||
else if (_cascadeInfo is not null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Outlined" Class="mt-3">
|
||||
<MudText Typo="Typo.body2">
|
||||
Cette action supprimera également :
|
||||
@Text["SitesPage_DeleteCascadeDescription"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Class="mt-1">
|
||||
• <strong>@(_cascadeInfo.AgentCount)</strong> agent(s)
|
||||
• <strong>@_cascadeInfo.AgentCount</strong> @Text["SitesPage_AgentCount"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2">
|
||||
• <strong>@(_cascadeInfo.CameraCount)</strong> caméra(s)
|
||||
• <strong>@_cascadeInfo.CameraCount</strong> @Text["SitesPage_CameraCount"]
|
||||
</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">@Text["SitesPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@ExecuteDelete"
|
||||
Disabled="@_cascadeInfoLoading">Supprimer</MudButton>
|
||||
Disabled="@_cascadeInfoLoading">@Text["SitesPage_Delete"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@* ─── Edit dialog ───────────────────────────────────────────── *@
|
||||
<MudOverlay Visible="@_showEdit" OnClick="@(() => _showEdit = false)" />
|
||||
<MudDialog @bind-Visible="_showEdit">
|
||||
<TitleContent><MudText Typo="Typo.h6">Modifier le site</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["SitesPage_EditTitle"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_editName" Label="Nom du site *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_editName" Label="@Text["SitesPage_NameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true" />
|
||||
<MudTextField @bind-Value="_editAddress" Label="Adresse" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<MudTextField @bind-Value="_editAddress" Label="@Text["SitesPage_Address"]" Variant="Variant.Outlined" Class="mb-4" />
|
||||
<TimezoneAutocomplete @bind-Value="_editTimezone" Class="mb-4"
|
||||
HelperText="Recherche par ville ou identifiant (défaut: UTC)" />
|
||||
<MudTextField @bind-Value="_editNtfyTopic" Label="Topic ntfy (optionnel)" Variant="Variant.Outlined" Class="mb-4"
|
||||
HelperText="Topic dédié pour les notifications de ce site. Vide = topic personnel de l'utilisateur." />
|
||||
HelperText="@Text["SitesPage_TimezoneHelper"]" />
|
||||
<MudTextField @bind-Value="_editNtfyTopic" Label="@Text["SitesPage_NtfyLabel"]" Variant="Variant.Outlined" Class="mb-4"
|
||||
HelperText="@Text["SitesPage_NtfyHelper"]" />
|
||||
<MudSwitch T="bool" @bind-Value="_editAutoUpdate" Color="Color.Primary" Class="mb-4"
|
||||
Label="Mises à jour automatiques des agents"
|
||||
HelperText="Autoriser les agents de ce site à se mettre à jour automatiquement depuis le serveur central." />
|
||||
Label="@Text["SitesPage_AutoUpdate"]"
|
||||
HelperText="@Text["SitesPage_AutoUpdateHelper"]" />
|
||||
@if (!string.IsNullOrEmpty(_editError))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4">@_editError</MudAlert>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showEdit = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showEdit = false)">@Text["SitesPage_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveEdit" Disabled="@_editing">
|
||||
@if (_editing) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Enregistrer
|
||||
@Text["SitesPage_Save"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -175,13 +178,13 @@ else
|
||||
<MudOverlay Visible="@_showInstall" OnClick="@(() => _showInstall = false)" />
|
||||
<MudDialog @bind-Visible="_showInstall" Options="new DialogOptions { MaxWidth = MaxWidth.Large, FullWidth = true }">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Installer un agent — @_installSiteName</MudText>
|
||||
<MudText Typo="Typo.h6">@string.Format(Language.Culture, Text["SitesPage_InstallTitle"], _installSiteName)</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@if (_tokenLoading)
|
||||
{
|
||||
<MudProgressCircular Indeterminate="true" Class="mb-4" />
|
||||
<MudText>Génération du token...</MudText>
|
||||
<MudText>@Text["SitesPage_TokenGenerating"]</MudText>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_tokenError))
|
||||
{
|
||||
@@ -191,7 +194,7 @@ else
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="mb-4">
|
||||
<MudText Typo="Typo.body2" Class="mb-2">
|
||||
Ce token expire dans 24h et ne sera plus affiché.
|
||||
@Text["SitesPage_TokenExpiresWarning"]
|
||||
</MudText>
|
||||
<code class="hmd-code-block">
|
||||
@_generatedToken
|
||||
@@ -202,7 +205,7 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showInstall = false)">Fermer</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showInstall = false)">@Text["SitesPage_Close"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@@ -210,13 +213,13 @@ else
|
||||
<MudOverlay Visible="@_showTokenDialog" OnClick="@(() => _showTokenDialog = false)" />
|
||||
<MudDialog @bind-Visible="_showTokenDialog">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">Token d'enregistrement</MudText>
|
||||
<MudText Typo="Typo.h6">@Text["SitesPage_RegistrationToken"]</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
@if (_tokenLoading)
|
||||
{
|
||||
<MudProgressCircular Indeterminate="true" Class="mb-4" />
|
||||
<MudText>Génération du token...</MudText>
|
||||
<MudText>@Text["SitesPage_TokenGenerating"]</MudText>
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_tokenError))
|
||||
{
|
||||
@@ -226,13 +229,13 @@ else
|
||||
{
|
||||
<MudAlert Severity="Severity.Info">
|
||||
<MudText Typo="Typo.body2" Class="mb-2">
|
||||
Utilisez ce token pour enregistrer un agent sur ce site :
|
||||
@Text["SitesPage_TokenUsage"]
|
||||
</MudText>
|
||||
<code class="hmd-code-block mt-2">
|
||||
@_generatedToken
|
||||
</code>
|
||||
<MudText Typo="Typo.body2" Color="Color.Warning" Class="mt-2">
|
||||
⚠ Ce token expire dans 24h. Copiez-le maintenant.
|
||||
⚠ @Text["SitesPage_TokenExpiresCopy"]
|
||||
</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -240,7 +243,7 @@ else
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary"
|
||||
OnClick="@(() => _showTokenDialog = false)">
|
||||
Fermer
|
||||
@Text["Close"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -292,7 +295,15 @@ else
|
||||
return "https://heimdall.tordais.cc";
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadSites();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadSites();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
|
||||
private async Task LoadSites()
|
||||
{
|
||||
@@ -305,7 +316,7 @@ else
|
||||
}
|
||||
catch {
|
||||
_error = true;
|
||||
Snackbar.Add(UiErrors.OperationFailed(), Severity.Error);
|
||||
Snackbar.Add(Text["SitesPage_OperationFailed"], Severity.Error);
|
||||
}
|
||||
finally { _loading = false; }
|
||||
}
|
||||
@@ -359,7 +370,7 @@ else
|
||||
|
||||
private async Task ConfirmCreate()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_newName)) { _creationError = "Le nom est requis"; return; }
|
||||
if (string.IsNullOrWhiteSpace(_newName)) { _creationError = Text["SitesPage_NameRequiredError"]; return; }
|
||||
_saving = true;
|
||||
_creationError = "";
|
||||
try
|
||||
@@ -368,15 +379,15 @@ else
|
||||
if (!result.Succeeded)
|
||||
{
|
||||
_creationError = string.IsNullOrWhiteSpace(result.ErrorMessage)
|
||||
? UiErrors.OperationFailed("la création du site")
|
||||
? Text["SitesPage_CreateError"]
|
||||
: result.ErrorMessage;
|
||||
return;
|
||||
}
|
||||
_createdToken = result.Data?.RegistrationToken ?? "Token non disponible";
|
||||
Snackbar.Add("Site créé avec succès", Severity.Success);
|
||||
_createdToken = result.Data?.RegistrationToken ?? Text["SitesPage_TokenUnavailable"];
|
||||
Snackbar.Add(Text["SitesPage_Created"], Severity.Success);
|
||||
await LoadSites();
|
||||
}
|
||||
catch { _creationError = UiErrors.OperationFailed(); }
|
||||
catch { _creationError = Text["SitesPage_OperationFailed"]; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
@@ -395,16 +406,16 @@ else
|
||||
var result = await Api.GenerateSiteTokenAsync(siteId);
|
||||
if (result is null)
|
||||
{
|
||||
_tokenError = "Erreur lors de la génération du token";
|
||||
_tokenError = Text["SitesPage_TokenGenerationError"];
|
||||
}
|
||||
else
|
||||
{
|
||||
_generatedToken = result.Token;
|
||||
Snackbar.Add("Token généré avec succès", Severity.Success);
|
||||
Snackbar.Add(Text["SitesPage_TokenGenerated"], Severity.Success);
|
||||
}
|
||||
}
|
||||
catch {
|
||||
_tokenError = UiErrors.OperationFailed();
|
||||
_tokenError = Text["SitesPage_OperationFailed"];
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -426,18 +437,18 @@ else
|
||||
|
||||
private async Task SaveEdit()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_editName)) { _editError = "Le nom est requis"; return; }
|
||||
if (string.IsNullOrWhiteSpace(_editName)) { _editError = Text["SitesPage_NameRequiredError"]; return; }
|
||||
_editing = true;
|
||||
_editError = "";
|
||||
try
|
||||
{
|
||||
var ok = await Api.UpdateSiteAsync(_editId, _editName, _editAddress, _editTimezone, _editNtfyTopic, _editAutoUpdate);
|
||||
if (!ok) { _editError = "Erreur lors de la mise à jour"; return; }
|
||||
Snackbar.Add("Site modifié avec succès", Severity.Success);
|
||||
if (!ok) { _editError = Text["SitesPage_UpdateError"]; return; }
|
||||
Snackbar.Add(Text["SitesPage_Updated"], Severity.Success);
|
||||
_showEdit = false;
|
||||
await LoadSites();
|
||||
}
|
||||
catch { _editError = UiErrors.OperationFailed(); }
|
||||
catch { _editError = Text["SitesPage_OperationFailed"]; }
|
||||
finally { _editing = false; }
|
||||
}
|
||||
|
||||
@@ -445,10 +456,10 @@ else
|
||||
{
|
||||
if (await Api.DeleteSiteAsync(id))
|
||||
{
|
||||
Snackbar.Add($"Site \"{name}\" supprimé", Severity.Success);
|
||||
Snackbar.Add(string.Format(Language.Culture, Text["SitesPage_Deleted"], name), Severity.Success);
|
||||
await LoadSites();
|
||||
}
|
||||
else
|
||||
Snackbar.Add("Erreur lors de la suppression", Severity.Error);
|
||||
Snackbar.Add(Text["SitesPage_DeleteError"], Severity.Error);
|
||||
}
|
||||
}
|
||||
@@ -5,29 +5,31 @@
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
@inject UiLanguageService Language
|
||||
@inject UiText Text
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-images mr-2"></i>
|
||||
Galerie de snapshots
|
||||
@Text["SnapshotsPage_Title"]
|
||||
</MudText>
|
||||
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4">
|
||||
<MudToolBar>
|
||||
<MudTextField @bind-Value="_search" Label="Rechercher (label ou caméra)" Variant="Variant.Outlined"
|
||||
Class="mr-2" style="min-width:300px;" Placeholder="ex: Personne, Visage..." />
|
||||
<MudSelect T="string" @bind-Value="_type" Label="Type" Variant="Variant.Outlined" Clearable="true" Class="mr-2" Style="min-width:180px;">
|
||||
<MudSelectItem Value="@nameof(EventType.MotionDetected)">Mouvement</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.PersonDetected)">Personne</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.VehicleDetected)">Véhicule</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.UnknownPerson)">Personne inconnue</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.FaceRecognized)">Visage reconnu</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.LicensePlateDetected)">Plaque détectée</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.CameraOffline)">Caméra hors ligne</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.CameraOnline)">Caméra en ligne</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.ManualSnapshot)">Capture manuelle</MudSelectItem>
|
||||
<MudTextField @bind-Value="_search" Label="@Text["SnapshotsPage_SearchLabel"]" Variant="Variant.Outlined"
|
||||
Class="mr-2" style="min-width:300px;" Placeholder="@Text["SnapshotsPage_SearchPlaceholder"]" />
|
||||
<MudSelect T="string" @bind-Value="_type" Label="@Text["SnapshotsPage_Type"]" Variant="Variant.Outlined" Clearable="true" Class="mr-2" Style="min-width:180px;">
|
||||
<MudSelectItem Value="@nameof(EventType.MotionDetected)">@Text["SnapshotsPage_Motion"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.PersonDetected)">@Text["SnapshotsPage_Person"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.VehicleDetected)">@Text["SnapshotsPage_Vehicle"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.UnknownPerson)">@Text["SnapshotsPage_UnknownPerson"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.FaceRecognized)">@Text["SnapshotsPage_FaceRecognized"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.LicensePlateDetected)">@Text["SnapshotsPage_LicensePlate"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.CameraOffline)">@Text["SnapshotsPage_CameraOffline"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.CameraOnline)">@Text["SnapshotsPage_CameraOnline"]</MudSelectItem>
|
||||
<MudSelectItem Value="@nameof(EventType.ManualSnapshot)">@Text["SnapshotsPage_ManualSnapshot"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@ApplyFilters">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Search" Class="mr-1" Size="Size.Small" /> Charger
|
||||
<MudIcon Icon="@Icons.Material.Filled.Search" Class="mr-1" Size="Size.Small" /> @Text["SnapshotsPage_Load"]
|
||||
</MudButton>
|
||||
</MudToolBar>
|
||||
</MudPaper>
|
||||
@@ -38,37 +40,37 @@
|
||||
}
|
||||
else if (_snapshots is null || _snapshots.Count == 0)
|
||||
{
|
||||
<MudAlert Severity="Severity.Info" Class="mt-4">Aucun snapshot trouvé.</MudAlert>
|
||||
<MudAlert Severity="Severity.Info" Class="mt-4">@Text["SnapshotsPage_Empty"]</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@_snapshots.Count snapshot(s) trouvé(s)
|
||||
@string.Format(Text["SnapshotsPage_CountFound"], _snapshots.Count)
|
||||
</MudText>
|
||||
|
||||
<div class="d-flex flex-wrap" style="gap: 12px;">
|
||||
@foreach (var ev in _snapshots)
|
||||
{
|
||||
<MudPaper Elevation="2" Class="pa-2" Style="border-radius: 8px; width: 240px; cursor: pointer;"
|
||||
@key="ev.Id">
|
||||
<div @onclick="() => OpenLightbox(ev)" role="button" tabindex="0"
|
||||
@key="ev.Id">
|
||||
<div @onclick="() => OpenLightbox(ev)" role="button" tabindex="0" aria-label="@Text["SnapshotsPage_OpenSnapshot"]"
|
||||
style="cursor: pointer;">
|
||||
<img src="@(ev.SnapshotThumbUrl ?? ev.SnapshotUrl)" alt="Snapshot"
|
||||
<img src="@(ev.SnapshotThumbUrl ?? ev.SnapshotUrl)" alt="@Text["SnapshotsPage_SnapshotAlt"]"
|
||||
style="width:100%;height:160px;object-fit:cover;border-radius:4px;" />
|
||||
<MudText Typo="Typo.caption" Class="mt-1" Color="Color.Secondary">
|
||||
@FormatEventType(ev.Type) · @ev.Confidence.ToString("P0")
|
||||
@FormatEventType(ev.Type) · @ev.Confidence.ToString("P0", Language.Culture)
|
||||
</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">
|
||||
@ev.OccurredAt.ToLocalTime().ToString("g")
|
||||
@ev.OccurredAt.ToLocalTime().ToString("g", Language.Culture)
|
||||
</MudText>
|
||||
</div>
|
||||
</MudPaper>
|
||||
}
|
||||
</div>
|
||||
<div class="d-flex align-center justify-center mt-4" style="gap:16px;">
|
||||
<MudButton Disabled="@(_page <= 1)" OnClick="@(() => GoToPage(_page - 1))">Précédent</MudButton>
|
||||
<MudText Typo="Typo.body2">Page @_page / @_totalPages · @_total snapshot(s)</MudText>
|
||||
<MudButton Disabled="@(_page >= _totalPages)" OnClick="@(() => GoToPage(_page + 1))">Suivant</MudButton>
|
||||
<MudButton Disabled="@(_page <= 1)" OnClick="@(() => GoToPage(_page - 1))">@Text["SnapshotsPage_Previous"]</MudButton>
|
||||
<MudText Typo="Typo.body2">@string.Format(Text["SnapshotsPage_PageInfo"], _page, _totalPages, _total)</MudText>
|
||||
<MudButton Disabled="@(_page >= _totalPages)" OnClick="@(() => GoToPage(_page + 1))">@Text["SnapshotsPage_Next"]</MudButton>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -80,22 +82,22 @@ else
|
||||
<MudDialog @bind-Visible="_showLightbox" Options="_lightboxOptions">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">
|
||||
@FormatEventType(_lightboxEvent!.Type) · @_lightboxEvent!.OccurredAt.ToLocalTime().ToString("g")
|
||||
<MudLink Href="@($"/cameras/{_lightboxEvent!.CameraId}")" Typo="Typo.caption" Class="ml-4">Voir la caméra</MudLink>
|
||||
@FormatEventType(_lightboxEvent!.Type) · @_lightboxEvent!.OccurredAt.ToLocalTime().ToString("g", Language.Culture)
|
||||
<MudLink Href="@($"/cameras/{_lightboxEvent!.CameraId}")" Typo="Typo.caption" Class="ml-4">@Text["SnapshotsPage_ViewCamera"]</MudLink>
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<img src="@_lightboxEvent!.SnapshotUrl" alt="Snapshot" style="width:100%;height:auto;" class="rounded-lg" />
|
||||
<img src="@_lightboxEvent!.SnapshotUrl" alt="@Text["SnapshotsPage_SnapshotAlt"]" style="width:100%;height:auto;" class="rounded-lg" />
|
||||
@if (!string.IsNullOrEmpty(_lightboxEvent!.Label))
|
||||
{
|
||||
<MudText Color="Color.Primary" Typo="Typo.body2" Class="mt-2">@_lightboxEvent!.Label</MudText>
|
||||
}
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-2">
|
||||
Confiance : @_lightboxEvent!.Confidence.ToString("P0") · ID : @_lightboxEvent!.Id.ToString()[..8]
|
||||
@string.Format(Text["SnapshotsPage_ConfidenceAndId"], _lightboxEvent!.Confidence.ToString("P0", Language.Culture), _lightboxEvent!.Id.ToString()[..8])
|
||||
</MudText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="@(() => _showLightbox = false)">Fermer</MudButton>
|
||||
<MudButton OnClick="@(() => _showLightbox = false)">@Text["SnapshotsPage_Close"]</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
@@ -121,7 +123,11 @@ else
|
||||
CloseButton = true
|
||||
};
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadSnapshots();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadSnapshots();
|
||||
}
|
||||
|
||||
private async Task LoadSnapshots()
|
||||
{
|
||||
@@ -137,11 +143,18 @@ else
|
||||
_totalPages = Math.Max(1, (int)Math.Ceiling(_total / (double)PageSize));
|
||||
}
|
||||
catch (OperationCanceledException) when (_cts.IsCancellationRequested) { }
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
catch { Snackbar.Add(Text["SnapshotsPage_LoadFailed"], Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
}
|
||||
|
||||
public void Dispose() => _cts.Cancel();
|
||||
public void Dispose()
|
||||
{
|
||||
Language.LanguageChanged -= OnLanguageChanged;
|
||||
_cts.Cancel();
|
||||
_cts.Dispose();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
private async Task GoToPage(int page)
|
||||
{
|
||||
@@ -161,13 +174,17 @@ else
|
||||
_showLightbox = true;
|
||||
}
|
||||
|
||||
private static string FormatEventType(string type) => type switch
|
||||
private string FormatEventType(string type) => type switch
|
||||
{
|
||||
"ManualSnapshot" => "Capture manuelle",
|
||||
"MotionDetected" => "Mouvement",
|
||||
"PersonDetected" => "Personne",
|
||||
"VehicleDetected" => "Véhicule",
|
||||
"FaceRecognized" => "Visage",
|
||||
"ManualSnapshot" => Text["SnapshotsPage_ManualSnapshot"],
|
||||
"MotionDetected" => Text["SnapshotsPage_Motion"],
|
||||
"PersonDetected" => Text["SnapshotsPage_Person"],
|
||||
"VehicleDetected" => Text["SnapshotsPage_Vehicle"],
|
||||
"FaceRecognized" => Text["SnapshotsPage_FaceRecognized"],
|
||||
"UnknownPerson" => Text["SnapshotsPage_UnknownPerson"],
|
||||
"LicensePlateDetected" => Text["SnapshotsPage_LicensePlate"],
|
||||
"CameraOffline" => Text["SnapshotsPage_CameraOffline"],
|
||||
"CameraOnline" => Text["SnapshotsPage_CameraOnline"],
|
||||
_ => type
|
||||
};
|
||||
}
|
||||
@@ -3,16 +3,19 @@
|
||||
@layout MainLayout
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject UiText Text
|
||||
@inject UiLanguageService Language
|
||||
@implements IDisposable
|
||||
@using Heimdall.Web.Components.Pages
|
||||
@using Heimdall.Application.DTOs
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<i class="fas fa-users mr-2"></i>
|
||||
Utilisateurs
|
||||
@Text["UsersPage_Title"]
|
||||
</MudText>
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@(() => _showCreate = true)" Class="mb-4">
|
||||
<MudIcon Icon="@Icons.Material.Filled.PersonAdd" Class="mr-1" /> Nouvel utilisateur
|
||||
<MudIcon Icon="@Icons.Material.Filled.PersonAdd" Class="mr-1" /> @Text["UsersPage_NouvelUtilisateur"]
|
||||
</MudButton>
|
||||
|
||||
@if (_loading)
|
||||
@@ -22,9 +25,9 @@
|
||||
else if (_error)
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4" Variant="Variant.Filled">
|
||||
<MudText>Erreur lors du chargement des utilisateurs.</MudText>
|
||||
<MudText>@Text["UsersPage_ErreurLorsDuChargementDesUtilisateurs"]</MudText>
|
||||
<MudButton Variant="Variant.Text" Color="Color.Inherit" OnClick="@LoadUsers" 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["UsersPage_Reessayer"]
|
||||
</MudButton>
|
||||
</MudAlert>
|
||||
}
|
||||
@@ -32,17 +35,17 @@ else
|
||||
{
|
||||
<MudTable Items="@_users" Hover="true" Striped="true" Elevation="2">
|
||||
<HeaderContent>
|
||||
<MudTh>Nom</MudTh>
|
||||
<MudTh>Email</MudTh>
|
||||
<MudTh>Rôles</MudTh>
|
||||
<MudTh>Statut</MudTh>
|
||||
<MudTh>Inscrit le</MudTh>
|
||||
<MudTh>Actions</MudTh>
|
||||
<MudTh>@Text["UsersPage_Nom"]</MudTh>
|
||||
<MudTh>@Text["UsersPage_EmailLabel"]</MudTh>
|
||||
<MudTh>@Text["UsersPage_Roles"]</MudTh>
|
||||
<MudTh>@Text["UsersPage_Statut"]</MudTh>
|
||||
<MudTh>@Text["UsersPage_InscritLe"]</MudTh>
|
||||
<MudTh>@Text["UsersPage_Actions"]</MudTh>
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Nom">@context.DisplayName</MudTd>
|
||||
<MudTd DataLabel="Email">@context.Email</MudTd>
|
||||
<MudTd DataLabel="Rôles">
|
||||
<MudTd DataLabel="@Text["UsersPage_Nom"]">@context.DisplayName</MudTd>
|
||||
<MudTd DataLabel="@Text["UsersPage_EmailLabel"]">@context.Email</MudTd>
|
||||
<MudTd DataLabel="@Text["UsersPage_Roles"]">
|
||||
@foreach (var r in context.Roles ?? [])
|
||||
{
|
||||
<MudText Typo="Typo.body2" Class="d-inline mr-1" @key="r"
|
||||
@@ -51,62 +54,62 @@ else
|
||||
</MudText>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Statut">
|
||||
<MudTd DataLabel="@Text["UsersPage_Statut"]">
|
||||
@if (context.IsLockedOut)
|
||||
{
|
||||
<MudText Color="Color.Error" Typo="Typo.body2">🔒 Verrouillé</MudText>
|
||||
<MudText Color="Color.Error" Typo="Typo.body2">🔒 @Text["UsersPage_Verrouille"]</MudText>
|
||||
}
|
||||
else if (!context.EmailConfirmed)
|
||||
{
|
||||
<MudText Color="Color.Warning" Typo="Typo.body2">⏳ En attente</MudText>
|
||||
<MudText Color="Color.Warning" Typo="Typo.body2">@Text["UsersPage_EnAttente"]</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudText Color="Color.Success" Typo="Typo.body2">✓ Actif</MudText>
|
||||
<MudText Color="Color.Success" Typo="Typo.body2">@Text["UsersPage_Actif"]</MudText>
|
||||
}
|
||||
</MudTd>
|
||||
<MudTd DataLabel="Inscrit le">@context.CreatedAt.ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Actions">
|
||||
<MudTd DataLabel="@Text["UsersPage_InscritLe"]">@context.CreatedAt.ToString("g", Language.Culture)</MudTd>
|
||||
<MudTd DataLabel="@Text["UsersPage_Actions"]">
|
||||
@if (!context.EmailConfirmed)
|
||||
{
|
||||
<MudTooltip Text="Confirmer l’email">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.MarkEmailRead" Size="Size.Small" aria-label="Confirmer l’email"
|
||||
<MudTooltip Text="@Text["UsersPage_ConfirmerLemail"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.MarkEmailRead" Size="Size.Small" aria-label="@Text["UsersPage_ConfirmerLemail"]"
|
||||
Disabled="@(_confirmingEmailId == context.Id)"
|
||||
OnClick="@(() => ConfirmUserEmail(context))" />
|
||||
</MudTooltip>
|
||||
}
|
||||
<MudTooltip Text="Gérer l'accès aux caméras">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.VideoLibrary" Size="Size.Small" aria-label="Gérer les caméras"
|
||||
<MudTooltip Text="@Text["UsersPage_GererLAccesAuxCameras"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.VideoLibrary" Size="Size.Small" aria-label="@Text["UsersPage_GererLesCameras"]"
|
||||
OnClick="@(() => OpenCameraAccess(context))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Modifier cet utilisateur (rôles, statut, mot de passe)">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" aria-label="Modifier l'utilisateur"
|
||||
<MudTooltip Text="@Text["UsersPage_ModifierCetUtilisateurRolesStatutMotDePasse"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Edit" Size="Size.Small" aria-label="@Text["UsersPage_ModifierLUtilisateur"]"
|
||||
OnClick="@(() => OpenEdit(context))" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Supprimer cet utilisateur">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" aria-label="Supprimer l'utilisateur"
|
||||
<MudTooltip Text="@Text["UsersPage_SupprimerCetUtilisateur"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" aria-label="@Text["UsersPage_SupprimerLUtilisateur"]"
|
||||
Color="Color.Error"
|
||||
OnClick="@(() => OpenDeleteConfirm(context))" />
|
||||
</MudTooltip>
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
<NoRecordsContent>
|
||||
<MudText Align="Align.Center" Class="py-4">Aucun utilisateur</MudText>
|
||||
<MudText Align="Align.Center" Class="py-4">@Text["UsersPage_AucunUtilisateur"]</MudText>
|
||||
</NoRecordsContent>
|
||||
</MudTable>
|
||||
|
||||
@* Pagination *@
|
||||
<MudPaper Class="d-flex align-center pa-4 mt-4">
|
||||
<MudText Typo="Typo.body2" Class="mr-4">
|
||||
Page @_page sur @_totalPages (@_total utilisateurs)
|
||||
@string.Format(Language.Culture, Text["UsersPage_Pagination"], _page, _totalPages, _total)
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Class="mr-2"
|
||||
Disabled="@(_page <= 1)" OnClick="@(() => GoToPage(_page - 1))">
|
||||
← Précédent
|
||||
@Text["UsersPage_Precedent"]
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small"
|
||||
Disabled="@(_page >= _totalPages)" OnClick="@(() => GoToPage(_page + 1))">
|
||||
Suivant →
|
||||
@Text["UsersPage_Suivant"]
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
}
|
||||
@@ -114,23 +117,23 @@ else
|
||||
@* Dialog: Créer un utilisateur *@
|
||||
<MudOverlay Visible="@_showCreate" OnClick="@(() => _showCreate = false)" />
|
||||
<MudDialog @bind-Visible="_showCreate">
|
||||
<TitleContent><MudText Typo="Typo.h6">Nouvel utilisateur</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["UsersPage_NouvelUtilisateur"]</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_createEmail" Label="Email *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_createEmail" Label="@Text["UsersPage_EmailRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true"
|
||||
Autocomplete="email" />
|
||||
<MudTextField @bind-Value="_createDisplayName" Label="Nom d'affichage *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_createDisplayName" Label="@Text["UsersPage_DisplayNameRequired"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true"
|
||||
Autocomplete="name" />
|
||||
<MudTextField @bind-Value="_createPassword" Label="Mot de passe *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_createPassword" Label="@Text["UsersPage_MotDePasse"]" Variant="Variant.Outlined"
|
||||
InputType="InputType.Password" Class="mb-4" Required="true" Immediate="true"
|
||||
HelperText="Minimum 12 caractères"
|
||||
HelperText="@Text["UsersPage_Minimum12Caracteres"]"
|
||||
Autocomplete="new-password" />
|
||||
<MudText Typo="Typo.body2" Class="mb-2">Rôle</MudText>
|
||||
<MudSelect @bind-Value="_createRole" Label="Rôle" Variant="Variant.Outlined" Class="mb-4">
|
||||
<MudSelectItem Value="@("Viewer")">Viewer</MudSelectItem>
|
||||
<MudSelectItem Value="@("Supervisor")">Supervisor</MudSelectItem>
|
||||
<MudSelectItem Value="@("Admin")">Admin</MudSelectItem>
|
||||
<MudText Typo="Typo.body2" Class="mb-2">@Text["UsersPage_Role"]</MudText>
|
||||
<MudSelect @bind-Value="_createRole" Label="@Text["UsersPage_Role"]" Variant="Variant.Outlined" Class="mb-4">
|
||||
<MudSelectItem Value="@("Viewer")">@Text["UsersPage_Viewer"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Supervisor")">@Text["UsersPage_Supervisor"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("Admin")">@Text["UsersPage_Admin"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
@if (!string.IsNullOrEmpty(_createError))
|
||||
{
|
||||
@@ -138,10 +141,10 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showCreate = false)">@Text["UsersPage_Annuler"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@CreateUser" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Créer
|
||||
@Text["UsersPage_Creer"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -149,104 +152,104 @@ else
|
||||
@* Dialog: Modifier un utilisateur *@
|
||||
<MudOverlay Visible="@_showEdit" OnClick="@CloseEdit" />
|
||||
<MudDialog Visible="@_showEdit" VisibleChanged="@OnEditVisibilityChanged" Class="edit-user-dialog">
|
||||
<TitleContent><MudText Typo="Typo.h6">Utilisateur : @_editUser!.DisplayName</MudText></TitleContent>
|
||||
<TitleContent><MudText Typo="Typo.h6">@Text["UsersPage_Utilisateur"] @_editUser!.DisplayName</MudText></TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_editEmail" Label="Adresse email" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_editEmail" Label="@Text["UsersPage_AdresseEmail"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" />
|
||||
|
||||
@* Section: Informations *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">Informations</MudText>
|
||||
<MudTextField @bind-Value="_editDisplayName" Label="Nom d'affichage" Variant="Variant.Outlined"
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">@Text["UsersPage_Informations"]</MudText>
|
||||
<MudTextField @bind-Value="_editDisplayName" Label="@Text["UsersPage_NomDAffichage"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" />
|
||||
<MudTextField @bind-Value="_editTheme" Label="Thème" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" HelperText="Light, Dark ou Auto" />
|
||||
<MudSelect @bind-Value="_editLanguage" Label="Langue" Variant="Variant.Outlined" Class="mb-4" Immediate="true">
|
||||
<MudSelectItem Value="@("fr")">Français</MudSelectItem>
|
||||
<MudSelectItem Value="@("en")">English</MudSelectItem>
|
||||
<MudTextField @bind-Value="_editTheme" Label="@Text["UsersPage_Theme"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Immediate="true" HelperText="@Text["UsersPage_LightDarkOuAuto"]" />
|
||||
<MudSelect @bind-Value="_editLanguage" Label="@Text["UsersPage_Langue"]" Variant="Variant.Outlined" Class="mb-4" Immediate="true">
|
||||
<MudSelectItem Value="@("fr")">@Text["UsersPage_Francais"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("en")">@Text["UsersPage_English"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
|
||||
@* Section: Rôles (multi-sélection) *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">Rôles</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">@Text["UsersPage_Roles"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-2">
|
||||
Un utilisateur peut avoir plusieurs rôles
|
||||
@Text["UsersPage_UnUtilisateurPeutAvoirPlusieursRoles"]
|
||||
</MudText>
|
||||
<MudPaper Class="pa-4 mb-4 user-section-card" Elevation="0">
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox T="bool" @bind-Value="_editRoleAdmin" Color="Color.Tertiary" Label="Admin — accès complet à toutes les fonctionnalités" />
|
||||
<MudCheckBox T="bool" @bind-Value="_editRoleAdmin" Color="Color.Tertiary" Label="@Text["UsersPage_AdminAccesCompletAToutesLesFonctionnalites"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox T="bool" @bind-Value="_editRoleSupervisor" Color="Color.Secondary" Label="Supervisor — gestion des sites, caméras et événements" />
|
||||
<MudCheckBox T="bool" @bind-Value="_editRoleSupervisor" Color="Color.Secondary" Label="@Text["UsersPage_SupervisorGestionDesSitesCamerasEtEvenements"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudCheckBox T="bool" @bind-Value="_editRoleViewer" Color="Color.Primary" Label="Viewer — consultation en lecture seule" />
|
||||
<MudCheckBox T="bool" @bind-Value="_editRoleViewer" Color="Color.Primary" Label="@Text["UsersPage_ViewerConsultationEnLectureSeule"]" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudPaper>
|
||||
|
||||
@* Section: Statut du compte *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">Statut du compte</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">@Text["UsersPage_StatutDuCompte"]</MudText>
|
||||
<MudPaper Class="pa-4 mb-4 user-section-card" Elevation="0">
|
||||
<MudGrid>
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">2FA</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["UsersPage_2Fa"]</MudText>
|
||||
<MudText Typo="Typo.body1">
|
||||
<MudIcon Icon="@(_editUser!.TwoFactorEnabled ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Cancel)"
|
||||
Color="@(_editUser!.TwoFactorEnabled ? Color.Success : Color.Default)" Size="Size.Small" />
|
||||
@(_editUser!.TwoFactorEnabled ? "Activé" : "Désactivé")
|
||||
@(_editUser!.TwoFactorEnabled ? Text["UsersPage_Active"] : Text["UsersPage_Desactive"])
|
||||
</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Email confirmé</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["UsersPage_EmailConfirme"]</MudText>
|
||||
<MudText Typo="Typo.body1">
|
||||
<MudIcon Icon="@(_editUser!.EmailConfirmed ? Icons.Material.Filled.CheckCircle : Icons.Material.Filled.Cancel)"
|
||||
Color="@(_editUser!.EmailConfirmed ? Color.Success : Color.Default)" Size="Size.Small" />
|
||||
@(_editUser!.EmailConfirmed ? "Oui" : "Non")
|
||||
@(_editUser!.EmailConfirmed ? Text["UsersPage_Oui"] : Text["UsersPage_Non"])
|
||||
</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Tentatives échouées</MudText>
|
||||
<MudText Typo="Typo.body1">@_editUser!.AccessFailedCount / 5</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["UsersPage_TentativesEchouees"]</MudText>
|
||||
<MudText Typo="Typo.body1">@_editUser!.AccessFailedCount.ToString(Language.Culture) / 5</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="6" Class="mt-2">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Verrouillé</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">@Text["UsersPage_Verrouille"]</MudText>
|
||||
<MudText Typo="Typo.body1" Color="@(_editUser!.IsLockedOut ? Color.Error : Color.Success)">
|
||||
@(_editUser!.IsLockedOut ? "Oui" : "Non")
|
||||
@(_editUser!.IsLockedOut ? Text["UsersPage_Oui"] : Text["UsersPage_Non"])
|
||||
</MudText>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudPaper>
|
||||
|
||||
@* Actions du compte *@
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">Actions</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2 mt-4">@Text["UsersPage_Actions"]</MudText>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Warning" FullWidth="true" Class="mb-2"
|
||||
OnClick="@ResetPassword">
|
||||
<MudIcon Icon="@Icons.Material.Filled.LockReset" Class="mr-1" /> Réinitialiser le mot de passe
|
||||
<MudIcon Icon="@Icons.Material.Filled.LockReset" Class="mr-1" /> @Text["UsersPage_ReinitialiserLeMotDePasse"]
|
||||
</MudButton>
|
||||
@if (_editUser!.IsLockedOut)
|
||||
{
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Success" FullWidth="true" Class="mb-2"
|
||||
OnClick="@UnlockUser">
|
||||
<MudIcon Icon="@Icons.Material.Filled.LockOpen" Class="mr-1" /> Déverrouiller le compte
|
||||
<MudIcon Icon="@Icons.Material.Filled.LockOpen" Class="mr-1" /> @Text["UsersPage_DeverrouillerLeCompte"]
|
||||
</MudButton>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Error" FullWidth="true" Class="mb-2"
|
||||
OnClick="@LockUser">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Lock" Class="mr-1" /> Verrouiller le compte
|
||||
<MudIcon Icon="@Icons.Material.Filled.Lock" Class="mr-1" /> @Text["UsersPage_VerrouillerLeCompte"]
|
||||
</MudButton>
|
||||
}
|
||||
|
||||
<MudDivider Class="my-4" />
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">Accès aux caméras</MudText>
|
||||
<MudText Typo="Typo.subtitle1" Class="mb-2">@Text["UsersPage_AccesAuxCameras"]</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-2">
|
||||
Gérer les sites et caméras auxquels cet utilisateur peut accéder.
|
||||
@Text["UsersPage_GererLesSitesEtCamerasAuxquelsCetUtilisateurPeutAcceder"]
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Primary" FullWidth="true" Class="mb-2"
|
||||
OnClick="@ToggleCameraAccess">
|
||||
<MudIcon Icon="@Icons.Material.Filled.VideoLibrary" Class="mr-1" />
|
||||
@(_showCameraAccess ? "Masquer les accès caméra" : "Gérer les accès caméra")
|
||||
@(_showCameraAccess ? Text["UsersPage_MasquerLesAccesCamera"] : Text["UsersPage_GererLesAccesCamera"])
|
||||
</MudButton>
|
||||
|
||||
@if (_showCameraAccess && _editUser is not null)
|
||||
@@ -261,21 +264,21 @@ else
|
||||
@if (!string.IsNullOrEmpty(_temporaryPassword))
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning" Class="mt-2">
|
||||
<strong>Nouveau mot de passe temporaire :</strong><br />
|
||||
<strong>@Text["UsersPage_NouveauMotDePasseTemporaire"]</strong><br />
|
||||
<code class="hmd-code-block mt-2">
|
||||
@_temporaryPassword
|
||||
</code>
|
||||
<MudText Typo="Typo.body2" Color="Color.Warning" Class="mt-2">
|
||||
⚠ L'utilisateur devra changer ce mot de passe à la prochaine connexion.
|
||||
@Text["UsersPage_LUtilisateurDevraChangerCeMotDePasseALaProchaineConnexion"]
|
||||
</MudText>
|
||||
</MudAlert>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@CloseEdit">Fermer</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@CloseEdit">@Text["UsersPage_Fermer"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveEdit" Disabled="@_saving">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Enregistrer
|
||||
@Text["UsersPage_Enregistrer"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -285,12 +288,12 @@ else
|
||||
<MudDialog @bind-Visible="_showDeleteConfirm">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6" Color="Color.Error">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Warning" Class="mr-1" /> Supprimer l'utilisateur
|
||||
<MudIcon Icon="@Icons.Material.Filled.Warning" Class="mr-1" /> @Text["UsersPage_SupprimerLUtilisateur"]
|
||||
</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudText Typo="Typo.body1" Class="mb-2">
|
||||
Souhaitez-vous vraiment supprimer l'utilisateur suivant ?
|
||||
@Text["UsersPage_SouhaitezVousVraimentSupprimerLUtilisateurSuivant"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body1" Class="mb-1">
|
||||
<strong>@_deleteUserTarget?.DisplayName</strong>
|
||||
@@ -299,7 +302,7 @@ else
|
||||
@_deleteUserTarget?.Email
|
||||
</MudText>
|
||||
<MudAlert Severity="Severity.Warning" Variant="Variant.Filled" Class="mb-2">
|
||||
Cette action est irréversible. Toutes les données associées seront supprimées.
|
||||
@Text["UsersPage_CetteActionEstIrreversibleToutesLesDonneesAssocieesSerontSupprimees"]
|
||||
</MudAlert>
|
||||
@if (!string.IsNullOrEmpty(_deleteError))
|
||||
{
|
||||
@@ -307,10 +310,10 @@ else
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showDeleteConfirm = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _showDeleteConfirm = false)">@Text["UsersPage_Annuler"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@DeleteUser" Disabled="@_deleting">
|
||||
@if (_deleting) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
Supprimer
|
||||
@Text["UsersPage_Supprimer"]
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -354,7 +357,15 @@ else
|
||||
private UserItem? _deleteUserTarget;
|
||||
private string _deleteError = "";
|
||||
|
||||
protected override async Task OnInitializedAsync() => await LoadUsers();
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Language.LanguageChanged += OnLanguageChanged;
|
||||
await LoadUsers();
|
||||
}
|
||||
|
||||
private void OnLanguageChanged() => _ = InvokeAsync(StateHasChanged);
|
||||
|
||||
public void Dispose() => Language.LanguageChanged -= OnLanguageChanged;
|
||||
|
||||
private async Task LoadUsers()
|
||||
{
|
||||
@@ -389,17 +400,17 @@ else
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_createEmail) || string.IsNullOrWhiteSpace(_createPassword)
|
||||
|| string.IsNullOrWhiteSpace(_createDisplayName))
|
||||
{ _createError = "Tous les champs sont requis"; return; }
|
||||
{ _createError = Text["UsersPage_AllFieldsRequired"]; return; }
|
||||
_saving = true;
|
||||
_createError = "";
|
||||
try
|
||||
{
|
||||
var result = await Api.CreateUserAsync(_createEmail, _createPassword, _createDisplayName,
|
||||
new List<string> { _createRole });
|
||||
if (result is null) { _createError = "Erreur lors de la création"; return; }
|
||||
if (result is null) { _createError = Text["UsersPage_CreateFailed"]; return; }
|
||||
_showCreate = false;
|
||||
_createEmail = ""; _createPassword = ""; _createDisplayName = ""; _createRole = "Viewer";
|
||||
Snackbar.Add("Utilisateur créé avec succès", Severity.Success);
|
||||
Snackbar.Add(Text["UsersPage_Created"], Severity.Success);
|
||||
await LoadUsers();
|
||||
}
|
||||
catch { _createError = UiErrors.OperationFailed(); }
|
||||
@@ -471,7 +482,7 @@ else
|
||||
if (_editUser is null) return;
|
||||
if (!new System.ComponentModel.DataAnnotations.EmailAddressAttribute().IsValid(_editEmail))
|
||||
{
|
||||
_editError = "Adresse email invalide";
|
||||
_editError = Text["UsersPage_InvalidEmail"];
|
||||
return;
|
||||
}
|
||||
_saving = true;
|
||||
@@ -486,7 +497,7 @@ else
|
||||
// Ensure at least one role
|
||||
if (selectedRoles.Count == 0)
|
||||
{
|
||||
_editError = "Au moins un rôle doit être sélectionné";
|
||||
_editError = Text["UsersPage_AtLeastOneRole"];
|
||||
_saving = false;
|
||||
return;
|
||||
}
|
||||
@@ -495,15 +506,15 @@ else
|
||||
_editUser.Id, _editEmail, _editDisplayName, _editTheme, _editLanguage);
|
||||
if (!update.Succeeded)
|
||||
{
|
||||
_editError = update.ErrorMessage ?? "Erreur lors de la mise à jour";
|
||||
_editError = update.ErrorMessage ?? Text["UsersPage_UpdateFailed"];
|
||||
return;
|
||||
}
|
||||
if (!await Api.AssignRolesAsync(_editUser.Id, selectedRoles))
|
||||
{
|
||||
_editError = "Erreur lors de la mise à jour des rôles";
|
||||
_editError = Text["UsersPage_RolesUpdateFailed"];
|
||||
return;
|
||||
}
|
||||
Snackbar.Add("Utilisateur mis à jour", Severity.Success);
|
||||
Snackbar.Add(Text["UsersPage_Updated"], Severity.Success);
|
||||
await CloseEdit();
|
||||
await LoadUsers();
|
||||
}
|
||||
@@ -519,9 +530,9 @@ else
|
||||
if (await Api.LockUserAsync(_editUser.Id))
|
||||
{
|
||||
_editUser!.IsLockedOut = true;
|
||||
Snackbar.Add("Compte verrouillé", Severity.Success);
|
||||
Snackbar.Add(Text["UsersPage_LockedSuccess"], Severity.Success);
|
||||
}
|
||||
else Snackbar.Add("Erreur", Severity.Error);
|
||||
else Snackbar.Add(Text["UsersPage_Error"], Severity.Error);
|
||||
}
|
||||
|
||||
private async Task UnlockUser()
|
||||
@@ -531,9 +542,9 @@ else
|
||||
{
|
||||
_editUser!.IsLockedOut = false;
|
||||
_editUser!.AccessFailedCount = 0;
|
||||
Snackbar.Add("Compte déverrouillé", Severity.Success);
|
||||
Snackbar.Add(Text["UsersPage_UnlockedSuccess"], Severity.Success);
|
||||
}
|
||||
else Snackbar.Add("Erreur", Severity.Error);
|
||||
else Snackbar.Add(Text["UsersPage_Error"], Severity.Error);
|
||||
}
|
||||
|
||||
private async Task ConfirmUserEmail(UserItem user)
|
||||
@@ -544,12 +555,12 @@ else
|
||||
{
|
||||
if (!await Api.ConfirmUserEmailAsync(user.Id))
|
||||
{
|
||||
Snackbar.Add("Impossible de confirmer l’email", Severity.Error);
|
||||
Snackbar.Add(Text["UsersPage_ConfirmEmailFailed"], Severity.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
user.EmailConfirmed = true;
|
||||
Snackbar.Add("Email confirmé", Severity.Success);
|
||||
Snackbar.Add(Text["UsersPage_EmailConfirmed"], Severity.Success);
|
||||
await LoadUsers();
|
||||
}
|
||||
catch { Snackbar.Add(UiErrors.OperationFailed(), Severity.Error); }
|
||||
@@ -564,9 +575,9 @@ else
|
||||
try
|
||||
{
|
||||
var result = await Api.ResetPasswordAsync(_editUser.Id);
|
||||
if (result is null) { _editError = "Erreur lors de la réinitialisation"; return; }
|
||||
if (result is null) { _editError = Text["UsersPage_ResetFailed"]; return; }
|
||||
_temporaryPassword = result.TemporaryPassword;
|
||||
Snackbar.Add("Mot de passe réinitialisé", Severity.Success);
|
||||
Snackbar.Add(Text["UsersPage_PasswordReset"], Severity.Success);
|
||||
}
|
||||
catch { _editError = UiErrors.OperationFailed(); }
|
||||
finally { _saving = false; }
|
||||
@@ -595,7 +606,7 @@ else
|
||||
return;
|
||||
}
|
||||
_showDeleteConfirm = false;
|
||||
Snackbar.Add("Utilisateur supprimé", Severity.Success);
|
||||
Snackbar.Add(Text["UsersPage_Deleted"], Severity.Success);
|
||||
await LoadUsers();
|
||||
}
|
||||
catch { _deleteError = UiErrors.OperationFailed(); }
|
||||
|
||||
@@ -1,57 +1,58 @@
|
||||
@namespace Heimdall.Web.Components.Settings
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4" Style="border-radius: var(--hmd-radius-lg);">
|
||||
<div class="d-flex align-center mb-3">
|
||||
<MudText Typo="Typo.h6" Class="flex-grow-1">
|
||||
<i class="fas fa-microchip mr-2"></i> Défauts agents
|
||||
<i class="fas fa-microchip mr-2"></i> @Text["AgentDefaultsSection_Title"]
|
||||
</MudText>
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary">Globaux</MudChip>
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary">@Text["AgentDefaultsSection_Global"]</MudChip>
|
||||
</div>
|
||||
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-3">
|
||||
Valeurs par défaut appliquées à tous les agents. Chaque agent peut les surcharger individuellement.
|
||||
@Text["AgentDefaultsSection_Description"]
|
||||
</MudText>
|
||||
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">
|
||||
<i class="fas fa-list mr-1" style="color: var(--mud-palette-primary);"></i> Logs
|
||||
<i class="fas fa-list mr-1" style="color: var(--mud-palette-primary);"></i> @Text["AgentDefaultsSection_Logs"]
|
||||
</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudSelect T="string" Label="Niveau de log global" Variant="Variant.Outlined"
|
||||
<MudSelect T="string" Label="@Text["AgentDefaultsSection_LogLevel"]" Variant="Variant.Outlined"
|
||||
Value="@(GetValue("log.level") ?? "info")"
|
||||
ValueChanged="OnLogLevelChanged" Immediate="true"
|
||||
HelperText="Appliqué à chaud aux agents (règle de niveau partagée).">
|
||||
<MudSelectItem Value="@("trace")">Trace</MudSelectItem>
|
||||
<MudSelectItem Value="@("debug")">Debug</MudSelectItem>
|
||||
<MudSelectItem Value="@("info")">Info</MudSelectItem>
|
||||
<MudSelectItem Value="@("warn")">Warn</MudSelectItem>
|
||||
<MudSelectItem Value="@("error")">Error</MudSelectItem>
|
||||
HelperText="@Text["AgentDefaultsSection_LogLevelHelp"]">
|
||||
<MudSelectItem Value="@("trace")">@Text["AgentDefaultsSection_LogTrace"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("debug")">@Text["AgentDefaultsSection_LogDebug"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("info")">@Text["AgentDefaultsSection_LogInfo"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("warn")">@Text["AgentDefaultsSection_LogWarn"]</MudSelectItem>
|
||||
<MudSelectItem Value="@("error")">@Text["AgentDefaultsSection_LogError"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudNumericField T="int?" Label="Rétention des logs agents (jours)" Variant="Variant.Outlined"
|
||||
<MudNumericField T="int?" Label="@Text["AgentDefaultsSection_LogRetention"]" Variant="Variant.Outlined"
|
||||
Value="@(int.TryParse(GetValue("log.retentiondays"), out var r) ? r : null)"
|
||||
ValueChanged="OnRetentionChanged" Min="1" Max="3650"
|
||||
HelperText="Durée de conservation des logs remontés par les agents." />
|
||||
HelperText="@Text["AgentDefaultsSection_LogRetentionHelp"]" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-3">
|
||||
<i class="fas fa-heartbeat mr-1" style="color: var(--mud-palette-primary);"></i> Heartbeat
|
||||
<i class="fas fa-heartbeat mr-1" style="color: var(--mud-palette-primary);"></i> @Text["AgentDefaultsSection_Heartbeat"]
|
||||
</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudNumericField T="int?" Label="Intervalle de heartbeat (secondes)" Variant="Variant.Outlined"
|
||||
<MudNumericField T="int?" Label="@Text["AgentDefaultsSection_HeartbeatInterval"]" Variant="Variant.Outlined"
|
||||
Value="@(int.TryParse(GetValue("heartbeat.interval.seconds"), out var h) ? h : null)"
|
||||
ValueChanged="OnHeartbeatChanged" Min="5" Max="300"
|
||||
HelperText="Fréquence de la remontée d'état des agents vers le central." />
|
||||
HelperText="@Text["AgentDefaultsSection_HeartbeatHelp"]" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-3">
|
||||
<i class="fas fa-bug mr-1" style="color: var(--mud-palette-primary);"></i> Diagnostic
|
||||
<i class="fas fa-bug mr-1" style="color: var(--mud-palette-primary);"></i> @Text["AgentDefaultsSection_Diagnostics"]
|
||||
</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12">
|
||||
@@ -59,8 +60,8 @@
|
||||
Value="@(GetValue("sentry.enabled")?.Equals("true", StringComparison.OrdinalIgnoreCase) == true)"
|
||||
ValueChanged="OnSentryEnabledChanged"
|
||||
Color="Color.Primary"
|
||||
Label="Envoyer les erreurs vers GlitchTip"
|
||||
HelperText="Le DSN est fixe (configuré par l'application). Nécessite un redémarrage pour être pris en compte." />
|
||||
Label="@Text["AgentDefaultsSection_SendErrors"]"
|
||||
HelperText="@Text["AgentDefaultsSection_SendErrorsHelp"]" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
</MudPaper>
|
||||
@@ -108,11 +109,11 @@
|
||||
Category: "agent", ValueType: "string", AllowedValues: null, AgentScoped: null));
|
||||
}
|
||||
_settings = await Api.GetSettingsAsync();
|
||||
Snackbar.Add($"Paramètre {key} mis à jour", Severity.Success);
|
||||
Snackbar.Add(string.Format(Text["AgentDefaultsSection_SettingUpdated"], key), Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Échec de la mise à jour : {ex.Message}", Severity.Error);
|
||||
Snackbar.Add(string.Format(Text["AgentDefaultsSection_SettingUpdateFailed"], ex.Message), Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,47 @@
|
||||
@namespace Heimdall.Web.Components.Settings
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4" Style="border-radius: var(--hmd-radius-lg);">
|
||||
<div class="d-flex align-center mb-3">
|
||||
<MudText Typo="Typo.h6" Class="flex-grow-1">
|
||||
<i class="fas fa-brain mr-2"></i> Intelligence artificielle
|
||||
<i class="fas fa-brain mr-2"></i> @Text["AiSettingsSection_Title"]
|
||||
</MudText>
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary">Détection</MudChip>
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary">@Text["AiSettingsSection_Detection"]</MudChip>
|
||||
</div>
|
||||
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-3">
|
||||
Moteurs d'analyse utilisés par les agents pour la détection d'objets et de personnes.
|
||||
@Text["AiSettingsSection_Description"]
|
||||
</MudText>
|
||||
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="URL CodeProject.AI" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["AiSettingsSection_CpaiUrl"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("ai.cpaiurl")"
|
||||
ValueChanged="OnCpaiUrlChanged"
|
||||
HelperText="Endpoint CodeProject.AI (ex : http://cpai:32168)." />
|
||||
HelperText="@Text["AiSettingsSection_CpaiHelp"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="URL Ollama" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["AiSettingsSection_OllamaUrl"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("ai.ollamaurl")"
|
||||
ValueChanged="OnOllamaUrlChanged"
|
||||
HelperText="Endpoint Ollama pour l'inférence locale (ex : http://ollama:11434)." />
|
||||
HelperText="@Text["AiSettingsSection_OllamaHelp"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudSwitch T="bool"
|
||||
Value="@(GetValue("ai.detection.enabled")?.Equals("true", StringComparison.OrdinalIgnoreCase) == true)"
|
||||
ValueChanged="OnDetectionEnabledChanged"
|
||||
Color="Color.Primary"
|
||||
Label="Détection IA activée"
|
||||
HelperText="Défaut global appliqué aux agents. Une modification nécessite le rechargement de la configuration des agents." />
|
||||
Label="@Text["AiSettingsSection_Enabled"]"
|
||||
HelperText="@Text["AiSettingsSection_EnabledHelp"]" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<div class="d-flex align-center mt-3">
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Info" StartIcon="@Icons.Material.Filled.Radar"
|
||||
OnClick="TestAiAsync" Disabled="@_testing">
|
||||
@(_testing ? "Test en cours…" : "Tester les moteurs IA")
|
||||
@(_testing ? Text["AiSettingsSection_Testing"] : Text["AiSettingsSection_Test"])
|
||||
</MudButton>
|
||||
</div>
|
||||
@if (_testResult is not null)
|
||||
@@ -81,11 +82,11 @@
|
||||
_testResult = null;
|
||||
try
|
||||
{
|
||||
_testResult = await Api.TestAiAsync() ?? new TestActionResult(false, "Test impossible (API indisponible).");
|
||||
_testResult = await Api.TestAiAsync() ?? new TestActionResult(false, Text["AiSettingsSection_TestUnavailable"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_testResult = new TestActionResult(false, $"Test impossible : {ex.Message}");
|
||||
_testResult = new TestActionResult(false, string.Format(Text["AiSettingsSection_TestFailed"], ex.Message));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -113,11 +114,11 @@
|
||||
Category: "ai", ValueType: "string", AllowedValues: null, AgentScoped: null));
|
||||
}
|
||||
_settings = await Api.GetSettingsAsync();
|
||||
Snackbar.Add($"Paramètre {key} mis à jour", Severity.Success);
|
||||
Snackbar.Add(string.Format(Text["AiSettingsSection_SettingUpdated"], key), Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Échec de la mise à jour : {ex.Message}", Severity.Error);
|
||||
Snackbar.Add(string.Format(Text["AiSettingsSection_SettingUpdateFailed"], ex.Message), Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,17 +1,18 @@
|
||||
@namespace Heimdall.Web.Components.Settings
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4" Style="border-radius: var(--hmd-radius-lg);">
|
||||
<div class="d-flex align-center mb-3">
|
||||
<MudText Typo="Typo.h6" Class="flex-grow-1">
|
||||
<i class="fas fa-bell mr-2"></i> Notifications
|
||||
<i class="fas fa-bell mr-2"></i> @Text["NotificationSettingsSection_Title"]
|
||||
</MudText>
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary">ntfy + Email</MudChip>
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary">@Text["NotificationSettingsSection_Channels"]</MudChip>
|
||||
</div>
|
||||
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-3">
|
||||
Canaux de notification utilisés pour les alertes de détection, les digests et les événements système.
|
||||
@Text["NotificationSettingsSection_Description"]
|
||||
</MudText>
|
||||
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2">
|
||||
@@ -19,77 +20,77 @@
|
||||
</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Serveur ntfy" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["NotificationSettingsSection_NtfyServer"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("ntfy.baseurl")"
|
||||
ValueChanged="OnBaseUrlChanged"
|
||||
HelperText="URL de base du serveur ntfy (ex : https://ntfy.sh)." />
|
||||
HelperText="@Text["NotificationSettingsSection_NtfyServerHelp"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Token d'accès" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["NotificationSettingsSection_AccessToken"]" Variant="Variant.Outlined"
|
||||
Type="InputType.Password"
|
||||
Value="@SecretValue("ntfy.token")"
|
||||
ValueChanged="OnTokenChanged"
|
||||
Placeholder="•••••••• (déjà configuré)"
|
||||
HelperText="Token optionnel pour les serveurs ntfy authentifiés." />
|
||||
Placeholder="@Text["NotificationSettingsSection_SecretConfigured"]"
|
||||
HelperText="@Text["NotificationSettingsSection_AccessTokenHelp"]" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<MudText Typo="Typo.subtitle2" Class="mb-2 mt-3">
|
||||
<i class="fas fa-envelope mr-1" style="color: var(--mud-palette-primary);"></i> Email SMTP
|
||||
<i class="fas fa-envelope mr-1" style="color: var(--mud-palette-primary);"></i> @Text["NotificationSettingsSection_SmtpEmail"]
|
||||
</MudText>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Adresse expéditrice" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["NotificationSettingsSection_FromAddress"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("email.fromaddress")"
|
||||
ValueChanged="OnFromAddressChanged"
|
||||
HelperText="Adresse « De » des emails envoyés." />
|
||||
HelperText="@Text["NotificationSettingsSection_FromAddressHelp"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Nom expéditeur" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["NotificationSettingsSection_FromName"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("email.fromname")"
|
||||
ValueChanged="OnFromNameChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="4">
|
||||
<MudTextField T="string" Label="Serveur SMTP" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["NotificationSettingsSection_SmtpHost"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("email.smtphost")"
|
||||
ValueChanged="OnSmtpHostChanged"
|
||||
HelperText="Ex : smtp.gmail.com" />
|
||||
HelperText="@Text["NotificationSettingsSection_SmtpHostHelp"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="6" md="2">
|
||||
<MudNumericField T="int?" Label="Port SMTP" Variant="Variant.Outlined"
|
||||
<MudNumericField T="int?" Label="@Text["NotificationSettingsSection_SmtpPort"]" Variant="Variant.Outlined"
|
||||
Value="@(int.TryParse(GetValue("email.smtpport"), out var p) ? p : null)"
|
||||
ValueChanged="OnSmtpPortChanged" Min="1" Max="65535" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="3">
|
||||
<MudTextField T="string" Label="Utilisateur SMTP" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["NotificationSettingsSection_SmtpUsername"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("email.username")"
|
||||
ValueChanged="OnUsernameChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="3">
|
||||
<MudTextField T="string" Label="Mot de passe SMTP" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["NotificationSettingsSection_SmtpPassword"]" Variant="Variant.Outlined"
|
||||
Type="InputType.Password"
|
||||
Value="@SecretValue("email.password")"
|
||||
ValueChanged="OnPasswordChanged"
|
||||
Placeholder="•••••••• (déjà configuré)" />
|
||||
Placeholder="@Text["NotificationSettingsSection_SecretConfigured"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12">
|
||||
<MudSwitch T="bool"
|
||||
Value="@(GetValue("email.usessl")?.Equals("true", StringComparison.OrdinalIgnoreCase) == true)"
|
||||
ValueChanged="OnUseSslChanged"
|
||||
Color="Color.Primary"
|
||||
Label="Utiliser SSL/TLS"
|
||||
HelperText="Active le chiffrement TLS lors de la connexion SMTP." />
|
||||
Label="@Text["NotificationSettingsSection_UseTls"]"
|
||||
HelperText="@Text["NotificationSettingsSection_UseTlsHelp"]" />
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
<div class="d-flex align-center mt-3">
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Info" StartIcon="@Icons.Material.Filled.Send"
|
||||
OnClick="TestNtfyAsync" Disabled="@_testing">
|
||||
@(_testing ? "Test en cours…" : "Tester ntfy")
|
||||
@(_testing ? Text["NotificationSettingsSection_Testing"] : Text["NotificationSettingsSection_TestNtfy"])
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Info" Class="ml-2" StartIcon="@Icons.Material.Filled.Email"
|
||||
OnClick="TestEmailAsync" Disabled="@_testing">
|
||||
@(_testing ? "Test en cours…" : "Tester l'envoi email")
|
||||
@(_testing ? Text["NotificationSettingsSection_Testing"] : Text["NotificationSettingsSection_TestEmail"])
|
||||
</MudButton>
|
||||
</div>
|
||||
@if (_testResult is not null)
|
||||
@@ -145,11 +146,11 @@
|
||||
_testResult = null;
|
||||
try
|
||||
{
|
||||
_testResult = await Api.TestNtfyAsync() ?? new TestActionResult(false, "Test impossible (API indisponible).");
|
||||
_testResult = await Api.TestNtfyAsync() ?? new TestActionResult(false, Text["NotificationSettingsSection_TestUnavailable"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_testResult = new TestActionResult(false, $"Test impossible : {ex.Message}");
|
||||
_testResult = new TestActionResult(false, string.Format(Text["NotificationSettingsSection_TestFailed"], ex.Message));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -163,11 +164,11 @@
|
||||
_testResult = null;
|
||||
try
|
||||
{
|
||||
_testResult = await Api.TestEmailAsync() ?? new TestActionResult(false, "Test impossible (API indisponible).");
|
||||
_testResult = await Api.TestEmailAsync() ?? new TestActionResult(false, Text["NotificationSettingsSection_TestUnavailable"]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_testResult = new TestActionResult(false, $"Test impossible : {ex.Message}");
|
||||
_testResult = new TestActionResult(false, string.Format(Text["NotificationSettingsSection_TestFailed"], ex.Message));
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -195,11 +196,11 @@
|
||||
Category: "integrations", ValueType: "string", AllowedValues: null, AgentScoped: null));
|
||||
}
|
||||
_settings = await Api.GetSettingsAsync();
|
||||
Snackbar.Add($"Paramètre {key} mis à jour", Severity.Success);
|
||||
Snackbar.Add(string.Format(Text["NotificationSettingsSection_SettingUpdated"], key), Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Échec de la mise à jour : {ex.Message}", Severity.Error);
|
||||
Snackbar.Add(string.Format(Text["NotificationSettingsSection_SettingUpdateFailed"], ex.Message), Severity.Error);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,61 +1,62 @@
|
||||
@namespace Heimdall.Web.Components.Settings
|
||||
@inject HeimdallApiClient Api
|
||||
@inject ISnackbar Snackbar
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudPaper Elevation="1" Class="pa-4 mb-4" Style="border-radius: var(--hmd-radius-lg);">
|
||||
<div class="d-flex align-center mb-3">
|
||||
<MudText Typo="Typo.h6" Class="flex-grow-1">
|
||||
<i class="fas fa-database mr-2"></i> Stockage
|
||||
<i class="fas fa-database mr-2"></i> @Text["StorageSettingsSection_Title"]
|
||||
</MudText>
|
||||
<MudChip T="string" Size="Size.Small" Variant="Variant.Outlined" Color="Color.Primary">@_provider</MudChip>
|
||||
</div>
|
||||
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-3">
|
||||
Choisissez le mode de stockage des snapshots et enregistrements : disque local (« Fichier ») ou objet S3 (Alarik/MinIO).
|
||||
@Text["StorageSettingsSection_Description"]
|
||||
</MudText>
|
||||
|
||||
<MudGrid>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudSelect T="string" Label="Provider" Variant="Variant.Outlined" Value="@_provider" ValueChanged="async v => await SaveProviderAsync(v)" Immediate="true">
|
||||
<MudSelectItem T="string" Value="@("Local")">Fichier (disque local)</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("S3")">S3 (Alarik / MinIO)</MudSelectItem>
|
||||
<MudSelect T="string" Label="@Text["StorageSettingsSection_Provider"]" Variant="Variant.Outlined" Value="@_provider" ValueChanged="async v => await SaveProviderAsync(v)" Immediate="true">
|
||||
<MudSelectItem T="string" Value="@("Local")">@Text["StorageSettingsSection_Local"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("S3")">@Text["StorageSettingsSection_S3Provider"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
</MudItem>
|
||||
|
||||
@if (_provider == "Local")
|
||||
{
|
||||
<MudItem xs="12">
|
||||
<MudTextField T="string" Label="Chemin racine" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["StorageSettingsSection_RootPath"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("storage.local.path")"
|
||||
ValueChanged="OnLocalPathChanged"
|
||||
HelperText="Dossier local où sont écrits snapshots et enregistrements." />
|
||||
HelperText="@Text["StorageSettingsSection_RootPathHelp"]" />
|
||||
</MudItem>
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Endpoint S3" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["StorageSettingsSection_S3Endpoint"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("storage.s3.endpoint")"
|
||||
ValueChanged="OnEndpointChanged"
|
||||
HelperText="Ex : http://alarik:9000" />
|
||||
HelperText="@Text["StorageSettingsSection_S3EndpointExample"]" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Bucket" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["StorageSettingsSection_Bucket"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("storage.s3.bucket")"
|
||||
ValueChanged="OnBucketChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Clé d'accès" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["StorageSettingsSection_AccessKey"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("storage.s3.accessKey")"
|
||||
ValueChanged="OnAccessKeyChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Clé secrète" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["StorageSettingsSection_SecretKey"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("storage.s3.secretKey")" Type="InputType.Password"
|
||||
ValueChanged="OnSecretKeyChanged" />
|
||||
</MudItem>
|
||||
<MudItem xs="12" md="6">
|
||||
<MudTextField T="string" Label="Région" Variant="Variant.Outlined"
|
||||
<MudTextField T="string" Label="@Text["StorageSettingsSection_Region"]" Variant="Variant.Outlined"
|
||||
Value="@GetValue("storage.s3.region")"
|
||||
ValueChanged="OnRegionChanged" />
|
||||
</MudItem>
|
||||
@@ -65,7 +66,7 @@
|
||||
<div class="d-flex align-center mt-3">
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Info" StartIcon="@Icons.Material.Filled.VerifiedUser"
|
||||
OnClick="@TestAsync" Disabled="@_testing">
|
||||
@(_testing ? "Test en cours…" : "Tester la connexion")
|
||||
@(_testing ? Text["StorageSettingsSection_Testing"] : Text["StorageSettingsSection_TestConnection"])
|
||||
</MudButton>
|
||||
@if (_testResult is not null)
|
||||
{
|
||||
@@ -85,9 +86,9 @@
|
||||
|
||||
private string GetStorageTestStatus()
|
||||
{
|
||||
if (_testResult?.Healthy is true) return "Opérationnel";
|
||||
if (_testResult?.Configured is false) return "Non configuré";
|
||||
return "Injoignable";
|
||||
if (_testResult?.Healthy is true) return Text["StorageSettingsSection_Operational"];
|
||||
if (_testResult?.Configured is false) return Text["StorageSettingsSection_NotConfigured"];
|
||||
return Text["StorageSettingsSection_Unreachable"];
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -131,7 +132,7 @@
|
||||
await Api.CreateSettingAsync(new CreateAppSettingRequest(
|
||||
Key: key, Value: value, Category: "storage",
|
||||
Description: key.StartsWith("storage.s3.secretKey", StringComparison.Ordinal)
|
||||
? "Clé secrète S3" : key,
|
||||
? Text["StorageSettingsSection_SecretDescription"] : key,
|
||||
ValueType: "string", AllowedValues: null, AgentScoped: false));
|
||||
}
|
||||
else
|
||||
@@ -142,11 +143,11 @@
|
||||
}
|
||||
// Les records sont immuables : recharger plutôt que muter.
|
||||
_settings = await Api.GetSettingsAsync();
|
||||
Snackbar.Add($"Paramètre {key} mis à jour", Severity.Success);
|
||||
Snackbar.Add(string.Format(Text["StorageSettingsSection_SettingUpdated"], key), Severity.Success);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Échec de la mise à jour : {ex.Message}", Severity.Error);
|
||||
Snackbar.Add(string.Format(Text["StorageSettingsSection_SettingUpdateFailed"], ex.Message), Severity.Error);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +160,7 @@
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Snackbar.Add($"Test impossible : {ex.Message}", Severity.Error);
|
||||
Snackbar.Add(string.Format(Text["StorageSettingsSection_TestFailed"], ex.Message), Severity.Error);
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@* Reusable filter bar with search text field and optional category dropdown. *@
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudPaper Elevation="1" Class="@($"pa-4 mb-4 {Class}")" Style="border-radius: var(--hmd-radius-md);">
|
||||
<form @onsubmit="OnSearch" method="post">
|
||||
@@ -6,7 +7,7 @@
|
||||
<MudItem xs="12" sm="@(HasCategory ? 6 : 10)">
|
||||
<MudTextField Value="_search"
|
||||
ValueChanged="(string v) => OnSearchValueChanged(v)"
|
||||
Label="Rechercher..."
|
||||
Label="@Text["SharedFilterBar_Search"]"
|
||||
Variant="Variant.Outlined"
|
||||
Immediate="true"
|
||||
Class="mb-0"
|
||||
@@ -19,11 +20,11 @@
|
||||
<MudItem xs="12" sm="4">
|
||||
<MudSelect Value="_category"
|
||||
ValueChanged="(string? v) => OnCategoryValueChanged(v)"
|
||||
Label="Catégorie"
|
||||
Label="@Text["SharedFilterBar_Category"]"
|
||||
Variant="Variant.Outlined"
|
||||
Class="mb-0"
|
||||
Clearable="true">
|
||||
<MudSelectItem T="string" Value="@null">Toutes</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@null">@Text["SharedFilterBar_AllCategories"]</MudSelectItem>
|
||||
@foreach (var cat in Categories!)
|
||||
{
|
||||
<MudSelectItem Value="@cat" @key="cat">@cat</MudSelectItem>
|
||||
@@ -33,7 +34,7 @@
|
||||
}
|
||||
<MudItem xs="12" sm="2" Class="d-flex align-center">
|
||||
<MudButton Variant="Variant.Text" OnClick="@Reset" Class="mb-0">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Clear" Size="Size.Small" Class="mr-1" /> Effacer
|
||||
<MudIcon Icon="@Icons.Material.Filled.Clear" Size="Size.Small" Class="mr-1" /> @Text["SharedFilterBar_Clear"]
|
||||
</MudButton>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
@inject Heimdall.Web.Services.UiLanguageService Language
|
||||
|
||||
<MudPaper Elevation="0" Class="pa-3" Style="border: 1px solid var(--mud-palette-lines-default); border-radius: 8px; height: 100%;">
|
||||
<MudText Typo="Typo.subtitle2">@Title</MudText>
|
||||
@if (Points.Count == 0 || !Points.Any(point => point.Value.HasValue))
|
||||
{
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-4">Aucune donnée sur cette période.</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mt-4">@Text["SharedMetricHistory_NoData"]</MudText>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -17,8 +20,8 @@
|
||||
}
|
||||
</svg>
|
||||
<div class="d-flex justify-space-between">
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@Points[0].TimestampUtc.ToLocalTime().ToString("g")</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@Points[^1].TimestampUtc.ToLocalTime().ToString("g")</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@Points[0].TimestampUtc.ToLocalTime().ToString("g", Language.Culture)</MudText>
|
||||
<MudText Typo="Typo.caption" Color="Color.Secondary">@Points[^1].TimestampUtc.ToLocalTime().ToString("g", Language.Culture)</MudText>
|
||||
</div>
|
||||
}
|
||||
</MudPaper>
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
@implements IAsyncDisposable
|
||||
@inject NotificationsHubClient Hub
|
||||
@inject NavigationManager Navigation
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudTooltip Text="Notifications">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Notifications" Color="Color.Inherit" aria-label="Notifications"
|
||||
<MudTooltip Text="@Text["SharedNotificationBadge_Title"]">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Notifications" Color="Color.Inherit" aria-label="@Text["SharedNotificationBadge_Title"]"
|
||||
OnClick="@(() => Navigation.NavigateTo("/events"))">
|
||||
@if (Hub.UnreadCount > 0)
|
||||
{
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
@* Pagination navigation bar with page info and Previous/Next buttons. *@
|
||||
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudPaper Class="@($"d-flex align-center pa-4 mt-4 {Class}")" Style="border-radius: var(--hmd-radius-md);">
|
||||
<MudText Typo="Typo.body2" Class="mr-4">
|
||||
Page @Page sur @TotalPages (@Total entrées)
|
||||
@Text["SharedPaginationBar_Page"] @Page @Text["SharedPaginationBar_Of"] @TotalPages (@Total @Text["SharedPaginationBar_Entries"])
|
||||
</MudText>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small" Class="mr-2"
|
||||
Disabled="@(Page <= 1)" OnClick="@(() => Previous.InvokeAsync())">
|
||||
← Précédent
|
||||
← @Text["SharedPaginationBar_Previous"]
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Size="Size.Small"
|
||||
Disabled="@(Page >= TotalPages)" OnClick="@(() => Next.InvokeAsync())">
|
||||
Suivant →
|
||||
@Text["SharedPaginationBar_Next"] →
|
||||
</MudButton>
|
||||
</MudPaper>
|
||||
|
||||
|
||||
@@ -2,39 +2,39 @@
|
||||
|
||||
<MudDialog @bind-Visible="Visible">
|
||||
<TitleContent>
|
||||
<MudText Typo="Typo.h6">@(IsEdit ? "Edit Person" : "New Person")</MudText>
|
||||
<MudText Typo="Typo.h6">@(IsEdit ? Text["PersonFormDialog_EditTitle"] : Text["PersonFormDialog_NewTitle"])</MudText>
|
||||
</TitleContent>
|
||||
<DialogContent>
|
||||
<MudTextField @bind-Value="_displayName" Label="Name *" Variant="Variant.Outlined"
|
||||
<MudTextField @bind-Value="_displayName" Label="@Text["PersonFormDialog_Name"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Required="true" Immediate="true"
|
||||
HelperText="Display name of the person" />
|
||||
<MudTextField @bind-Value="_photoUrl" Label="Photo URL" Variant="Variant.Outlined"
|
||||
Class="mb-4" HelperText="URL of the main photo (optional)" />
|
||||
<MudTextField @bind-Value="_notes" Label="Notes" Variant="Variant.Outlined"
|
||||
HelperText="@Text["PersonFormDialog_NameHelp"]" />
|
||||
<MudTextField @bind-Value="_photoUrl" Label="@Text["PersonFormDialog_PhotoUrl"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" HelperText="@Text["PersonFormDialog_PhotoHelp"]" />
|
||||
<MudTextField @bind-Value="_notes" Label="@Text["PersonFormDialog_Notes"]" Variant="Variant.Outlined"
|
||||
Class="mb-4" Lines="3"
|
||||
HelperText="Free-form notes about this person" />
|
||||
<MudSelect T="string" @bind-Value="_category" Label="Category" Variant="Variant.Outlined"
|
||||
HelperText="@Text["PersonFormDialog_NotesHelp"]" />
|
||||
<MudSelect T="string" @bind-Value="_category" Label="@Text["PersonFormDialog_Category"]" Variant="Variant.Outlined"
|
||||
Class="mb-4">
|
||||
<MudSelectItem T="string" Value="@("")">— None —</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("family")">Family</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("employee")">Employee</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("watchlist")">Watchlist</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("unknown")">Unknown</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("")">@Text["PersonFormDialog_None"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("family")">@Text["PersonFormDialog_Family"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("employee")">@Text["PersonFormDialog_Employee"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("watchlist")">@Text["PersonFormDialog_Watchlist"]</MudSelectItem>
|
||||
<MudSelectItem T="string" Value="@("unknown")">@Text["PersonFormDialog_Unknown"]</MudSelectItem>
|
||||
</MudSelect>
|
||||
<MudSwitch T="bool" @bind-Value="_isWatchlisted" Color="Color.Warning"
|
||||
Label="Watchlisted"
|
||||
HelperText="Prioritised in alert notifications" Class="mb-4" />
|
||||
Label="@Text["PersonFormDialog_Watchlisted"]"
|
||||
HelperText="@Text["PersonFormDialog_WatchlistedHelp"]" Class="mb-4" />
|
||||
@if (!string.IsNullOrEmpty(_error))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4">@_error</MudAlert>
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@Cancel">Cancel</MudButton>
|
||||
<MudButton Variant="Variant.Text" OnClick="@Cancel">@Text["PersonFormDialog_Cancel"]</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@Submit"
|
||||
Disabled="@(_saving)">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
@(IsEdit ? "Save" : "Create")
|
||||
@(IsEdit ? Text["PersonFormDialog_Save"] : Text["PersonFormDialog_Create"])
|
||||
</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
@@ -47,6 +47,7 @@
|
||||
|
||||
[Inject] private HeimdallApiClient Api { get; set; } = default!;
|
||||
[Inject] private ISnackbar Snackbar { get; set; } = default!;
|
||||
[Inject] private Heimdall.Web.Services.UiText Text { get; set; } = default!;
|
||||
|
||||
private bool IsEdit => Existing is not null;
|
||||
private string _displayName = "";
|
||||
@@ -79,7 +80,7 @@
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_displayName))
|
||||
{
|
||||
_error = "Name is required";
|
||||
_error = Text["PersonFormDialog_NameRequired"];
|
||||
return;
|
||||
}
|
||||
_saving = true;
|
||||
@@ -100,7 +101,7 @@
|
||||
FaceCount = Existing.FaceCount,
|
||||
CreatedAt = Existing.CreatedAt
|
||||
});
|
||||
if (!ok) { _error = "Failed to update person"; return; }
|
||||
if (!ok) { _error = Text["PersonFormDialog_UpdateFailed"]; return; }
|
||||
result = new PersonClientItem
|
||||
{
|
||||
Id = Existing!.Id,
|
||||
@@ -119,12 +120,12 @@
|
||||
_displayName.Trim(), _category, _notes, _isWatchlisted, _photoUrl);
|
||||
if (!apiResult.Succeeded || apiResult.Data is null)
|
||||
{
|
||||
_error = apiResult.ErrorMessage ?? "Failed to create person";
|
||||
_error = apiResult.ErrorMessage ?? Text["PersonFormDialog_CreateFailed"];
|
||||
return;
|
||||
}
|
||||
result = apiResult.Data;
|
||||
}
|
||||
Snackbar.Add(IsEdit ? "Person updated" : "Person created", Severity.Success);
|
||||
Snackbar.Add(IsEdit ? Text["PersonFormDialog_Updated"] : Text["PersonFormDialog_Created"], Severity.Success);
|
||||
await VisibleChanged.InvokeAsync(false);
|
||||
await OnSaved.InvokeAsync(result);
|
||||
}
|
||||
@@ -136,4 +137,4 @@
|
||||
{
|
||||
await VisibleChanged.InvokeAsync(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,8 +7,8 @@
|
||||
ValueChanged="OnSelectedChanged"
|
||||
SearchFunc="SearchTimeZones"
|
||||
ToStringFunc="@(tz => tz?.Id ?? "")"
|
||||
Label="@Label"
|
||||
Placeholder="@Placeholder"
|
||||
Label="@EffectiveLabel"
|
||||
Placeholder="@EffectivePlaceholder"
|
||||
HelperText="@HelperText"
|
||||
Variant="Variant.Outlined"
|
||||
Class="@Class"
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
[Parameter] public EventCallback<string?> ValueChanged { get; set; }
|
||||
|
||||
[Parameter] public string Label { get; set; } = "Fuseau horaire";
|
||||
[Parameter] public string Label { get; set; } = "";
|
||||
|
||||
[Parameter] public string Placeholder { get; set; } = "Rechercher un fuseau (ex: Europe/Paris)";
|
||||
[Parameter] public string Placeholder { get; set; } = "";
|
||||
|
||||
[Parameter] public string? HelperText { get; set; }
|
||||
|
||||
@@ -34,6 +34,11 @@
|
||||
|
||||
private TimeZoneInfo? _selected;
|
||||
|
||||
[Inject] private Heimdall.Web.Services.UiText Text { get; set; } = default!;
|
||||
|
||||
private string EffectiveLabel => string.IsNullOrEmpty(Label) ? Text["SharedTimezoneAutocomplete_Label"] : Label;
|
||||
private string EffectivePlaceholder => string.IsNullOrEmpty(Placeholder) ? Text["SharedTimezoneAutocomplete_Placeholder"] : Placeholder;
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
if (_selected?.Id != Value)
|
||||
|
||||
@@ -2,30 +2,25 @@
|
||||
Heimdall sur un site, façon Pangolin (choix de la méthode + code à copier).
|
||||
Modes : Docker Compose (recommandé) ou script shell. *@
|
||||
@using MudBlazor
|
||||
@inject Heimdall.Web.Services.UiText Text
|
||||
|
||||
<MudText Typo="Typo.h6" Class="mb-1">
|
||||
<MudIcon Icon="@Icons.Material.Filled.Download" Size="Size.Small" Class="mr-1" />
|
||||
Installer un agent sur ce site
|
||||
@Text["SiteInstallPanel_Title"]
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
Déployez le connecteur d'agent Heimdall sur la machine qui doit surveiller ce site.
|
||||
@Text["SiteInstallPanel_Description"]
|
||||
</MudText>
|
||||
|
||||
<MudTabs Class="mb-4" Elevation="0" Rounded="true">
|
||||
<MudTabPanel Text="Docker Compose" Icon="@Icons.Material.Filled.IntegrationInstructions">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-2">
|
||||
Copiez ce fichier <code>docker-compose.yml</code> sur la machine cible puis lancez
|
||||
<code>docker compose up -d</code>.
|
||||
</MudText>
|
||||
<MudTabPanel Text="@Text["SiteInstallPanel_DockerCompose"]" Icon="@Icons.Material.Filled.IntegrationInstructions">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-2">@((MarkupString)string.Format(Text["SiteInstallPanel_ComposeInstructions"], "<code>docker-compose.yml</code>", "<code>docker compose up -d</code>"))</MudText>
|
||||
<MudAlert Severity="Severity.Info" Class="mb-3">
|
||||
Avant de démarrer, placez la clé publique de release fournie par votre canal de confiance
|
||||
indépendant de Central dans <code>agent-release-public.pem</code>, à côté du compose, avec
|
||||
des droits de lecture pour l’UID 1654 (par exemple <code>chmod 644</code>). Elle est requise
|
||||
pour vérifier et installer les mises à jour signées.
|
||||
@((MarkupString)string.Format(Text["SiteInstallPanel_ReleaseKeyInstructions"], "<code>agent-release-public.pem</code>", "<code>chmod 644</code>"))
|
||||
</MudAlert>
|
||||
@if (_agentImageReference is null)
|
||||
{
|
||||
<MudAlert Severity="Severity.Warning">Le manifeste d’image de l’agent fourni par le Central est indisponible. Réessayez avant de copier le compose.</MudAlert>
|
||||
<MudAlert Severity="Severity.Warning">@Text["SiteInstallPanel_ImageUnavailable"]</MudAlert>
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -34,20 +29,20 @@
|
||||
</MudPaper>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-3"
|
||||
OnClick="@(() => CopyCode(ComposeYaml))" StartIcon="@Icons.Material.Filled.ContentCopy">
|
||||
Copier le docker-compose.yml
|
||||
@Text["SiteInstallPanel_CopyCompose"]
|
||||
</MudButton>
|
||||
}
|
||||
</MudTabPanel>
|
||||
<MudTabPanel Text="Script shell" Icon="@Icons.Material.Filled.Terminal">
|
||||
<MudTabPanel Text="@Text["SiteInstallPanel_ShellScript"]" Icon="@Icons.Material.Filled.Terminal">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-2">
|
||||
Exécutez cette commande sur la machine cible (Linux) :
|
||||
@Text["SiteInstallPanel_ShellInstructions"]
|
||||
</MudText>
|
||||
<MudPaper Class="pa-3" Style="border-radius: 8px; background: #0d1117; overflow-x: auto;">
|
||||
<pre class="mb-0" style="color:#c9d1d9;font-size:0.85rem;"><code>@ShellCommand</code></pre>
|
||||
</MudPaper>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" Class="mt-3"
|
||||
OnClick="@(() => CopyCode(ShellCommand))" StartIcon="@Icons.Material.Filled.ContentCopy">
|
||||
Copier la commande
|
||||
@Text["SiteInstallPanel_CopyCommand"]
|
||||
</MudButton>
|
||||
</MudTabPanel>
|
||||
</MudTabs>
|
||||
@@ -138,7 +133,7 @@
|
||||
private async Task CopyCode(string code)
|
||||
{
|
||||
await JsRuntime.InvokeVoidAsync("navigator.clipboard.writeText", code);
|
||||
Snackbar.Add("Code copié dans le presse-papiers", Severity.Success);
|
||||
Snackbar.Add(Text["SiteInstallPanel_Copied"], Severity.Success);
|
||||
}
|
||||
|
||||
[Inject] private IJSRuntime JsRuntime { get; set; } = default!;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Heimdall.Application.Agents.Queries.GetAgent;
|
||||
using Heimdall.Application.Agents.Commands.AcknowledgeCameraConfig;
|
||||
using Heimdall.Application.Common;
|
||||
using Heimdall.Application.DTOs;
|
||||
using Heimdall.Application.Localization;
|
||||
using Heimdall.Application.Services;
|
||||
using Heimdall.Application.Settings.Commands.CreateAppSetting;
|
||||
using Heimdall.Application.Settings.Commands.UpdateAppSetting;
|
||||
@@ -18,6 +19,7 @@ using MediatR;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.RateLimiting;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Heimdall.Api.Controllers;
|
||||
|
||||
@@ -299,25 +301,31 @@ public class SettingsController : ControllerBase
|
||||
[ProducesResponseType(typeof(object), StatusCodes.Status400BadRequest)]
|
||||
public async Task<IActionResult> TestEmail(
|
||||
[FromServices] IEmailService emailService,
|
||||
[FromServices] IApplicationDbContext db,
|
||||
CancellationToken ct)
|
||||
{
|
||||
var language = this.TryGetUserId(out var userId)
|
||||
? await db.Users.AsNoTracking().Where(user => user.Id == userId).Select(user => user.Language).FirstOrDefaultAsync(ct)
|
||||
: null;
|
||||
var settings = await _mediator.Send(new GetSettingsQuery(), ct);
|
||||
if (!settings.IsSuccess)
|
||||
return StatusCode(settings.StatusCode ?? 400, new { error = settings.Error });
|
||||
|
||||
var fromAddress = settings.Data!.FirstOrDefault(s => s.Key == "email.fromaddress")?.Value;
|
||||
if (string.IsNullOrWhiteSpace(fromAddress))
|
||||
return BadRequest(new { error = "Adresse expéditrice non configurée (email.fromaddress)." });
|
||||
return BadRequest(new { error = ServerText.Get("Settings.EmailTest.NotConfigured", language) });
|
||||
|
||||
try
|
||||
{
|
||||
await emailService.SendEmailAsync(fromAddress, "Heimdall — test de configuration",
|
||||
"<h2>✅ Configuration email OK</h2><p>Ce message confirme que le serveur SMTP est joignable et que l'authentification fonctionne.</p>", ct);
|
||||
return Ok(new { success = true, message = $"Email de test envoyé à {fromAddress}" });
|
||||
var title = ServerText.Get("Settings.EmailTest.Title", language);
|
||||
var body = ServerText.Get("Settings.EmailTest.Body", language);
|
||||
await emailService.SendEmailAsync(fromAddress, ServerText.Get("Settings.EmailTest.Subject", language),
|
||||
$"<h2>{System.Net.WebUtility.HtmlEncode(title)}</h2><p>{System.Net.WebUtility.HtmlEncode(body)}</p>", ct);
|
||||
return Ok(new { success = true, message = ServerText.Format("Settings.EmailTest.Sent", language, fromAddress) });
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Ok(new { success = false, message = $"Échec de l'envoi : {ex.Message}" });
|
||||
return Ok(new { success = false, message = ServerText.Format("Settings.EmailTest.Failed", language, ex.Message) });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -1371,7 +1371,8 @@ public record UpdateNotificationConfigRequest(
|
||||
string? NtfyTopic,
|
||||
bool? DailyDigest,
|
||||
bool? WeeklyDigest,
|
||||
List<string>? SubscribedEvents
|
||||
List<string>? SubscribedEvents,
|
||||
string? Language = null
|
||||
);
|
||||
|
||||
// ─── API Key DTOs ──────────────────────────────────────────────────
|
||||
|
||||
@@ -110,7 +110,7 @@ public class AuthFlowTests : E2ETestBase
|
||||
await Page.FillAsync("input[autocomplete='name']", "E2E Register");
|
||||
await Page.FillAsync("input[autocomplete='email']", email);
|
||||
await Page.FillAsync("input[autocomplete='new-password']", "RegisterPass123!");
|
||||
await Page.ClickAsync("button:has-text(\"S'inscrire\")");
|
||||
await Page.ClickAsync("button:has-text('S’inscrire')");
|
||||
|
||||
// New viewer account lands on the dashboard
|
||||
await Page.WaitForURLAsync("**/dashboard**", new() { Timeout = 20000 });
|
||||
@@ -141,7 +141,7 @@ public class AuthFlowTests : E2ETestBase
|
||||
await Page.FillAsync("input[autocomplete='name']", "E2E Blocked");
|
||||
await Page.FillAsync("input[autocomplete='email']", email);
|
||||
await Page.FillAsync("input[autocomplete='new-password']", "RegisterPass123!");
|
||||
await Page.ClickAsync("button:has-text(\"S'inscrire\")");
|
||||
await Page.ClickAsync("button:has-text('S’inscrire')");
|
||||
|
||||
// The UI shows a generic error and stays on the register page when the
|
||||
// backend rejects the signup (public registration disabled).
|
||||
|
||||
@@ -38,7 +38,7 @@ public class AgentCardTests : PageTestBase
|
||||
cut.Markup.ShouldContain("CPU");
|
||||
cut.Markup.ShouldContain("Mémoire");
|
||||
cut.Markup.ShouldContain("Disque");
|
||||
cut.Markup.ShouldContain("Uptime");
|
||||
cut.Markup.ShouldContain("Temps de fonctionnement");
|
||||
// 35% CPU affiché
|
||||
cut.Markup.ShouldContain("35%");
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class AgentCardTests : PageTestBase
|
||||
|
||||
cut.Markup.ShouldContain("Hors ligne");
|
||||
cut.Markup.ShouldContain("Agent hors ligne");
|
||||
cut.Markup.ShouldNotContain("Uptime");
|
||||
cut.Markup.ShouldNotContain("Temps de fonctionnement");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Bunit;
|
||||
using Heimdall.Web.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using MudBlazor;
|
||||
using MudBlazor.Services;
|
||||
@@ -35,6 +36,11 @@ public abstract class MudTestBase : TestContext
|
||||
|
||||
var services = (IServiceCollection)Services;
|
||||
|
||||
// Shared components now resolve text through UiText. Register the
|
||||
// same localization services for every component test context.
|
||||
services.AddScoped<UiLanguageService>();
|
||||
services.AddScoped<UiText>();
|
||||
|
||||
// Register all MudBlazor services except KeyInterceptorService
|
||||
services.AddMudServices(config =>
|
||||
{
|
||||
|
||||
@@ -37,8 +37,8 @@ public class AuditLogsPageTests : PageTestBase
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("admin@heimdall.local");
|
||||
cut.Markup.ShouldContain("UserCreated");
|
||||
cut.Markup.ShouldContain("Site.Created");
|
||||
cut.Markup.ShouldContain("Création utilisateur");
|
||||
cut.Markup.ShouldContain("Site créé");
|
||||
cut.Markup.ShouldContain("192.168.1.10");
|
||||
cut.Markup.ShouldContain("User");
|
||||
});
|
||||
@@ -74,7 +74,7 @@ public class AuditLogsPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<AuditLogsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("UserCreated"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Création utilisateur"));
|
||||
|
||||
// Champ resourceType (Immediate=true → Input), puis submit du form de filtre
|
||||
cut.FindAll("input")[1].Input("User");
|
||||
@@ -93,7 +93,7 @@ public class AuditLogsPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<AuditLogsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("UserCreated"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Création utilisateur"));
|
||||
|
||||
cut.FindAll("input")[1].Input("User");
|
||||
await cut.InvokeAsync(() => cut.Find("form").Submit());
|
||||
|
||||
@@ -147,7 +147,8 @@ public class DiscoveriesPageTests : PageTestBase
|
||||
|
||||
// Le nom par défaut est pré-rempli et l'URL de flux sélectionnée → bouton actif.
|
||||
// Find+Click dans InvokeAsync (handler périmé sinon, flaky CI).
|
||||
await cut.InvokeAsync(() => cut.FindAll("button").Single(b => b.TextContent.Contains("Ajouter la caméra") && b.TextContent.Contains("Ajouter")).Click());
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button")
|
||||
.Single(b => b.TextContent.Trim() == "Ajouter une caméra").Click());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
@@ -172,7 +173,8 @@ public class DiscoveriesPageTests : PageTestBase
|
||||
cut.FindAll("button[aria-label='Confirmer la caméra']")[0].Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Ajouter la caméra 192.168.1.10"));
|
||||
|
||||
await cut.InvokeAsync(() => cut.FindAll("button").Single(b => b.TextContent.Contains("Ajouter la caméra") && b.TextContent.Contains("Ajouter")).Click());
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button")
|
||||
.Single(b => b.TextContent.Trim() == "Ajouter une caméra").Click());
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Caméra déjà enregistrée sur ce site"));
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ public class EventsPageTests : PageTestBase
|
||||
cut.Markup.ShouldContain("Mouvement");
|
||||
cut.Markup.ShouldContain("Personne");
|
||||
cut.Markup.ShouldContain("Véhicule");
|
||||
cut.Markup.ShouldContain("87%");
|
||||
cut.Markup.ShouldContain("66%");
|
||||
cut.Markup.ShouldContain("87");
|
||||
cut.Markup.ShouldContain("66");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class EventsPageTests : PageTestBase
|
||||
{
|
||||
var snackbar = Services.GetRequiredService<ISnackbar>();
|
||||
snackbar.ShownSnackbars.ShouldNotBeEmpty();
|
||||
(snackbar.ShownSnackbars.First().Message?.ToString() ?? "").ShouldContain("Erreur");
|
||||
(snackbar.ShownSnackbars.First().Message?.ToString() ?? "").ShouldContain("Impossible de charger les événements");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ public class EventsPageTests : PageTestBase
|
||||
var cut = RenderPage<EventsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Mouvement"));
|
||||
|
||||
cut.FindAll("button.mud-icon-button").First(b => b.GetAttribute("aria-label") == "Voir le snapshot").Click();
|
||||
cut.FindAll("button.mud-icon-button").First(b => b.GetAttribute("aria-label") == "Voir la capture").Click();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Snapshot — Mouvement");
|
||||
cut.Markup.ShouldContain("Capture — Mouvement");
|
||||
cut.Markup.ShouldContain("/snapshots/1.jpg");
|
||||
});
|
||||
}
|
||||
@@ -98,16 +98,16 @@ public class EventsPageTests : PageTestBase
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Mouvement"));
|
||||
|
||||
// Ouvrir
|
||||
cut.FindAll("button.mud-icon-button").First(b => b.GetAttribute("aria-label") == "Voir le snapshot").Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Snapshot — Mouvement"));
|
||||
cut.FindAll("button.mud-icon-button").First(b => b.GetAttribute("aria-label") == "Voir la capture").Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Capture — Mouvement"));
|
||||
|
||||
// Fermer
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Fermer")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldNotContain("Snapshot — Mouvement"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldNotContain("Capture — Mouvement"));
|
||||
|
||||
// Rouvrir — le dialog doit répondre à nouveau (pas de composant orphelin)
|
||||
cut.FindAll("button.mud-icon-button").First(b => b.GetAttribute("aria-label") == "Voir le snapshot").Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Snapshot — Mouvement"));
|
||||
cut.FindAll("button.mud-icon-button").First(b => b.GetAttribute("aria-label") == "Voir la capture").Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Capture — Mouvement"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -73,7 +73,7 @@ public class LoginTests : PageTestBase
|
||||
await cut.InvokeAsync(() => cut.Find("form").Submit());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
cut.Markup.ShouldContain("Erreur lors de la création de la session"));
|
||||
cut.Markup.ShouldContain("La session n’a pas pu être créée. Veuillez réessayer."));
|
||||
nav.Uri.ShouldBe("http://localhost/");
|
||||
}
|
||||
|
||||
|
||||
@@ -50,9 +50,6 @@ public abstract class PageTestBase : MudTestBase
|
||||
|
||||
// ILogger<T> (required by Login page) — silent by default
|
||||
Services.AddLogging();
|
||||
Services.AddScoped<UiLanguageService>();
|
||||
Services.AddScoped<UiText>();
|
||||
|
||||
var httpClient = new HttpClient(Handler) { BaseAddress = new Uri("http://localhost/") };
|
||||
var httpFactory = Substitute.For<IHttpClientFactory>();
|
||||
httpFactory.CreateClient("HeimdallApi").Returns(httpClient);
|
||||
|
||||
@@ -67,9 +67,9 @@ public class PersonDetailPageTests : PageTestBase
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Alice Dupont");
|
||||
cut.Markup.ShouldContain("Family");
|
||||
cut.Markup.ShouldContain("Created");
|
||||
cut.Markup.ShouldContain("Watchlisted");
|
||||
cut.Markup.ShouldContain("Famille");
|
||||
cut.Markup.ShouldContain("Créée le");
|
||||
cut.Markup.ShouldContain("Surveillée");
|
||||
cut.Markup.ShouldContain("Member of the family");
|
||||
});
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class PersonDetailPageTests : PageTestBase
|
||||
|
||||
var cut = RenderPage<PersonDetailPage>(p => p.Add(x => x.Id, PersonId));
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Person not found"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Personne introuvable"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -122,7 +122,7 @@ public class PersonDetailPageTests : PageTestBase
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("https://example.com/face1.jpg");
|
||||
cut.Markup.ShouldContain("Registered faces");
|
||||
cut.Markup.ShouldContain("visage(s) enregistré(s)");
|
||||
cut.Markup.ShouldContain("evt-1234");
|
||||
});
|
||||
}
|
||||
@@ -135,7 +135,7 @@ public class PersonDetailPageTests : PageTestBase
|
||||
var cut = RenderPage<PersonDetailPage>(p => p.Add(x => x.Id, PersonId));
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
cut.Markup.ShouldContain("No face registered"));
|
||||
cut.Markup.ShouldContain("Aucun visage enregistré"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -151,7 +151,7 @@ public class PersonDetailPageTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Associated vehicles");
|
||||
cut.Markup.ShouldContain("véhicule(s) associé(s)");
|
||||
cut.Markup.ShouldContain("<code>AB-123-CD</code>");
|
||||
cut.Markup.ShouldContain("Toyota");
|
||||
cut.Markup.ShouldContain("Prius");
|
||||
@@ -167,7 +167,7 @@ public class PersonDetailPageTests : PageTestBase
|
||||
var cut = RenderPage<PersonDetailPage>(p => p.Add(x => x.Id, PersonId));
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
cut.Markup.ShouldContain("No vehicle associated"));
|
||||
cut.Markup.ShouldContain("Aucun véhicule associé à cette personne."));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -183,12 +183,12 @@ public class PersonDetailPageTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Detection history");
|
||||
cut.Markup.ShouldContain("Historique de détection");
|
||||
// The table displays the label (person name)
|
||||
cut.Markup.ShouldContain("Alice Dupont");
|
||||
cut.Markup.ShouldContain("92%");
|
||||
// The table includes an IconButton with aria-label="View snapshot" if snapshot exists
|
||||
cut.Markup.ShouldContain("aria-label=\"View snapshot\"");
|
||||
cut.Markup.ShouldContain("92");
|
||||
// The table includes a localized snapshot button when a snapshot exists.
|
||||
cut.Markup.ShouldContain("aria-label=\"Voir la capture\"");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -222,18 +222,18 @@ public class PersonDetailPageTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Alice Dupont"));
|
||||
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Delete")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Confirm deletion"));
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Supprimer")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Confirmer la suppression"));
|
||||
|
||||
// The confirm dialog's Delete button is inside the dialog actions.
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button")
|
||||
.Single(b => b.TextContent.Trim() == "Delete").Click());
|
||||
.Single(b => b.TextContent.Trim() == "Supprimer").Click());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
var snackbar = Services.GetRequiredService<ISnackbar>();
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "")
|
||||
.ShouldContain(m => m.Contains("deleted", StringComparison.OrdinalIgnoreCase));
|
||||
.ShouldContain(m => m.Contains("supprimée", StringComparison.OrdinalIgnoreCase));
|
||||
nav.Uri.ShouldBe("http://localhost/persons");
|
||||
});
|
||||
}
|
||||
@@ -248,12 +248,12 @@ public class PersonDetailPageTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Alice Dupont"));
|
||||
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Edit")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Edit Person"));
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Modifier")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Modifier la personne"));
|
||||
|
||||
cut.FindAll("input")[0].Input("Alice Renommee");
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button")
|
||||
.Single(b => b.TextContent.Trim() == "Save").Click());
|
||||
.Single(b => b.TextContent.Trim() == "Enregistrer").Click());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
@@ -261,7 +261,7 @@ public class PersonDetailPageTests : PageTestBase
|
||||
&& r.RequestUri!.PathAndQuery.Contains("api/persons")).ShouldBe(1);
|
||||
var snackbar = Services.GetRequiredService<ISnackbar>();
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "")
|
||||
.ShouldContain(m => m.Contains("updated", StringComparison.OrdinalIgnoreCase));
|
||||
.ShouldContain(m => m.Contains("mise à jour", StringComparison.OrdinalIgnoreCase));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -46,10 +46,10 @@ public class PersonsListPageTests : PageTestBase
|
||||
{
|
||||
cut.Markup.ShouldContain("Alice");
|
||||
cut.Markup.ShouldContain("Bob");
|
||||
cut.Markup.ShouldContain("Family");
|
||||
cut.Markup.ShouldContain("Employee");
|
||||
cut.Markup.ShouldContain("2 face(s)");
|
||||
cut.Markup.ShouldContain("1 face(s)");
|
||||
cut.Markup.ShouldContain("Famille");
|
||||
cut.Markup.ShouldContain("Employé");
|
||||
cut.Markup.ShouldContain("2 visage(s)");
|
||||
cut.Markup.ShouldContain("1 visage(s)");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -63,8 +63,8 @@ public class PersonsListPageTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("No person registered");
|
||||
cut.Markup.ShouldContain("Add a person");
|
||||
cut.Markup.ShouldContain("Aucune personne enregistrée");
|
||||
cut.Markup.ShouldContain("Ajouter une personne");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class PersonsListPageTests : PageTestBase
|
||||
var cut = RenderPage<PersonsListPage>();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
cut.Markup.ShouldContain("Unable to load persons."));
|
||||
cut.Markup.ShouldContain("Impossible de charger les personnes."));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -140,7 +140,7 @@ public class PersonsListPageTests : PageTestBase
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Alice"));
|
||||
|
||||
cut.FindAll("input")[0].Input("zzz");
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("No person matches the filters"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Aucune personne ne correspond aux filtres"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -153,22 +153,22 @@ public class PersonsListPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<PersonsListPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Add a person"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Ajouter une personne"));
|
||||
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Add a person")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Name *"));
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Ajouter une personne")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Nom *"));
|
||||
|
||||
// The dialog content renders in the host markup (MudDialogProvider),
|
||||
// so interact via the host's elements directly.
|
||||
cut.FindAll("input")[0].Input("New Person");
|
||||
await cut.InvokeAsync(() => cut.FindAll("button").Single(b => b.TextContent.Trim() == "Create").Click());
|
||||
await cut.InvokeAsync(() => cut.FindAll("button").Single(b => b.TextContent.Trim() == "Créer").Click());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
Handler.Requests.Count(r => r.Method == HttpMethod.Post
|
||||
&& r.RequestUri!.PathAndQuery.Contains("api/persons")).ShouldBe(1);
|
||||
var snackbar = Services.GetRequiredService<ISnackbar>();
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "").ShouldContain("Person created");
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "").ShouldContain("Personne créée");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -179,15 +179,15 @@ public class PersonsListPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<PersonsListPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Add a person"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Ajouter une personne"));
|
||||
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Add a person")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Name *"));
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Ajouter une personne")).Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Nom *"));
|
||||
|
||||
// Find+Click in InvokeAsync: a direct Click may use a stale
|
||||
// event handler reference after the dialog re-rendered.
|
||||
cut.InvokeAsync(() => cut.FindAll("button").Single(b => b.TextContent.Trim() == "Create").Click());
|
||||
cut.InvokeAsync(() => cut.FindAll("button").Single(b => b.TextContent.Trim() == "Créer").Click());
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Name is required"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Le nom est obligatoire"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,10 +23,10 @@ public class RegisterTests : PageTestBase
|
||||
var cut = RenderPage<Register>();
|
||||
|
||||
cut.Markup.ShouldContain("Créer un compte");
|
||||
cut.Markup.ShouldContain("Nom d'affichage");
|
||||
cut.Markup.ShouldContain("Nom d’affichage");
|
||||
cut.Markup.ShouldContain("Email");
|
||||
cut.Markup.ShouldContain("Mot de passe");
|
||||
cut.Markup.ShouldContain("S'inscrire");
|
||||
cut.Markup.ShouldContain("S’inscrire");
|
||||
cut.FindAll("input").Count.ShouldBe(3);
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class RegisterTests : PageTestBase
|
||||
await cut.InvokeAsync(() => cut.Find("form").Submit());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
cut.Markup.ShouldContain("Erreur lors de l'inscription"));
|
||||
cut.Markup.ShouldContain("Erreur lors de l’inscription"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -23,7 +23,7 @@ public class SettingsPageTests : PageTestBase
|
||||
cut.Markup.ShouldContain("Stockage");
|
||||
cut.Markup.ShouldContain("Notifications");
|
||||
cut.Markup.ShouldContain("Intelligence artificielle");
|
||||
cut.Markup.ShouldContain("Défauts agents");
|
||||
cut.Markup.ShouldContain("Paramètres par défaut des agents");
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -157,7 +157,7 @@ public class SiteDetailTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Identifiants caméras");
|
||||
cut.Markup.ShouldContain("Identifiants des caméras");
|
||||
cut.Markup.ShouldContain("admin principal");
|
||||
cut.Markup.ShouldContain("compte NVR");
|
||||
cut.Markup.ShouldContain("<code>admin</code>");
|
||||
@@ -176,7 +176,7 @@ public class SiteDetailTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<SiteDetail>(p => p.Add(x => x.Id, SiteId));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Identifiants caméras"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Identifiants des caméras"));
|
||||
|
||||
// Ouvrir le dialog d'ajout (bouton "Ajouter" de la section, pas du dialog).
|
||||
cut.FindAll("button").First(b => b.TextContent.Trim() == "Ajouter").Click();
|
||||
|
||||
@@ -51,7 +51,7 @@ public class SitesPageTests : PageTestBase
|
||||
var cut = RenderPage<SitesPage>();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
cut.Markup.ShouldContain("Erreur lors du chargement des sites."));
|
||||
cut.Markup.ShouldContain("Erreur lors du chargement des sites"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SnapshotsPageTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("2 snapshot(s) trouvé(s)");
|
||||
cut.Markup.ShouldContain("2 capture(s) trouvée(s)");
|
||||
cut.Markup.ShouldContain("Personne");
|
||||
cut.Markup.ShouldContain("/snapshots/1.jpg");
|
||||
cut.Markup.ShouldContain("/snapshots/2.jpg");
|
||||
@@ -54,7 +54,7 @@ public class SnapshotsPageTests : PageTestBase
|
||||
|
||||
var cut = RenderPage<SnapshotsPage>();
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Aucun snapshot trouvé."));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Aucune capture trouvée."));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -77,7 +77,7 @@ public class SnapshotsPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<SnapshotsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("2 snapshot(s) trouvé(s)"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("2 capture(s) trouvée(s)"));
|
||||
|
||||
// Champ recherche sans Immediate → Change
|
||||
cut.FindAll("input")[0].Change("Personne");
|
||||
@@ -86,7 +86,7 @@ public class SnapshotsPageTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("1 snapshot(s) trouvé(s)");
|
||||
cut.Markup.ShouldContain("1 capture(s) trouvée(s)");
|
||||
cut.Markup.ShouldContain("Personne");
|
||||
cut.Markup.ShouldNotContain("Voiture");
|
||||
});
|
||||
@@ -110,14 +110,14 @@ public class SnapshotsPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<SnapshotsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Page 1 / 2 · 49 snapshot(s)"));
|
||||
cut.Find("img[alt='Snapshot']").GetAttribute("src").ShouldBe("/snapshots/original.jpg");
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Page 1 / 2 · 49 captures"));
|
||||
cut.Find("img[alt='Capture d’événement']").GetAttribute("src").ShouldBe("/snapshots/original.jpg");
|
||||
|
||||
await cut.InvokeAsync(() => cut.FindAll("button").Single(b => b.TextContent.Contains("Suivant")).Click());
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Page 2 / 2 · 49 snapshot(s)");
|
||||
cut.Find("img[alt='Snapshot']").GetAttribute("src").ShouldBe("/snapshots/second.jpg");
|
||||
cut.Markup.ShouldContain("Page 2 / 2 · 49 captures");
|
||||
cut.Find("img[alt='Capture d’événement']").GetAttribute("src").ShouldBe("/snapshots/second.jpg");
|
||||
});
|
||||
Handler.Requests.Last().RequestUri!.Query.ShouldContain("page=2");
|
||||
Handler.Requests.Last().RequestUri!.Query.ShouldContain("pageSize=48");
|
||||
@@ -133,7 +133,11 @@ public class SnapshotsPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<SnapshotsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Personne · 87%"));
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Personne");
|
||||
cut.Markup.ShouldContain("87");
|
||||
});
|
||||
|
||||
// La carte est un div cliquable (role=button)
|
||||
var cards = cut.FindAll("div[role=button]");
|
||||
@@ -154,7 +158,11 @@ public class SnapshotsPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<SnapshotsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Personne · 87%"));
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Personne");
|
||||
cut.Markup.ShouldContain("87");
|
||||
});
|
||||
|
||||
// Ouvrir la lightbox.
|
||||
cut.FindAll("div[role=button]")[0].Click();
|
||||
@@ -179,7 +187,11 @@ public class SnapshotsPageTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<SnapshotsPage>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Personne · 87%"));
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Personne");
|
||||
cut.Markup.ShouldContain("87");
|
||||
});
|
||||
|
||||
// Dialog présent dans l'arbre dès le rendu initial, alors que le
|
||||
// lightbox est fermé (Visible=false).
|
||||
|
||||
@@ -32,7 +32,7 @@ public class NotFoundTests : PageTestBase
|
||||
var cut = RenderPage<NotFound>();
|
||||
|
||||
cut.Markup.ShouldContain("Page introuvable");
|
||||
cut.Markup.ShouldContain("Retour au Dashboard");
|
||||
cut.Markup.ShouldContain("Retour au tableau de bord");
|
||||
cut.FindAll("a[href=\"/dashboard\"]").ShouldNotBeEmpty();
|
||||
}
|
||||
}
|
||||
@@ -49,6 +49,6 @@ public class ErrorPageTests : PageTestBase
|
||||
|
||||
cut.Markup.ShouldContain("Une erreur est survenue");
|
||||
cut.Markup.ShouldContain("Retour au tableau de bord");
|
||||
cut.Markup.ShouldContain("Consultez les logs serveur");
|
||||
cut.Markup.ShouldContain("Consultez les journaux du serveur pour plus de détails sur cette erreur.");
|
||||
}
|
||||
}
|
||||
@@ -29,10 +29,10 @@ public class AgentDefaultsSectionTests : PageTestBase
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Niveau de log global");
|
||||
cut.Markup.ShouldContain("Rétention des logs agents");
|
||||
cut.Markup.ShouldContain("Intervalle de heartbeat");
|
||||
cut.Markup.ShouldContain("Envoyer les erreurs vers GlitchTip");
|
||||
cut.Markup.ShouldContain("Niveau de journalisation global");
|
||||
cut.Markup.ShouldContain("Rétention des journaux des agents");
|
||||
cut.Markup.ShouldContain("Intervalle du heartbeat");
|
||||
cut.Markup.ShouldContain("Envoyer les erreurs à GlitchTip");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class AgentDefaultsSectionTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = Render<AgentDefaultsSection>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Envoyer les erreurs vers GlitchTip"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Envoyer les erreurs à GlitchTip"));
|
||||
|
||||
// Le switch sentry.enabled est le seul input[type=checkbox] de la section
|
||||
// (MudSwitch déclenche onchange, pas onclick)
|
||||
|
||||
@@ -31,8 +31,8 @@ public class NotificationSettingsSectionTests : PageTestBase
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Serveur ntfy");
|
||||
cut.Markup.ShouldContain("Token d'accès");
|
||||
cut.Markup.ShouldContain("Adresse expéditrice");
|
||||
cut.Markup.ShouldContain("Jeton d’accès");
|
||||
cut.Markup.ShouldContain("Adresse d’expédition");
|
||||
cut.Markup.ShouldContain("Serveur SMTP");
|
||||
cut.Markup.ShouldContain("https://ntfy.sh");
|
||||
cut.Markup.ShouldContain("smtp.gmail.com");
|
||||
@@ -114,9 +114,9 @@ public class NotificationSettingsSectionTests : PageTestBase
|
||||
LoginAs();
|
||||
|
||||
var cut = Render<NotificationSettingsSection>();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Tester l'envoi email"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Tester l’envoi de courriel"));
|
||||
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Tester l'envoi email")).Click();
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Tester l’envoi de courriel")).Click();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
|
||||
@@ -28,9 +28,9 @@ public class PersonFormDialogTests : PageTestBase
|
||||
LoginAs();
|
||||
var cut = RenderPage<PersonFormDialog>(p => p.Add(x => x.Visible, true));
|
||||
|
||||
cut.FindAll("div.mud-dialog-actions button").Single(b => b.TextContent.Trim() == "Create").Click();
|
||||
cut.FindAll("div.mud-dialog-actions button").Single(b => b.TextContent.Trim() == "Créer").Click();
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Name is required"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Le nom est obligatoire"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -44,14 +44,14 @@ public class PersonFormDialogTests : PageTestBase
|
||||
var cut = RenderPage<PersonFormDialog>(p => p.Add(x => x.Visible, true));
|
||||
|
||||
cut.FindAll("input")[0].Input("New Person");
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button").Single(b => b.TextContent.Trim() == "Create").Click());
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button").Single(b => b.TextContent.Trim() == "Créer").Click());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
Handler.Requests.Count(r => r.Method == HttpMethod.Post
|
||||
&& r.RequestUri!.PathAndQuery.Contains("api/persons")).ShouldBe(1);
|
||||
var snackbar = Services.GetRequiredService<ISnackbar>();
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "").ShouldContain("Person created");
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "").ShouldContain("Personne créée");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -67,11 +67,11 @@ public class PersonFormDialogTests : PageTestBase
|
||||
p.Add(x => x.Existing, Existing());
|
||||
});
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Edit Person"));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Modifier la personne"));
|
||||
|
||||
cut.FindAll("input")[0].Input("Alice Updated");
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button")
|
||||
.Single(b => b.TextContent.Trim() == "Save").Click());
|
||||
.Single(b => b.TextContent.Trim() == "Enregistrer").Click());
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
@@ -79,7 +79,7 @@ public class PersonFormDialogTests : PageTestBase
|
||||
&& r.RequestUri!.PathAndQuery.Contains("api/persons")).ShouldBe(1);
|
||||
var snackbar = Services.GetRequiredService<ISnackbar>();
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "")
|
||||
.ShouldContain(m => m.Contains("updated", StringComparison.OrdinalIgnoreCase));
|
||||
.ShouldContain(m => m.Contains("mise à jour", StringComparison.OrdinalIgnoreCase));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -94,8 +94,8 @@ public class PersonFormDialogTests : PageTestBase
|
||||
var cut = RenderPage<PersonFormDialog>(p => p.Add(x => x.Visible, true));
|
||||
|
||||
cut.FindAll("input")[0].Input("New Person");
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button").Single(b => b.TextContent.Trim() == "Create").Click());
|
||||
await cut.InvokeAsync(() => cut.FindAll("div.mud-dialog-actions button").Single(b => b.TextContent.Trim() == "Créer").Click());
|
||||
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Display name already exists"));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ namespace Heimdall.Web.Tests.Components;
|
||||
/// StatusChip is omitted because MudChip requires complex MudBlazor DI setup.
|
||||
/// </summary>
|
||||
|
||||
public class PaginationBarTests : TestContext
|
||||
public class PaginationBarTests : MudTestBase
|
||||
{
|
||||
[Fact]
|
||||
public void Should_render_page_info()
|
||||
|
||||
@@ -43,7 +43,7 @@ Ce fichier remplace les rapports de `docs/audits/` et constitue le suivi courant
|
||||
- [x] **Inventaire #86** La PR #84 livre les échantillons Central idempotents toutes les 5 min, l’horodatage distinct de réception, les agrégats API bornés (5 min/30 min) avec trous conservés, l’historique agent, la capacité par site, les graphiques 24 h/7 j, l’index et la purge en lots à 8 jours. La migration, les tests et scans d’images ont passé dans le run PR #273. Les températures GPU sont disponibles lorsque l’Agent remonte un inventaire GPU.
|
||||
- [ ] **mDNS #81** La PR #78 fait de l'Agent la source unique des probes HomeKit sur le LAN caméra ; Central persiste et restitue catégorie, appairage et port, et la fusion conserve l'annonce mDNS même si le scan TCP a vu l'IP d'abord. Le client partagé assemble PTR/SRV/TXT/A, décode `ci` et `sf`, et filtre les catégories 17/18. La CI #246 a passé build, tests et scans d'images ; reste une validation sur LAN avec caméra/sonnette réelles.
|
||||
- [ ] **UI groupes #138 / accès #134** L'édition des groupes permet maintenant de lister les caméras des sites, d'accorder/révoquer les accès de groupe et d'afficher les noms de site/caméra via l'API existante. Restent la validation produit et la vérification de l'union accès direct/groupe ainsi que des priorités dans l'interface.
|
||||
- [ ] **Localisation #142** Extraire tous les textes UI, erreurs, notifications et emails ; persister FR/EN par utilisateur, basculer sans rechargement, garder français par défaut et vérifier les clés des deux ressources. Premier lot : shell, tableau de bord et profil (dont notifications du profil, erreurs et types d’événements) ; les autres pages, notifications émises et emails restent à migrer.
|
||||
- [x] **Localisation #142** Le shell, le tableau de bord, le profil et les pages/composants UI utilisent les ressources FR/EN, avec français par défaut, bascule sans rechargement et clés complètes. Les notifications d’événements, les digests, les emails d’inscription/réinitialisation et le test SMTP utilisent aussi les ressources serveur FR/EN. La CI PR #93 (run #303) a passé le build, les suites .NET (1 730 tests), les 34 tests E2E, le contrôle NuGet et les builds/scans des images serveur et Agent.
|
||||
- [ ] **Métriques #14** Les endpoints Prometheus `/metrics` Web et Agent sont mappés. La PR #68 ajoute et valide `heimdall.signalr.connections_by_hub` sur les cinq hubs Web. La jauge de viewers existe, mais aucun producteur WebRTC n'existe avant FEAT-01. Restent la validation de scraping sur un déploiement et l'évolution réelle des mesures.
|
||||
- [x] Ajouter `.agents/skills/secure-env-secrets/SKILL.md` : procédures pour lire/écrire les secrets fournis par l'utilisateur dans l'environnement local, avec stockage persistant optionnel hors dépôt, permissions utilisateur uniquement et sans exposer la valeur. Le skill ne configure pas les secrets des workflows distants.
|
||||
- [ ] Vérifier readiness et alertes pour modèle absent, file pleine, backlog, disque, jobs bloqués, perte de configuration et échec de livraison. Le contrôle stockage est aligné sur le fournisseur actif (settings DB/env), avec probe d’écriture locale, probe du bucket S3 sélectionné et timeout borné ; les health checks IA convertissent aussi leurs timeouts internes en état dégradé tout en propageant l’annulation appelante. Les scénarios réels de panne restent à valider.
|
||||
|
||||
Reference in new issue
Block a user