Name common identity resilience and static builder fields

This commit is contained in:
Joseph Doherty
2026-11-13 21:38:19 -05:00
parent 27bca683c1
commit 28add408c4
9 changed files with 298 additions and 37 deletions
@@ -8,25 +8,25 @@
<div style="padding:1rem">
<div class="row">
<div class="col-md-6 mb-3">
<label class="form-label" for="instId">DriverInstanceId</label>
<InputText id="instId" @bind-Value="Model.DriverInstanceId" disabled="@(!IsNew)"
<label class="form-label" for="@FieldId("instId")">DriverInstanceId</label>
<InputText aria-describedby="@FieldId("instId-error")" id="@FieldId("instId")" @bind-Value="Model.DriverInstanceId" disabled="@(!IsNew)"
class="form-control form-control-sm mono"
placeholder="drv-modbus-line3-01" />
<ValidationMessage For="@(() => Model.DriverInstanceId)" />
<div id="@FieldId("instId-error")"><ValidationMessage For="@(() => Model.DriverInstanceId)" /></div>
</div>
<div class="col-md-6 mb-3">
<label class="form-label" for="name">Display name</label>
<InputText id="name" @bind-Value="Model.Name" class="form-control form-control-sm"
<label class="form-label" for="@FieldId("name")">Display name</label>
<InputText aria-describedby="@FieldId("name-error")" id="@FieldId("name")" @bind-Value="Model.Name" class="form-control form-control-sm"
placeholder="Line 3 Modbus" />
<ValidationMessage For="@(() => Model.Name)" />
<div id="@FieldId("name-error")"><ValidationMessage For="@(() => Model.Name)" /></div>
</div>
</div>
<div class="row">
@if (ShowDriverType)
{
<div class="col-md-6 mb-3">
<label class="form-label" for="dtype">Driver type</label>
<InputSelect id="dtype" @bind-Value="Model.DriverType" disabled="@(!IsNew)"
<label class="form-label" for="@FieldId("dtype")">Driver type</label>
<InputSelect aria-describedby="@FieldId("dtype-hint")" id="@FieldId("dtype")" @bind-Value="Model.DriverType" disabled="@(!IsNew)"
class="form-select form-select-sm">
<option value="Modbus">Modbus TCP</option>
<option value="AbCip">AbCip</option>
@@ -38,21 +38,24 @@
<option value="GalaxyMxGateway">Galaxy</option>
<option value="Sql">Sql</option>
</InputSelect>
<div class="form-text">Cannot be changed after creation — drives the actor type that owns this instance.</div>
<div id="@FieldId("dtype-hint")" class="form-text">Cannot be changed after creation — drives the actor type that owns this instance.</div>
</div>
}
</div>
<div class="mb-3">
<label class="form-label" for="enabled">Enabled</label>
<label class="form-label" for="@FieldId("enabled")">Enabled</label>
<div class="form-check form-switch">
<InputCheckbox id="enabled" @bind-Value="Model.Enabled" class="form-check-input" />
<label class="form-check-label" for="enabled">Spawn this driver in deployments</label>
<InputCheckbox id="@FieldId("enabled")" @bind-Value="Model.Enabled" class="form-check-input" />
<label class="form-check-label" for="@FieldId("enabled")">Spawn this driver in deployments</label>
</div>
</div>
</div>
</section>
@code {
private readonly string _fieldScope = "driver-identity-section-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter, EditorRequired] public DriverIdentityModel Model { get; set; } = new();
[Parameter] public bool IsNew { get; set; }
[Parameter] public bool ShowDriverType { get; set; }
@@ -29,17 +29,17 @@
<div class="table-wrap mt-3">
<table class="data-table">
<thead><tr><th>Capability</th><th>Timeout (s)</th><th>Retries</th><th>Breaker threshold</th></tr></thead>
<thead><tr><th scope="col">Capability</th><th scope="col" id="@FieldId("timeout")">Timeout (s)</th><th scope="col" id="@FieldId("retries")">Retries</th><th scope="col" id="@FieldId("breaker")">Breaker threshold</th></tr></thead>
<tbody>
@foreach (var cap in ResilienceFormModel.Capabilities)
{
var row = _m.Policies[cap];
var writeShaped = cap is "Write" or "AlarmAcknowledge";
<tr>
<td class="mono">@cap</td>
<td><input type="number" class="form-control form-control-sm" @bind="row.TimeoutSeconds" @bind:after="EmitAsync" placeholder="default" disabled="@_m.ParseFailed" /></td>
<td><input type="number" class="form-control form-control-sm" @bind="row.RetryCount" @bind:after="EmitAsync" placeholder="@(writeShaped ? "never" : "default")" disabled="@(writeShaped || _m.ParseFailed)" title="@(writeShaped ? "Writes/acks never retry — per-tag opt-in not yet available" : null)" /></td>
<td><input type="number" class="form-control form-control-sm" @bind="row.BreakerFailureThreshold" @bind:after="EmitAsync" placeholder="default" disabled="@_m.ParseFailed" /></td>
<th scope="row" class="mono" id="@FieldId(cap)">@cap</th>
<td><input aria-labelledby="@(FieldId(cap) + " " + FieldId("timeout"))" type="number" class="form-control form-control-sm" @bind="row.TimeoutSeconds" @bind:after="EmitAsync" placeholder="default" disabled="@_m.ParseFailed" /></td>
<td><input aria-labelledby="@(FieldId(cap) + " " + FieldId("retries"))" type="number" class="form-control form-control-sm" @bind="row.RetryCount" @bind:after="EmitAsync" placeholder="@(writeShaped ? "never" : "default")" disabled="@(writeShaped || _m.ParseFailed)" title="@(writeShaped ? "Writes/acks never retry — per-tag opt-in not yet available" : null)" /></td>
<td><input aria-labelledby="@(FieldId(cap) + " " + FieldId("breaker"))" type="number" class="form-control form-control-sm" @bind="row.BreakerFailureThreshold" @bind:after="EmitAsync" placeholder="default" disabled="@_m.ParseFailed" /></td>
</tr>
}
</tbody>
@@ -70,6 +70,9 @@
</section>
@code {
private readonly string _fieldScope = "resilience-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string? ResilienceConfig { get; set; }
[Parameter] public EventCallback<string?> ResilienceConfigChanged { get; set; }
@@ -3,8 +3,8 @@
<div class="row g-3">
<div class="col-md-3">
<label class="form-label">File type</label>
<select class="form-select form-select-sm" @bind="_fileType" @bind:after="OnChangedAsync">
<label for="@FieldId("field-01")" class="form-label">File type</label>
<select id="@FieldId("field-01")" class="form-select form-select-sm" @bind="_fileType" @bind:after="OnChangedAsync">
<option value="N">N — Integer</option>
<option value="B">B — Binary/Bit</option>
<option value="F">F — Float</option>
@@ -17,14 +17,14 @@
</select>
</div>
<div class="col-md-3">
<label class="form-label">File number</label>
<input type="number" class="form-control form-control-sm" min="0" max="999"
<label for="@FieldId("field-02")" class="form-label">File number</label>
<input id="@FieldId("field-02")" type="number" class="form-control form-control-sm" min="0" max="999"
@bind="_fileNumber" @bind:after="OnChangedAsync" />
<div class="form-text">e.g. 7 for N7</div>
</div>
<div class="col-md-3">
<label class="form-label">Element</label>
<input type="number" class="form-control form-control-sm" min="0" max="9999"
<label for="@FieldId("field-03")" class="form-label">Element</label>
<input id="@FieldId("field-03")" type="number" class="form-control form-control-sm" min="0" max="9999"
@bind="_element" @bind:after="OnChangedAsync" />
<div class="form-text">e.g. 0 for N7:0</div>
</div>
@@ -36,6 +36,9 @@
</div>
@code {
private readonly string _fieldScope = "ab-legacy-address-picker-body-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string CurrentAddress { get; set; } = "";
[Parameter] public EventCallback<string> CurrentAddressChanged { get; set; }
@@ -3,8 +3,8 @@
<div class="row g-3">
<div class="col-md-4">
<label class="form-label">Register type</label>
<select class="form-select form-select-sm" @bind="_regType" @bind:after="OnChangedAsync">
<label for="@FieldId("field-01")" class="form-label">Register type</label>
<select id="@FieldId("field-01")" class="form-select form-select-sm" @bind="_regType" @bind:after="OnChangedAsync">
<option value="Coil">Coil (0x)</option>
<option value="DiscreteInput">DiscreteInput (1x)</option>
<option value="Input">Input (3x)</option>
@@ -12,13 +12,13 @@
</select>
</div>
<div class="col-md-3">
<label class="form-label">Offset</label>
<input type="number" class="form-control form-control-sm" min="0" max="99999"
<label for="@FieldId("field-02")" class="form-label">Offset</label>
<input id="@FieldId("field-02")" type="number" class="form-control form-control-sm" min="0" max="99999"
@bind="_offset" @bind:after="OnChangedAsync" />
</div>
<div class="col-md-3">
<label class="form-label">Length</label>
<input type="number" class="form-control form-control-sm" min="1" max="125"
<label for="@FieldId("field-03")" class="form-label">Length</label>
<input id="@FieldId("field-03")" type="number" class="form-control form-control-sm" min="1" max="125"
@bind="_length" @bind:after="OnChangedAsync" />
</div>
</div>
@@ -29,6 +29,9 @@
</div>
@code {
private readonly string _fieldScope = "modbus-address-picker-body-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string CurrentAddress { get; set; } = "";
[Parameter] public EventCallback<string> CurrentAddressChanged { get; set; }
@@ -3,8 +3,8 @@
<div class="row g-3">
<div class="col-md-2">
<label class="form-label">Area</label>
<select class="form-select form-select-sm" @bind="_area" @bind:after="OnChangedAsync">
<label for="@FieldId("field-01")" class="form-label">Area</label>
<select id="@FieldId("field-01")" class="form-select form-select-sm" @bind="_area" @bind:after="OnChangedAsync">
<option value="DB">DB — Data Block</option>
<option value="M">M — Merker</option>
<option value="I">I — Input</option>
@@ -14,19 +14,19 @@
@if (_area == "DB")
{
<div class="col-md-2">
<label class="form-label">DB number</label>
<input type="number" class="form-control form-control-sm" min="1" max="65535"
<label for="@FieldId("field-02")" class="form-label">DB number</label>
<input id="@FieldId("field-02")" type="number" class="form-control form-control-sm" min="1" max="65535"
@bind="_dbNumber" @bind:after="OnChangedAsync" />
</div>
}
<div class="col-md-2">
<label class="form-label">Offset (bytes)</label>
<input type="number" class="form-control form-control-sm" min="0" max="65535"
<label for="@FieldId("field-03")" class="form-label">Offset (bytes)</label>
<input id="@FieldId("field-03")" type="number" class="form-control form-control-sm" min="0" max="65535"
@bind="_offset" @bind:after="OnChangedAsync" />
</div>
<div class="col-md-2">
<label class="form-label">S7 type</label>
<select class="form-select form-select-sm" @bind="_s7Type" @bind:after="OnChangedAsync">
<label for="@FieldId("field-04")" class="form-label">S7 type</label>
<select id="@FieldId("field-04")" class="form-select form-select-sm" @bind="_s7Type" @bind:after="OnChangedAsync">
<option value="X">X — Bit</option>
<option value="B">B — Byte</option>
<option value="W">W — Word</option>
@@ -42,6 +42,9 @@
</div>
@code {
private readonly string _fieldScope = "s7-address-picker-body-" + Guid.NewGuid().ToString("N");
private string FieldId(string name) => $"{_fieldScope}-{name}";
[Parameter] public string CurrentAddress { get; set; } = "";
[Parameter] public EventCallback<string> CurrentAddressChanged { get; set; }