feat(admin-ui): pause live-tail snapshots while retaining bounded updates
This commit is contained in:
@@ -20,29 +20,39 @@
|
||||
<div class="page-head">
|
||||
<h1>Alerts</h1>
|
||||
<span class="spacer"></span>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div class="ot-toolbar d-flex flex-wrap align-items-center gap-2">
|
||||
<span class="conn-pill" data-state="@(_connected ? "connected" : "disconnected")">
|
||||
<span class="dot"></span><span>@(_connected ? "live" : "disconnected")</span>
|
||||
</span>
|
||||
<button class="btn btn-sm btn-outline-secondary" @onclick="ClearAsync">Clear</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-testid="tail-pause" aria-pressed="@(_paused ? "true" : "false")" @onclick="TogglePause">@(_paused ? "Resume" : "Pause")</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-testid="tail-clear" @onclick="ClearAsync">Clear visible log</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p role="status" aria-live="polite" aria-atomic="true" data-testid="tail-status">@(_connected ? "Connected" : "Disconnected") · @(_paused ? "Paused — displayed rows are frozen." : "Live — showing the latest retained entries.")</p>
|
||||
<p class="small text-muted"><span data-testid="tail-retained-count">@_tail.Items.Count</span> retained (maximum @Capacity). @(_paused ? "New arrivals continue replacing the oldest retained entries. Resume to see the latest window." : "Only this page’s current window is shown.") Clear affects this visible window, not historian records.</p>
|
||||
|
||||
<section class="panel notice rise" style="animation-delay:.02s">
|
||||
Shows the most-recent @Capacity entries since the page opened; reload for a fresh window.
|
||||
</section>
|
||||
|
||||
@if (_tail.Items.Count == 0)
|
||||
@if (_displayed.Count == 0)
|
||||
{
|
||||
<section class="panel notice rise mt-3" style="animation-delay:.08s">
|
||||
No alarms in the current window. The table will populate as soon as a
|
||||
ScriptedAlarmActor or driver alarm bridge publishes a transition.
|
||||
@if (_paused)
|
||||
{
|
||||
<span>No alert transitions in the paused snapshot. Resume to show retained transitions.</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>No alarms in the current window. The table will populate as soon as a ScriptedAlarmActor or driver alarm bridge publishes a transition.</span>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="panel rise mt-3" style="animation-delay:.08s">
|
||||
<h2 class="panel-head">Recent transitions (@_tail.Items.Count)</h2>
|
||||
<h2 class="panel-head">Displayed transitions (@_displayed.Count)</h2>
|
||||
<div class="table-wrap" role="region" aria-label="Recent alert transitions" tabindex="0">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
@@ -61,7 +71,7 @@ else
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var e in _tail.Items)
|
||||
@foreach (var e in _displayed)
|
||||
{
|
||||
<tr>
|
||||
<td><span class="mono small">@e.TimestampUtc.ToString("HH:mm:ss.fff")</span></td>
|
||||
@@ -144,6 +154,8 @@ else
|
||||
private readonly LiveTailBuffer<AlarmTransitionEvent> _tail = new(Capacity);
|
||||
private CoalescingRenderScheduler? _render;
|
||||
private bool _connected;
|
||||
private bool _paused;
|
||||
private IReadOnlyList<AlarmTransitionEvent> _displayed = Array.Empty<AlarmTransitionEvent>();
|
||||
|
||||
// Authorization — DriverOperator gates the per-row Ack/Shelve/Unshelve controls.
|
||||
private bool _canOperate;
|
||||
@@ -292,7 +304,9 @@ else
|
||||
// Render context: drain the queue into the ring and render once.
|
||||
private void FlushTail()
|
||||
{
|
||||
if (_tail.Flush()) StateHasChanged();
|
||||
if (!_tail.Flush()) return;
|
||||
if (!_paused) _displayed = _tail.Items;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
// Raised by the broadcaster (on the bridge actor's thread) whenever the upstream DPS
|
||||
@@ -301,9 +315,20 @@ else
|
||||
private void OnConnectionStateChanged(bool connected) =>
|
||||
InvokeAsync(() => { _connected = connected; StateHasChanged(); });
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
FlushTail();
|
||||
_paused = !_paused;
|
||||
if (!_paused)
|
||||
{
|
||||
_displayed = _tail.Items;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ClearAsync()
|
||||
{
|
||||
_tail.Clear();
|
||||
_displayed = Array.Empty<AlarmTransitionEvent>();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,27 +30,31 @@
|
||||
<span class="conn-pill" data-state="@(_connected ? "connected" : "disconnected")">
|
||||
<span class="dot"></span><span>@(_connected ? "live" : "disconnected")</span>
|
||||
</span>
|
||||
<button class="btn btn-sm btn-outline-secondary" @onclick="ClearAsync">Clear</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-testid="tail-pause" aria-pressed="@(_paused ? "true" : "false")" @onclick="TogglePause">@(_paused ? "Resume" : "Pause")</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-secondary" data-testid="tail-clear" @onclick="ClearAsync">Clear visible log</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p role="status" aria-live="polite" aria-atomic="true" data-testid="tail-status">@(_connected ? "Connected" : "Disconnected") · @(_paused ? "Paused — displayed rows are frozen." : "Live — showing the latest retained entries.")</p>
|
||||
<p class="small text-muted"><span data-testid="tail-retained-count">@_tail.Items.Count</span> retained (maximum @Capacity). @(_paused ? "New arrivals continue replacing the oldest retained entries. Resume to see the latest window." : "Only this page’s current window is shown.") Clear affects this visible window, not historian records.</p>
|
||||
|
||||
@if (_visible.Count == 0)
|
||||
{
|
||||
<section class="panel notice rise mt-3" style="animation-delay:.08s">
|
||||
@if (_tail.Items.Count == 0)
|
||||
@if (_displayed.Count == 0)
|
||||
{
|
||||
<span>No script-log entries yet.</span>
|
||||
<span>@(_paused ? "No entries in the paused snapshot. Resume to show retained entries." : "No script-log entries yet.")</span>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span>No entries match the current filter (@_tail.Items.Count entries available).</span>
|
||||
<span>No entries match the current filter (@_displayed.Count entries in the displayed snapshot).</span>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
else
|
||||
{
|
||||
<section class="panel rise mt-3" style="animation-delay:.08s">
|
||||
<h2 class="panel-head">Showing @_visible.Count of @_tail.Items.Count</h2>
|
||||
<h2 class="panel-head">Showing @_visible.Count of @_displayed.Count displayed entries</h2>
|
||||
<div class="table-wrap" role="region" aria-label="Script log entries" tabindex="0">
|
||||
<table class="data-table">
|
||||
<thead>
|
||||
@@ -94,6 +98,8 @@ else
|
||||
// The filtered rows, recomputed on flush / filter change — not on every render.
|
||||
private IReadOnlyList<ScriptLogEntry> _visible = Array.Empty<ScriptLogEntry>();
|
||||
private bool _connected;
|
||||
private bool _paused;
|
||||
private IReadOnlyList<ScriptLogEntry> _displayed = Array.Empty<ScriptLogEntry>();
|
||||
private string _levelFilter = "";
|
||||
private string _scriptFilter = "";
|
||||
|
||||
@@ -104,7 +110,7 @@ else
|
||||
|
||||
private void RecomputeVisible()
|
||||
{
|
||||
IEnumerable<ScriptLogEntry> q = _tail.Items;
|
||||
IEnumerable<ScriptLogEntry> q = _displayed;
|
||||
if (!string.IsNullOrWhiteSpace(_levelFilter)
|
||||
&& LevelRank.TryGetValue(_levelFilter, out var minRank))
|
||||
{
|
||||
@@ -144,13 +150,29 @@ else
|
||||
private void FlushTail()
|
||||
{
|
||||
if (!_tail.Flush()) return;
|
||||
RecomputeVisible();
|
||||
if (!_paused)
|
||||
{
|
||||
_displayed = _tail.Items;
|
||||
RecomputeVisible();
|
||||
}
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private void TogglePause()
|
||||
{
|
||||
FlushTail();
|
||||
_paused = !_paused;
|
||||
if (!_paused)
|
||||
{
|
||||
_displayed = _tail.Items;
|
||||
RecomputeVisible();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ClearAsync()
|
||||
{
|
||||
_tail.Clear();
|
||||
_displayed = Array.Empty<ScriptLogEntry>();
|
||||
RecomputeVisible();
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user