1475991fd6
M1: PageErrorBoundary wraps the body of every InteractiveServer page; the inert layout boundary is removed. m1: DisposeBridge cancels its CTS when the 5 s wait times out. m2: a CSV import that commits after the modal closed still raises OnSaved. m3: document SecurityMode=None no-fallback in Client.CLI.md / Client.UI.md. m4: browsePageDelayMs written only when loaded or changed; negative flagged. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
89 lines
3.5 KiB
Plaintext
89 lines
3.5 KiB
Plaintext
@page "/alarms-historian"
|
|
@* Live status of the local node's IAlarmHistorianSink (queue depth, drain state) via the
|
|
HistorianAdapterActor.GetStatus query landed in F11. *@
|
|
@attribute [Authorize(Policy = AdminUiPolicies.AuthenticatedRead)]
|
|
@rendermode RenderMode.InteractiveServer
|
|
@using Akka.Actor
|
|
@using Akka.Hosting
|
|
@using ZB.MOM.WW.OtOpcUa.Core.AlarmHistorian
|
|
@using ZB.MOM.WW.OtOpcUa.Runtime
|
|
@using ZB.MOM.WW.OtOpcUa.Runtime.Historian
|
|
@inject IRequiredActor<HistorianAdapterActorKey> HistorianActor
|
|
@implements IDisposable
|
|
|
|
<PageErrorBoundary>
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<h4 class="mb-0">Alarms historian sink</h4>
|
|
</div>
|
|
|
|
<div class="text-muted small mb-3">Polling every @PollSeconds s.</div>
|
|
|
|
@if (_status is null)
|
|
{
|
|
<p class="mt-3">Loading…</p>
|
|
}
|
|
else
|
|
{
|
|
<section class="card-grid rise mt-3" style="animation-delay:.08s">
|
|
<div class="metric-card">
|
|
<div class="panel-head">Queue</div>
|
|
<div class="kv"><span class="k">Depth</span><span class="v numeric">@_status.QueueDepth</span></div>
|
|
<div class="kv"><span class="k">Dead-lettered</span><span class="v numeric">@_status.DeadLetterDepth</span></div>
|
|
<div class="kv"><span class="k">Evicted (lifetime)</span><span class="v numeric">@_status.EvictedCount</span></div>
|
|
</div>
|
|
|
|
<div class="metric-card">
|
|
<div class="panel-head">Drain state</div>
|
|
<div class="kv"><span class="k">State</span><span class="v"><span class="@StateChipClass(_status.DrainState)">@_status.DrainState</span></span></div>
|
|
<div class="kv"><span class="k">Last drain</span><span class="v">@(_status.LastDrainUtc?.ToString("u") ?? "—")</span></div>
|
|
<div class="kv"><span class="k">Last success</span><span class="v">@(_status.LastSuccessUtc?.ToString("u") ?? "—")</span></div>
|
|
@if (!string.IsNullOrWhiteSpace(_status.LastError))
|
|
{
|
|
<div class="kv"><span class="k">Last error</span><span class="v text-danger small" title="@_status.LastError">@DisplayText.Abbreviate(_status.LastError, 80)</span></div>
|
|
}
|
|
</div>
|
|
</section>
|
|
}
|
|
</PageErrorBoundary>
|
|
|
|
@code {
|
|
private const int PollSeconds = 5;
|
|
|
|
private HistorianSinkStatus? _status;
|
|
private Timer? _timer;
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
await RefreshAsync();
|
|
_timer = new Timer(_ => _ = InvokeAsync(RefreshAsync), null,
|
|
TimeSpan.FromSeconds(PollSeconds), TimeSpan.FromSeconds(PollSeconds));
|
|
}
|
|
|
|
private async Task RefreshAsync()
|
|
{
|
|
try
|
|
{
|
|
_status = await HistorianActor.ActorRef.Ask<HistorianSinkStatus>(
|
|
HistorianAdapterActor.GetStatus.Instance, TimeSpan.FromSeconds(2));
|
|
StateHasChanged();
|
|
}
|
|
catch
|
|
{
|
|
// Actor unavailable (admin-only node, not driver-role) — leave _status null and let
|
|
// the page show "Loading…". A dedicated "this role doesn't run a historian" message
|
|
// would be nicer; lands when we add role gating to the UI.
|
|
}
|
|
}
|
|
|
|
private static string StateChipClass(HistorianDrainState state) => state switch
|
|
{
|
|
HistorianDrainState.Disabled => "chip chip-idle",
|
|
HistorianDrainState.Idle => "chip chip-idle",
|
|
HistorianDrainState.Draining => "chip chip-ok",
|
|
HistorianDrainState.BackingOff => "chip chip-caution",
|
|
_ => "chip chip-idle",
|
|
};
|
|
|
|
public void Dispose() => _timer?.Dispose();
|
|
}
|