M5: Blazor dashboard (MudBlazor + ApexCharts)

- MudBlazor theme (dark default) + responsive drawer/appbar layout + nav.
- DashboardService read model: KPIs with period-over-period deltas, category breakdown,
  "what cost more/less" difference view, monthly trends.
- Pages: Overview (KPI cards + DeltaChip + donut + difference table), Trends (range-select
  bar chart), Meters (list + source status), Import (load reference dataset + CSV dry-run
  preview), Admin (energy types, tariffs). Charts isolated into components to avoid the
  ApexCharts/MudBlazor Color/Format name clashes.
- ReferenceDataImporter: one-click load of all four sheets as a starter dataset (meters,
  tank, tariff history, category memberships) — bundled sample CSVs copied to app output.
- End-to-end render test: import creates meters + consumption; overview/meters/trends/
  import/admin pages all return 200 with KPI cards rendered.

92 tests green (56 Core + 36 integration).

Deferred to polish: dedicated PV & oil/consumable panels, meter-detail page, full admin
CRUD, prev-year trend overlay.

Claude-Session: https://claude.ai/code/session_01WujdMtMJPbxDpDnMeK22rr
This commit is contained in:
2026-07-13 12:11:12 +02:00
parent 6fc710d55a
commit d5419729e5
25 changed files with 1094 additions and 74 deletions
@@ -0,0 +1,29 @@
namespace MeterVault.Infrastructure.Dashboard;
/// <summary>KPI card figures for a period plus the delta versus the previous comparable period.</summary>
public sealed record CostKpi(double Current, double Previous)
{
public double Delta => Current - Previous;
public double DeltaPercent => Previous == 0 ? 0 : (Current - Previous) / Math.Abs(Previous) * 100.0;
/// <summary>+1 up, -1 down, 0 flat.</summary>
public int Direction => Math.Sign(Math.Round(Delta, 2));
}
/// <summary>The overview KPIs: month and year cost, each with its previous-period comparison.</summary>
public sealed record DashboardSummary(DateOnly AsOf, CostKpi Month, CostKpi Year, double LatestMonthCost);
/// <summary>One slice of the cost breakdown / "what costs most" view.</summary>
public sealed record CategorySlice(string Name, string? ColorHex, double Cost);
/// <summary>A point on a monthly cost/consumption trend.</summary>
public sealed record TrendPoint(DateOnly Period, double Cost);
/// <summary>A row of the "what cost more / less" difference view.</summary>
public sealed record DifferenceRow(string Name, double Current, double Previous)
{
public double Delta => Current - Previous;
public double DeltaPercent => Previous == 0 ? 0 : (Current - Previous) / Math.Abs(Previous) * 100.0;
}