121 lines
5.1 KiB
Plaintext
121 lines
5.1 KiB
Plaintext
@using System.Globalization
|
|
@using Flypaper.Storage.Dashboard
|
|
@using Flypaper.Web.Components.Shared
|
|
|
|
@{
|
|
var byMedian = Entries.Any(entry => entry.MedianHold is not null);
|
|
var barMax = byMedian
|
|
? Entries.Where(entry => entry.Count >= StrategyNames.MinCatches).Select(entry => entry.MedianHold!.Value.TotalMilliseconds).DefaultIfEmpty(0).Max()
|
|
: Entries.Count == 0 ? 0 : Entries[0].Count;
|
|
}
|
|
@if (Entries.Count == 0)
|
|
{
|
|
<p class="empty">Noch keine Einträge.</p>
|
|
}
|
|
else
|
|
{
|
|
<table class="top-table @(byMedian ? "by-median" : null)">
|
|
<colgroup>
|
|
<col />
|
|
<col class="share" />
|
|
<col class="count" />
|
|
@if (byMedian)
|
|
{
|
|
<col class="hold" />
|
|
}
|
|
<col class="hold sum" />
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th>@KeyLabel</th>
|
|
<th><span class="sr-only">Anteil</span></th>
|
|
<th class="num">Fänge</th>
|
|
@if (byMedian)
|
|
{
|
|
<th class="num" title="Mittlere Haltezeit pro Fang (Median): Einzelne Dauerhalter verfälschen sie nicht">Median</th>
|
|
}
|
|
<th class="num sum">@(byMedian ? "Summe" : "Haltezeit")</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
@foreach (var entry in Entries)
|
|
{
|
|
var key = KeyFormatter?.Invoke(entry.Key) ?? entry.Key;
|
|
var label = LabelFormatter is null ? entry.Label : LabelFormatter(entry.Key, entry.Label);
|
|
var value = byMedian ? entry.MedianHold!.Value.TotalMilliseconds : entry.Count;
|
|
var share = (barMax == 0 ? 0 : Math.Min(100, value * 100.0 / barMax)).ToString("0.#", CultureInfo.InvariantCulture);
|
|
var sparse = byMedian && entry.Count < StrategyNames.MinCatches;
|
|
var badges = BadgesFormatter?.Invoke(entry.Key) ?? [];
|
|
var active = IsActive(entry);
|
|
var title = TitleFormatter?.Invoke(entry.Key) ?? (label is null ? key : $"{label} · {key}");
|
|
if (sparse)
|
|
{
|
|
title += $"\nNur {entry.Count} {(entry.Count == 1 ? "Fang" : "Fänge")}: wenig aussagekräftig";
|
|
}
|
|
|
|
<tr data-href="@Href(entry)" class="@(active ? "active" : null) @(sparse ? "sparse" : null)">
|
|
<td class="clip" title="@title">
|
|
<a href="@Href(entry)" aria-current="@(active ? "true" : null)" title="@(active ? $"Filter {title} entfernen" : $"Fänge filtern: {title}")">
|
|
@if (ShowFlags)
|
|
{
|
|
<span class="flag">@Formatting.Flag(entry.Key)</span>
|
|
}
|
|
@if (label is not null)
|
|
{
|
|
<span class="top-label">@label</span>
|
|
@foreach (var badge in badges)
|
|
{
|
|
<span class="badge">@badge</span>
|
|
}
|
|
@if (sparse)
|
|
{
|
|
<span class="badge sparse-note">wenige Daten</span>
|
|
}
|
|
@if (key.Length > 0)
|
|
{
|
|
<span class="top-key mono">@key</span>
|
|
}
|
|
}
|
|
else
|
|
{
|
|
<span class="mono">@key</span>
|
|
}
|
|
</a>
|
|
</td>
|
|
<td><span class="share-bar" style="--share: @(share)%"></span></td>
|
|
<td class="num">@Formatting.Number(entry.Count)</td>
|
|
@if (byMedian)
|
|
{
|
|
<td class="num">@Formatting.Duration(entry.MedianHold!.Value)</td>
|
|
}
|
|
<td class="num sum">@Formatting.Duration(entry.HoldTime)</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
@if (byMedian)
|
|
{
|
|
<p class="top-note">Balken = Median Haltezeit pro Fang. Unter @StrategyNames.MinCatches Fängen wenig aussagekräftig, diese Zeilen stehen am Ende.</p>
|
|
}
|
|
}
|
|
|
|
@code {
|
|
[Parameter, EditorRequired] public required string KeyLabel { get; set; }
|
|
|
|
[Parameter, EditorRequired] public required IReadOnlyList<TopEntry> Entries { get; set; }
|
|
|
|
[Parameter] public bool ShowFlags { get; set; }
|
|
|
|
[Parameter] public Func<string?, string?>? KeyFormatter { get; set; }
|
|
|
|
[Parameter] public Func<string?, string?, string?>? LabelFormatter { get; set; }
|
|
|
|
[Parameter] public Func<string?, string?>? TitleFormatter { get; set; }
|
|
|
|
[Parameter] public Func<string?, IReadOnlyList<string>>? BadgesFormatter { get; set; }
|
|
|
|
[Parameter, EditorRequired] public required Func<TopEntry, string> Href { get; set; }
|
|
|
|
[Parameter, EditorRequired] public required Func<TopEntry, bool> IsActive { get; set; }
|
|
}
|