feat(centralui): Site Call KPI tiles on the Health dashboard
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
@using ScadaLink.Commons.Interfaces.Repositories
|
||||
@using ScadaLink.HealthMonitoring
|
||||
@using ScadaLink.Commons.Messages.Notification
|
||||
@using ScadaLink.Commons.Messages.Audit
|
||||
@using ScadaLink.Communication
|
||||
@implements IDisposable
|
||||
@inject ICentralHealthAggregator HealthAggregator
|
||||
@@ -60,6 +61,12 @@
|
||||
<div class="text-muted small mb-3">Notification Outbox KPIs unavailable: @_outboxKpiError</div>
|
||||
}
|
||||
|
||||
@* Site Call Audit (#22) Task 7 — three KPI tiles for the Site Call channel
|
||||
(buffered / stuck / parked). Refreshed alongside the site states. *@
|
||||
<SiteCallKpiTiles Snapshot="@_siteCallKpi"
|
||||
IsAvailable="@_siteCallKpiAvailable"
|
||||
ErrorMessage="@_siteCallKpiError" />
|
||||
|
||||
@* Audit Log (#23) M7 Bundle E — three KPI tiles for the Audit channel
|
||||
(volume / error rate / backlog). Refreshed alongside the site states. *@
|
||||
<AuditKpiTiles Snapshot="@_auditKpi"
|
||||
@@ -364,6 +371,13 @@
|
||||
private bool _auditKpiAvailable;
|
||||
private string? _auditKpiError;
|
||||
|
||||
// Site Call Audit (#22) Task 7 — Site Call KPI tiles. Point-in-time counts
|
||||
// from the central SiteCalls table, fetched alongside the site states. The
|
||||
// SiteCallKpiResponse message doubles as the snapshot the tile takes.
|
||||
private SiteCallKpiResponse? _siteCallKpi;
|
||||
private bool _siteCallKpiAvailable;
|
||||
private string? _siteCallKpiError;
|
||||
|
||||
private static bool SiteHasActiveErrors(SiteHealthState state)
|
||||
{
|
||||
var report = state.LatestReport;
|
||||
@@ -401,6 +415,7 @@
|
||||
{
|
||||
_siteStates = HealthAggregator.GetAllSiteStates();
|
||||
await LoadOutboxKpis();
|
||||
await LoadSiteCallKpis();
|
||||
await LoadAuditKpis();
|
||||
}
|
||||
|
||||
@@ -429,6 +444,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Site Call KPI loader: wraps the service call so a transient fault degrades
|
||||
// the three Site Call tiles to em dashes with an inline error rather than
|
||||
// killing the dashboard. Mirrors LoadOutboxKpis's error handling shape — a
|
||||
// response with Success == false (repository fault) and an Ask that threw
|
||||
// (transport fault) both collapse to "unavailable".
|
||||
private async Task LoadSiteCallKpis()
|
||||
{
|
||||
try
|
||||
{
|
||||
var response = await CommunicationService.GetSiteCallKpisAsync(
|
||||
new SiteCallKpiRequest(Guid.NewGuid().ToString("N")));
|
||||
if (response.Success)
|
||||
{
|
||||
_siteCallKpi = response;
|
||||
_siteCallKpiAvailable = true;
|
||||
_siteCallKpiError = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_siteCallKpiAvailable = false;
|
||||
_siteCallKpiError = response.ErrorMessage ?? "KPI query failed.";
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_siteCallKpiAvailable = false;
|
||||
_siteCallKpiError = $"KPI query failed: {ex.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
// Tiles show the numeric KPI when available, or an em dash when the outbox
|
||||
// KPI query failed — matching how the page renders other unavailable data.
|
||||
private string OutboxTileValue(int value) =>
|
||||
|
||||
Reference in New Issue
Block a user