feat(dashboard): make Galaxy browse and watch accessible
This commit is contained in:
@@ -24,10 +24,22 @@
|
||||
<div class="section-heading">
|
||||
<h2>Galaxy Hierarchy</h2>
|
||||
</div>
|
||||
<input class="form-control form-control-sm browse-search"
|
||||
placeholder="Filter attributes by name or reference…"
|
||||
@bind="Search"
|
||||
@bind:event="oninput" />
|
||||
<TechField Label="Filter Galaxy attributes" For="browse-search" HintId="browse-search-hint"
|
||||
Hint="Search cached attribute names or references. Values are not searched.">
|
||||
<div class="browse-search-controls">
|
||||
<input @ref="_searchInput" id="browse-search" type="search" class="form-control form-control-sm browse-search"
|
||||
placeholder="Name or reference…" aria-describedby="browse-search-hint" aria-controls="browse-results"
|
||||
@bind="Search" @bind:event="oninput" />
|
||||
<TechButton Variant="ButtonVariant.Secondary" Size="ButtonSize.Small" disabled="@(Search.Length == 0)" @onclick="ClearSearch">Clear search</TechButton>
|
||||
</div>
|
||||
</TechField>
|
||||
<div id="browse-results" aria-busy="@(_searchPending ? "true" : "false")">
|
||||
@if (!string.IsNullOrWhiteSpace(Search))
|
||||
{
|
||||
<p role="status" class="browse-search-note" data-testid="browse-search-status">
|
||||
@(_searchPending ? "Searching cached attributes…" : _searchError is not null ? "Search unavailable." : $"{_searchMatches.Count} matching attribute{(_searchMatches.Count == 1 ? "" : "s")}{(_searchMatches.Count >= SearchResultLimit ? " shown; refine the filter for more specific results." : ".")}")
|
||||
</p>
|
||||
}
|
||||
|
||||
@if (_roots.Count == 0)
|
||||
{
|
||||
@@ -48,11 +60,11 @@
|
||||
}
|
||||
else if (_searchMatches.Count == 0)
|
||||
{
|
||||
<div class="empty-state">No attributes match “@Search”.</div>
|
||||
<div class="empty-state">No attributes match “@Search”. Clear search to return to the hierarchy.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="browse-tree browse-search-results">
|
||||
<div class="browse-tree browse-search-results" role="region" aria-label="Galaxy search results" tabindex="0">
|
||||
@foreach (GalaxyAttribute hit in _searchMatches)
|
||||
{
|
||||
GalaxyAttribute row = hit;
|
||||
@@ -72,6 +84,10 @@
|
||||
{
|
||||
<span class="attr-flag attr-flag-hist">hist</span>
|
||||
}
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm tree-watch"
|
||||
aria-label="@($"Watch {row.FullTagReference}")"
|
||||
@ondblclick:stopPropagation="true"
|
||||
@onclick="() => AddTagAsync(row.FullTagReference)">Watch</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -88,7 +104,7 @@
|
||||
<div class="alert alert-info browse-stale-banner" role="status"
|
||||
@onclick="ClearStaleBanner">@_staleBanner</div>
|
||||
}
|
||||
<div class="browse-tree">
|
||||
<div class="browse-tree" role="region" aria-label="Galaxy hierarchy" tabindex="0">
|
||||
@foreach (DashboardBrowseNode root in _roots)
|
||||
{
|
||||
<BrowseTreeNodeView Node="root"
|
||||
@@ -97,8 +113,9 @@
|
||||
OnLoadChildren="LoadChildrenAsync" />
|
||||
}
|
||||
</div>
|
||||
<div class="browse-search-note">Double-click a tag, or right-click for the menu.</div>
|
||||
<div class="browse-search-note">Choose Watch to add an attribute. Double-click and the right-click menu are also available.</div>
|
||||
}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="dashboard-section browse-panel">
|
||||
@@ -135,14 +152,13 @@
|
||||
@if (_subscribed.Count == 0)
|
||||
{
|
||||
<div class="empty-state">
|
||||
No tags subscribed. Right-click a tag in the hierarchy and choose
|
||||
<strong>Add to subscription panel</strong> (or double-click it) to watch its
|
||||
live value, quality and source timestamp here.
|
||||
No tags subscribed. Choose Watch beside an attribute to see its live value, quality and source timestamp here.
|
||||
Double-click and <strong>Add to subscription panel</strong> in the context menu are also available.
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="table-responsive">
|
||||
<div class="table-responsive" role="region" aria-label="Watched attribute values" tabindex="0">
|
||||
<table class="table table-sm dashboard-table sub-table">
|
||||
<thead>
|
||||
<tr>
|
||||
@@ -151,7 +167,7 @@
|
||||
<th scope="col">Type</th>
|
||||
<th scope="col">Quality</th>
|
||||
<th scope="col">Updated</th>
|
||||
<th scope="col" class="sub-actions-col"></th>
|
||||
<th scope="col" class="sub-actions-col">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -183,6 +199,7 @@
|
||||
<td class="sub-actions-col">
|
||||
<button type="button"
|
||||
class="btn btn-outline-secondary btn-sm"
|
||||
aria-label="@($"Remove {key}")"
|
||||
@onclick="@(() => RemoveTag(key))">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -209,6 +226,25 @@
|
||||
}
|
||||
|
||||
@code {
|
||||
private ElementReference _searchInput;
|
||||
private bool _focusSearch;
|
||||
private bool _disposing;
|
||||
|
||||
private void ClearSearch()
|
||||
{
|
||||
Search = string.Empty;
|
||||
_focusSearch = true;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override async Task OnAfterRenderAsync(bool firstRender)
|
||||
{
|
||||
if (!_focusSearch || _disposing) return;
|
||||
_focusSearch = false;
|
||||
try { await _searchInput.FocusAsync(); }
|
||||
catch (Microsoft.JSInterop.JSDisconnectedException) { }
|
||||
}
|
||||
|
||||
private const int SearchResultLimit = 300;
|
||||
|
||||
// Keystrokes inside this window coalesce into one search: typing a tag name no
|
||||
@@ -653,6 +689,7 @@
|
||||
/// <inheritdoc />
|
||||
public async ValueTask DisposeAsync()
|
||||
{
|
||||
_disposing = true;
|
||||
try
|
||||
{
|
||||
await _cts.CancelAsync().ConfigureAwait(false);
|
||||
|
||||
+30
-16
@@ -3,7 +3,7 @@
|
||||
@*
|
||||
Recursive Browse hierarchy node. Renders one Galaxy object, its child
|
||||
objects (recursively, lazy-loaded on first expand), and its attributes as
|
||||
right-clickable tag rows. Expansion state is local; children render only
|
||||
explicitly watchable tag rows (with mouse accelerators). Expansion state is local; children render only
|
||||
while expanded.
|
||||
|
||||
The expand triangle is shown whenever the server's child_has_children
|
||||
@@ -16,27 +16,36 @@
|
||||
<div class="tree-row @(Node.IsArea ? "tree-row-area" : "tree-row-object")">
|
||||
@if (ShowToggle())
|
||||
{
|
||||
<button type="button" class="tree-toggle" @onclick="ToggleAsync" aria-label="Toggle">
|
||||
@(_expanded ? "▾" : "▸")
|
||||
<button type="button" class="tree-node-toggle" @onclick="ToggleAsync"
|
||||
aria-label="@($"{(_expanded ? "Collapse" : "Expand")} {Node.DisplayName}")"
|
||||
aria-expanded="@(_expanded ? "true" : "false")" aria-controls="@ChildrenId">
|
||||
<span class="tree-toggle" aria-hidden="true">@(_expanded ? "▾" : "▸")</span>
|
||||
<span class="tree-icon" aria-hidden="true">@(Node.IsArea ? "▣" : "◇")</span>
|
||||
<span class="tree-name">@Node.DisplayName</span>
|
||||
@if (!string.IsNullOrWhiteSpace(Node.Object.TagName)
|
||||
&& !string.Equals(Node.Object.TagName, Node.DisplayName, StringComparison.Ordinal))
|
||||
{
|
||||
<code class="tree-tag">@Node.Object.TagName</code>
|
||||
}
|
||||
</button>
|
||||
}
|
||||
else
|
||||
{
|
||||
<span class="tree-toggle tree-toggle-empty"></span>
|
||||
<span class="tree-toggle tree-toggle-empty" aria-hidden="true"></span>
|
||||
<span class="tree-label tree-leaf-label">
|
||||
<span class="tree-icon" aria-hidden="true">@(Node.IsArea ? "▣" : "◇")</span>
|
||||
<span class="tree-name">@Node.DisplayName</span>
|
||||
@if (!string.IsNullOrWhiteSpace(Node.Object.TagName)
|
||||
&& !string.Equals(Node.Object.TagName, Node.DisplayName, StringComparison.Ordinal))
|
||||
{
|
||||
<code class="tree-tag">@Node.Object.TagName</code>
|
||||
}
|
||||
</span>
|
||||
}
|
||||
<span class="tree-label" @onclick="ToggleAsync">
|
||||
<span class="tree-icon">@(Node.IsArea ? "▣" : "◇")</span>
|
||||
<span class="tree-name">@Node.DisplayName</span>
|
||||
@if (!string.IsNullOrWhiteSpace(Node.Object.TagName)
|
||||
&& !string.Equals(Node.Object.TagName, Node.DisplayName, StringComparison.Ordinal))
|
||||
{
|
||||
<code class="tree-tag">@Node.Object.TagName</code>
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
<div id="@ChildrenId" class="tree-children" hidden="@(!_expanded)">
|
||||
@if (_expanded)
|
||||
{
|
||||
<div class="tree-children">
|
||||
@if (Node.LoadState == BrowseLoadState.Loading)
|
||||
{
|
||||
<div class="tree-load-status text-secondary">
|
||||
@@ -81,19 +90,24 @@
|
||||
{
|
||||
<span class="attr-flag attr-flag-hist">hist</span>
|
||||
}
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm tree-watch"
|
||||
aria-label="@($"Watch {row.FullTagReference}")"
|
||||
@ondblclick:stopPropagation="true"
|
||||
@onclick="() => OnAddTag.InvokeAsync(row.FullTagReference)">Watch</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private readonly string ChildrenId = $"browse-children-{Guid.NewGuid():N}";
|
||||
/// <summary>The hierarchy node this view renders.</summary>
|
||||
[Parameter]
|
||||
[EditorRequired]
|
||||
public DashboardBrowseNode Node { get; set; } = null!;
|
||||
|
||||
/// <summary>Raised with a tag's full reference when the operator double-clicks it.</summary>
|
||||
/// <summary>Raised with a tag's full reference when Watch or its mouse accelerator is activated.</summary>
|
||||
[Parameter]
|
||||
public EventCallback<string> OnAddTag { get; set; }
|
||||
|
||||
|
||||
@@ -547,3 +547,22 @@ code {
|
||||
.dashboard-native-dialog .modal-header, .dashboard-native-dialog .modal-footer { flex-shrink: 0; }
|
||||
.dashboard-native-dialog.api-key-create-modal .modal-body { min-height: 0; max-height: none; overflow-y: auto; }
|
||||
.dashboard-native-dialog .native-dialog-feedback { margin: 0; border-radius: 0; flex-shrink: 0; }
|
||||
|
||||
/* One native expansion target per node; Watch uses the existing subscription path. */
|
||||
.tree-node-toggle {
|
||||
display: flex; align-items: center; gap: .35rem; min-width: 0;
|
||||
padding: 0; border: 0; background: transparent; color: inherit;
|
||||
font: inherit; text-align: left; cursor: pointer;
|
||||
}
|
||||
.tree-leaf-label { cursor: default; }
|
||||
.tree-watch { margin-left: auto; flex-shrink: 0; }
|
||||
|
||||
.browse-search-controls { display: flex; align-items: start; flex-wrap: wrap; gap: .5rem; }
|
||||
.browse-search-controls .browse-search { flex: 1 1 12rem; min-width: 0; }
|
||||
|
||||
/* Domain tree/table containment; compact desktop rows retain their existing size. */
|
||||
.browse-panel { min-width: 0; }
|
||||
.tree-watch { position: sticky; right: 0; }
|
||||
@media (pointer: coarse) {
|
||||
.browse-layout button, .browse-search-controls .form-control { min-width: 44px; min-height: 44px; }
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ZB.MOM.WW.GalaxyRepository;
|
||||
using ZB.MOM.WW.GalaxyRepository.Grpc;
|
||||
using ZB.MOM.WW.MxGateway.Server.Dashboard;
|
||||
using ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Pages;
|
||||
|
||||
namespace ZB.MOM.WW.MxGateway.Tests.Dashboard;
|
||||
|
||||
/// <summary>Persistent search semantics against real cache projection; interaction uses browser fixtures.</summary>
|
||||
public sealed class BrowseSearchAccessibilityTests
|
||||
{
|
||||
/// <summary>The purpose and metadata-only boundary remain visible after typing.</summary>
|
||||
[Fact]
|
||||
public async Task Search_HasPersistentLabelHintAndControlledResults()
|
||||
{
|
||||
ServiceCollection services = new();
|
||||
services.AddLogging();
|
||||
services.AddSingleton<IGalaxyHierarchyCache, InMemoryCache>();
|
||||
services.AddSingleton<IDashboardBrowseService, DashboardBrowseService>();
|
||||
services.AddSingleton<IGalaxyDeployNotifier, GalaxyDeployNotifier>();
|
||||
services.AddSingleton<DashboardBrowseSearchIndex>();
|
||||
services.AddScoped<DashboardCircuitConnectionTracker>();
|
||||
services.AddSingleton<IDashboardLiveDataService, NoWorkerLiveData>();
|
||||
await using ServiceProvider provider = services.BuildServiceProvider();
|
||||
await using HtmlRenderer renderer = new(provider, provider.GetRequiredService<ILoggerFactory>());
|
||||
string html = await renderer.Dispatcher.InvokeAsync(async () =>
|
||||
(await renderer.RenderComponentAsync<BrowsePage>()).ToHtmlString());
|
||||
Assert.Contains("for=\"browse-search\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("id=\"browse-search\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("Filter Galaxy attributes", html, StringComparison.Ordinal);
|
||||
Assert.Contains("aria-describedby=\"browse-search-hint\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("id=\"browse-search-hint\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("aria-controls=\"browse-results\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("id=\"browse-results\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("Clear search", html, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private sealed class InMemoryCache : IGalaxyHierarchyCache
|
||||
{
|
||||
public GalaxyHierarchyCacheEntry Current { get; }
|
||||
public InMemoryCache()
|
||||
{
|
||||
GalaxyObject row = new() { GobjectId = 1, TagName = "SyntheticPump", BrowseName = "SyntheticPump" };
|
||||
row.Attributes.Add(new GalaxyAttribute { AttributeName = "PV", FullTagReference = "SyntheticPump.PV" });
|
||||
Current = GalaxyHierarchyCacheEntry.Empty with { Status = GalaxyCacheStatus.Healthy, Sequence = 1,
|
||||
Objects = [row], Index = GalaxyHierarchyIndex.Build([row]), ObjectCount = 1, LastSuccessAt = DateTimeOffset.UnixEpoch };
|
||||
}
|
||||
public Task RefreshAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
public Task WaitForFirstLoadAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
private sealed class NoWorkerLiveData : IDashboardLiveDataService
|
||||
{
|
||||
public Task<DashboardLiveReadResult> ReadAsync(IReadOnlyCollection<string> tags, CancellationToken cancellationToken) => Task.FromResult(DashboardLiveReadResult.Empty);
|
||||
public Task<DashboardAlarmQueryResult> QueryAlarmsAsync(CancellationToken cancellationToken) => Task.FromResult(new DashboardAlarmQueryResult([], null, null));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Components.Web;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using ZB.MOM.WW.GalaxyRepository.Grpc;
|
||||
using ZB.MOM.WW.MxGateway.Server.Dashboard;
|
||||
using ZB.MOM.WW.MxGateway.Server.Dashboard.Components.Shared;
|
||||
|
||||
namespace ZB.MOM.WW.MxGateway.Tests.Dashboard;
|
||||
|
||||
/// <summary>Initial recursive browse semantics; keyboard watch flow uses a real browser.</summary>
|
||||
public sealed class BrowseTreeAccessibilityTests
|
||||
{
|
||||
/// <summary>A lazy object's visible toggle is named and describes its real collapsed state.</summary>
|
||||
[Fact]
|
||||
public async Task LazyNode_HasNamedNativeExpansionAndControlledRegion()
|
||||
{
|
||||
string html = await RenderAsync(new DashboardBrowseNode
|
||||
{
|
||||
Object = new GalaxyObject { BrowseName = "Pump01", TagName = "Area.Pump01" },
|
||||
HasChildrenHint = true,
|
||||
});
|
||||
Assert.Contains("aria-label=\"Expand Pump01\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("aria-expanded=\"false\"", html, StringComparison.Ordinal);
|
||||
Assert.Contains("aria-controls=", html, StringComparison.Ordinal);
|
||||
Assert.DoesNotContain("aria-label=\"Toggle\"", html, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
/// <summary>Terminal objects do not advertise a meaningless expansion action.</summary>
|
||||
[Fact]
|
||||
public async Task LeafNode_DoesNotExposeUnavailableExpansion()
|
||||
{
|
||||
string html = await RenderAsync(new DashboardBrowseNode
|
||||
{
|
||||
Object = new GalaxyObject { BrowseName = "Leaf" },
|
||||
});
|
||||
Assert.DoesNotContain("<button", html, StringComparison.Ordinal);
|
||||
Assert.Contains("Leaf", html, StringComparison.Ordinal);
|
||||
}
|
||||
|
||||
private static async Task<string> RenderAsync(DashboardBrowseNode node)
|
||||
{
|
||||
ServiceCollection services = new();
|
||||
services.AddLogging();
|
||||
await using ServiceProvider provider = services.BuildServiceProvider();
|
||||
await using HtmlRenderer renderer = new(provider, provider.GetRequiredService<ILoggerFactory>());
|
||||
return await renderer.Dispatcher.InvokeAsync(async () =>
|
||||
(await renderer.RenderComponentAsync<BrowseTreeNodeView>(ParameterView.FromDictionary(
|
||||
new Dictionary<string, object?> { [nameof(BrowseTreeNodeView.Node)] = node }))).ToHtmlString());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user