feat(web): live view & CameraDetail enrichie (Fixes #35)
- Vue live 16:9 : snapshot rafraîchi toutes les 10s (garde CancellationToken, pause si disposé), skeleton pendant chargement, point live pulsant, actions Prendre un snapshot / Actualiser en overlay. - RTSP masquée par défaut (InputType.Password) avec toggle œil. - Actions complètes : Enregistrer, Activer/Désactiver (statut), Supprimer avec dialog de confirmation — toujours rendus, @bind-Visible (pattern c266f26, corrige le @if autour du dialog snapshot présent avant). - Mini-timeline : 10 événements récents avec chips colorées par type (traduit), confiance en %, snapshot cliquable, lien vers /events?q=. - Statut traduit en badge (En ligne/Hors ligne/Désactivée). - Tests : 5 nouveaux (infos, RTSP masqué+toggle, vue live, toggle statut, suppression+navigation). 178 tests Web verts.
This commit is contained in:
1 parent
45e7969488
commit
2ddf51c57e
2 files changed
+376
-49
No files matched your search
@@ -5,14 +5,25 @@
|
||||
@inject ISnackbar Snackbar
|
||||
@inject NavigationManager Nav
|
||||
|
||||
<MudText Typo="Typo.h1" Class="mb-6">
|
||||
<MudText Typo="Typo.h1" Class="mb-2">
|
||||
<i class="fas fa-camera mr-2"></i>
|
||||
Caméra : @_camera?.Name
|
||||
</MudText>
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary" Class="mb-4">
|
||||
@if (_camera is not null)
|
||||
{
|
||||
<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>
|
||||
}
|
||||
</MudText>
|
||||
|
||||
@if (_loading)
|
||||
{
|
||||
<MudProgressCircular Indeterminate="true" />
|
||||
<MudPaper Elevation="0" Style="border-radius: var(--hmd-radius-lg);">
|
||||
<MudSkeleton Variant="SkeletonVariant.Rectangular" Height="360px" />
|
||||
</MudPaper>
|
||||
}
|
||||
else if (_camera is null)
|
||||
{
|
||||
@@ -20,14 +31,60 @@ else if (_camera is null)
|
||||
}
|
||||
else
|
||||
{
|
||||
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
||||
@* ─── Live view : snapshot rafraîchi ─── *@
|
||||
<MudPaper Elevation="2" Class="pa-0 mb-6" Style="border-radius: var(--hmd-radius-lg); overflow: hidden;">
|
||||
<div style="position: relative; aspect-ratio: 16/9; background: var(--mud-palette-dark);">
|
||||
@if (_snapshotLoading)
|
||||
{
|
||||
<MudSkeleton Variant="SkeletonVariant.Rectangular" Height="100%" />
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(_latestSnapshotUrl))
|
||||
{
|
||||
<img src="@_latestSnapshotUrl" alt="Vue live de @_camera.Name"
|
||||
style="width:100%; height:100%; object-fit:contain;" />
|
||||
@if (_camera.Status == "Online")
|
||||
{
|
||||
<span class="hmd-live-dot" style="position:absolute; top:12px; left:12px;" aria-hidden="true"></span>
|
||||
}
|
||||
}
|
||||
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
|
||||
</MudText>
|
||||
</div>
|
||||
}
|
||||
|
||||
@* Overlay actions live *@
|
||||
<div style="position:absolute; bottom:12px; right:12px;" class="d-flex gap-2">
|
||||
<MudTooltip Text="Prendre un snapshot">
|
||||
<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)"
|
||||
OnClick="@RefreshSnapshot" />
|
||||
</MudTooltip>
|
||||
<MudTooltip Text="Actualiser le flux">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Refresh" Color="Color.Inherit" Style="background: rgba(0,0,0,0.45);"
|
||||
aria-label="Actualiser le flux" OnClick="@RefreshSnapshot" />
|
||||
</MudTooltip>
|
||||
</div>
|
||||
</div>
|
||||
</MudPaper>
|
||||
|
||||
@* ─── 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>
|
||||
<MudGrid>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudTextField @bind-Value="_editName" Label="Nom" 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="URL RTSP" 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>
|
||||
@@ -37,48 +94,52 @@ else
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Modèle</MudText>
|
||||
<MudText Typo="Typo.body1">@(_camera.Model ?? "-")</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Statut</MudText>
|
||||
<MudText Color="@GetStatusColor(_camera.Status)">
|
||||
@GetStatusIcon(_camera.Status) @_camera.Status
|
||||
</MudText>
|
||||
</MudItem>
|
||||
<MudItem xs="12" sm="6">
|
||||
<MudText Typo="Typo.body2" Color="Color.Secondary">Créée le</MudText>
|
||||
<MudText Typo="Typo.body1">@_camera.CreatedAt.ToString("g")</MudText>
|
||||
</MudItem>
|
||||
</MudGrid>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_editError))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4">@_editError</MudAlert>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(_editSuccess))
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Class="mb-4">@_editSuccess</MudAlert>
|
||||
}
|
||||
|
||||
<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
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Color="@(_camera.Status == "Disabled" ? Color.Success : Color.Default)"
|
||||
OnClick="@ToggleCameraStatus">
|
||||
<MudIcon Icon="@(_camera.Status == "Disabled" ? Icons.Material.Filled.PlayArrow : Icons.Material.Filled.Stop)"
|
||||
Class="mr-1" />
|
||||
@(_camera.Status == "Disabled" ? "Activer" : "Désactiver")
|
||||
</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>
|
||||
<MudSpacer />
|
||||
<MudButton Variant="Variant.Text" Color="Color.Default" OnClick="@(() => Nav.NavigateTo($"/sites/{_camera.SiteId}/cameras"))">
|
||||
← Retour aux caméras
|
||||
</MudButton>
|
||||
</div>
|
||||
</MudPaper>
|
||||
|
||||
@if (!string.IsNullOrEmpty(_editError))
|
||||
{
|
||||
<MudAlert Severity="Severity.Error" Class="mb-4">@_editError</MudAlert>
|
||||
}
|
||||
@if (!string.IsNullOrEmpty(_editSuccess))
|
||||
{
|
||||
<MudAlert Severity="Severity.Success" Class="mb-4">@_editSuccess</MudAlert>
|
||||
}
|
||||
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="@SaveCamera" Disabled="@_saving" Class="mr-2">
|
||||
@if (_saving) { <MudProgressCircular Size="Size.Small" Class="mr-1" /> }
|
||||
<MudIcon Icon="@Icons.Material.Filled.Save" Class="mr-1" /> Enregistrer
|
||||
</MudButton>
|
||||
<MudButton Variant="Variant.Outlined" Color="Color.Default" OnClick="@(() => Nav.NavigateTo($"/sites/{_camera.SiteId}/cameras"))">
|
||||
← Retour aux caméras
|
||||
</MudButton>
|
||||
|
||||
@* Recent Events *@
|
||||
<MudText Typo="Typo.h6" Class="mb-4 mt-8">
|
||||
@* ─── 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
|
||||
</MudText>
|
||||
|
||||
@if (_eventsLoading)
|
||||
{
|
||||
<MudProgressCircular Indeterminate="true" Size="Size.Small" />
|
||||
<MudPaper Elevation="0" Style="border-radius: var(--hmd-radius-md);">
|
||||
<MudSkeleton Variant="SkeletonVariant.Rectangular" Height="120px" />
|
||||
</MudPaper>
|
||||
}
|
||||
else if (_events is { Count: > 0 })
|
||||
{
|
||||
<MudTable Items="@_events" Hover="true" Elevation="1">
|
||||
<MudTable Items="@_events" Hover="true" Elevation="1" Dense="true">
|
||||
<HeaderContent>
|
||||
<MudTh>Horodatage</MudTh>
|
||||
<MudTh>Type</MudTh>
|
||||
@@ -88,17 +149,21 @@ else
|
||||
</HeaderContent>
|
||||
<RowTemplate>
|
||||
<MudTd DataLabel="Horodatage">@context.OccurredAt.ToLocalTime().ToString("g")</MudTd>
|
||||
<MudTd DataLabel="Type">@context.Type</MudTd>
|
||||
<MudTd DataLabel="Confiance">@($"{context.Confidence:P0}")</MudTd>
|
||||
<MudTd DataLabel="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="">
|
||||
<MudIconButton Icon="@Icons.Material.Filled.Image" Size="Size.Small" aria-label="Voir le snapshot"
|
||||
Disabled="@(context.SnapshotUrl is null)"
|
||||
OnClick="@(() => _showSnapshotUrl = context.SnapshotUrl)" />
|
||||
OnClick="@(() => { _showSnapshotUrl = context.SnapshotUrl; _showSnapshotDialog = true; })" />
|
||||
</MudTd>
|
||||
</RowTemplate>
|
||||
</MudTable>
|
||||
<MudLink Href="@($"/sites/{_camera?.SiteId}/events")" Class="mt-2 d-block">
|
||||
<MudLink Href="@($"/events?q={Uri.EscapeDataString(_camera.Name)}")" Class="mt-2 d-block">
|
||||
Voir tous les événements →
|
||||
</MudLink>
|
||||
}
|
||||
@@ -107,17 +172,30 @@ else
|
||||
<MudText Class="mt-2" Typo="Typo.body2" Color="Color.Default">Aucun événement récent.</MudText>
|
||||
}
|
||||
|
||||
@if (_showSnapshotUrl is not null)
|
||||
{
|
||||
<MudDialog @bind-Visible="@_showSnapshotDialog" Options="_snapshotOptions">
|
||||
<DialogContent>
|
||||
@* ─── 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>
|
||||
<DialogContent>
|
||||
<MudText>Supprimer la caméra "@_camera.Name" ? Cette action est irréversible.</MudText>
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton Variant="Variant.Text" OnClick="@(() => _confirmDeleteShow = false)">Annuler</MudButton>
|
||||
<MudButton Variant="Variant.Filled" Color="Color.Error" OnClick="@DeleteCamera">Supprimer</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
|
||||
<MudDialog @bind-Visible="_showSnapshotDialog" Options="_snapshotOptions">
|
||||
<DialogContent>
|
||||
@if (_showSnapshotUrl is not null)
|
||||
{
|
||||
<img src="@_showSnapshotUrl" alt="Snapshot" style="width:100%;height:auto;" class="rounded-lg" />
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="@(() => _showSnapshotDialog = false)">Fermer</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
}
|
||||
}
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<MudButton OnClick="@(() => _showSnapshotDialog = false)">Fermer</MudButton>
|
||||
</DialogActions>
|
||||
</MudDialog>
|
||||
}
|
||||
|
||||
@code {
|
||||
@@ -130,6 +208,8 @@ else
|
||||
private string _editSuccess = "";
|
||||
private bool _loading = true;
|
||||
private bool _saving;
|
||||
private bool _showRtsp;
|
||||
private bool _confirmDeleteShow;
|
||||
|
||||
private List<EventItem>? _events;
|
||||
private bool _eventsLoading;
|
||||
@@ -142,6 +222,11 @@ else
|
||||
CloseButton = true
|
||||
};
|
||||
|
||||
private string? _latestSnapshotUrl;
|
||||
private bool _snapshotLoading;
|
||||
private CancellationTokenSource? _refreshCts;
|
||||
private bool _disposed;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
try
|
||||
@@ -156,11 +241,53 @@ else
|
||||
catch (Exception ex) { Snackbar.Add($"Erreur : {ex.Message}", Severity.Error); }
|
||||
finally { _loading = false; }
|
||||
|
||||
await LoadEventsAsync();
|
||||
await LoadLatestSnapshotAsync();
|
||||
await StartAutoRefresh();
|
||||
}
|
||||
|
||||
private async Task LoadEventsAsync()
|
||||
{
|
||||
try { _eventsLoading = true; _events = await Api.GetRecentEventsAsync(Id, 10); }
|
||||
catch { }
|
||||
finally { _eventsLoading = false; }
|
||||
}
|
||||
|
||||
private async Task LoadLatestSnapshotAsync()
|
||||
{
|
||||
_snapshotLoading = true;
|
||||
try
|
||||
{
|
||||
var events = await Api.GetRecentEventsAsync(Id, 1);
|
||||
_latestSnapshotUrl = events?
|
||||
.FirstOrDefault(e => !string.IsNullOrEmpty(e.SnapshotThumbUrl ?? e.SnapshotUrl)) is { } latest
|
||||
? (latest.SnapshotThumbUrl ?? latest.SnapshotUrl)
|
||||
: null;
|
||||
}
|
||||
catch { /* flux indisponible */ }
|
||||
finally
|
||||
{
|
||||
_snapshotLoading = false;
|
||||
if (!_disposed) await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task StartAutoRefresh()
|
||||
{
|
||||
_refreshCts = new CancellationTokenSource();
|
||||
try
|
||||
{
|
||||
while (!_refreshCts.Token.IsCancellationRequested)
|
||||
{
|
||||
await Task.Delay(TimeSpan.FromSeconds(10), _refreshCts.Token);
|
||||
if (!_disposed) await LoadLatestSnapshotAsync();
|
||||
}
|
||||
}
|
||||
catch (OperationCanceledException) { /* arrêt volontaire */ }
|
||||
}
|
||||
|
||||
private async Task RefreshSnapshot() => await LoadLatestSnapshotAsync();
|
||||
|
||||
private async Task SaveCamera()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(_editName)) { _editError = "Le nom est requis"; return; }
|
||||
@@ -180,6 +307,36 @@ else
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
private async Task ToggleCameraStatus()
|
||||
{
|
||||
if (_camera is null) return;
|
||||
var newStatus = _camera.Status == "Disabled" ? "Online" : "Disabled";
|
||||
_saving = true;
|
||||
_editError = "";
|
||||
try
|
||||
{
|
||||
if (await Api.UpdateCameraAsync(Id, _camera.Name, _camera.RtspUrl, newStatus))
|
||||
{
|
||||
_camera.Status = newStatus;
|
||||
Snackbar.Add(newStatus == "Online" ? "Caméra activée" : "Caméra désactivée", Severity.Success);
|
||||
}
|
||||
else _editError = "Erreur lors de la mise à jour du statut";
|
||||
}
|
||||
catch (Exception ex) { _editError = $"Erreur : {ex.Message}"; }
|
||||
finally { _saving = false; }
|
||||
}
|
||||
|
||||
private async Task DeleteCamera()
|
||||
{
|
||||
if (_camera is null) return;
|
||||
if (await Api.DeleteCameraAsync(Id))
|
||||
{
|
||||
Snackbar.Add($"Caméra \"{_camera.Name}\" supprimée", Severity.Success);
|
||||
Nav.NavigateTo($"/sites/{_camera.SiteId}/cameras");
|
||||
}
|
||||
else Snackbar.Add("Erreur lors de la suppression", Severity.Error);
|
||||
}
|
||||
|
||||
private static Color GetStatusColor(string status) => status switch
|
||||
{
|
||||
"Online" => Color.Success,
|
||||
@@ -194,4 +351,38 @@ else
|
||||
"Offline" => "○",
|
||||
_ => "?"
|
||||
};
|
||||
|
||||
private static string FormatStatus(string status) => status switch
|
||||
{
|
||||
"Online" => "En ligne",
|
||||
"Offline" => "Hors ligne",
|
||||
"Disabled" => "Désactivée",
|
||||
_ => status
|
||||
};
|
||||
|
||||
private static string FormatEventType(string type) => type switch
|
||||
{
|
||||
"MotionDetected" => "Mouvement",
|
||||
"PersonDetected" => "Personne",
|
||||
"VehicleDetected" => "Véhicule",
|
||||
"FaceRecognized" => "Visage",
|
||||
"CameraOffline" => "Hors ligne",
|
||||
_ => type
|
||||
};
|
||||
|
||||
private static Color GetEventColor(string type) => type switch
|
||||
{
|
||||
"MotionDetected" => Color.Warning,
|
||||
"PersonDetected" => Color.Error,
|
||||
"VehicleDetected" => Color.Info,
|
||||
"FaceRecognized" => Color.Success,
|
||||
_ => Color.Default
|
||||
};
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_disposed = true;
|
||||
_refreshCts?.Cancel();
|
||||
_refreshCts?.Dispose();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using Bunit;
|
||||
using Bunit.TestDoubles;
|
||||
using Heimdall.Web.Components.Pages;
|
||||
using Heimdall.Web.Services;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Shouldly;
|
||||
|
||||
namespace Heimdall.Web.Tests.Components.Pages;
|
||||
|
||||
public class CameraDetailTests : PageTestBase
|
||||
{
|
||||
private static readonly Guid CameraId = Guid.NewGuid();
|
||||
private static readonly Guid SiteId = Guid.NewGuid();
|
||||
|
||||
private static CameraItem Camera(string status = "Online") => new()
|
||||
{
|
||||
Id = CameraId,
|
||||
SiteId = SiteId,
|
||||
Name = "Caméra Entrée",
|
||||
Manufacturer = "Hikvision",
|
||||
Model = "DS-2CD",
|
||||
RtspUrl = "rtsp://192.168.1.50:554/stream1",
|
||||
Status = status,
|
||||
CreatedAt = DateTime.UtcNow.AddDays(-2)
|
||||
};
|
||||
|
||||
private void HandlerCamera(CameraItem camera)
|
||||
=> Handler.OnGet("api/cameras/", camera);
|
||||
|
||||
[Fact]
|
||||
public void CameraDetail_AfficheInformationsEtStatut()
|
||||
{
|
||||
HandlerCamera(Camera());
|
||||
Handler.OnGet("api/events/camera/", new List<EventItem>());
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<CameraDetail>(p => p.Add(x => x.Id, CameraId));
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("Caméra : Caméra Entrée");
|
||||
cut.Markup.ShouldContain("Hikvision");
|
||||
cut.Markup.ShouldContain("DS-2CD");
|
||||
cut.Markup.ShouldContain("En ligne");
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CameraDetail_RtspMasqueParDefaut_ToggleRevele()
|
||||
{
|
||||
HandlerCamera(Camera());
|
||||
Handler.OnGet("api/events/camera/", new List<EventItem>());
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<CameraDetail>(p => p.Add(x => x.Id, CameraId));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Caméra : Caméra Entrée"));
|
||||
|
||||
// Par défaut le champ RTSP est de type password (masqué)
|
||||
var rtspInput = cut.FindAll("input").First(i => i.GetAttribute("value")!.Contains("rtsp://"));
|
||||
rtspInput.GetAttribute("type").ShouldBe("password");
|
||||
|
||||
// Cliquer sur l'adornment (icon-button du champ) révèle le mot de passe.
|
||||
// MudBlazor : wrapper .mud-input-adornment-end contenant un button.mud-icon-button.
|
||||
var adornment = cut.Find(".mud-input-adornment-end button.mud-icon-button");
|
||||
adornment.Click();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
var visible = cut.FindAll("input").First(i => (i.GetAttribute("value") ?? "").Contains("rtsp://"));
|
||||
visible.GetAttribute("type").ShouldBe("text");
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CameraDetail_VueLive_AfficheDernierSnapshot()
|
||||
{
|
||||
HandlerCamera(Camera());
|
||||
Handler.OnGet("api/events/camera/", new List<EventItem>
|
||||
{
|
||||
new(Guid.NewGuid(), CameraId, "PersonDetected", 0.9, "Personne",
|
||||
"http://alarik/snapshots/live.jpg", "http://alarik/thumbs/live.jpg",
|
||||
DateTime.UtcNow.AddMinutes(-1), DateTime.UtcNow)
|
||||
});
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<CameraDetail>(p => p.Add(x => x.Id, CameraId));
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
cut.Markup.ShouldContain("http://alarik/thumbs/live.jpg");
|
||||
cut.Markup.ShouldContain("Vue live de Caméra Entrée");
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CameraDetail_ToggleStatut_ActiveEtDesactive()
|
||||
{
|
||||
HandlerCamera(Camera("Disabled"));
|
||||
Handler.OnGet("api/events/camera/", new List<EventItem>());
|
||||
Handler.On(HttpMethod.Put, "api/cameras/", System.Net.HttpStatusCode.OK);
|
||||
LoginAs();
|
||||
|
||||
var cut = RenderPage<CameraDetail>(p => p.Add(x => x.Id, CameraId));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Désactivée"));
|
||||
|
||||
cut.FindAll("button").Single(b => b.TextContent.Contains("Activer")).Click();
|
||||
|
||||
cut.WaitForAssertion(() =>
|
||||
{
|
||||
var snackbar = Services.GetRequiredService<MudBlazor.ISnackbar>();
|
||||
snackbar.ShownSnackbars.Select(m => m.Message?.ToString() ?? "")
|
||||
.ShouldContain(m => m.Contains("Caméra activée", StringComparison.OrdinalIgnoreCase));
|
||||
});
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CameraDetail_Supprimer_ConfirmeEtNavigue()
|
||||
{
|
||||
HandlerCamera(Camera());
|
||||
Handler.OnGet("api/events/camera/", new List<EventItem>());
|
||||
Handler.On(HttpMethod.Delete, "api/cameras/", System.Net.HttpStatusCode.OK);
|
||||
LoginAs();
|
||||
|
||||
var nav = Services.GetRequiredService<BunitNavigationManager>();
|
||||
var cut = RenderPage<CameraDetail>(p => p.Add(x => x.Id, CameraId));
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Caméra : Caméra Entrée"));
|
||||
|
||||
// Bouton "Supprimer la caméra" de la barre d'actions.
|
||||
cut.Find("button[aria-label=\"Supprimer la caméra\"]").Click();
|
||||
cut.WaitForAssertion(() => cut.Markup.ShouldContain("Confirmer la suppression"));
|
||||
// Dans le dialog, le bouton de confirmation est le seul "Supprimer" du dialog.
|
||||
cut.FindAll(".mud-dialog button").Single(b => b.TextContent.Trim() == "Supprimer").Click();
|
||||
|
||||
cut.WaitForAssertion(() => nav.Uri.ShouldBe("http://localhost/sites/" + SiteId + "/cameras"));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user