45 lines
1.9 KiB
C#
45 lines
1.9 KiB
C#
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Web;
|
|
using Microsoft.AspNetCore.Routing;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using ZB.MOM.WW.OtOpcUa.AdminUI.Hubs;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.AdminUI;
|
|
|
|
public static class EndpointRouteBuilderExtensions
|
|
{
|
|
/// <summary>
|
|
/// Mounts the AdminUI Razor components and the AdminUI static asset pipeline at the root.
|
|
/// Call from the fused Host's Program.cs alongside <c>app.MapOtOpcUaAuth()</c>.
|
|
///
|
|
/// Razor component migration from legacy <c>OtOpcUa.Admin/Components/</c> is staged for
|
|
/// follow-up F15 — 47 .razor files plus codebehind. Until then this extension wires the
|
|
/// Blazor pipeline but the only built-in components are the v2-native ones added in this
|
|
/// library (e.g. <c>Deployments</c>, Task 52).
|
|
/// </summary>
|
|
/// <typeparam name="TApp">The root component type for Razor pages.</typeparam>
|
|
/// <param name="app">The endpoint route builder.</param>
|
|
public static IEndpointRouteBuilder MapAdminUI<TApp>(this IEndpointRouteBuilder app)
|
|
where TApp : IComponent
|
|
{
|
|
// Razor class library static assets (_content/ZB.MOM.WW.OtOpcUa.AdminUI/**) are
|
|
// served via the Host's app.UseStaticFiles() middleware which must run BEFORE
|
|
// UseAuthentication() — see Program.cs.
|
|
app.MapRazorComponents<TApp>()
|
|
.AddInteractiveServerRenderMode();
|
|
return app;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Adds AdminUI services to the dependency injection container.
|
|
/// </summary>
|
|
/// <param name="services">The service collection.</param>
|
|
public static IServiceCollection AddAdminUI(this IServiceCollection services)
|
|
{
|
|
services.AddRazorComponents().AddInteractiveServerComponents();
|
|
services.AddOtOpcUaDriverStatusServices();
|
|
return services;
|
|
}
|
|
}
|