Gap 2 (#25): VirtualTagsTab.razor + /virtual-tags global page — list/create/toggle virtual tags per draft generation with DataType, Script, trigger, Historize, Enabled fields. Tab wired into DraftEditor. Gap 3 (#26): ScriptedAlarmsTab.razor + /scripted-alarms global page — list/create scripted alarms with AlarmType, Severity, MessageTemplate, PredicateScript, HistorizeToAveva, Retain. SeverityBand helper shows Low/Medium/High/Critical label. Tab wired into DraftEditor. Gap 4 (#27): ScriptLogHub (SignalR IAsyncEnumerable stream) tails scripts-*.log with optional ScriptName filter; ScriptLog.razor provides Start/Stop/Clear controls plus level filter dropdown. Hub registered at /hubs/script-log in Program.cs. Nav rail gains a "Scripting" eyebrow with entries for all three pages. 19 new unit tests for ScriptLogHub parse/filter/tail helpers (Category=Unit). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
128 lines
6.1 KiB
Plaintext
128 lines
6.1 KiB
Plaintext
@page "/clusters/{ClusterId}/draft/{GenerationId:long}"
|
|
@attribute [Microsoft.AspNetCore.Authorization.Authorize]
|
|
@using Microsoft.AspNetCore.Components.Web
|
|
@using ZB.MOM.WW.OtOpcUa.Admin.Services
|
|
@using ZB.MOM.WW.OtOpcUa.Configuration.Enums
|
|
@using ZB.MOM.WW.OtOpcUa.Configuration.Validation
|
|
@rendermode RenderMode.InteractiveServer
|
|
@inject GenerationService GenerationSvc
|
|
@inject DraftValidationService ValidationSvc
|
|
@inject NavigationManager Nav
|
|
|
|
<ClusterAuthorizeView ClusterId="@ClusterId" MinRole="AdminRole.ConfigEditor">
|
|
<NotAuthorized>
|
|
<section class="panel notice rise" style="animation-delay:.02s">
|
|
Editing cluster <span class="mono">@ClusterId</span> requires the
|
|
<span class="mono">ConfigEditor</span> role for this cluster.
|
|
</section>
|
|
</NotAuthorized>
|
|
<Authorized>
|
|
|
|
<div class="d-flex justify-content-between align-items-center mb-3">
|
|
<div>
|
|
<h1 class="page-title mb-0">Draft editor</h1>
|
|
<small class="text-muted">Cluster <span class="mono">@ClusterId</span> · generation @GenerationId</small>
|
|
</div>
|
|
<div>
|
|
<a class="btn btn-outline-secondary" href="/clusters/@ClusterId">Back to cluster</a>
|
|
<a class="btn btn-outline-primary ms-2" href="/clusters/@ClusterId/draft/@GenerationId/diff">View diff</a>
|
|
<ClusterAuthorizeView ClusterId="@ClusterId" MinRole="AdminRole.FleetAdmin">
|
|
<button class="btn btn-primary ms-2" disabled="@(_errors.Count != 0 || _busy)" @onclick="PublishAsync">Publish</button>
|
|
</ClusterAuthorizeView>
|
|
</div>
|
|
</div>
|
|
|
|
<ul class="nav nav-tabs mb-3">
|
|
<li class="nav-item"><button class="nav-link @Active("equipment")" @onclick='() => _tab = "equipment"'>Equipment</button></li>
|
|
<li class="nav-item"><button class="nav-link @Active("uns")" @onclick='() => _tab = "uns"'>UNS</button></li>
|
|
<li class="nav-item"><button class="nav-link @Active("namespaces")" @onclick='() => _tab = "namespaces"'>Namespaces</button></li>
|
|
<li class="nav-item"><button class="nav-link @Active("drivers")" @onclick='() => _tab = "drivers"'>Drivers</button></li>
|
|
<li class="nav-item"><button class="nav-link @Active("acls")" @onclick='() => _tab = "acls"'>ACLs</button></li>
|
|
<li class="nav-item"><button class="nav-link @Active("scripts")" @onclick='() => _tab = "scripts"'>Scripts</button></li>
|
|
<li class="nav-item"><button class="nav-link @Active("virtual-tags")" @onclick='() => _tab = "virtual-tags"'>Virtual Tags</button></li>
|
|
<li class="nav-item"><button class="nav-link @Active("scripted-alarms")" @onclick='() => _tab = "scripted-alarms"'>Scripted Alarms</button></li>
|
|
</ul>
|
|
|
|
<div class="row">
|
|
<div class="col-md-8">
|
|
@if (_tab == "equipment") { <EquipmentTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
else if (_tab == "uns") { <UnsTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
else if (_tab == "namespaces") { <NamespacesTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
else if (_tab == "drivers") { <DriversTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
else if (_tab == "acls") { <AclsTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
else if (_tab == "scripts") { <ScriptsTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
else if (_tab == "virtual-tags") { <VirtualTagsTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
else if (_tab == "scripted-alarms") { <ScriptedAlarmsTab GenerationId="@GenerationId" ClusterId="@ClusterId"/> }
|
|
</div>
|
|
<div class="col-md-4">
|
|
<section class="panel rise sticky-top" style="animation-delay:.02s">
|
|
<div class="panel-head d-flex justify-content-between align-items-center">
|
|
<strong>Validation</strong>
|
|
<button class="btn btn-sm btn-outline-secondary" @onclick="RevalidateAsync">Re-run</button>
|
|
</div>
|
|
<div class="p-3">
|
|
@if (_validating) { <p class="text-muted">Checking…</p> }
|
|
else if (_errors.Count == 0) { <p class="s-ok mb-0">No validation errors — safe to publish.</p> }
|
|
else
|
|
{
|
|
<p class="s-bad mb-2">@_errors.Count error@(_errors.Count == 1 ? "" : "s")</p>
|
|
<ul class="list-unstyled">
|
|
@foreach (var e in _errors)
|
|
{
|
|
<li class="mb-2">
|
|
<span class="chip chip-bad me-1">@e.Code</span>
|
|
<small>@e.Message</small>
|
|
@if (!string.IsNullOrEmpty(e.Context)) { <div class="text-muted"><span class="mono">@e.Context</span></div> }
|
|
</li>
|
|
}
|
|
</ul>
|
|
}
|
|
</div>
|
|
</section>
|
|
|
|
@if (_publishError is not null) { <section class="panel notice rise mt-2" style="animation-delay:.08s"><span class="s-bad">@_publishError</span></section> }
|
|
</div>
|
|
</div>
|
|
|
|
</Authorized>
|
|
</ClusterAuthorizeView>
|
|
|
|
@code {
|
|
[Parameter] public string ClusterId { get; set; } = string.Empty;
|
|
[Parameter] public long GenerationId { get; set; }
|
|
|
|
private string _tab = "equipment";
|
|
private List<ValidationError> _errors = [];
|
|
private bool _validating;
|
|
private bool _busy;
|
|
private string? _publishError;
|
|
|
|
private string Active(string k) => _tab == k ? "active" : string.Empty;
|
|
|
|
protected override async Task OnParametersSetAsync() => await RevalidateAsync();
|
|
|
|
private async Task RevalidateAsync()
|
|
{
|
|
_validating = true;
|
|
try
|
|
{
|
|
var errors = await ValidationSvc.ValidateAsync(GenerationId, CancellationToken.None);
|
|
_errors = errors.ToList();
|
|
}
|
|
finally { _validating = false; }
|
|
}
|
|
|
|
private async Task PublishAsync()
|
|
{
|
|
_busy = true;
|
|
_publishError = null;
|
|
try
|
|
{
|
|
await GenerationSvc.PublishAsync(ClusterId, GenerationId, notes: "Published via Admin UI", CancellationToken.None);
|
|
Nav.NavigateTo($"/clusters/{ClusterId}");
|
|
}
|
|
catch (Exception ex) { _publishError = ex.Message; }
|
|
finally { _busy = false; }
|
|
}
|
|
}
|