Phases 4-6: Complete Central UI — Admin, Design, Deployment, and Operations pages
Phase 4 — Operator/Admin UI: - Sites, DataConnections, Areas (hierarchical), API Keys (auto-generated) CRUD - Health Dashboard (live refresh, per-site metrics from CentralHealthAggregator) - Instance list with filtering/staleness/lifecycle actions - Deployment status tracking with auto-refresh Phase 5 — Authoring UI: - Template authoring with inheritance tree, tabs (attrs/alarms/scripts/compositions) - Lock indicators, on-demand validation, collision detection - Shared scripts with syntax check - External systems, DB connections, notification lists, Inbound API methods Phase 6 — Deployment Operations UI: - Staleness indicators, validation gating - Debug view (instance selection, attribute/alarm live tables) - Site event log viewer (filters, keyword search, keyset pagination) - Parked message management, Audit log viewer with JSON state Shared components: DataTable, ConfirmDialog, ToastNotification, LoadingSpinner, TimestampDisplay 623 tests pass, zero warnings. All Bootstrap 5, clean corporate design.
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
@* Reusable confirmation dialog using Bootstrap modal *@
|
||||
|
||||
@if (_visible)
|
||||
{
|
||||
<div class="modal-backdrop fade show"></div>
|
||||
<div class="modal fade show d-block" tabindex="-1" role="dialog">
|
||||
<div class="modal-dialog modal-dialog-centered" role="document">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">@Title</h5>
|
||||
<button type="button" class="btn-close" @onclick="Cancel"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>@Message</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" @onclick="Cancel">Cancel</button>
|
||||
<button type="button" class="btn @ConfirmButtonClass btn-sm" @onclick="Confirm">@ConfirmText</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private bool _visible;
|
||||
private TaskCompletionSource<bool>? _tcs;
|
||||
|
||||
[Parameter] public string Title { get; set; } = "Confirm";
|
||||
[Parameter] public string Message { get; set; } = "Are you sure?";
|
||||
[Parameter] public string ConfirmText { get; set; } = "Confirm";
|
||||
[Parameter] public string ConfirmButtonClass { get; set; } = "btn-danger";
|
||||
|
||||
public Task<bool> ShowAsync(string? message = null, string? title = null)
|
||||
{
|
||||
if (message != null) Message = message;
|
||||
if (title != null) Title = title;
|
||||
_visible = true;
|
||||
_tcs = new TaskCompletionSource<bool>();
|
||||
StateHasChanged();
|
||||
return _tcs.Task;
|
||||
}
|
||||
|
||||
private void Confirm()
|
||||
{
|
||||
_visible = false;
|
||||
_tcs?.TrySetResult(true);
|
||||
}
|
||||
|
||||
private void Cancel()
|
||||
{
|
||||
_visible = false;
|
||||
_tcs?.TrySetResult(false);
|
||||
}
|
||||
}
|
||||
128
src/ScadaLink.CentralUI/Components/Shared/DataTable.razor
Normal file
128
src/ScadaLink.CentralUI/Components/Shared/DataTable.razor
Normal file
@@ -0,0 +1,128 @@
|
||||
@* Reusable data table with sorting, filtering, and pagination *@
|
||||
@typeparam TItem
|
||||
|
||||
<div class="mb-2">
|
||||
@if (ShowSearch)
|
||||
{
|
||||
<div class="row mb-2">
|
||||
<div class="col-md-4">
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Search..."
|
||||
@bind="_searchTerm" @bind:event="oninput" @bind:after="ApplyFilter" />
|
||||
</div>
|
||||
@if (FilterContent != null)
|
||||
{
|
||||
<div class="col-md-8 d-flex gap-2 align-items-center">
|
||||
@FilterContent
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
<table class="table table-sm table-striped table-hover">
|
||||
<thead class="table-dark">
|
||||
<tr>
|
||||
@HeaderContent
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@if (_pagedItems.Count == 0)
|
||||
{
|
||||
<tr>
|
||||
<td colspan="100" class="text-muted text-center">@EmptyMessage</td>
|
||||
</tr>
|
||||
}
|
||||
else
|
||||
{
|
||||
@foreach (var item in _pagedItems)
|
||||
{
|
||||
@RowContent(item)
|
||||
}
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
@if (_totalPages > 1)
|
||||
{
|
||||
<nav>
|
||||
<ul class="pagination pagination-sm justify-content-end">
|
||||
<li class="page-item @(_currentPage <= 1 ? "disabled" : "")">
|
||||
<button class="page-link" @onclick="() => GoToPage(_currentPage - 1)">Previous</button>
|
||||
</li>
|
||||
@for (int i = 1; i <= _totalPages; i++)
|
||||
{
|
||||
var page = i;
|
||||
<li class="page-item @(page == _currentPage ? "active" : "")">
|
||||
<button class="page-link" @onclick="() => GoToPage(page)">@(page)</button>
|
||||
</li>
|
||||
}
|
||||
<li class="page-item @(_currentPage >= _totalPages ? "disabled" : "")">
|
||||
<button class="page-link" @onclick="() => GoToPage(_currentPage + 1)">Next</button>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
}
|
||||
|
||||
<div class="text-muted small">
|
||||
Showing @((_currentPage - 1) * PageSize + 1)–@Math.Min(_currentPage * PageSize, _filteredItems.Count) of @_filteredItems.Count items
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private string _searchTerm = string.Empty;
|
||||
private int _currentPage = 1;
|
||||
private List<TItem> _filteredItems = new();
|
||||
private List<TItem> _pagedItems = new();
|
||||
private int _totalPages;
|
||||
|
||||
[Parameter, EditorRequired] public IReadOnlyList<TItem> Items { get; set; } = [];
|
||||
[Parameter, EditorRequired] public RenderFragment HeaderContent { get; set; } = default!;
|
||||
[Parameter, EditorRequired] public RenderFragment<TItem> RowContent { get; set; } = default!;
|
||||
[Parameter] public RenderFragment? FilterContent { get; set; }
|
||||
[Parameter] public int PageSize { get; set; } = 25;
|
||||
[Parameter] public bool ShowSearch { get; set; } = true;
|
||||
[Parameter] public string EmptyMessage { get; set; } = "No items found.";
|
||||
[Parameter] public Func<TItem, string, bool>? SearchFilter { get; set; }
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
ApplyFilter();
|
||||
}
|
||||
|
||||
private void ApplyFilter()
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_searchTerm) && SearchFilter != null)
|
||||
{
|
||||
_filteredItems = Items.Where(i => SearchFilter(i, _searchTerm)).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
_filteredItems = Items.ToList();
|
||||
}
|
||||
|
||||
_totalPages = Math.Max(1, (int)Math.Ceiling(_filteredItems.Count / (double)PageSize));
|
||||
if (_currentPage > _totalPages) _currentPage = 1;
|
||||
|
||||
UpdatePage();
|
||||
}
|
||||
|
||||
private void GoToPage(int page)
|
||||
{
|
||||
if (page < 1 || page > _totalPages) return;
|
||||
_currentPage = page;
|
||||
UpdatePage();
|
||||
}
|
||||
|
||||
private void UpdatePage()
|
||||
{
|
||||
_pagedItems = _filteredItems
|
||||
.Skip((_currentPage - 1) * PageSize)
|
||||
.Take(PageSize)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public void Refresh()
|
||||
{
|
||||
ApplyFilter();
|
||||
StateHasChanged();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
@* Reusable loading spinner *@
|
||||
|
||||
@if (IsLoading)
|
||||
{
|
||||
<div class="d-flex align-items-center text-muted @CssClass">
|
||||
<div class="spinner-border spinner-border-sm me-2" role="status">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
<span>@Message</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
[Parameter] public bool IsLoading { get; set; }
|
||||
[Parameter] public string Message { get; set; } = "Loading...";
|
||||
[Parameter] public string CssClass { get; set; } = "";
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
@* Displays a UTC DateTimeOffset formatted for display. Tooltip shows UTC value. *@
|
||||
|
||||
<span title="@Value.UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss") UTC">@Value.LocalDateTime.ToString(Format)</span>
|
||||
|
||||
@code {
|
||||
[Parameter, EditorRequired] public DateTimeOffset Value { get; set; }
|
||||
[Parameter] public string Format { get; set; } = "yyyy-MM-dd HH:mm:ss";
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
@* Reusable toast notification component *@
|
||||
@implements IDisposable
|
||||
|
||||
<div class="position-fixed bottom-0 end-0 p-3" style="z-index: 1090;">
|
||||
@foreach (var toast in _toasts)
|
||||
{
|
||||
<div class="toast show mb-2" role="alert">
|
||||
<div class="toast-header @GetHeaderClass(toast.Type)">
|
||||
<strong class="me-auto">@toast.Title</strong>
|
||||
<button type="button" class="btn-close btn-close-white" @onclick="() => Dismiss(toast)"></button>
|
||||
</div>
|
||||
<div class="toast-body">@toast.Message</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private readonly List<ToastItem> _toasts = new();
|
||||
private readonly object _lock = new();
|
||||
|
||||
public void ShowSuccess(string message, string title = "Success")
|
||||
{
|
||||
AddToast(title, message, ToastType.Success);
|
||||
}
|
||||
|
||||
public void ShowError(string message, string title = "Error")
|
||||
{
|
||||
AddToast(title, message, ToastType.Error);
|
||||
}
|
||||
|
||||
public void ShowWarning(string message, string title = "Warning")
|
||||
{
|
||||
AddToast(title, message, ToastType.Warning);
|
||||
}
|
||||
|
||||
public void ShowInfo(string message, string title = "Info")
|
||||
{
|
||||
AddToast(title, message, ToastType.Info);
|
||||
}
|
||||
|
||||
private void AddToast(string title, string message, ToastType type)
|
||||
{
|
||||
var toast = new ToastItem { Title = title, Message = message, Type = type };
|
||||
lock (_lock)
|
||||
{
|
||||
_toasts.Add(toast);
|
||||
}
|
||||
StateHasChanged();
|
||||
|
||||
// Auto-dismiss after 5 seconds
|
||||
_ = Task.Delay(5000).ContinueWith(_ =>
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_toasts.Remove(toast);
|
||||
}
|
||||
InvokeAsync(StateHasChanged);
|
||||
});
|
||||
}
|
||||
|
||||
private void Dismiss(ToastItem toast)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_toasts.Remove(toast);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetHeaderClass(ToastType type) => type switch
|
||||
{
|
||||
ToastType.Success => "bg-success text-white",
|
||||
ToastType.Error => "bg-danger text-white",
|
||||
ToastType.Warning => "bg-warning text-dark",
|
||||
ToastType.Info => "bg-info text-dark",
|
||||
_ => "bg-secondary text-white"
|
||||
};
|
||||
|
||||
public void Dispose() { }
|
||||
|
||||
private enum ToastType { Success, Error, Warning, Info }
|
||||
|
||||
private class ToastItem
|
||||
{
|
||||
public string Title { get; init; } = "";
|
||||
public string Message { get; init; } = "";
|
||||
public ToastType Type { get; init; }
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user