Unify gateway styling and preserve identity through recovery
ci / java (push) Failing after 15m11s
ci / nightly-windev (push) Failing after 10m18s
ci / portable (push) Failing after 27m42s
ci / windows-x86 (push) Failing after 22m19s

This commit is contained in:
Joseph Doherty
2026-11-13 20:12:00 -05:00
parent b06921ce85
commit 26a90883fa
76 changed files with 20585 additions and 128 deletions
@@ -0,0 +1,6 @@
@namespace MxUiCanary.Components
@page "/apikeys"
@layout ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Layout.MainLayout
@inject IJSRuntime JS
<ApiKeysPage/>
@code { protected override async Task OnAfterRenderAsync(bool firstRender){if(firstRender)await JS.InvokeVoidAsync("mxCanaryReady");} }
@@ -1,5 +1,7 @@
@namespace MxUiCanary.Components
@page "/browse-fixture"
@page "/browse"
@layout ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Layout.MainLayout
@inject IJSRuntime JS
<ThemeShell Product="Synthetic MX browse"><ChildContent><p>Synthetic cached Galaxy and redacted fixture values. No COM or worker.</p><BrowsePage/></ChildContent></ThemeShell>
<p>Synthetic cached Galaxy and redacted fixture values. No COM or worker.</p><BrowsePage/>
@code { protected override async Task OnAfterRenderAsync(bool firstRender){if(firstRender)await JS.InvokeVoidAsync("mxCanaryReady");} }
@@ -0,0 +1,20 @@
@namespace MxUiCanary.Components
@using ZB.MOM.WW.MxGateway.Server.Dashboard
@page "/fault-identity-fixture"
@implements IDisposable
@inject IJSRuntime JS
<ThemeShell Product="Synthetic fault identity"><ChildContent>
<h1>Fault identity fixture</h1>
<button type="button" class="btn btn-primary" @onclick="ArmAsync">Arm synthetic next snapshot</button>
<p role="status">Snapshot @_round</p>
<section data-fault-mode="compact"><FaultList Faults="_faults" Compact="true" /></section>
<section data-fault-mode="table"><FaultList Faults="_faults" /></section>
</ChildContent></ThemeShell>
@code {
private int _round;private bool _disposed;
private IReadOnlyList<DashboardFaultSummary> _faults=[Fault("session-a"),Fault("session-b")];
private static DashboardFaultSummary Fault(string id)=>new("Worker",id,123,"Faulted","Synthetic fault for "+id+" "+new string('x',300),DateTimeOffset.UnixEpoch);
private async Task ArmAsync(){await Task.Delay(1200);if(_disposed)return;_round++;_faults=[Fault("session-c"),Fault("session-b"),Fault("session-a") with{ObservedAt=DateTimeOffset.UnixEpoch.AddMinutes(1)}];}
protected override async Task OnAfterRenderAsync(bool firstRender){if(firstRender)await JS.InvokeVoidAsync("mxCanaryReady");}
public void Dispose()=>_disposed=true;
}
@@ -1,5 +1,5 @@
@namespace MxUiCanary.Components
@page "/"
@page "/native-fixture"
@inject IJSRuntime JS
<ThemeShell Product="Synthetic MX UI canary">
<ChildContent>
@@ -0,0 +1,7 @@
@namespace MxUiCanary.Components
@page "/layout-fixture"
@layout ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Layout.MainLayout
@inject IJSRuntime JS
<h1>Navigation fixture</h1>
<p>Synthetic principals; links and the logout form are inspected without submitting them.</p>
@code { protected override async Task OnAfterRenderAsync(bool firstRender){if(firstRender)await JS.InvokeVoidAsync("mxCanaryReady");} }
@@ -1,5 +1,7 @@
@namespace MxUiCanary.Components
@page "/overview-fixture"
@page "/"
@layout ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Layout.MainLayout
@inject IJSRuntime JS
<ThemeShell Product="Synthetic MX overview"><ChildContent><DashboardHome/></ChildContent></ThemeShell>
<DashboardHome/>
@code { protected override async Task OnAfterRenderAsync(bool firstRender){if(firstRender)await JS.InvokeVoidAsync("mxCanaryReady");} }
@@ -0,0 +1,22 @@
@namespace MxUiCanary.Components
@page "/style-fixture"
@inject IJSRuntime JS
<ThemeShell Product="Synthetic style fixture"><ChildContent>
<h1>Component states</h1>
<p>Shared components with MX host adapters; no operation provider.</p>
<div class="d-flex gap-2 flex-wrap">
<TechButton id="style-primary">Primary action</TechButton>
<TechButton Variant="ButtonVariant.Secondary">Secondary action</TechButton>
<TechButton Variant="ButtonVariant.Danger">Danger action</TechButton>
<TechButton disabled>Disabled action</TechButton>
<TechButton Busy="true" BusyText="Working…">Busy action</TechButton>
</div>
<TechField Label="Fixture field" For="style-field"><input id="style-field" class="form-control" /></TechField>
<section class="dashboard-section">
<p><span class="quality-chip quality-good">Good</span> <span class="quality-chip quality-bad">Bad</span></p>
<p><span class="alarm-state alarm-state-active">Active</span> <span class="alarm-state alarm-state-acked">Acknowledged</span> <span class="alarm-state alarm-state-other">Unknown</span></p>
<p><span class="text-secondary">Secondary text</span> <span class="text-success">Success text</span> <span class="text-warning">Warning text</span> <span class="text-danger">Danger text</span> <span class="text-info">Information text</span></p>
<div class="alert alert-success">Success notice</div><div class="alert alert-danger">Error notice</div><div class="alert alert-info">Information notice</div><div class="alert alert-warning">Warning notice</div>
</section>
</ChildContent></ThemeShell>
@code { protected override async Task OnAfterRenderAsync(bool firstRender){if(firstRender)await JS.InvokeVoidAsync("mxCanaryReady");} }
+26 -10
View File
@@ -71,7 +71,7 @@ using ZB.MOM.WW.MxGateway.Server.Security.Authorization;
internal sealed class ManagingApiKeyService : IDashboardApiKeyManagementService
{
/// <inheritdoc />
public bool CanManage(ClaimsPrincipal user) => true;
public bool CanManage(ClaimsPrincipal user) => user.IsInRole(DashboardRoles.Admin);
/// <inheritdoc />
public Task<DashboardApiKeyManagementResult> CreateAsync(
@@ -102,15 +102,16 @@ using ZB.MOM.WW.MxGateway.Server.Security.Authorization;
Task.FromResult(DashboardApiKeyManagementResult.Fail("not exercised"));
}
internal sealed class StubAuthenticationStateProvider : AuthenticationStateProvider
internal sealed class StubAuthenticationStateProvider(Microsoft.AspNetCore.Components.NavigationManager nav) : AuthenticationStateProvider
{
/// <inheritdoc />
public override Task<AuthenticationState> GetAuthenticationStateAsync() =>
Task.FromResult(new AuthenticationState(new ClaimsPrincipal(new ClaimsIdentity(
[new Claim(ClaimTypes.Name, "admin-user"), new Claim(ClaimTypes.Role, DashboardRoles.Admin)],
authenticationType: "test",
nameType: ClaimTypes.Name,
roleType: ClaimTypes.Role))));
public override Task<AuthenticationState> GetAuthenticationStateAsync()
{
var query = Microsoft.AspNetCore.WebUtilities.QueryHelpers.ParseQuery(new Uri(nav.Uri).Query);
string role = query.TryGetValue("principal", out var value) ? value.ToString() : "admin";
var identity = role == "anonymous" ? new ClaimsIdentity() : new ClaimsIdentity(
[new Claim(ClaimTypes.Name, "fixture-user"), new Claim(ClaimTypes.Role, role == "viewer" ? DashboardRoles.Viewer : DashboardRoles.Admin)], "synthetic");
return Task.FromResult(new AuthenticationState(new ClaimsPrincipal(identity)));
}
}
// In-memory Galaxy projection and read-only fake values for the actual BrowsePage.
internal sealed class FixtureGalaxyCache : ZB.MOM.WW.GalaxyRepository.IGalaxyHierarchyCache
@@ -124,7 +125,7 @@ internal sealed class FixtureGalaxyCache : ZB.MOM.WW.GalaxyRepository.IGalaxyHie
pump.Attributes.Add(new ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyAttribute { AttributeName = new string('x', 200), FullTagReference = "Pump01." + new string('x', 200), DataTypeName = "Float" });
var sibling = new ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyObject { GobjectId = 3, ParentGobjectId = 1, TagName = "Sibling01", BrowseName = "Sibling01" };
sibling.Attributes.Add(new ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyAttribute { AttributeName = "PV", FullTagReference = "Sibling01.PV", DataTypeName = "Float" });
ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyObject[] rows = [plant, pump, sibling];
ZB.MOM.WW.GalaxyRepository.Grpc.GalaxyObject[] rows = [plant, pump, sibling, new() { GobjectId=4, ParentGobjectId=2, TagName="PumpChild", BrowseName="PumpChild" }];
Current = ZB.MOM.WW.GalaxyRepository.GalaxyHierarchyCacheEntry.Empty with {
Status = ZB.MOM.WW.GalaxyRepository.GalaxyCacheStatus.Healthy, Sequence = 1,
Objects = rows, Index = ZB.MOM.WW.GalaxyRepository.GalaxyHierarchyIndex.Build(rows), ObjectCount = rows.Length, AttributeCount = 3,
@@ -141,3 +142,18 @@ internal sealed class FixtureLiveData : IDashboardLiveDataService
public Task<DashboardAlarmQueryResult> QueryAlarmsAsync(CancellationToken cancellationToken) =>
Task.FromResult(new DashboardAlarmQueryResult([], null, null));
}
internal sealed class FaultableBrowseService(ZB.MOM.WW.GalaxyRepository.IGalaxyHierarchyCache cache) : IDashboardBrowseService
{
private readonly DashboardBrowseService _real = new(cache);
public bool FailNext { get; set; }
public int Attempts { get; private set; }
public ulong CurrentCacheSequence => _real.CurrentCacheSequence;
public BrowseLevelResult GetRoots(BrowseFilterArgs filter) => _real.GetRoots(filter);
public BrowseLevelResult GetChildren(int id, BrowseFilterArgs filter)
{
Attempts++;
if (FailNext) { FailNext = false; throw new InvalidOperationException("Synthetic hierarchy outage " + new string('x', 600) + " <script>fixture</script>"); }
return _real.GetChildren(id, filter);
}
}
+13 -2
View File
@@ -1,3 +1,4 @@
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.FileProviders;
using MxUiCanary.Components;
@@ -6,12 +7,20 @@ var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseUrls("http://127.0.0.1:0");
builder.WebHost.UseStaticWebAssets();
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
builder.Services.AddDataProtection().UseEphemeralDataProtectionProvider();
builder.Services.AddAuthorizationCore(options => {
ZB.MOM.WW.Secrets.Ui.SecretsAuthorization.AddSecretsAuthorization(options);
options.AddPolicy(DashboardAuthenticationDefaults.AlarmsPolicy, policy => policy.AddRequirements(AuthenticatedDashboardRoleRequirement.AnyDashboardRole));
});
builder.Services.AddSingleton<Microsoft.AspNetCore.Authorization.IAuthorizationHandler, AuthenticatedDashboardRoleHandler>();
builder.Services.AddCascadingAuthenticationState();
builder.Services.AddSingleton<IDashboardSnapshotService, StubSnapshotService>();
builder.Services.AddSingleton<IDashboardSnapshotFeed, IdleSnapshotFeed>();
builder.Services.AddSingleton<IDashboardApiKeyManagementService, ManagingApiKeyService>();
builder.Services.AddSingleton<AuthenticationStateProvider, StubAuthenticationStateProvider>();
builder.Services.AddScoped<AuthenticationStateProvider, StubAuthenticationStateProvider>();
builder.Services.AddSingleton<ZB.MOM.WW.GalaxyRepository.IGalaxyHierarchyCache, FixtureGalaxyCache>();
builder.Services.AddSingleton<IDashboardBrowseService, DashboardBrowseService>();
builder.Services.AddSingleton<FaultableBrowseService>();
builder.Services.AddSingleton<IDashboardBrowseService>(s=>s.GetRequiredService<FaultableBrowseService>());
builder.Services.AddSingleton<IDashboardLiveDataService, FixtureLiveData>();
builder.Services.AddSingleton<ZB.MOM.WW.GalaxyRepository.IGalaxyDeployNotifier, ZB.MOM.WW.GalaxyRepository.GalaxyDeployNotifier>();
builder.Services.AddSingleton<DashboardBrowseSearchIndex>();
@@ -25,4 +34,6 @@ app.MapPost("/fixtures/snapshot/{scene}",(string scene, IDashboardSnapshotServic
((StubSnapshotService)source).Scene = scene; return Results.Ok(new { scene, syntheticOnly=true });
});
app.MapGet("/provenance",()=>new { theme=typeof(ZB.MOM.WW.Theme.ThemeShell).Assembly.GetName().Version?.ToString(), syntheticOnly=true });
app.MapPost("/fixtures/fail-next-browse",(FaultableBrowseService source)=>{source.FailNext=true;return Results.Ok();});
app.MapGet("/fixtures/browse-counts",(FaultableBrowseService source)=>new{attempts=source.Attempts});
app.Run();