Heimdall Gitea / Build and tests (pull_request) Failing after 2m10s
Heimdall Gitea / Build and scan server image (pull_request) Skipped
Heimdall Gitea / Build and scan agent image (pull_request) Skipped
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Publish versioned release (pull_request) Skipped
106 lines
5.0 KiB
Plaintext
106 lines
5.0 KiB
Plaintext
@* 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 ─── *@
|
|
<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="@string.Format(Text["CameraTile_SnapshotAlt"], 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">
|
|
@(GetStatusLabel(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="@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" ? 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" ? Text["CameraTile_Enable"] : Text["CameraTile_Disable"])"
|
|
OnClick="@OnToggleStatus" Disabled="@_toggling" />
|
|
</MudTooltip>
|
|
<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="@Text["CameraTile_Delete"]">
|
|
<MudIconButton Icon="@Icons.Material.Filled.Delete" Size="Size.Small" Color="Color.Error"
|
|
aria-label="@Text["CameraTile_Delete"]" 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 bool SnapshotRequesting { get; set; }
|
|
[Parameter] public EventCallback OnSnapshot { get; set; }
|
|
[Parameter] public EventCallback OnDelete { get; set; }
|
|
[Parameter] public EventCallback OnToggleStatus { get; set; }
|
|
|
|
private bool _toggling;
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
// Reset toggling state when camera data changes (after parent refreshes list)
|
|
_toggling = false;
|
|
}
|
|
|
|
private static Color GetStatusColor(string? status) => status switch
|
|
{
|
|
"Online" => Color.Success,
|
|
"Disabled" => Color.Default,
|
|
_ => Color.Warning
|
|
};
|
|
|
|
private string GetStatusLabel(string? status) => status switch
|
|
{
|
|
"Online" => Text["CameraTile_StatusOnline"],
|
|
"Disabled" => Text["CameraTile_StatusDisabled"],
|
|
"Offline" => Text["CameraTile_StatusOffline"],
|
|
_ => status ?? "—"
|
|
};
|
|
}
|