Update
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en" data-bs-theme="dark">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>HA History Replay</title>
|
||||
<base href="/" />
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" />
|
||||
<link href="css/app.css" rel="stylesheet" />
|
||||
<HeadOutlet @rendermode="InteractiveServer" />
|
||||
</head>
|
||||
<body>
|
||||
<Routes @rendermode="InteractiveServer" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="_framework/blazor.web.js"></script>
|
||||
<script src="_content/Blazor-ApexCharts/js/apexcharts.esm.js" type="module"></script>
|
||||
<script src="_content/Blazor-ApexCharts/js/blazor-apexcharts.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,44 @@
|
||||
@code {
|
||||
[Parameter] public ReplayDataSeries? DataSeries { get; set; }
|
||||
|
||||
private List<ReplayDataPoint> PowerData => DataSeries?.GetSeries("Boiler", "PowerWatts").ToList() ?? [];
|
||||
private List<ReplayDataPoint> BudgetData => DataSeries?.GetSeries("Boiler", "BudgetPercent").ToList() ?? [];
|
||||
private List<ReplayDataPoint> SwitchData => DataSeries?.GetSeries("Boiler", "SwitchState").ToList() ?? [];
|
||||
|
||||
private ApexChartOptions<ReplayDataPoint> ChartOptions => new()
|
||||
{
|
||||
Chart = new Chart { Background = "transparent", ForeColor = "#adb5bd" },
|
||||
Theme = new Theme { Mode = Mode.Dark },
|
||||
Stroke = new Stroke { Width = 2 },
|
||||
Xaxis = new XAxis { Type = XAxisType.Datetime },
|
||||
Yaxis =
|
||||
[
|
||||
new YAxis { Title = new AxisTitle { Text = "Watts" }, SeriesName = "Power (W)", DecimalsInFloat = 0 },
|
||||
new YAxis { Title = new AxisTitle { Text = "%" }, SeriesName = "Budget %", Opposite = true, Max = 100, DecimalsInFloat = 0 }
|
||||
],
|
||||
Tooltip = new Tooltip { X = new TooltipX { Format = "HH:mm" } },
|
||||
Grid = new Grid { BorderColor = "#343a40" }
|
||||
};
|
||||
}
|
||||
|
||||
@if (PowerData.Count > 0)
|
||||
{
|
||||
<ApexChart TItem="ReplayDataPoint" Options="ChartOptions" Height="300">
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="PowerData"
|
||||
SeriesType="SeriesType.Area"
|
||||
Name="Power (W)"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="BudgetData"
|
||||
SeriesType="SeriesType.Line"
|
||||
Name="Budget %"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
</ApexChart>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-muted text-center py-4">No boiler data available</div>
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
@code {
|
||||
[Parameter] public ReplayTimeline? Timeline { get; set; }
|
||||
|
||||
private IReadOnlyList<ReplayEvent> LightEvents =>
|
||||
Timeline?.GetEventsByMonitor("Light") ?? [];
|
||||
}
|
||||
|
||||
<div class="card bg-dark">
|
||||
<div class="card-body">
|
||||
@if (LightEvents.Count > 0)
|
||||
{
|
||||
<div class="d-flex flex-column gap-2">
|
||||
@foreach (var evt in LightEvents)
|
||||
{
|
||||
var iconClass = evt.EventType == ReplayEventType.Decision ? "text-warning" : "text-muted";
|
||||
var icon = evt.EventType == ReplayEventType.Decision ? "☀" : "•";
|
||||
<div class="d-flex align-items-start gap-2">
|
||||
<span class="font-monospace small text-nowrap">@evt.Timestamp.ToLocalTime().ToString("HH:mm")</span>
|
||||
<span class="@iconClass">@((MarkupString)icon)</span>
|
||||
<span class="small">@evt.Message</span>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-muted text-center py-4">No light events</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,32 @@
|
||||
@code {
|
||||
[Parameter] public ReplayDataSeries? DataSeries { get; set; }
|
||||
|
||||
private List<ReplayDataPoint> PriceData => DataSeries?.GetSeries("NordPool", "Price").ToList() ?? [];
|
||||
|
||||
private ApexChartOptions<ReplayDataPoint> ChartOptions => new()
|
||||
{
|
||||
Chart = new Chart { Background = "transparent", ForeColor = "#adb5bd" },
|
||||
Theme = new Theme { Mode = Mode.Dark },
|
||||
Stroke = new Stroke { Curve = Curve.Smooth, Width = 2 },
|
||||
Xaxis = new XAxis { Type = XAxisType.Datetime },
|
||||
Yaxis = [new YAxis { Title = new AxisTitle { Text = "ct/kWh" }, DecimalsInFloat = 2 }],
|
||||
Tooltip = new Tooltip { X = new TooltipX { Format = "HH:mm" } },
|
||||
Grid = new Grid { BorderColor = "#343a40" }
|
||||
};
|
||||
}
|
||||
|
||||
@if (PriceData.Count > 0)
|
||||
{
|
||||
<ApexChart TItem="ReplayDataPoint" Options="ChartOptions" Height="300">
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="PriceData"
|
||||
SeriesType="SeriesType.Area"
|
||||
Name="Price (ct/kWh)"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
</ApexChart>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-muted text-center py-4">No price data available</div>
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
@code {
|
||||
[Parameter] public ReplayDataSeries? DataSeries { get; set; }
|
||||
|
||||
private List<ReplayDataPoint> TotalData => DataSeries?.GetSeries("Power", "TotalPower").ToList() ?? [];
|
||||
private List<ReplayDataPoint> KnownData => DataSeries?.GetSeries("Power", "KnownDevices").ToList() ?? [];
|
||||
private List<ReplayDataPoint> OtherData => DataSeries?.GetSeries("Power", "OtherPower").ToList() ?? [];
|
||||
|
||||
private ApexChartOptions<ReplayDataPoint> ChartOptions => new()
|
||||
{
|
||||
Chart = new Chart { Background = "transparent", ForeColor = "#adb5bd", Stacked = true },
|
||||
Theme = new Theme { Mode = Mode.Dark },
|
||||
Stroke = new Stroke { Width = 1 },
|
||||
Xaxis = new XAxis { Type = XAxisType.Datetime },
|
||||
Yaxis = [new YAxis { Title = new AxisTitle { Text = "Watts" }, DecimalsInFloat = 0 }],
|
||||
Tooltip = new Tooltip { X = new TooltipX { Format = "HH:mm:ss" } },
|
||||
Grid = new Grid { BorderColor = "#343a40" }
|
||||
};
|
||||
}
|
||||
|
||||
@if (TotalData.Count > 0)
|
||||
{
|
||||
<ApexChart TItem="ReplayDataPoint" Options="ChartOptions" Height="300">
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="KnownData"
|
||||
SeriesType="SeriesType.Area"
|
||||
Name="Known Devices"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="OtherData"
|
||||
SeriesType="SeriesType.Area"
|
||||
Name="Other Power"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
</ApexChart>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-muted text-center py-4">No power data available</div>
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
@code {
|
||||
[Parameter] public ReplayDataSeries? DataSeries { get; set; }
|
||||
|
||||
private List<ReplayDataPoint> BathroomData => DataSeries?.GetSeries("Shower", "BathroomHumidity").ToList() ?? [];
|
||||
private List<ReplayDataPoint> HomeData => DataSeries?.GetSeries("Shower", "HomeHumidity").ToList() ?? [];
|
||||
private List<ReplayDataPoint> DiffData => DataSeries?.GetSeries("Shower", "Differential").ToList() ?? [];
|
||||
|
||||
private ApexChartOptions<ReplayDataPoint> ChartOptions => new()
|
||||
{
|
||||
Chart = new Chart { Background = "transparent", ForeColor = "#adb5bd" },
|
||||
Theme = new Theme { Mode = Mode.Dark },
|
||||
Stroke = new Stroke { Curve = Curve.Smooth, Width = 2 },
|
||||
Xaxis = new XAxis { Type = XAxisType.Datetime },
|
||||
Yaxis = [new YAxis { Title = new AxisTitle { Text = "Humidity %" }, DecimalsInFloat = 1 }],
|
||||
Tooltip = new Tooltip { X = new TooltipX { Format = "HH:mm" } },
|
||||
Grid = new Grid { BorderColor = "#343a40" }
|
||||
};
|
||||
}
|
||||
|
||||
@if (BathroomData.Count > 0)
|
||||
{
|
||||
<ApexChart TItem="ReplayDataPoint" Options="ChartOptions" Height="300">
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="BathroomData"
|
||||
SeriesType="SeriesType.Line"
|
||||
Name="Bathroom Humidity"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="HomeData"
|
||||
SeriesType="SeriesType.Line"
|
||||
Name="Home Humidity"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
<ApexPointSeries TItem="ReplayDataPoint"
|
||||
Items="DiffData"
|
||||
SeriesType="SeriesType.Area"
|
||||
Name="Differential"
|
||||
XValue="p => p.Timestamp.ToLocalTime().DateTime"
|
||||
YValue="p => (decimal)p.Value" />
|
||||
</ApexChart>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="text-muted text-center py-4">No shower data available</div>
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
@inherits LayoutComponentBase
|
||||
|
||||
<div class="d-flex flex-column min-vh-100">
|
||||
<nav class="navbar navbar-dark bg-dark border-bottom border-secondary px-3">
|
||||
<span class="navbar-brand mb-0 h1">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" class="bi bi-house-door me-2" viewBox="0 0 16 16">
|
||||
<path d="M8.354 1.146a.5.5 0 0 0-.708 0l-6 6A.5.5 0 0 0 1.5 7.5v7a.5.5 0 0 0 .5.5h4.5a.5.5 0 0 0 .5-.5v-4h2v4a.5.5 0 0 0 .5.5H14a.5.5 0 0 0 .5-.5v-7a.5.5 0 0 0-.146-.354L13 5.793V2.5a.5.5 0 0 0-.5-.5h-1a.5.5 0 0 0-.5.5v1.293zM2.5 14V7.707l5.5-5.5 5.5 5.5V14H10v-4a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5v4z"/>
|
||||
</svg>
|
||||
HA History Replay
|
||||
</span>
|
||||
<span class="text-muted small">Debug Dashboard</span>
|
||||
</nav>
|
||||
|
||||
<main class="flex-grow-1 p-3">
|
||||
@Body
|
||||
</main>
|
||||
</div>
|
||||
@@ -0,0 +1,240 @@
|
||||
@page "/"
|
||||
@inject ReplayOrchestrationService Replay
|
||||
@implements IDisposable
|
||||
|
||||
<h4 class="mb-3">History Replay Dashboard</h4>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<div class="row g-3 align-items-end">
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small">Start Time</label>
|
||||
<input type="datetime-local" class="form-control form-control-sm"
|
||||
@bind="_startTime" />
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<label class="form-label small">End Time</label>
|
||||
<input type="datetime-local" class="form-control form-control-sm"
|
||||
@bind="_endTime" />
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label class="form-label small">Monitors</label>
|
||||
<div class="d-flex gap-3 flex-wrap">
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" @bind="_monitors.NordPool" id="chkNord" />
|
||||
<label class="form-check-label small" for="chkNord">NordPool</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" @bind="_monitors.Boiler" id="chkBoiler" />
|
||||
<label class="form-check-label small" for="chkBoiler">Boiler</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" @bind="_monitors.Shower" id="chkShower" />
|
||||
<label class="form-check-label small" for="chkShower">Shower</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" @bind="_monitors.Power" id="chkPower" />
|
||||
<label class="form-check-label small" for="chkPower">Power</label>
|
||||
</div>
|
||||
<div class="form-check form-check-inline">
|
||||
<input class="form-check-input" type="checkbox" @bind="_monitors.Light" id="chkLight" />
|
||||
<label class="form-check-label small" for="chkLight">Light</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<button class="btn btn-primary w-100" @onclick="RunReplay"
|
||||
disabled="@(_isRunning)">
|
||||
@if (_isRunning)
|
||||
{
|
||||
<span class="spinner-border spinner-border-sm me-1" role="status"></span>
|
||||
}
|
||||
Run Replay
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="status-bar mb-3">
|
||||
@switch (Replay.Status)
|
||||
{
|
||||
case ReplayStatus.FetchingHistory:
|
||||
<div class="alert alert-info py-2 mb-0 d-flex align-items-center">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>
|
||||
@(Replay.ProgressMessage ?? "Fetching history data from Home Assistant...")
|
||||
</div>
|
||||
break;
|
||||
case ReplayStatus.Running:
|
||||
<div class="alert alert-info py-2 mb-0 d-flex align-items-center">
|
||||
<span class="spinner-border spinner-border-sm me-2"></span>
|
||||
@(Replay.ProgressMessage ?? "Running replay...")
|
||||
</div>
|
||||
break;
|
||||
case ReplayStatus.Completed:
|
||||
<div class="alert alert-success py-2 mb-0">
|
||||
Replay completed -- @Replay.Timeline.GetAllEvents().Count event(s)
|
||||
</div>
|
||||
break;
|
||||
case ReplayStatus.Failed:
|
||||
<div class="alert alert-danger py-2 mb-0">
|
||||
Replay failed: @Replay.ErrorMessage
|
||||
</div>
|
||||
break;
|
||||
}
|
||||
</div>
|
||||
|
||||
@if (Replay.Status == ReplayStatus.Completed)
|
||||
{
|
||||
<SummaryCards Timeline="Replay.Timeline" />
|
||||
|
||||
<ul class="nav nav-tabs mb-3" role="tablist">
|
||||
@foreach (var monitor in _enabledMonitors)
|
||||
{
|
||||
var tab = monitor;
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link @(tab == _activeTab ? "active" : "")"
|
||||
@onclick="() => SetActiveTab(tab)">
|
||||
@tab
|
||||
</button>
|
||||
</li>
|
||||
}
|
||||
<li class="nav-item" role="presentation">
|
||||
<button class="nav-link @(_activeTab == ServiceCallsTab ? "active" : "")"
|
||||
@onclick="() => SetActiveTab(ServiceCallsTab)">
|
||||
Service Calls
|
||||
</button>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div class="tab-content">
|
||||
@if (_activeTab == NordPoolTab)
|
||||
{
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">NordPool Price Timeline</div>
|
||||
<div class="card-body"><NordPoolChart DataSeries="Replay.DataSeries" /></div>
|
||||
</div>
|
||||
<EventTable Events="GetMonitorEvents(NordPoolTab)" />
|
||||
}
|
||||
else if (_activeTab == BoilerTab)
|
||||
{
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">Boiler Power and Budget</div>
|
||||
<div class="card-body"><BoilerChart DataSeries="Replay.DataSeries" /></div>
|
||||
</div>
|
||||
<EventTable Events="GetMonitorEvents(BoilerTab)" />
|
||||
}
|
||||
else if (_activeTab == ShowerTab)
|
||||
{
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">Humidity and Shower Detection</div>
|
||||
<div class="card-body"><ShowerChart DataSeries="Replay.DataSeries" /></div>
|
||||
</div>
|
||||
<EventTable Events="GetMonitorEvents(ShowerTab)" />
|
||||
}
|
||||
else if (_activeTab == PowerTab)
|
||||
{
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">Power Breakdown</div>
|
||||
<div class="card-body"><PowerChart DataSeries="Replay.DataSeries" /></div>
|
||||
</div>
|
||||
<EventTable Events="GetMonitorEvents(PowerTab)" />
|
||||
}
|
||||
else if (_activeTab == LightTab)
|
||||
{
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">Light Control Events</div>
|
||||
<div class="card-body"><LightChart Timeline="Replay.Timeline" /></div>
|
||||
</div>
|
||||
<EventTable Events="GetMonitorEvents(LightTab)" />
|
||||
}
|
||||
else if (_activeTab == ServiceCallsTab)
|
||||
{
|
||||
<EventTable Events="GetMonitorEvents(ServiceCallMonitor)" />
|
||||
}
|
||||
</div>
|
||||
}
|
||||
|
||||
@code {
|
||||
private const string NordPoolTab = "NordPool";
|
||||
private const string BoilerTab = "Boiler";
|
||||
private const string ShowerTab = "Shower";
|
||||
private const string PowerTab = "Power";
|
||||
private const string LightTab = "Light";
|
||||
private const string ServiceCallsTab = "ServiceCalls";
|
||||
private const string ServiceCallMonitor = "ServiceCall";
|
||||
|
||||
private DateTime _startTime = DateTime.Today.AddDays(-1);
|
||||
private DateTime _endTime = DateTime.Today.AddHours(23).AddMinutes(59);
|
||||
private readonly ReplayMonitorFlags _monitors = new();
|
||||
private bool _isRunning;
|
||||
private string _activeTab = NordPoolTab;
|
||||
private IReadOnlyList<string> _enabledMonitors = [];
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
Replay.OnStateChanged += HandleStateChanged;
|
||||
}
|
||||
|
||||
private IReadOnlyList<ReplayEvent> GetMonitorEvents(string monitor) =>
|
||||
Replay.Timeline.GetEventsByMonitor(monitor);
|
||||
|
||||
private void SetActiveTab(string tab)
|
||||
{
|
||||
_activeTab = tab;
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
private async Task RunReplay()
|
||||
{
|
||||
_isRunning = true;
|
||||
_enabledMonitors = BuildEnabledMonitors();
|
||||
_activeTab = _enabledMonitors.FirstOrDefault() ?? NordPoolTab;
|
||||
|
||||
var start = new DateTimeOffset(_startTime, TimeZoneInfo.Local.GetUtcOffset(_startTime));
|
||||
var end = new DateTimeOffset(_endTime, TimeZoneInfo.Local.GetUtcOffset(_endTime));
|
||||
|
||||
try
|
||||
{
|
||||
await Task.Run(async () =>
|
||||
await Replay.RunReplayAsync(start, end, _monitors));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Replay.SetError(ex.Message);
|
||||
}
|
||||
finally
|
||||
{
|
||||
_isRunning = false;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
}
|
||||
|
||||
private IReadOnlyList<string> BuildEnabledMonitors()
|
||||
{
|
||||
var list = new List<string>();
|
||||
if (_monitors.NordPool) list.Add(NordPoolTab);
|
||||
if (_monitors.Boiler) list.Add(BoilerTab);
|
||||
if (_monitors.Shower) list.Add(ShowerTab);
|
||||
if (_monitors.Power) list.Add(PowerTab);
|
||||
if (_monitors.Light) list.Add(LightTab);
|
||||
return list;
|
||||
}
|
||||
|
||||
private async void HandleStateChanged()
|
||||
{
|
||||
try
|
||||
{
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
// Component was disposed while an update was in flight
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Replay.OnStateChanged -= HandleStateChanged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
<Router AppAssembly="typeof(Program).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" />
|
||||
<FocusOnNavigate RouteData="routeData" Selector="h1" />
|
||||
</Found>
|
||||
</Router>
|
||||
@@ -0,0 +1,54 @@
|
||||
@code {
|
||||
[Parameter] public IReadOnlyList<ReplayEvent> Events { get; set; } = [];
|
||||
[Parameter] public int MaxRows { get; set; } = 200;
|
||||
|
||||
private string GetBadgeClass(ReplayEventType type) => type switch
|
||||
{
|
||||
ReplayEventType.Decision => "badge-decision",
|
||||
ReplayEventType.StateChange => "badge-statechange",
|
||||
ReplayEventType.Warning => "badge-warning",
|
||||
ReplayEventType.Anomaly => "badge-anomaly",
|
||||
ReplayEventType.ServiceCall => "badge-servicecall",
|
||||
_ => "badge-info"
|
||||
};
|
||||
}
|
||||
|
||||
@if (Events.Count == 0)
|
||||
{
|
||||
<div class="text-muted text-center py-4">No events recorded for this monitor.</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="table-responsive" style="max-height: 400px; overflow-y: auto;">
|
||||
<table class="table table-sm table-hover align-middle mb-0">
|
||||
<thead class="sticky-top" style="background-color: #2b3035;">
|
||||
<tr>
|
||||
<th style="width: 100px;">Time</th>
|
||||
<th style="width: 100px;">Type</th>
|
||||
<th>Message</th>
|
||||
<th>Details</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var evt in Events.Take(MaxRows))
|
||||
{
|
||||
<tr>
|
||||
<td class="text-nowrap font-monospace small">
|
||||
@evt.Timestamp.ToLocalTime().ToString("HH:mm:ss")
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge @GetBadgeClass(evt.EventType)">@evt.EventType</span>
|
||||
</td>
|
||||
<td class="small">@evt.Message</td>
|
||||
<td class="text-muted small">@evt.Details</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@if (Events.Count > MaxRows)
|
||||
{
|
||||
<div class="text-muted small mt-1">Showing @MaxRows of @Events.Count events</div>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
@code {
|
||||
[Parameter] public ReplayTimeline? Timeline { get; set; }
|
||||
|
||||
private IReadOnlyList<ReplayEvent> AllEvents => Timeline?.GetAllEvents() ?? [];
|
||||
private int TotalEvents => AllEvents.Count;
|
||||
private int Decisions => AllEvents.Count(e => e.EventType == ReplayEventType.Decision);
|
||||
private int ServiceCalls => AllEvents.Count(e => e.EventType == ReplayEventType.ServiceCall);
|
||||
private int Warnings => AllEvents.Count(e => e.EventType == ReplayEventType.Warning);
|
||||
private int Anomalies => AllEvents.Count(e => e.EventType == ReplayEventType.Anomaly);
|
||||
}
|
||||
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col">
|
||||
<div class="card stat-card">
|
||||
<div class="card-body">
|
||||
<div class="display-6">@TotalEvents</div>
|
||||
<div class="text-muted small">Total Events</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card stat-card border-success">
|
||||
<div class="card-body">
|
||||
<div class="display-6 text-success">@Decisions</div>
|
||||
<div class="text-muted small">Decisions</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card stat-card border-info">
|
||||
<div class="card-body">
|
||||
<div class="display-6 text-info">@ServiceCalls</div>
|
||||
<div class="text-muted small">Service Calls</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card stat-card border-warning">
|
||||
<div class="card-body">
|
||||
<div class="display-6 text-warning">@Warnings</div>
|
||||
<div class="text-muted small">Warnings</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<div class="card stat-card border-danger">
|
||||
<div class="card-body">
|
||||
<div class="display-6 text-danger">@Anomalies</div>
|
||||
<div class="text-muted small">Anomalies</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,15 @@
|
||||
@using System.Net.Http
|
||||
@using Microsoft.AspNetCore.Components.Forms
|
||||
@using Microsoft.AspNetCore.Components.Routing
|
||||
@using Microsoft.AspNetCore.Components.Web
|
||||
@using static Microsoft.AspNetCore.Components.Web.RenderMode
|
||||
@using Microsoft.AspNetCore.Components.Web.Virtualization
|
||||
@using Microsoft.JSInterop
|
||||
@using ApexCharts
|
||||
@using HomeAssistant.HistoryReplay.Components
|
||||
@using HomeAssistant.HistoryReplay.Components.Layout
|
||||
@using HomeAssistant.HistoryReplay.Components.Shared
|
||||
@using HomeAssistant.HistoryReplay.Components.Charts
|
||||
@using HomeAssistant.HistoryReplay.Reporting
|
||||
@using HomeAssistant.HistoryReplay.Services
|
||||
@using HomeAssistant.HistoryReplay.Configuration
|
||||
Reference in New Issue
Block a user