feat(adminui): F15 Phase B — cluster CRUD + Overview/Redundancy routes
Some checks failed
v2-ci / build (push) Failing after 38s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (push) Has been skipped

- ClustersList (/clusters) — table view, row-click opens detail
- NewCluster (/clusters/new) — EditForm with DataAnnotations; redundancy
  mode + node-count coupling enforced client-side (None→1, Warm/Hot→2);
  CreatedBy taken from AuthenticationStateProvider
- ClusterOverview (/clusters/{id}) — cluster details + last-deployment
  badge + node list. Per Q3, the legacy 10-tab monolith is split into
  separate routes; this page hosts the Overview "tab" as its primary slot
- ClusterRedundancy (/clusters/{id}/redundancy) — static ServiceLevelBase
  config view; live ServiceLevel comes via RedundancyStateActor DPS topic
  (deferred to its own follow-up once the SignalR bridge lands)

The other 8 v1 cluster tabs (Equipment, UNS, Namespaces, Drivers, Tags,
ACLs, ScriptedAlarms, Scripts, Audit) land in Phase C/D.
This commit is contained in:
Joseph Doherty
2026-05-26 07:52:41 -04:00
parent 850d6774ea
commit fd0cc4dfdb
4 changed files with 465 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
@page "/clusters/{ClusterId}"
@attribute [Microsoft.AspNetCore.Authorization.Authorize]
@rendermode RenderMode.InteractiveServer
@using Microsoft.EntityFrameworkCore
@using ZB.MOM.WW.OtOpcUa.Configuration
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
@inject NavigationManager Nav
@if (!_loaded)
{
<p>Loading…</p>
}
else if (_cluster is null)
{
<section class="panel notice rise" style="animation-delay:.02s">
Cluster <span class="mono">@ClusterId</span> was not found.
<a class="ms-2" href="/clusters">Back to list</a>.
</section>
}
else
{
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<h4 class="mb-0">@_cluster.Name</h4>
<span class="mono text-muted">@_cluster.ClusterId</span>
@if (!_cluster.Enabled) { <span class="chip chip-idle ms-2">Disabled</span> }
</div>
<div>
<a href="/deployments" class="btn btn-outline-primary btn-sm">Deployments</a>
</div>
</div>
<ul class="nav nav-tabs mb-3">
<li class="nav-item"><a class="nav-link active" href="/clusters/@ClusterId">Overview</a></li>
<li class="nav-item"><a class="nav-link" href="/clusters/@ClusterId/redundancy">Redundancy</a></li>
</ul>
<section class="card-grid rise" style="animation-delay:.08s">
<div class="metric-card">
<div class="panel-head">Cluster details</div>
<div class="kv"><span class="k">Enterprise / Site</span><span class="v">@_cluster.Enterprise / @_cluster.Site</span></div>
<div class="kv"><span class="k">Redundancy</span><span class="v">@_cluster.RedundancyMode (@_cluster.NodeCount node@(_cluster.NodeCount == 1 ? "" : "s"))</span></div>
<div class="kv"><span class="k">Created</span><span class="v">@_cluster.CreatedAt.ToString("u") by @_cluster.CreatedBy</span></div>
@if (_cluster.ModifiedAt is not null)
{
<div class="kv"><span class="k">Modified</span><span class="v">@_cluster.ModifiedAt?.ToString("u") by @(_cluster.ModifiedBy ?? "—")</span></div>
}
@if (!string.IsNullOrWhiteSpace(_cluster.Notes))
{
<div class="kv"><span class="k">Notes</span><span class="v">@_cluster.Notes</span></div>
}
</div>
<div class="metric-card">
<div class="panel-head">Last deployment</div>
@if (_lastDeployment is null)
{
<div class="kv"><span class="k">Status</span><span class="v text-muted">none — cluster has never been deployed</span></div>
}
else
{
<div class="kv"><span class="k">Revision</span><span class="v mono">@_lastDeployment.RevisionHash[..16]…</span></div>
<div class="kv"><span class="k">Status</span><span class="v">@_lastDeployment.Status</span></div>
<div class="kv"><span class="k">Created</span><span class="v">@_lastDeployment.CreatedAtUtc.ToString("u")</span></div>
@if (_lastDeployment.SealedAtUtc is not null)
{
<div class="kv"><span class="k">Sealed</span><span class="v">@_lastDeployment.SealedAtUtc?.ToString("u")</span></div>
}
}
</div>
</section>
<section class="panel rise mt-3" style="animation-delay:.14s">
<div class="panel-head">Nodes</div>
@if (_nodes is null || _nodes.Count == 0)
{
<div style="padding:1rem" class="text-muted">No nodes registered.</div>
}
else
{
<div class="table-wrap">
<table class="data-table">
<thead>
<tr>
<th>Node ID</th>
<th>Host</th>
<th>OPC UA port</th>
<th>ApplicationUri</th>
<th class="num">ServiceLevel base</th>
</tr>
</thead>
<tbody>
@foreach (var n in _nodes)
{
<tr>
<td><span class="mono">@n.NodeId</span></td>
<td>@n.Host</td>
<td class="num">@n.OpcUaPort</td>
<td><span class="mono small">@n.ApplicationUri</span></td>
<td class="num">@n.ServiceLevelBase</td>
</tr>
}
</tbody>
</table>
</div>
}
</section>
}
@code {
[Parameter] public string ClusterId { get; set; } = "";
private bool _loaded;
private ServerCluster? _cluster;
private List<ClusterNode>? _nodes;
private Deployment? _lastDeployment;
protected override async Task OnInitializedAsync()
{
await using var db = await DbFactory.CreateDbContextAsync();
_cluster = await db.ServerClusters.AsNoTracking()
.FirstOrDefaultAsync(c => c.ClusterId == ClusterId);
if (_cluster is not null)
{
_nodes = await db.ClusterNodes.AsNoTracking()
.Where(n => n.ClusterId == ClusterId)
.OrderBy(n => n.NodeId)
.ToListAsync();
_lastDeployment = await db.Deployments.AsNoTracking()
.OrderByDescending(d => d.CreatedAtUtc)
.FirstOrDefaultAsync();
}
_loaded = true;
}
}

View File

@@ -0,0 +1,111 @@
@page "/clusters/{ClusterId}/redundancy"
@attribute [Microsoft.AspNetCore.Authorization.Authorize]
@rendermode RenderMode.InteractiveServer
@using Microsoft.EntityFrameworkCore
@using ZB.MOM.WW.OtOpcUa.Configuration
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
@if (!_loaded)
{
<p>Loading…</p>
}
else if (_cluster is null)
{
<section class="panel notice rise" style="animation-delay:.02s">
Cluster <span class="mono">@ClusterId</span> was not found.
<a class="ms-2" href="/clusters">Back to list</a>.
</section>
}
else
{
<div class="d-flex justify-content-between align-items-center mb-3">
<div>
<h4 class="mb-0">@_cluster.Name &middot; Redundancy</h4>
<span class="mono text-muted">@_cluster.ClusterId</span>
</div>
</div>
<ul class="nav nav-tabs mb-3">
<li class="nav-item"><a class="nav-link" href="/clusters/@ClusterId">Overview</a></li>
<li class="nav-item"><a class="nav-link active" href="/clusters/@ClusterId/redundancy">Redundancy</a></li>
</ul>
<section class="panel notice rise" style="animation-delay:.02s">
v2 redundancy is computed at runtime by <span class="mono">RedundancyStateActor</span>
on each admin node. The values below are the static configuration; the resolved live
<span class="mono">ServiceLevel</span> for each peer is broadcast on the
<span class="mono">redundancy-state</span> DPS topic and consumed by the OPC UA host's
<span class="mono">ServerStatus</span> publisher. See
<a href="/docs/v2/Architecture-v2.md">docs/v2/Architecture-v2.md</a>.
</section>
<section class="card-grid rise mt-3" style="animation-delay:.08s">
<div class="metric-card">
<div class="panel-head">Cluster redundancy</div>
<div class="kv"><span class="k">Mode</span><span class="v">@_cluster.RedundancyMode</span></div>
<div class="kv"><span class="k">Node count</span><span class="v">@_cluster.NodeCount</span></div>
</div>
</section>
<section class="panel rise mt-3" style="animation-delay:.14s">
<div class="panel-head">Node service-level configuration</div>
@if (_nodes is null || _nodes.Count == 0)
{
<div style="padding:1rem" class="text-muted">No nodes registered.</div>
}
else
{
<div class="table-wrap">
<table class="data-table">
<thead>
<tr>
<th>Node ID</th>
<th>ApplicationUri</th>
<th class="num">ServiceLevel base</th>
<th>Notes</th>
</tr>
</thead>
<tbody>
@foreach (var n in _nodes)
{
<tr>
<td><span class="mono">@n.NodeId</span></td>
<td><span class="mono small">@n.ApplicationUri</span></td>
<td class="num">@n.ServiceLevelBase</td>
<td class="text-muted small">
@if (n.ServiceLevelBase >= 200) { <text>Primary preference</text> }
else if (n.ServiceLevelBase >= 100) { <text>Secondary preference</text> }
else { <text>Custom</text> }
</td>
</tr>
}
</tbody>
</table>
</div>
}
</section>
}
@code {
[Parameter] public string ClusterId { get; set; } = "";
private bool _loaded;
private ServerCluster? _cluster;
private List<ClusterNode>? _nodes;
protected override async Task OnInitializedAsync()
{
await using var db = await DbFactory.CreateDbContextAsync();
_cluster = await db.ServerClusters.AsNoTracking()
.FirstOrDefaultAsync(c => c.ClusterId == ClusterId);
if (_cluster is not null)
{
_nodes = await db.ClusterNodes.AsNoTracking()
.Where(n => n.ClusterId == ClusterId)
.OrderBy(n => n.NodeId)
.ToListAsync();
}
_loaded = true;
}
}

View File

@@ -0,0 +1,77 @@
@page "/clusters"
@attribute [Microsoft.AspNetCore.Authorization.Authorize]
@rendermode RenderMode.InteractiveServer
@using Microsoft.EntityFrameworkCore
@using ZB.MOM.WW.OtOpcUa.Configuration
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
@inject NavigationManager Nav
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="mb-0">Clusters</h4>
<a href="/clusters/new" class="btn btn-primary btn-sm">New cluster</a>
</div>
@if (_rows is null)
{
<p>Loading…</p>
}
else if (_rows.Count == 0)
{
<section class="panel notice rise" style="animation-delay:.02s">
No clusters defined yet. Use <strong>New cluster</strong> above to create one.
</section>
}
else
{
<section class="panel rise" style="animation-delay:.08s">
<div class="panel-head">All clusters</div>
<div class="table-wrap">
<table class="data-table">
<thead>
<tr>
<th>Cluster</th>
<th>Site</th>
<th>Nodes</th>
<th>Redundancy</th>
<th>Status</th>
<th>Created</th>
</tr>
</thead>
<tbody>
@foreach (var c in _rows)
{
<tr style="cursor:pointer" @onclick="() => OpenCluster(c.ClusterId)">
<td>
<span class="mono">@c.ClusterId</span>
<div class="text-muted small">@c.Name</div>
</td>
<td>@c.Enterprise / @c.Site</td>
<td class="num">@c.NodeCount</td>
<td>@c.RedundancyMode</td>
<td>
@if (c.Enabled) { <span class="chip chip-ok">Enabled</span> }
else { <span class="chip chip-idle">Disabled</span> }
</td>
<td class="text-muted small">@c.CreatedAt.ToString("u")</td>
</tr>
}
</tbody>
</table>
</div>
</section>
}
@code {
private List<ServerCluster>? _rows;
protected override async Task OnInitializedAsync()
{
await using var db = await DbFactory.CreateDbContextAsync();
_rows = await db.ServerClusters.AsNoTracking()
.OrderBy(c => c.ClusterId)
.ToListAsync();
}
private void OpenCluster(string clusterId) => Nav.NavigateTo($"/clusters/{clusterId}");
}

View File

@@ -0,0 +1,141 @@
@page "/clusters/new"
@attribute [Microsoft.AspNetCore.Authorization.Authorize]
@rendermode RenderMode.InteractiveServer
@using Microsoft.AspNetCore.Components.Forms
@using Microsoft.EntityFrameworkCore
@using ZB.MOM.WW.OtOpcUa.Configuration
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
@using ZB.MOM.WW.OtOpcUa.Configuration.Enums
@inject IDbContextFactory<OtOpcUaConfigDbContext> DbFactory
@inject NavigationManager Nav
@inject AuthenticationStateProvider AuthState
<div class="d-flex justify-content-between align-items-center mb-3">
<h4 class="mb-0">New cluster</h4>
<a href="/clusters" class="btn btn-outline-secondary btn-sm">Cancel</a>
</div>
<EditForm Model="_form" OnValidSubmit="SubmitAsync" FormName="newCluster">
<DataAnnotationsValidator />
<section class="panel rise" style="animation-delay:.02s">
<div class="panel-head">Identity</div>
<div style="padding:1rem">
<div class="mb-3">
<label class="form-label" for="clusterId">Cluster ID</label>
<InputText id="clusterId" @bind-Value="_form.ClusterId" class="form-control form-control-sm mono"
placeholder="LINE3-OPCUA" />
</div>
<div class="mb-3">
<label class="form-label" for="name">Name</label>
<InputText id="name" @bind-Value="_form.Name" class="form-control form-control-sm" />
</div>
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label" for="enterprise">Enterprise</label>
<InputText id="enterprise" @bind-Value="_form.Enterprise" class="form-control form-control-sm"
placeholder="zb" />
</div>
<div class="col-md-6 mb-3">
<label class="form-label" for="site">Site</label>
<InputText id="site" @bind-Value="_form.Site" class="form-control form-control-sm"
placeholder="warsaw-west" />
</div>
</div>
</div>
</section>
<section class="panel rise mt-3" style="animation-delay:.08s">
<div class="panel-head">Topology</div>
<div style="padding:1rem">
<div class="mb-3">
<label class="form-label" for="redundancy">Redundancy mode</label>
<InputSelect id="redundancy" @bind-Value="_form.RedundancyMode" class="form-select form-select-sm">
<option value="@RedundancyMode.None">None (1 node)</option>
<option value="@RedundancyMode.Warm">Warm (2 nodes, non-transparent)</option>
<option value="@RedundancyMode.Hot">Hot (2 nodes, non-transparent)</option>
</InputSelect>
<div class="form-text">NodeCount is implied — 1 for None, 2 for Warm/Hot.</div>
</div>
<div class="mb-3">
<label class="form-label" for="notes">Notes</label>
<InputTextArea id="notes" @bind-Value="_form.Notes" class="form-control form-control-sm" rows="3" />
</div>
</div>
</section>
@if (!string.IsNullOrWhiteSpace(_error))
{
<div class="panel notice mt-3">@_error</div>
}
<div class="mt-3 d-flex gap-2">
<button type="submit" class="btn btn-primary" disabled="@_busy">
@if (_busy) { <span class="spinner-border spinner-border-sm me-1"></span> }
Create cluster
</button>
<a href="/clusters" class="btn btn-outline-secondary">Cancel</a>
</div>
</EditForm>
@code {
private FormModel _form = new();
private string? _error;
private bool _busy;
private async Task SubmitAsync()
{
_busy = true;
_error = null;
try
{
await using var db = await DbFactory.CreateDbContextAsync();
if (await db.ServerClusters.AnyAsync(c => c.ClusterId == _form.ClusterId))
{
_error = $"Cluster '{_form.ClusterId}' already exists.";
return;
}
var auth = await AuthState.GetAuthenticationStateAsync();
var createdBy = auth.User.Identity?.Name ?? "(anonymous)";
var entity = new ServerCluster
{
ClusterId = _form.ClusterId,
Name = _form.Name,
Enterprise = _form.Enterprise,
Site = _form.Site,
RedundancyMode = _form.RedundancyMode,
NodeCount = _form.RedundancyMode == RedundancyMode.None ? (byte)1 : (byte)2,
Notes = string.IsNullOrWhiteSpace(_form.Notes) ? null : _form.Notes,
Enabled = true,
CreatedAt = DateTime.UtcNow,
CreatedBy = createdBy,
};
db.ServerClusters.Add(entity);
await db.SaveChangesAsync();
Nav.NavigateTo($"/clusters/{entity.ClusterId}");
}
catch (Exception ex)
{
_error = ex.Message;
}
finally
{
_busy = false;
}
}
private sealed class FormModel
{
[System.ComponentModel.DataAnnotations.Required, System.ComponentModel.DataAnnotations.RegularExpression("^[A-Z0-9_-]+$", ErrorMessage = "Use uppercase letters, digits, dash, underscore.")]
public string ClusterId { get; set; } = "";
[System.ComponentModel.DataAnnotations.Required]
public string Name { get; set; } = "";
[System.ComponentModel.DataAnnotations.Required]
public string Enterprise { get; set; } = "zb";
[System.ComponentModel.DataAnnotations.Required]
public string Site { get; set; } = "";
public RedundancyMode RedundancyMode { get; set; } = RedundancyMode.None;
public string? Notes { get; set; }
}
}