diff --git a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor index 8d0a0612..bbf9e444 100644 --- a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor +++ b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor @@ -31,12 +31,12 @@
diff --git a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor.cs b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor.cs index dfce1c10..17e69792 100644 --- a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor.cs +++ b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Audit/AuditLogPage.razor.cs @@ -2,6 +2,7 @@ using System.Globalization; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Routing; using Microsoft.AspNetCore.WebUtilities; +using Microsoft.Extensions.Logging; using ZB.MOM.WW.ScadaBridge.CentralUI.Services; using ZB.MOM.WW.ScadaBridge.Commons.Types.Audit; using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums; @@ -56,6 +57,10 @@ public partial class AuditLogPage : IDisposable /// [Inject] private IKpiHistoryQueryService KpiHistory { get; set; } = null!; + /// Logger for the best-effort Trends panel — a degraded series fetch + /// is logged at warning level so the silent fallback is still observable. + [Inject] private ILogger Logger { get; set; } = null!; + private AuditLogQueryFilter? _currentFilter; private AuditEventView? _selectedEvent; private bool _drawerOpen; @@ -271,6 +276,13 @@ public partial class AuditLogPage : IDisposable /// Whether the Trends panel is expanded (open by default). private bool _trendsOpen = true; + /// + /// True while a window's series are being (re)fetched — disables the 24h/7d + /// window toggle buttons so a mid-flight click cannot stack overlapping loads + /// (mirrors the K13/K14 trend pages). + /// + private bool _trendsLoading; + /// Active window in hours — 24 (default) or 168 (7 days). private int _windowHours = 24; @@ -297,25 +309,35 @@ public partial class AuditLogPage : IDisposable /// private async Task LoadTrendsAsync() { - var toUtc = DateTime.UtcNow; - var fromUtc = toUtc - TimeSpan.FromHours(_windowHours); - - foreach (var (metric, _, _) in TrendMetrics) + _trendsLoading = true; + try { - try + var toUtc = DateTime.UtcNow; + var fromUtc = toUtc - TimeSpan.FromHours(_windowHours); + + foreach (var (metric, _, _) in TrendMetrics) { - var points = await KpiHistory.GetSeriesAsync( - KpiSources.AuditLog, metric, KpiScopes.Global, scopeKey: null, - fromUtc, toUtc); - _trendSeries[metric] = new TrendSeries(points, IsAvailable: true, ErrorMessage: null); - } - catch (Exception) - { - // Best-effort: degrade this chart only, keep the rest of the page alive. - _trendSeries[metric] = new TrendSeries( - Points: null, IsAvailable: false, ErrorMessage: "Trend data unavailable."); + try + { + var points = await KpiHistory.GetSeriesAsync( + KpiSources.AuditLog, metric, KpiScopes.Global, scopeKey: null, + fromUtc, toUtc); + _trendSeries[metric] = new TrendSeries(points, IsAvailable: true, ErrorMessage: null); + } + catch (Exception ex) + { + // Best-effort: degrade this chart only, keep the rest of the page + // alive — but log the failure so the silent fallback is observable. + Logger.LogWarning(ex, "Failed to load Audit Log KPI trend series for metric {Metric}.", metric); + _trendSeries[metric] = new TrendSeries( + Points: null, IsAvailable: false, ErrorMessage: "Trend data unavailable."); + } } } + finally + { + _trendsLoading = false; + } } /// Returns the rendered state for a metric, defaulting to available-empty. diff --git a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Monitoring/Health.razor b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Monitoring/Health.razor index 9ecc5ebd..a2381855 100644 --- a/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Monitoring/Health.razor +++ b/src/ZB.MOM.WW.ScadaBridge.CentralUI/Components/Pages/Monitoring/Health.razor @@ -92,6 +92,7 @@