fix(adminui,cli): /raw device-name placeholder + no-prerender tree, CLI read prints Bad status (#577)
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
This commit is contained in:
@@ -45,7 +45,23 @@ public class ReadCommand : CommandBase
|
||||
var ct = console.RegisterCancellationHandler();
|
||||
(service, _) = await CreateServiceAndConnectAsync(ct);
|
||||
|
||||
var value = await service.ReadValueAsync(nodeId, ct);
|
||||
DataValue value;
|
||||
try
|
||||
{
|
||||
value = await service.ReadValueAsync(nodeId, ct);
|
||||
}
|
||||
catch (ServiceResultException ex) when (ex.StatusCode != StatusCodes.BadSessionIdInvalid
|
||||
&& ex.StatusCode != StatusCodes.BadConnectionClosed
|
||||
&& ex.StatusCode != StatusCodes.BadSecureChannelClosed)
|
||||
{
|
||||
// The SDK's Session.ReadValue surfaces a Bad node status (BadNodeIdUnknown,
|
||||
// BadUserAccessDenied, ...) as an exception. A read command's job is to REPORT that status,
|
||||
// not crash with a stack trace (#577) — session-level failures still propagate.
|
||||
await console.Output.WriteLineAsync($"Node: {NodeId}");
|
||||
await console.Output.WriteLineAsync($"Value: ");
|
||||
await console.Output.WriteLineAsync($"Status: {(StatusCode)ex.StatusCode} ({StatusCodes.GetBrowseName(ex.StatusCode)})");
|
||||
return;
|
||||
}
|
||||
|
||||
await console.Output.WriteLineAsync($"Node: {NodeId}");
|
||||
await console.Output.WriteLineAsync($"Value: {value.Value}");
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
@page "/raw"
|
||||
@attribute [Authorize(Policy = AdminUiPolicies.ConfigEditor)]
|
||||
@rendermode RenderMode.InteractiveServer
|
||||
@* prerender: false (#577 "first tree click ignored"): with prerender on, the server-rendered tree is shown
|
||||
before the circuit attaches, so a click on its (handler-less) twists is silently dropped, and the
|
||||
component then re-runs OnInitializedAsync and swaps in a second, freshly loaded node set. The tree
|
||||
is the only content here and needs the circuit anyway, so render it once, interactively. *@
|
||||
@rendermode @(new InteractiveServerRenderMode(prerender: false))
|
||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Uns
|
||||
@using ZB.MOM.WW.OtOpcUa.AdminUI.Components.Shared.Raw
|
||||
@inject IRawTreeService Svc
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<div class="row g-3 mb-2">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Device name</label>
|
||||
<input class="form-control form-control-sm mono" @bind="_name" placeholder="Device1" />
|
||||
<input class="form-control form-control-sm mono" @bind="_name" placeholder="e.g. plc1" />
|
||||
<div class="form-text">A RawPath segment — letters, digits, dash, underscore.</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
@@ -145,7 +145,7 @@
|
||||
{
|
||||
_resolvedDriverInstanceId = DriverInstanceId;
|
||||
_driverType = DriverType ?? "";
|
||||
_name = "Device1";
|
||||
_name = ""; // placeholder only: a pre-filled value made typing append to it (#577); the name is validated on save
|
||||
_enabled = true;
|
||||
_deviceConfigJson = "{}";
|
||||
_rowVersion = [];
|
||||
|
||||
Reference in New Issue
Block a user