154 lines
6.9 KiB
Plaintext
154 lines
6.9 KiB
Plaintext
@page "/clusters/{ClusterId}"
|
|
@attribute [Authorize(Policy = AdminUiPolicies.AuthenticatedRead)]
|
|
@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
|
|
|
|
<PageErrorBoundary>
|
|
<PageTitle>Cluster overview · OtOpcUa</PageTitle>
|
|
@if (!_loaded)
|
|
{
|
|
<div class="page-head"><h1>Cluster overview</h1></div>
|
|
<p>Loading…</p>
|
|
}
|
|
else if (_cluster is null)
|
|
{
|
|
<div class="page-head"><h1>Cluster overview</h1></div>
|
|
<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="page-head">
|
|
<div>
|
|
<h1>@_cluster.Name</h1>
|
|
<span class="mono text-muted">@_cluster.ClusterId</span>
|
|
@if (!_cluster.Enabled) { <span class="chip chip-idle ms-2">Disabled</span> }
|
|
</div>
|
|
<span class="spacer"></span>
|
|
<AuthorizeView Policy="@AdminUiPolicies.ConfigEditor">
|
|
<div class="btn-group btn-group-sm" role="group" aria-label="Cluster authoring actions">
|
|
<a href="/clusters/@ClusterId/edit" class="btn btn-outline-secondary btn-sm">Edit cluster</a>
|
|
<a href="/deployments" class="btn btn-outline-primary btn-sm">Deployments</a>
|
|
</div>
|
|
</AuthorizeView>
|
|
</div>
|
|
|
|
<ClusterNav ClusterId="@ClusterId" ActiveTab="overview" />
|
|
|
|
<section class="card-grid rise" style="animation-delay:.08s">
|
|
<div class="metric-card">
|
|
<h2 class="panel-head">Cluster details</h2>
|
|
<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" title="@_cluster.Notes">@DisplayText.Abbreviate(_cluster.Notes, 120)</span></div>
|
|
}
|
|
</div>
|
|
|
|
<div class="metric-card">
|
|
<h2 class="panel-head">Last deployment</h2>
|
|
@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">@DisplayText.Abbreviate(_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 d-flex align-items-center">
|
|
<h2 class="m-0" style="font:inherit">Nodes</h2>
|
|
<AuthorizeView Policy="@AdminUiPolicies.ConfigEditor">
|
|
<a href="/clusters/@ClusterId/nodes/new" class="btn btn-sm btn-outline-primary ms-auto">New node</a>
|
|
</AuthorizeView>
|
|
</div>
|
|
@if (_nodes is null || _nodes.Count == 0)
|
|
{
|
|
<div style="padding:1rem" class="text-muted">No nodes registered.</div>
|
|
}
|
|
else
|
|
{
|
|
<div class="table-wrap" role="region" aria-label="Cluster nodes" tabindex="0">
|
|
<table class="data-table">
|
|
<thead>
|
|
<tr>
|
|
<th scope="col">Node ID</th>
|
|
<th scope="col">Host</th>
|
|
<th scope="col">OPC UA port</th>
|
|
<th scope="col">ApplicationUri</th>
|
|
<th scope="col" class="num">ServiceLevel base</th>
|
|
<AuthorizeView Policy="@AdminUiPolicies.ConfigEditor">
|
|
<th scope="col"><span class="visually-hidden">Actions</span></th>
|
|
</AuthorizeView>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var n in _nodes)
|
|
{
|
|
<tr>
|
|
<td><span class="mono">@n.NodeId</span></td>
|
|
<td title="@n.Host">@DisplayText.Abbreviate(n.Host, 30)</td>
|
|
<td class="num">@n.OpcUaPort</td>
|
|
<td title="@n.ApplicationUri"><span class="mono small">@DisplayText.Abbreviate(n.ApplicationUri, 40)</span></td>
|
|
<td class="num">@n.ServiceLevelBase</td>
|
|
<AuthorizeView Policy="@AdminUiPolicies.ConfigEditor">
|
|
<td><a href="/clusters/@ClusterId/nodes/@n.NodeId" class="btn btn-sm btn-outline-primary">Edit</a></td>
|
|
</AuthorizeView>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
}
|
|
</section>
|
|
}
|
|
</PageErrorBoundary>
|
|
|
|
@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;
|
|
}
|
|
}
|