90 lines
3.9 KiB
Plaintext
90 lines
3.9 KiB
Plaintext
@* CameraTile.razor — tuile caméra live : vignette snapshot, statut, actions. *@
|
|
@inject ISnackbar Snackbar
|
|
@inject NavigationManager Nav
|
|
|
|
<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 ─── *@
|
|
<div class="camera-thumb" style="position: relative; aspect-ratio: 16/9; background: var(--mud-palette-dark); overflow: hidden;">
|
|
@if (LoadingSnapshot)
|
|
{
|
|
<MudSkeleton Variant="SkeletonVariant.Rectangular" Height="100%" />
|
|
}
|
|
else if (!string.IsNullOrEmpty(SnapshotUrl))
|
|
{
|
|
<img src="@SnapshotUrl" alt="Vignette de @Camera.Name" style="width:100%; height:100%; object-fit:cover;"
|
|
loading="lazy" />
|
|
@if (Camera.Status == "Online")
|
|
{
|
|
<span class="hmd-live-dot" style="position:absolute; top:8px; left:8px;" aria-hidden="true"></span>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<div class="d-flex align-center justify-center" style="height:100%; min-height:120px;">
|
|
<MudIcon Icon="@Icons.Material.Filled.Videocam" Size="Size.Large" Color="Color.Secondary" />
|
|
</div>
|
|
}
|
|
|
|
@* Badge statut — coin haut droit *@
|
|
<div style="position:absolute; top:8px; right:8px;">
|
|
<MudChip T="string" Size="Size.Small" Color="@GetStatusColor(Camera.Status)" Variant="Variant.Filled">
|
|
@FormatStatus(Camera.Status)
|
|
</MudChip>
|
|
</div>
|
|
</div>
|
|
|
|
@* ─── Corps de la tuile ─── *@
|
|
<div class="pa-3 d-flex flex-column" style="flex:1;">
|
|
<MudLink Href="@($"/cameras/{Camera.Id}")" Typo="Typo.subtitle1" Class="font-weight-medium">
|
|
@Camera.Name
|
|
</MudLink>
|
|
<MudText Typo="Typo.caption" Color="Color.Secondary" Class="mb-2">
|
|
@if (!string.IsNullOrEmpty(Camera.Manufacturer)) { @Camera.Manufacturer }
|
|
@if (!string.IsNullOrEmpty(Camera.Model)) { <span> · @Camera.Model</span> }
|
|
@if (string.IsNullOrEmpty(Camera.Manufacturer) && string.IsNullOrEmpty(Camera.Model)) { <span>—</span> }
|
|
</MudText>
|
|
|
|
<MudSpacer />
|
|
|
|
@* ─── 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"
|
|
OnClick="@(() => Nav.NavigateTo($"/cameras/{Camera.Id}"))" />
|
|
</MudTooltip>
|
|
<MudTooltip Text="Prendre un snapshot">
|
|
<MudIconButton Icon="@Icons.Material.Filled.PhotoCamera" Size="Size.Small" aria-label="Prendre un snapshot"
|
|
Disabled="@(Camera.Status != "Online")" OnClick="@OnSnapshot" />
|
|
</MudTooltip>
|
|
<MudTooltip Text="Supprimer la caméra">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
|
|
aria-label="Supprimer la caméra" OnClick="@OnDelete" />
|
|
</MudTooltip>
|
|
</div>
|
|
</div>
|
|
</MudPaper>
|
|
|
|
@code {
|
|
[Parameter, EditorRequired] public CameraItem Camera { get; set; } = default!;
|
|
[Parameter] public string? SnapshotUrl { get; set; }
|
|
[Parameter] public bool LoadingSnapshot { get; set; }
|
|
[Parameter] public EventCallback OnSnapshot { get; set; }
|
|
[Parameter] public EventCallback OnDelete { get; set; }
|
|
|
|
private static Color GetStatusColor(string status) => status switch
|
|
{
|
|
"Online" => Color.Success,
|
|
"Offline" => Color.Error,
|
|
"Disabled" => Color.Default,
|
|
_ => Color.Warning
|
|
};
|
|
|
|
private static string FormatStatus(string status) => status switch
|
|
{
|
|
"Online" => "En ligne",
|
|
"Offline" => "Hors ligne",
|
|
"Disabled" => "Désactivée",
|
|
_ => status
|
|
};
|
|
}
|