Complete protocol field associations and verify rendered inventory

This commit is contained in:
Joseph Doherty
2026-11-13 21:29:03 -05:00
parent ee8ac73e8c
commit 27bca683c1
23 changed files with 11500 additions and 32 deletions
@@ -0,0 +1,27 @@
@page "/protocols"
@rendermode InteractiveServer
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers.Forms
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Uns.TagEditors
<main class="container-fluid p-3"><h1>Protocol field fixture</h1><p>Synthetic drafts only; no device or backend operations.</p><output id="interactive">@_ready</output>
<EditForm EditContext="_context" OnSubmit="IgnoreSubmit">
@foreach (var type in Types)
{
@for (int copy = 0; copy < 2; copy++)
{
var key = type.Name + copy;
<section data-protocol="@type.Name" data-copy="@copy" @key="key"><h2>@type.Name · instance @copy</h2><DynamicComponent Type="type" Parameters="Values(type)" /></section>
}
}
</EditForm></main>
@code {
[SupplyParameterFromQuery] public string? Kind { get; set; }
private readonly EditContext _context = new(new object());
private bool _ready;
protected override void OnAfterRender(bool firstRender) { if (firstRender) { _ready = true; StateHasChanged(); } }
private static readonly Type[] Drivers = [typeof(AbCipDriverForm), typeof(AbLegacyDriverForm), typeof(FocasDriverForm), typeof(GalaxyDriverForm), typeof(HeidenhainDriverForm), typeof(MTConnectDriverForm), typeof(ModbusDriverForm), typeof(MqttDriverForm), typeof(OpcUaClientDriverForm), typeof(S7DriverForm), typeof(SqlDriverForm), typeof(TwinCATDriverForm)];
private static readonly Type[] Tags = [typeof(AbCipTagConfigEditor), typeof(AbLegacyTagConfigEditor), typeof(CalculationTagConfigEditor), typeof(FocasTagConfigEditor), typeof(HeidenhainTagConfigEditor), typeof(MTConnectTagConfigEditor), typeof(ModbusTagConfigEditor), typeof(MqttTagConfigEditor), typeof(NativeAlarmEditor), typeof(OpcUaClientTagConfigEditor), typeof(S7TagConfigEditor), typeof(SqlTagConfigEditor), typeof(TwinCATTagConfigEditor)];
private Type[] Types => Kind == "drivers" ? Drivers : Tags;
private static Dictionary<string, object> Values(Type type) => type == typeof(NativeAlarmEditor)
? new() { ["DriverType"] = "AbCip", ["ConfigJson"] = "{\"alarm\":{\"severity\":500}}" } : new();
private void IgnoreSubmit(EditContext context) { }
}
@@ -1,6 +1,7 @@
using DeviceFormCanary.Components;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseStaticWebAssets();
builder.Services.AddSingleton(System.Reflection.DispatchProxy.Create<ZB.MOM.WW.OtOpcUa.AdminUI.Uns.IUnsTreeService, ProtocolReadOnlyProxy>());
builder.Services.AddRazorComponents().AddInteractiveServerComponents();
var app = builder.Build();
app.UseAntiforgery();
@@ -0,0 +1,9 @@
using System.Reflection;
using ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
/// <summary>Read-only empty script catalog; every backend operation is refused.</summary>
public class ProtocolReadOnlyProxy : DispatchProxy
{
protected override object? Invoke(MethodInfo? method, object?[]? args) => method?.Name == nameof(IUnsTreeService.LoadScriptsAsync)
? Task.FromResult<IReadOnlyList<(string ScriptId, string Display)>>([])
: throw new NotSupportedException("No backend operations in protocol fixture: " + method?.Name);
}