116 lines
4.5 KiB
Plaintext
116 lines
4.5 KiB
Plaintext
@using ZB.MOM.WW.OtOpcUa.Admin.Services
|
|
@using ZB.MOM.WW.OtOpcUa.Configuration.Entities
|
|
@inject UnsService UnsSvc
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="d-flex justify-content-between mb-2">
|
|
<h4>UNS Areas</h4>
|
|
<button class="btn btn-sm btn-primary" @onclick="() => _showAreaForm = true">Add area</button>
|
|
</div>
|
|
|
|
@if (_areas is null) { <p>Loading…</p> }
|
|
else if (_areas.Count == 0) { <p class="text-muted">No areas yet.</p> }
|
|
else
|
|
{
|
|
<table class="table table-sm">
|
|
<thead><tr><th>AreaId</th><th>Name</th></tr></thead>
|
|
<tbody>
|
|
@foreach (var a in _areas)
|
|
{
|
|
<tr><td><code>@a.UnsAreaId</code></td><td>@a.Name</td></tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
|
|
@if (_showAreaForm)
|
|
{
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="mb-2"><label class="form-label">Name (lowercase segment)</label><input class="form-control" @bind="_newAreaName"/></div>
|
|
<button class="btn btn-sm btn-primary" @onclick="AddAreaAsync">Save</button>
|
|
<button class="btn btn-sm btn-secondary ms-2" @onclick="() => _showAreaForm = false">Cancel</button>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="d-flex justify-content-between mb-2">
|
|
<h4>UNS Lines</h4>
|
|
<button class="btn btn-sm btn-primary" @onclick="() => _showLineForm = true" disabled="@(_areas is null || _areas.Count == 0)">Add line</button>
|
|
</div>
|
|
|
|
@if (_lines is null) { <p>Loading…</p> }
|
|
else if (_lines.Count == 0) { <p class="text-muted">No lines yet.</p> }
|
|
else
|
|
{
|
|
<table class="table table-sm">
|
|
<thead><tr><th>LineId</th><th>Area</th><th>Name</th></tr></thead>
|
|
<tbody>
|
|
@foreach (var l in _lines)
|
|
{
|
|
<tr><td><code>@l.UnsLineId</code></td><td><code>@l.UnsAreaId</code></td><td>@l.Name</td></tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
|
|
@if (_showLineForm && _areas is not null)
|
|
{
|
|
<div class="card">
|
|
<div class="card-body">
|
|
<div class="mb-2">
|
|
<label class="form-label">Area</label>
|
|
<select class="form-select" @bind="_newLineAreaId">
|
|
@foreach (var a in _areas) { <option value="@a.UnsAreaId">@a.Name (@a.UnsAreaId)</option> }
|
|
</select>
|
|
</div>
|
|
<div class="mb-2"><label class="form-label">Name</label><input class="form-control" @bind="_newLineName"/></div>
|
|
<button class="btn btn-sm btn-primary" @onclick="AddLineAsync">Save</button>
|
|
<button class="btn btn-sm btn-secondary ms-2" @onclick="() => _showLineForm = false">Cancel</button>
|
|
</div>
|
|
</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
[Parameter] public long GenerationId { get; set; }
|
|
[Parameter] public string ClusterId { get; set; } = string.Empty;
|
|
|
|
private List<UnsArea>? _areas;
|
|
private List<UnsLine>? _lines;
|
|
private bool _showAreaForm;
|
|
private bool _showLineForm;
|
|
private string _newAreaName = string.Empty;
|
|
private string _newLineName = string.Empty;
|
|
private string _newLineAreaId = string.Empty;
|
|
|
|
protected override async Task OnParametersSetAsync() => await ReloadAsync();
|
|
|
|
private async Task ReloadAsync()
|
|
{
|
|
_areas = await UnsSvc.ListAreasAsync(GenerationId, CancellationToken.None);
|
|
_lines = await UnsSvc.ListLinesAsync(GenerationId, CancellationToken.None);
|
|
}
|
|
|
|
private async Task AddAreaAsync()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(_newAreaName)) return;
|
|
await UnsSvc.AddAreaAsync(GenerationId, ClusterId, _newAreaName, notes: null, CancellationToken.None);
|
|
_newAreaName = string.Empty;
|
|
_showAreaForm = false;
|
|
await ReloadAsync();
|
|
}
|
|
|
|
private async Task AddLineAsync()
|
|
{
|
|
if (string.IsNullOrWhiteSpace(_newLineName) || string.IsNullOrWhiteSpace(_newLineAreaId)) return;
|
|
await UnsSvc.AddLineAsync(GenerationId, _newLineAreaId, _newLineName, notes: null, CancellationToken.None);
|
|
_newLineName = string.Empty;
|
|
_showLineForm = false;
|
|
await ReloadAsync();
|
|
}
|
|
}
|