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
{
///
/// Mounts the AdminUI Razor components and the AdminUI static asset pipeline at the root.
/// Call from the fused Host's Program.cs alongside app.MapOtOpcUaAuth().
///
/// Razor component migration from legacy OtOpcUa.Admin/Components/ 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. Deployments, Task 52).
///
/// The root component type for Razor pages.
/// The endpoint route builder.
public static IEndpointRouteBuilder MapAdminUI(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()
.AddInteractiveServerRenderMode();
return app;
}
///
/// Adds AdminUI services to the dependency injection container.
///
/// The service collection.
public static IServiceCollection AddAdminUI(this IServiceCollection services)
{
services.AddRazorComponents().AddInteractiveServerComponents();
services.AddOtOpcUaDriverStatusServices();
return services;
}
}