2026-07-17 19:08:17 +00:00
|
|
|
@page "/cameras/{Id:guid}"
|
|
|
|
|
@attribute [Authorize]
|
|
|
|
|
@layout MainLayout
|
|
|
|
|
@inject HeimdallApiClient Api
|
|
|
|
|
@inject ISnackbar Snackbar
|
|
|
|
|
@inject NavigationManager Nav
|
|
|
|
|
|
|
|
|
|
<MudText Typo="Typo.h4" Class="mb-6">
|
|
|
|
|
<MudIcon Icon="@Icons.Material.Filled.Videocam" Class="mr-2" />
|
|
|
|
|
Caméra : @_camera?.Name
|
|
|
|
|
</MudText>
|
|
|
|
|
|
|
|
|
|
@if (_loading)
|
|
|
|
|
{
|
|
|
|
|
<MudProgressCircular Indeterminate="true" />
|
|
|
|
|
}
|
|
|
|
|
else if (_camera is null)
|
|
|
|
|
{
|
|
|
|
|
<MudAlert Severity="Severity.Warning">Caméra introuvable</MudAlert>
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
<MudPaper Elevation="2" Class="pa-6 mb-6" Style="border-radius: 12px;">
|
|
|
|
|
<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" />
|
|
|
|
|
</MudItem>
|
|
|
|
|
<MudItem xs="12" sm="6">
|
|
|
|
|
<MudText Typo="Typo.body2" Color="Color.Secondary">Fabricant</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.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>
|
|
|
|
|
</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>
|
2026-07-19 13:21:25 +00:00
|
|
|
|
|
|
|
|
@* Recent Events *@
|
|
|
|
|
<MudText Typo="Typo.h6" Class="mb-4 mt-8">
|
|
|
|
|
<MudIcon Icon="@Icons.Material.Filled.Notifications" Class="mr-1" /> Événements récents
|
|
|
|
|
</MudText>
|
|
|
|
|
|
|
|
|
|
@if (_eventsLoading)
|
|
|
|
|
{
|
|
|
|
|
<MudProgressCircular Indeterminate="true" Size="Size.Small" />
|
|
|
|
|
}
|
|
|
|
|
else if (_events is { Count: > 0 })
|
|
|
|
|
{
|
|
|
|
|
<MudTable Items="@_events" Hover="true" Elevation="1">
|
|
|
|
|
<HeaderContent>
|
|
|
|
|
<MudTh>Horodatage</MudTh>
|
|
|
|
|
<MudTh>Type</MudTh>
|
|
|
|
|
<MudTh>Confiance</MudTh>
|
|
|
|
|
<MudTh>Label</MudTh>
|
|
|
|
|
<MudTh></MudTh>
|
|
|
|
|
</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="Label">@context.Label</MudTd>
|
|
|
|
|
<MudTd DataLabel="">
|
|
|
|
|
<MudIconButton Icon="@Icons.Material.Filled.Image" Size="Size.Small"
|
|
|
|
|
Disabled="@(context.SnapshotUrl is null)"
|
|
|
|
|
OnClick="@(() => _showSnapshotUrl = context.SnapshotUrl)" />
|
|
|
|
|
</MudTd>
|
|
|
|
|
</RowTemplate>
|
|
|
|
|
</MudTable>
|
|
|
|
|
<MudLink Href="@($"/sites/{_camera?.SiteId}/events")" Class="mt-2 d-block">
|
|
|
|
|
Voir tous les événements →
|
|
|
|
|
</MudLink>
|
|
|
|
|
}
|
|
|
|
|
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>
|
|
|
|
|
<img src="@_showSnapshotUrl" alt="Snapshot" style="width:100%;height:auto;" class="rounded-lg" />
|
|
|
|
|
</DialogContent>
|
|
|
|
|
<DialogActions>
|
|
|
|
|
<MudButton OnClick="@(() => _showSnapshotDialog = false)">Fermer</MudButton>
|
|
|
|
|
</DialogActions>
|
|
|
|
|
</MudDialog>
|
|
|
|
|
}
|
2026-07-17 19:08:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@code {
|
|
|
|
|
[Parameter] public Guid Id { get; set; }
|
|
|
|
|
|
|
|
|
|
private CameraItem? _camera;
|
|
|
|
|
private string _editName = "";
|
|
|
|
|
private string? _editRtspUrl;
|
|
|
|
|
private string _editError = "";
|
|
|
|
|
private string _editSuccess = "";
|
2026-07-19 13:21:25 +00:00
|
|
|
private bool _loading = true;
|
|
|
|
|
private bool _saving;
|
|
|
|
|
|
|
|
|
|
private List<EventItem>? _events;
|
|
|
|
|
private bool _eventsLoading;
|
|
|
|
|
private string? _showSnapshotUrl;
|
|
|
|
|
private bool _showSnapshotDialog;
|
|
|
|
|
private readonly DialogOptions _snapshotOptions = new()
|
|
|
|
|
{
|
|
|
|
|
FullWidth = true,
|
|
|
|
|
MaxWidth = MaxWidth.Large,
|
|
|
|
|
CloseButton = true
|
|
|
|
|
};
|
2026-07-17 19:08:17 +00:00
|
|
|
|
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
_camera = await Api.GetCameraAsync(Id);
|
|
|
|
|
if (_camera is not null)
|
|
|
|
|
{
|
|
|
|
|
_editName = _camera.Name;
|
|
|
|
|
_editRtspUrl = _camera.RtspUrl;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { Snackbar.Add($"Erreur : {ex.Message}", Severity.Error); }
|
|
|
|
|
finally { _loading = false; }
|
2026-07-19 13:21:25 +00:00
|
|
|
|
|
|
|
|
try { _eventsLoading = true; _events = await Api.GetRecentEventsAsync(Id, 10); }
|
|
|
|
|
catch { }
|
|
|
|
|
finally { _eventsLoading = false; }
|
2026-07-17 19:08:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private async Task SaveCamera()
|
|
|
|
|
{
|
|
|
|
|
if (string.IsNullOrWhiteSpace(_editName)) { _editError = "Le nom est requis"; return; }
|
|
|
|
|
_saving = true;
|
|
|
|
|
_editError = "";
|
|
|
|
|
_editSuccess = "";
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (await Api.UpdateCameraAsync(Id, _editName, _editRtspUrl, null))
|
|
|
|
|
{
|
|
|
|
|
_editSuccess = "Caméra mise à jour";
|
|
|
|
|
if (_camera is not null) _camera.Name = _editName;
|
|
|
|
|
}
|
|
|
|
|
else _editError = "Erreur lors de la mise à jour";
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex) { _editError = $"Erreur : {ex.Message}"; }
|
|
|
|
|
finally { _saving = false; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static Color GetStatusColor(string status) => status switch
|
|
|
|
|
{
|
|
|
|
|
"Online" => Color.Success,
|
|
|
|
|
"Offline" => Color.Error,
|
|
|
|
|
"Disabled" => Color.Default,
|
|
|
|
|
_ => Color.Warning
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private static string GetStatusIcon(string status) => status switch
|
|
|
|
|
{
|
|
|
|
|
"Online" => "●",
|
|
|
|
|
"Offline" => "○",
|
|
|
|
|
_ => "?"
|
|
|
|
|
};
|
|
|
|
|
}
|