feat(adminui): F15.3 closes F15 — live alerts/script-log, CSV import, Monaco editor
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been cancelled
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been cancelled
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been cancelled
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been cancelled
v2-ci / build (push) Has been cancelled
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been cancelled
v2-ci / integration (push) Has been cancelled

Final F15 batch wires up the SignalR-backed live pages, ports the bulk
equipment importer, and progressively enhances the Script source editor
with Monaco.

Message contracts:
- Commons.Messages.Alerts.AlarmTransitionEvent — fires on every alarm
  state transition; published on the `alerts` DPS topic by future
  ScriptedAlarmActor (F9) emits.
- Commons.Messages.Logging.ScriptLogEntry — one log line emitted by a
  hosted script; published on the `script-logs` DPS topic by future
  VirtualTagActor (F8) + ScriptedAlarmActor (F9) emits.
  (Folder named "Logging" to dodge .gitignore's "logs/" rule.)

SignalR plumbing:
- AlertHub gains MethodName + bridge actor (AlertSignalRBridge)
- ScriptLogHub introduced; ScriptLogSignalRBridge follows the same
  DPS-subscribe → IHubContext fan-out pattern as FleetStatusSignalRBridge
- WithOtOpcUaSignalRBridges now spawns all three bridges
- MapOtOpcUaHubs maps /hubs/script-log alongside the existing hubs

Pages:
- /alerts                      live alarm tail, 200-row capacity
- /script-log                  live script-log tail with level + script
                               filter, 500-row capacity
- /clusters/{id}/equipment/import — CSV bulk Equipment add with preview
                                    (Name/MachineCode/UnsLineId/Driver +
                                    optional ZTag/SAPID/Manufacturer/Model;
                                    skips rows whose MachineCode already
                                    exists in the fleet)
- ScriptEdit progressively enhanced with Monaco editor via JSInterop —
  the textarea remains Blazor's source of truth and Monaco syncs into it
  on every keystroke so @bind keeps working; falls back gracefully if
  the CDN is unreachable.

MainLayout nav gains a "Live" section (Deployments, Alerts, Alarms
historian) and a "Scripts" link under Scripting. ClusterEquipment
surfaces the new Import CSV button.

Tally: F15 ships ~42 razor pages + 3 SignalR hubs + 3 bridge actors.
Microsoft.AspNetCore.SignalR.Client added (was already in central PM).

All 104 v2 tests remain green.
This commit is contained in:
Joseph Doherty
2026-05-26 08:39:17 -04:00
parent e248e037e7
commit 59858129cb
15 changed files with 764 additions and 12 deletions
@@ -13,6 +13,7 @@
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
@inject NavigationManager Nav
@inject IJSRuntime JS
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="mb-0">@(IsNew ? "New script" : "Edit script")</h4>
@@ -56,10 +57,15 @@ else
<section class="panel rise mt-3">
<div class="panel-head">Source</div>
<div style="padding:1rem">
<InputTextArea @bind-Value="_form.SourceCode" class="form-control form-control-sm mono"
rows="20"
placeholder="// C# expression body — Monaco editor lands in a follow-up." />
<div class="form-text">SHA-256 hash is computed automatically on save.</div>
@* The textarea stays in the DOM and remains Blazor's source of truth. Monaco
mounts a <div> beside it (textarea hides), and the loader's onDidChangeModelContent
handler mirrors edits back into the textarea + fires the input event so @bind
picks them up. Falls back to the textarea gracefully if Monaco's CDN is
unreachable (air-gapped deployments — see monaco-loader.js). *@
<InputTextArea id="script-source" @bind-Value="_form.SourceCode"
class="form-control form-control-sm mono" rows="20"
placeholder="// C# expression body" />
<div class="form-text">SHA-256 hash is computed automatically on save. Monaco editor attaches over the textarea on render.</div>
</div>
</section>
@@ -104,6 +110,24 @@ else
_loaded = true;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender || !_loaded) return;
// Inject loader once, then attach over the textarea. Failures are silent — the page
// is fully usable via the underlying textarea if Monaco's CDN is unreachable.
try
{
await JS.InvokeVoidAsync("eval", "if (!document.querySelector('script[data-otopcua=monaco-loader]')) { var s=document.createElement('script'); s.src='/_content/ZB.MOM.WW.OtOpcUa.AdminUI/js/monaco-loader.js'; s.dataset.otopcua='monaco-loader'; document.head.appendChild(s); }");
// Wait a tick for the loader IIFE to register window.otOpcUaScriptEditor, then attach.
await Task.Delay(50);
await JS.InvokeVoidAsync("otOpcUaScriptEditor.attach", "script-source");
}
catch
{
// Textarea remains the editor — no-op.
}
}
private async Task SubmitAsync()
{
_busy = true; _error = null;