feat(adminui): typed resilience override form replaces JSON textarea

This commit is contained in:
Joseph Doherty
2026-05-29 09:15:54 -04:00
parent c4116e54c9
commit f655efc570
@@ -1,16 +1,42 @@
@* Resilience overrides — JSON textarea. Typed-form-ifying Polly is a follow-up; for now this @using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Drivers
matches the legacy DriverEdit.razor behaviour exactly. *@
<section class="panel rise mt-3" style="animation-delay:.14s"> <section class="panel rise mt-3" style="animation-delay:.14s">
<div class="panel-head">Resilience overrides (optional)</div> <div class="panel-head">Resilience overrides (optional)</div>
<div style="padding:1rem"> <div style="padding:1rem">
<InputTextArea Value="@ResilienceConfig" <p class="form-text mb-3">Blank fields use the driver type's stability-tier defaults
ValueExpression="() => ResilienceConfig" (see <span class="mono">docs/v2/driver-stability.md</span>). Set only what you need to override.</p>
ValueChanged="OnChangedAsync"
rows="6" <div class="row g-3">
class="form-control form-control-sm mono" <div class="col-md-4"><label class="form-label">Bulkhead max concurrent</label>
placeholder="Leave blank to use tier defaults" /> <input type="number" class="form-control form-control-sm" @bind="_m.BulkheadMaxConcurrent" @bind:after="EmitAsync" placeholder="tier default" /></div>
<div class="form-text">Polly pipeline overrides per docs/v2/driver-stability.md — bulkhead, retry counts, breaker thresholds. Null = use the driver type's tier defaults.</div> <div class="col-md-4"><label class="form-label">Bulkhead max queue</label>
<input type="number" class="form-control form-control-sm" @bind="_m.BulkheadMaxQueue" @bind:after="EmitAsync" placeholder="tier default" /></div>
<div class="col-md-4"><label class="form-label">Recycle interval (s, Tier C only)</label>
<input type="number" class="form-control form-control-sm" @bind="_m.RecycleIntervalSeconds" @bind:after="EmitAsync" placeholder="none" /></div>
</div>
<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>
<tbody>
@foreach (var cap in ResilienceFormModel.Capabilities)
{
var row = _m.Policies[cap];
<tr>
<td class="mono">@cap</td>
<td><input type="number" class="form-control form-control-sm" @bind="row.TimeoutSeconds" @bind:after="EmitAsync" placeholder="default" /></td>
<td><input type="number" class="form-control form-control-sm" @bind="row.RetryCount" @bind:after="EmitAsync" placeholder="default" /></td>
<td><input type="number" class="form-control form-control-sm" @bind="row.BreakerFailureThreshold" @bind:after="EmitAsync" placeholder="default" /></td>
</tr>
}
</tbody>
</table>
</div>
<details class="mt-3">
<summary class="small text-muted">Raw JSON (advanced)</summary>
<pre class="form-control form-control-sm mono mt-2" style="white-space:pre-wrap;min-height:3rem;">@(_m.ToJson() ?? "(null — all tier defaults)")</pre>
</details>
</div> </div>
</section> </section>
@@ -18,9 +44,24 @@
[Parameter] public string? ResilienceConfig { get; set; } [Parameter] public string? ResilienceConfig { get; set; }
[Parameter] public EventCallback<string?> ResilienceConfigChanged { get; set; } [Parameter] public EventCallback<string?> ResilienceConfigChanged { get; set; }
private async Task OnChangedAsync(string? newValue) private ResilienceFormModel _m = new();
private string? _lastParsed;
protected override void OnParametersSet()
{ {
ResilienceConfig = newValue; // Re-parse only when the inbound value actually changed (avoid clobbering edits on re-render).
await ResilienceConfigChanged.InvokeAsync(newValue); if (!string.Equals(_lastParsed, ResilienceConfig, StringComparison.Ordinal))
{
_m = ResilienceFormModel.FromJson(ResilienceConfig);
_lastParsed = ResilienceConfig;
}
}
private async Task EmitAsync()
{
var json = _m.ToJson();
_lastParsed = json;
ResilienceConfig = json;
await ResilienceConfigChanged.InvokeAsync(json);
} }
} }