fix(admin-ui): associate native device endpoint fields

This commit is contained in:
Joseph Doherty
2026-11-13 20:49:26 -05:00
parent 7b7fdf0eb7
commit 7e57074653
39 changed files with 3063 additions and 44 deletions
@@ -8,12 +8,12 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label">Host address</label>
<InputText @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="ab://gateway/1,0" />
<label for="@FieldId("field-01")" class="form-label">Host address</label>
<InputText id="@FieldId("field-01")" @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="ab://gateway/1,0" />
</div>
<div class="col-md-3">
<label class="form-label">PLC family</label>
<InputSelect @bind-Value="_model.PlcFamily" @bind-Value:after="EmitAsync" class="form-select form-select-sm">
<label for="@FieldId("field-02")" class="form-label">PLC family</label>
<InputSelect id="@FieldId("field-02")" @bind-Value="_model.PlcFamily" @bind-Value:after="EmitAsync" class="form-select form-select-sm">
@foreach (var e in Enum.GetValues<AbCipPlcFamily>())
{
<option value="@e">@e</option>
@@ -25,6 +25,9 @@
</section>
@code {
private readonly string _fieldScope = "ab-cip-device-form-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
/// <summary>The device's DeviceConfig JSON (endpoint/connection keys).</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired (PascalCase HostAddress/PlcFamily) whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>
@@ -8,12 +8,12 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label">Host address</label>
<InputText @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="10.0.0.10" />
<label for="@FieldId("field-01")" class="form-label">Host address</label>
<InputText id="@FieldId("field-01")" @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="10.0.0.10" />
</div>
<div class="col-md-6">
<label class="form-label">PLC family</label>
<InputSelect @bind-Value="_model.PlcFamily" @bind-Value:after="EmitAsync" class="form-select form-select-sm">
<label for="@FieldId("field-02")" class="form-label">PLC family</label>
<InputSelect id="@FieldId("field-02")" @bind-Value="_model.PlcFamily" @bind-Value:after="EmitAsync" class="form-select form-select-sm">
@foreach (var e in Enum.GetValues<AbLegacyPlcFamily>())
{
<option value="@e">@e</option>
@@ -25,6 +25,9 @@
</section>
@code {
private readonly string _fieldScope = "ab-legacy-device-form-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
/// <summary>The device's DeviceConfig JSON (endpoint/connection keys).</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired (PascalCase HostAddress/PlcFamily) whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>
@@ -8,12 +8,12 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label">Host address</label>
<InputText @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="192.168.0.10:8193" />
<label for="@FieldId("field-01")" class="form-label">Host address</label>
<InputText id="@FieldId("field-01")" @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="192.168.0.10:8193" />
</div>
<div class="col-md-6">
<label class="form-label">CNC series</label>
<InputSelect @bind-Value="_model.Series" @bind-Value:after="EmitAsync" class="form-select form-select-sm">
<label for="@FieldId("field-02")" class="form-label">CNC series</label>
<InputSelect id="@FieldId("field-02")" @bind-Value="_model.Series" @bind-Value:after="EmitAsync" class="form-select form-select-sm">
@foreach (var e in Enum.GetValues<FocasCncSeries>())
{
<option value="@e">@e</option>
@@ -25,6 +25,9 @@
</section>
@code {
private readonly string _fieldScope = "focas-device-form-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
/// <summary>The device's DeviceConfig JSON (endpoint/connection keys).</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired (PascalCase HostAddress/Series) whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>
@@ -8,14 +8,15 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-8">
<label class="form-label" for="hhHost">Host</label>
<InputText id="hhHost" @bind-Value="_model.Host" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="10.20.30.40" />
<div class="form-text">Control hostname or IP. No default endpoint. Plain LSV2 is unencrypted — route it over an externally managed secure network.</div>
<label class="form-label" for="@FieldId("hhHost")">Host</label>
<InputText aria-describedby="@FieldIds("hhHost-hint", "endpoint-error")" id="@FieldId("hhHost")" @bind-Value="_model.Host" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="10.20.30.40" />
<div id="@FieldId("hhHost-hint")" class="form-text">Control hostname or IP. No default endpoint. Plain LSV2 is unencrypted — route it over an externally managed secure network.</div>
</div>
<div class="col-md-4">
<label class="form-label" for="hhPort">Port</label>
<InputNumber id="hhPort" @bind-Value="_model.Port" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<div class="form-text">Default 19000.</div>
<label class="form-label" for="@FieldId("hhPort")">Port</label>
<InputNumber DisplayName="Port" aria-describedby="@FieldIds("hhPort-error", "hhPort-hint", "endpoint-error")" id="@FieldId("hhPort")" @bind-Value="_model.Port" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<div id="@FieldId("hhPort-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _model.Port)" /> }</div>
<div id="@FieldId("hhPort-hint")" class="form-text">Default 19000.</div>
</div>
</div>
</div>
@@ -26,27 +27,34 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-4">
<label class="form-label" for="hhInspect">INSPECT password ref</label>
<InputText id="hhInspect" @bind-Value="_model.InspectPassword" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="secret:heidenhain/inspect" />
<label class="form-label" for="@FieldId("hhInspect")">INSPECT password ref</label>
<InputText aria-describedby="@FieldId("credentials-reference-hint")" id="@FieldId("hhInspect")" @bind-Value="_model.InspectPassword" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="secret:heidenhain/inspect" />
</div>
<div class="col-md-4">
<label class="form-label" for="hhDnc">DNC password ref</label>
<InputText id="hhDnc" @bind-Value="_model.DncPassword" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="secret:heidenhain/dnc" />
<label class="form-label" for="@FieldId("hhDnc")">DNC password ref</label>
<InputText aria-describedby="@FieldId("credentials-reference-hint")" id="@FieldId("hhDnc")" @bind-Value="_model.DncPassword" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="secret:heidenhain/dnc" />
</div>
<div class="col-md-4">
<label class="form-label" for="hhData">DATA password ref</label>
<InputText id="hhData" @bind-Value="_model.DataPassword" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="env:OTOPCUA_HEIDENHAIN_DATA_PASSWORD" />
<label class="form-label" for="@FieldId("hhData")">DATA password ref</label>
<InputText aria-describedby="@FieldId("credentials-reference-hint")" id="@FieldId("hhData")" @bind-Value="_model.DataPassword" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="env:OTOPCUA_HEIDENHAIN_DATA_PASSWORD" />
</div>
</div>
<div class="form-text">Blank = use the driver-level reference. <span class="mono">secret:heidenhain/&lt;name&gt;</span> resolves from the node's secret store, <span class="mono">env:OTOPCUA_HEIDENHAIN_&lt;NAME&gt;</span> from the environment, at each login. A literal password is never stored.</div>
<div id="@FieldId("credentials-reference-hint")" class="form-text">Blank = use the driver-level reference. <span class="mono">secret:heidenhain/&lt;name&gt;</span> resolves from the node's secret store, <span class="mono">env:OTOPCUA_HEIDENHAIN_&lt;NAME&gt;</span> from the environment, at each login. A literal password is never stored.</div>
<div id="@FieldId("endpoint-error")" class="field-error">
@if (_model.Validate() is { } error)
{
<div class="text-danger small mt-2">@error</div>
}
</div>
</div>
</section>
@code {
private readonly string _fieldScope = "heidenhain-device-form-" + Guid.NewGuid().ToString("N");
private string FieldIds(params string[] names) => string.Join(" ", names.Select(FieldId));
private string FieldId(string name) => $"{_fieldScope}-{name}";
[CascadingParameter] private Microsoft.AspNetCore.Components.Forms.EditContext? _fieldEditContext { get; set; }
/// <summary>The device's DeviceConfig JSON.</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>
@@ -7,22 +7,28 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label">Host</label>
<InputText @bind-Value="_model.Host" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="127.0.0.1" />
<label for="@FieldId("field-01")" class="form-label">Host</label>
<InputText id="@FieldId("field-01")" @bind-Value="_model.Host" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="127.0.0.1" />
</div>
<div class="col-md-3">
<label class="form-label">Port</label>
<InputNumber @bind-Value="_model.Port" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<label for="@FieldId("field-02")" class="form-label">Port</label>
<InputNumber DisplayName="Port" aria-describedby="@FieldId("field-02-error")" id="@FieldId("field-02")" @bind-Value="_model.Port" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<div id="@FieldId("field-02-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _model.Port)" /> }</div>
</div>
<div class="col-md-3">
<label class="form-label">Unit ID (slave ID)</label>
<InputNumber @bind-Value="_model.UnitId" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<label for="@FieldId("field-03")" class="form-label">Unit ID (slave ID)</label>
<InputNumber DisplayName="Unit ID (slave ID)" aria-describedby="@FieldId("field-03-error")" id="@FieldId("field-03")" @bind-Value="_model.UnitId" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<div id="@FieldId("field-03-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _model.UnitId)" /> }</div>
</div>
</div>
</div>
</section>
@code {
private readonly string _fieldScope = "modbus-device-form-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[CascadingParameter] private Microsoft.AspNetCore.Components.Forms.EditContext? _fieldEditContext { get; set; }
/// <summary>The device's DeviceConfig JSON (endpoint/connection keys).</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired (PascalCase Host/Port/UnitId) whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>
@@ -7,15 +7,19 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-12">
<label class="form-label">Endpoint URL</label>
<InputText @bind-Value="_model.EndpointUrl" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="opc.tcp://plc.internal:4840" />
<div class="form-text">The upstream server. Used only when the driver's EndpointUrls failover list is empty.</div>
<label for="@FieldId("field-01")" class="form-label">Endpoint URL</label>
<InputText aria-describedby="@FieldIds("field-01-hint")" id="@FieldId("field-01")" @bind-Value="_model.EndpointUrl" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="opc.tcp://plc.internal:4840" />
<div id="@FieldId("field-01-hint")" class="form-text">The upstream server. Used only when the driver's EndpointUrls failover list is empty.</div>
</div>
</div>
</div>
</section>
@code {
private readonly string _fieldScope = "opc-ua-client-device-form-" + Guid.NewGuid().ToString("N");
private string FieldIds(params string[] names) => string.Join(" ", names.Select(FieldId));
private string FieldId(string name) => $"{_fieldScope}-{name}";
/// <summary>The device's DeviceConfig JSON (endpoint/connection keys).</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired (PascalCase EndpointUrl) whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>
@@ -7,26 +7,33 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-6">
<label class="form-label">Host</label>
<InputText @bind-Value="_model.Host" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="192.168.0.1" />
<label for="@FieldId("field-01")" class="form-label">Host</label>
<InputText id="@FieldId("field-01")" @bind-Value="_model.Host" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="192.168.0.1" />
</div>
<div class="col-md-2">
<label class="form-label">Port</label>
<InputNumber @bind-Value="_model.Port" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<label for="@FieldId("field-02")" class="form-label">Port</label>
<InputNumber DisplayName="Port" aria-describedby="@FieldId("field-02-error")" id="@FieldId("field-02")" @bind-Value="_model.Port" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<div id="@FieldId("field-02-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _model.Port)" /> }</div>
</div>
<div class="col-md-2">
<label class="form-label">Rack</label>
<InputNumber @bind-Value="_model.Rack" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<label for="@FieldId("field-03")" class="form-label">Rack</label>
<InputNumber DisplayName="Rack" aria-describedby="@FieldId("field-03-error")" id="@FieldId("field-03")" @bind-Value="_model.Rack" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<div id="@FieldId("field-03-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _model.Rack)" /> }</div>
</div>
<div class="col-md-2">
<label class="form-label">Slot</label>
<InputNumber @bind-Value="_model.Slot" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<label for="@FieldId("field-04")" class="form-label">Slot</label>
<InputNumber DisplayName="Slot" aria-describedby="@FieldId("field-04-error")" id="@FieldId("field-04")" @bind-Value="_model.Slot" @bind-Value:after="EmitAsync" class="form-control form-control-sm" />
<div id="@FieldId("field-04-error")" class="field-error">@if (_fieldEditContext is not null) { <ValidationMessage For="@(() => _model.Slot)" /> }</div>
</div>
</div>
</div>
</section>
@code {
private readonly string _fieldScope = "s7-device-form-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[CascadingParameter] private Microsoft.AspNetCore.Components.Forms.EditContext? _fieldEditContext { get; set; }
/// <summary>The device's DeviceConfig JSON (endpoint/connection keys).</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired (PascalCase Host/Port/Rack/Slot) whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>
@@ -7,14 +7,17 @@
<div style="padding:1rem">
<div class="row g-3">
<div class="col-md-12">
<label class="form-label">Host address (AMS Net Id:port)</label>
<InputText @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="192.168.0.1.1.1:851" />
<label for="@FieldId("field-01")" class="form-label">Host address (AMS Net Id:port)</label>
<InputText id="@FieldId("field-01")" @bind-Value="_model.HostAddress" @bind-Value:after="EmitAsync" class="form-control form-control-sm mono" placeholder="192.168.0.1.1.1:851" />
</div>
</div>
</div>
</section>
@code {
private readonly string _fieldScope = "twin-c-a-t-device-form-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
/// <summary>The device's DeviceConfig JSON (endpoint/connection keys).</summary>
[Parameter] public string DeviceConfigJson { get; set; } = "{}";
/// <summary>Fired (PascalCase HostAddress) whenever the endpoint changes — enables @bind-DeviceConfigJson.</summary>