feat(grpc-data): H2 AdminUI HistoryRead checkbox, history limit fields, X0 banner
Connection/export/mapping editors offer HistoryRead (DataOperationAuthoring, never ahead of the validator) and the HistoryTimeoutMilliseconds / MaxConcurrentHistoryReads / MaxHistoryValuesPerPage / MaxHistoryResponseBytes / MaxHistoryAssemblyBytesPerRequest fields; an informational banner shows while a post-v1 bit is ticked (plan 4.3).
This commit is contained in:
+13
-2
@@ -73,6 +73,7 @@ else
|
||||
<label class="form-label" for="secret-ref">Secret reference</label><input id="secret-ref" class="form-control mb-2" placeholder="secret:data/…" @bind="c.SecretReference" /><div class="form-text">Reference only; never enter a key or secret value.</div>
|
||||
<fieldset><legend class="fs-6">Consumer nodes</legend>@foreach (var n in Nodes) { <label class="me-3"><input type="checkbox" checked="@c.ConsumerNodeIds.Contains(n.NodeId)" @onchange="e => Toggle(c.ConsumerNodeIds, n.NodeId, (bool)e.Value!)" /> @n.NodeId</label> }</fieldset>
|
||||
@Operations(c.AllowedOperations, v => c.AllowedOperations = v)
|
||||
<label class="form-label" for="history-timeout">History call timeout (ms)</label><input id="history-timeout" type="number" min="1" class="form-control mb-2" @bind="c.HistoryTimeoutMilliseconds" /><div class="form-text">Each remote HistoryRead call is bounded by the caller's remaining deadline and this.</div>
|
||||
<label><input type="checkbox" @bind="c.Enabled" /> Enabled in next deployment</label>
|
||||
@Actions(c, c.DataConnectionRowId != Guid.Empty)
|
||||
</div></section>
|
||||
@@ -86,6 +87,9 @@ else
|
||||
<label class="form-label" for="export-realm">Realm</label><select id="export-realm" class="form-select mb-2" @bind="e.Realm"><option value="@DataRealm.Raw">Raw</option><option value="@DataRealm.Uns">UNS</option></select>
|
||||
<label class="form-label" for="export-root">Local export root</label><select id="export-root" class="form-select mb-2" value="@(e.RootKind + "|" + e.RootEntityId)" @onchange="args => SetExportRoot(e, args.Value?.ToString())"><option value="">Choose a root</option>@foreach (var p in ExportRoots(e.Realm)) { <option value="@p.Value">@p.Label</option> }</select>
|
||||
@Operations(e.AllowedOperations, v => e.AllowedOperations = v)
|
||||
<label class="form-label" for="export-history-reads">Concurrent history reads per peer</label><input id="export-history-reads" type="number" min="1" class="form-control mb-2" @bind="e.MaxConcurrentHistoryReads" />
|
||||
<label class="form-label" for="export-history-page">History values per page</label><input id="export-history-page" type="number" min="1" class="form-control mb-2" @bind="e.MaxHistoryValuesPerPage" />
|
||||
<label class="form-label" for="export-history-bytes">History response bytes</label><input id="export-history-bytes" type="number" min="1" class="form-control mb-2" @bind="e.MaxHistoryResponseBytes" /><div class="form-text">Larger answers are sent in bounded chunks.</div>
|
||||
<label><input type="checkbox" @bind="e.Enabled" /> Enabled in next deployment</label>@Actions(e, e.DataExportRowId != Guid.Empty)
|
||||
</div></section>
|
||||
}
|
||||
@@ -103,6 +107,7 @@ else
|
||||
<label class="form-label" for="identifier">Remote canonical identifier</label><input id="identifier" class="form-control mb-2" @bind="m.RemoteIdentifier" />
|
||||
<fieldset><legend class="fs-6">Consumer nodes</legend>@foreach (var n in Nodes) { <label class="me-3"><input type="checkbox" checked="@m.ConsumerNodeIds.Contains(n.NodeId)" @onchange="e => Toggle(m.ConsumerNodeIds, n.NodeId, (bool)e.Value!)" /> @n.NodeId</label> }</fieldset>
|
||||
@Operations(m.AllowedOperations, v => m.AllowedOperations = v)
|
||||
<label class="form-label" for="mapping-history-bytes">History assembly bytes per request</label><input id="mapping-history-bytes" type="number" min="1" class="form-control mb-2" @bind="m.MaxHistoryAssemblyBytesPerRequest" />
|
||||
<div><label><input type="checkbox" @bind="m.WriteThrough" /> Allow write-through</label></div><label><input type="checkbox" @bind="m.Enabled" /> Enabled in next deployment</label>@Actions(m, m.RemoteNamespaceMappingRowId != Guid.Empty)
|
||||
</div></section>
|
||||
}
|
||||
@@ -226,10 +231,16 @@ else
|
||||
private RenderFragment Operations(DataOperations current, Action<DataOperations> set) => builder =>
|
||||
{
|
||||
builder.OpenElement(0, "fieldset"); builder.OpenElement(1, "legend"); builder.AddAttribute(2, "class", "fs-6"); builder.AddContent(3, "Allowed operations"); builder.CloseElement();
|
||||
foreach (var bit in new[] { DataOperations.Browse, DataOperations.Metadata, DataOperations.Read, DataOperations.Subscribe, DataOperations.Write })
|
||||
foreach (var bit in DataOperationAuthoring.AuthorableOperations)
|
||||
{
|
||||
builder.OpenElement(4, "label"); builder.AddAttribute(5, "class", "me-3"); builder.OpenElement(6, "input"); builder.AddAttribute(7, "type", "checkbox"); builder.AddAttribute(8, "checked", current.HasFlag(bit));
|
||||
builder.AddAttribute(9, "onchange", EventCallback.Factory.Create<ChangeEventArgs>(this, args => set((bool)args.Value! ? current | bit : current & ~bit))); builder.CloseElement(); builder.AddContent(10, " " + bit); builder.CloseElement();
|
||||
builder.AddAttribute(9, "onchange", EventCallback.Factory.Create<ChangeEventArgs>(this, args => set((bool)args.Value! ? current | bit : current & ~bit))); builder.CloseElement(); builder.AddContent(10, " " + DataOperationAuthoring.Label(bit)); builder.CloseElement();
|
||||
}
|
||||
if (DataOperationAuthoring.FeatureBitBanner(current) is { } banner)
|
||||
{
|
||||
// Plan §4.3: the X0-everywhere rule is procedural, so the editor reminds whenever a post-v1 bit is ticked.
|
||||
builder.OpenElement(11, "div"); builder.AddAttribute(12, "class", "notice mt-2"); builder.AddAttribute(13, "role", "note");
|
||||
builder.AddContent(14, banner); builder.CloseElement();
|
||||
}
|
||||
builder.CloseElement();
|
||||
};
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
||||
|
||||
/// <summary>
|
||||
/// The operation checkboxes the data-connection editors offer, and the mixed-version banner (plan §4.3). The set
|
||||
/// grows with the authoring validator, never ahead of it: H2 adds <see cref="DataOperations.HistoryRead"/>.
|
||||
/// </summary>
|
||||
public static class DataOperationAuthoring
|
||||
{
|
||||
/// <summary>The operation bits an operator can tick, in display order.</summary>
|
||||
public static IReadOnlyList<DataOperations> AuthorableOperations { get; } =
|
||||
[DataOperations.Browse, DataOperations.Metadata, DataOperations.Read, DataOperations.Subscribe, DataOperations.Write, DataOperations.HistoryRead];
|
||||
|
||||
/// <summary>The checkbox label of a bit.</summary>
|
||||
public static string Label(DataOperations operation) => operation == DataOperations.HistoryRead ? "HistoryRead" : operation.ToString();
|
||||
|
||||
/// <summary>
|
||||
/// The informational banner shown while a post-v1 feature bit is ticked: ConfigDb records no node build, so the
|
||||
/// "every node is on X0" rule is a deploy-checklist step the editor can only remind about. Null when only v1 bits are set.
|
||||
/// </summary>
|
||||
public static string? FeatureBitBanner(DataOperations operations) => (operations & ~DataOperationSets.V1) == 0 ? null
|
||||
: "Every node of both clusters must run X0+ before authoring this: a pre-X0 node rejects the whole data-connection "
|
||||
+ "snapshot when a row carries an operation bit it does not know. Nothing checks this automatically.";
|
||||
}
|
||||
+63
@@ -0,0 +1,63 @@
|
||||
using Shouldly;
|
||||
using Xunit;
|
||||
using ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
|
||||
using ZB.MOM.WW.OtOpcUa.Configuration.Validation;
|
||||
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
|
||||
|
||||
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.DataConnections;
|
||||
|
||||
/// <summary>H2 editor models: the HistoryRead checkbox, the history limits' defaults and the mixed-version banner.</summary>
|
||||
[Trait("Category", "Unit"), Trait("Feature", "GrpcData"), Trait("Phase", "H2")]
|
||||
public sealed class GrpcDataHistoryEditorTests
|
||||
{
|
||||
[Fact]
|
||||
public void HistoryRead_is_authorable_and_new_drafts_do_not_grant_it()
|
||||
{
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldContain(DataOperations.HistoryRead);
|
||||
DataOperationAuthoring.AuthorableOperations.ShouldNotContain(DataOperations.AlarmSubscribe, "A2 bits stay unauthorable");
|
||||
// Every authorable bit is one the validator accepts — the editor never gets ahead of authoring.
|
||||
var all = DataOperationAuthoring.AuthorableOperations.Aggregate(DataOperations.None, (a, b) => a | b);
|
||||
(all & ~DataOperationSets.Understood).ShouldBe(DataOperations.None);
|
||||
new DataConnectionEditorModel().Value.AllowedOperations.HasFlag(DataOperations.HistoryRead).ShouldBeFalse();
|
||||
new RemoteMappingEditorModel().Value.AllowedOperations.HasFlag(DataOperations.HistoryRead).ShouldBeFalse();
|
||||
DataOperationAuthoring.Label(DataOperations.HistoryRead).ShouldBe("HistoryRead");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void New_drafts_carry_the_plans_history_limits()
|
||||
{
|
||||
new DataConnectionEditorModel().Value.HistoryTimeoutMilliseconds.ShouldBe(30000);
|
||||
new RemoteMappingEditorModel().Value.MaxHistoryAssemblyBytesPerRequest.ShouldBe(16 * 1024 * 1024);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void The_banner_shows_only_while_a_post_v1_bit_is_ticked()
|
||||
{
|
||||
DataOperationAuthoring.FeatureBitBanner(DataOperationSets.V1).ShouldBeNull();
|
||||
var banner = DataOperationAuthoring.FeatureBitBanner(DataOperations.Read | DataOperations.HistoryRead).ShouldNotBeNull();
|
||||
banner.ShouldContain("every node of both clusters must run X0+ before authoring this", Case.Insensitive);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void A_HistoryRead_draft_validates_and_a_zero_limit_does_not()
|
||||
{
|
||||
var draft = GrpcDataEditorValidationTestsAccess.ValidSnapshot(DataOperations.Read | DataOperations.HistoryRead);
|
||||
DataConnectionValidator.Validate(draft).ShouldNotContain(x => x.Code.EndsWith("OperationsInvalid", StringComparison.Ordinal));
|
||||
draft.DataConnections[0].HistoryTimeoutMilliseconds = 0;
|
||||
DataConnectionValidator.Validate(draft).ShouldContain(x => x.Code == "DataConnectionLimitInvalid");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A minimal valid draft for the editor tests.</summary>
|
||||
internal static class GrpcDataEditorValidationTestsAccess
|
||||
{
|
||||
public static DraftSnapshot ValidSnapshot(DataOperations operations) => new()
|
||||
{
|
||||
GenerationId = 1, ClusterId = "MAIN",
|
||||
DataConnections = [new() { DataConnectionId = "peer", ClusterId = "MAIN", Revision = 1, Enabled = true, AllowedOperations = operations,
|
||||
ConsumerNodeIds = [], EligibleTargetNodeIds = [], Endpoints = ["https://peer.example"] }],
|
||||
DataExports = [new() { DataExportId = "export", ClusterId = "MAIN", Enabled = true, AllowedOperations = operations, PrincipalId = "p", Revision = 1 }],
|
||||
RemoteNamespaceMappings = [new() { RemoteNamespaceMappingId = "mount", ClusterId = "MAIN", DataConnectionId = "peer", Enabled = true,
|
||||
AllowedOperations = operations, ConsumerNodeIds = [], Revision = 1 }],
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user