feat(overview): adopt delivered theme patch and record UI validation
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
@namespace OverviewUiCanary.Components
|
||||
@* Host page. Head order matters: Bootstrap first (the Theme kit's shell and
|
||||
TechButton are built on Bootstrap utility classes), then <ThemeHead/> which
|
||||
brings the design tokens and IBM Plex, then site.css so this app's own
|
||||
dashboard anatomy can override either. *@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<base href="/" />
|
||||
<link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css" />
|
||||
<ThemeHead />
|
||||
<link rel="stylesheet" href="/css/site.css" />
|
||||
<HeadOutlet @rendermode="InteractiveServer" />
|
||||
</head>
|
||||
<body>
|
||||
<Routes @rendermode="InteractiveServer" />
|
||||
<script src="/lib/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
<ThemeScripts />
|
||||
<script>window.overviewCanaryReady = () => document.documentElement.dataset.overviewReady = "true";</script>
|
||||
<ReadyProbe @rendermode="InteractiveServer" />
|
||||
<script src="/_framework/blazor.web.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,8 @@
|
||||
@namespace OverviewUiCanary.Components
|
||||
@inject IJSRuntime JS
|
||||
@code {
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (firstRender) await JS.InvokeVoidAsync("overviewCanaryReady");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
@using Microsoft.AspNetCore.Components
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using Microsoft.JSInterop
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@using ZB.MOM.WW.Overview.Components
|
||||
@using ZB.MOM.WW.Theme
|
||||
@@ -0,0 +1,22 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net10.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="../../../../../ZB.MOM.WW.Overview/src/ZB.MOM.WW.Overview/ZB.MOM.WW.Overview.csproj" />
|
||||
</ItemGroup>
|
||||
<!-- This fixture references an executable Blazor app. Both projects contribute
|
||||
the identical SDK framework files; keep one identity for compression. -->
|
||||
<Target Name="DeduplicateFixtureFrameworkAssets" BeforeTargets="ResolveBuildCompressedStaticWebAssetsConfiguration">
|
||||
<RemoveDuplicates Inputs="@(StaticWebAsset)">
|
||||
<Output TaskParameter="Filtered" ItemName="_UniqueFixtureStaticWebAsset" />
|
||||
</RemoveDuplicates>
|
||||
<ItemGroup>
|
||||
<StaticWebAsset Remove="@(StaticWebAsset)" />
|
||||
<StaticWebAsset Include="@(_UniqueFixtureStaticWebAsset)" />
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -0,0 +1,126 @@
|
||||
using Microsoft.AspNetCore.DataProtection;
|
||||
using Microsoft.Extensions.FileProviders;
|
||||
using OverviewUiCanary.Components;
|
||||
using ZB.MOM.WW.Overview.Components;
|
||||
using System.Text.Json;
|
||||
using ZB.MOM.WW.Overview.Polling;
|
||||
|
||||
// Actual Overview App/Routes/layout/cards, synthetic immutable snapshots only.
|
||||
// No polling, HTTP client, authentication or fleet service is registered.
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
builder.WebHost.UseStaticWebAssets();
|
||||
builder.Services.AddDataProtection().UseEphemeralDataProtectionProvider();
|
||||
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
|
||||
var clock = new FixtureClock();
|
||||
var store = new OverviewSnapshotStore();
|
||||
store.Publish(Scenes.Create("mixed", clock.GetUtcNow()));
|
||||
builder.Services.AddSingleton(store);
|
||||
builder.Services.AddSingleton<TimeProvider>(clock);
|
||||
var app = builder.Build();
|
||||
var sourceRoot = builder.Configuration["Canary:OverviewRoot"] ?? Path.GetFullPath(Path.Combine(
|
||||
builder.Environment.ContentRootPath, "../../../../../ZB.MOM.WW.Overview/src/ZB.MOM.WW.Overview"));
|
||||
app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.Combine(sourceRoot, "wwwroot")) });
|
||||
app.UseStaticFiles();
|
||||
app.UseAntiforgery();
|
||||
app.MapRazorComponents<FixtureApp>().AddInteractiveServerRenderMode().AddAdditionalAssemblies(typeof(App).Assembly);
|
||||
app.MapGet("/canary-provenance", () => new
|
||||
{
|
||||
purpose = "Actual Overview components with synthetic frozen snapshots; no production registry or probes",
|
||||
themeAssembly = typeof(ZB.MOM.WW.Theme.ThemeShell).Assembly.GetName().Version?.ToString(),
|
||||
generatedUtc = clock.GetUtcNow(),
|
||||
sourceRoot,
|
||||
});
|
||||
app.MapPost("/canary/scene/{scene}", (string scene) =>
|
||||
{
|
||||
if (scene is not ("mixed" or "empty" or "stale" or "long-error" or "split" or "pending" or "large")) return Results.NotFound();
|
||||
store.Publish(Scenes.Create(scene, clock.GetUtcNow()));
|
||||
return Results.Ok(new { scene, fixtureOnly = true });
|
||||
});
|
||||
app.MapPost("/canary/advance/{seconds:int}", (int seconds) =>
|
||||
{
|
||||
if (seconds < 0 || seconds > 600) return Results.BadRequest();
|
||||
clock.Advance(TimeSpan.FromSeconds(seconds));
|
||||
return Results.Ok(new { fixtureUtc = clock.GetUtcNow() });
|
||||
});
|
||||
app.Run();
|
||||
|
||||
internal sealed class FixtureClock : TimeProvider
|
||||
{
|
||||
private readonly object _gate = new();
|
||||
private DateTimeOffset _now = new(2026, 11, 13, 20, 0, 0, TimeSpan.Zero);
|
||||
public override DateTimeOffset GetUtcNow() { lock (_gate) return _now; }
|
||||
public void Advance(TimeSpan amount) { lock (_gate) _now += amount; }
|
||||
}
|
||||
|
||||
internal static class Scenes
|
||||
{
|
||||
public static OverviewSnapshot Create(string scene, DateTimeOffset now)
|
||||
{
|
||||
if (scene == "empty") return OverviewSnapshot.Empty;
|
||||
var rows = scene switch
|
||||
{
|
||||
"stale" => new[] { Row("Five-minute stale healthy", InstanceStatus.Up, now.AddMinutes(-5)) },
|
||||
"pending" => new[] { Row("Pending fixture", null, null) },
|
||||
"large" => Enumerable.Range(0, 500).Select(i => Row($"Synthetic instance {i:D3}",
|
||||
i % 10 == 0 ? InstanceStatus.Degraded : InstanceStatus.Up, now)).ToArray(),
|
||||
"split" => new[] { LeaderRow("a", "a", now), LeaderRow("b", "b", now) },
|
||||
"long-error" => new[] { Row("Unreachable long diagnostic", InstanceStatus.Unreachable, now,
|
||||
"Synthetic probe failure: <script>not executable</script> " + new string('x', 2000) + " diagnostic end")
|
||||
with { BaseUrl = "http://" + new string('h', 120) + ".invalid:5200", Report = EvidenceReport("unresolved-" + new string('q', 1200)) } },
|
||||
_ => new[]
|
||||
{
|
||||
Row("Healthy fixture", InstanceStatus.Up, now),
|
||||
Row("Degraded fixture", InstanceStatus.Degraded, now),
|
||||
Row("Down fixture", InstanceStatus.Down, now),
|
||||
Row("Unreachable fixture", InstanceStatus.Unreachable, now, "Synthetic loopback probe failure"),
|
||||
Row("Five-minute stale healthy", InstanceStatus.Up, now.AddMinutes(-5)),
|
||||
Row("Five-minute stale unreachable", InstanceStatus.Unreachable, now.AddMinutes(-5)),
|
||||
Row("Pending fixture", null, null),
|
||||
},
|
||||
};
|
||||
return new OverviewSnapshot(now, new[]
|
||||
{
|
||||
new ApplicationSnapshot("Synthetic local SCADA", rows, LeaderResolver.Resolve(rows)),
|
||||
});
|
||||
}
|
||||
|
||||
private static InstanceSnapshot LeaderRow(string name, string leader, DateTimeOffset now) =>
|
||||
Row(name, InstanceStatus.Up, now) with
|
||||
{
|
||||
BaseUrl = $"http://{name}:8084", HasActiveRole = true,
|
||||
Report = EvidenceReport($"akka.tcp://scadabridge@{leader}:8082"),
|
||||
};
|
||||
|
||||
private static ZbHealthReport EvidenceReport(string leader) => new()
|
||||
{
|
||||
Status = "Healthy",
|
||||
Entries = new Dictionary<string, ZbHealthEntry>
|
||||
{
|
||||
["synthetic-cluster"] = new()
|
||||
{
|
||||
Status = "Healthy", Description = "Synthetic cluster evidence, not a fleet probe",
|
||||
Data = new Dictionary<string, JsonElement>
|
||||
{
|
||||
[LeaderResolver.LeaderDataKey] = JsonSerializer.SerializeToElement(leader),
|
||||
["memberCount"] = JsonSerializer.SerializeToElement(2),
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
private static InstanceSnapshot Row(string name, InstanceStatus? status, DateTimeOffset? at, string? error = null) => new()
|
||||
{
|
||||
Application = "Synthetic local SCADA", Instance = name,
|
||||
Group = "Local fixtures", BaseUrl = "http://127.0.0.1:5200",
|
||||
Status = status, LastPolledUtc = at, LastReachableUtc = at,
|
||||
Latency = TimeSpan.FromMilliseconds(12), StaleAfter = TimeSpan.FromSeconds(45), Error = error,
|
||||
Report = status == InstanceStatus.Unreachable || status is null ? null : new ZbHealthReport
|
||||
{
|
||||
Status = status == InstanceStatus.Up ? "Healthy" : status == InstanceStatus.Degraded ? "Degraded" : "Unhealthy",
|
||||
Entries = new Dictionary<string, ZbHealthEntry>
|
||||
{
|
||||
["synthetic-check"] = new() { Status = status == InstanceStatus.Up ? "Healthy" : status == InstanceStatus.Degraded ? "Degraded" : "Unhealthy", Description = "Local fixture observation" },
|
||||
},
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user