Files
mxaccessgw/docs/ui-validation/host/Program.cs
T
Joseph Doherty 26a90883fa
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
Unify gateway styling and preserve identity through recovery
2026-11-13 20:12:00 -05:00

40 lines
2.8 KiB
C#

using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.Extensions.FileProviders;
using MxUiCanary.Components;
using ZB.MOM.WW.MxGateway.Server.Dashboard;
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.AddScoped<AuthenticationStateProvider, StubAuthenticationStateProvider>();
builder.Services.AddSingleton<ZB.MOM.WW.GalaxyRepository.IGalaxyHierarchyCache, FixtureGalaxyCache>();
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>();
builder.Services.AddScoped<DashboardCircuitConnectionTracker>();
var app = builder.Build();
app.UseStaticFiles(new StaticFileOptions { FileProvider = new PhysicalFileProvider(Path.GetFullPath("../../../src/ZB.MOM.WW.MxGateway.Server/wwwroot")) });
app.UseStaticFiles();app.UseAntiforgery();
app.MapRazorComponents<FixtureApp>().AddInteractiveServerRenderMode();
app.MapPost("/fixtures/snapshot/{scene}",(string scene, IDashboardSnapshotService source) => {
if (scene is not ("healthy" or "mixed" or "zero")) return Results.BadRequest();
((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();