feat(centralui): scaffold <OpcUaBrowserDialog/> modal
This commit is contained in:
@@ -0,0 +1,92 @@
|
|||||||
|
@using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Protocol
|
||||||
|
@using ZB.MOM.WW.ScadaBridge.Commons.Messages.Management
|
||||||
|
@using ZB.MOM.WW.ScadaBridge.CentralUI.Services
|
||||||
|
@inject IOpcUaBrowseService BrowseService
|
||||||
|
|
||||||
|
@if (_isVisible)
|
||||||
|
{
|
||||||
|
<div class="modal show d-block" tabindex="-1" role="dialog" style="background-color: rgba(0,0,0,0.5);">
|
||||||
|
<div class="modal-dialog modal-lg" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Browse OPC UA — @ConnectionName</h5>
|
||||||
|
<button type="button" class="btn-close" @onclick="Cancel"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
@if (_failure is not null)
|
||||||
|
{
|
||||||
|
<div class="alert alert-danger">
|
||||||
|
@_failureMessage
|
||||||
|
<button class="btn btn-sm btn-outline-danger ms-2" @onclick="RetryRootLoad">Retry</button>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
<div class="opcua-browser-tree">
|
||||||
|
<!-- Task 16 fills this in -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
|
<div class="input-group">
|
||||||
|
<span class="input-group-text">Manual node id:</span>
|
||||||
|
<input class="form-control" @bind="_manualNodeId" placeholder="ns=2;s=..." />
|
||||||
|
<button class="btn btn-outline-secondary" @onclick="UseManual" disabled="@string.IsNullOrWhiteSpace(_manualNodeId)">Use</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<span class="me-auto text-muted">Selected: <code>@(_selectedNodeId ?? "(none)")</code></span>
|
||||||
|
<button class="btn btn-secondary" @onclick="Cancel">Cancel</button>
|
||||||
|
<button class="btn btn-primary" @onclick="Confirm" disabled="@string.IsNullOrWhiteSpace(_selectedNodeId)">Select</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
@code {
|
||||||
|
[Parameter] public string SiteId { get; set; } = "";
|
||||||
|
[Parameter] public int DataConnectionId { get; set; }
|
||||||
|
[Parameter] public string ConnectionName { get; set; } = "";
|
||||||
|
[Parameter] public string? InitialNodeId { get; set; }
|
||||||
|
[Parameter] public EventCallback<string> OnSelected { get; set; }
|
||||||
|
[Parameter] public EventCallback OnCancelled { get; set; }
|
||||||
|
|
||||||
|
private bool _isVisible;
|
||||||
|
private string? _selectedNodeId;
|
||||||
|
private string _manualNodeId = "";
|
||||||
|
private BrowseFailure? _failure;
|
||||||
|
private string _failureMessage = "";
|
||||||
|
|
||||||
|
public async Task ShowAsync()
|
||||||
|
{
|
||||||
|
_isVisible = true;
|
||||||
|
_manualNodeId = InitialNodeId ?? "";
|
||||||
|
_selectedNodeId = InitialNodeId;
|
||||||
|
await LoadRootAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadRootAsync()
|
||||||
|
{
|
||||||
|
// Task 16
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task RetryRootLoad() => LoadRootAsync();
|
||||||
|
|
||||||
|
private void UseManual()
|
||||||
|
{
|
||||||
|
_selectedNodeId = _manualNodeId.Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Confirm()
|
||||||
|
{
|
||||||
|
_isVisible = false;
|
||||||
|
if (!string.IsNullOrWhiteSpace(_selectedNodeId))
|
||||||
|
await OnSelected.InvokeAsync(_selectedNodeId!);
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Cancel()
|
||||||
|
{
|
||||||
|
_isVisible = false;
|
||||||
|
await OnCancelled.InvokeAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user