80 lines
3.1 KiB
Plaintext
80 lines
3.1 KiB
Plaintext
@using System.Globalization
|
|
@using Flypaper.Storage.Dashboard
|
|
|
|
@if (Entries.Count == 0)
|
|
{
|
|
<p class="empty">Noch keine Einträge.</p>
|
|
}
|
|
else
|
|
{
|
|
<table class="top-table">
|
|
<colgroup>
|
|
<col />
|
|
<col class="share" />
|
|
<col class="count" />
|
|
<col class="hold" />
|
|
</colgroup>
|
|
<thead>
|
|
<tr>
|
|
<th>@KeyLabel</th>
|
|
<th><span class="sr-only">Anteil</span></th>
|
|
<th class="num">Fänge</th>
|
|
<th class="num">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 share = (entry.Count * 100.0 / Entries[0].Count).ToString("0.#", CultureInfo.InvariantCulture);
|
|
var active = IsActive(entry);
|
|
var title = TitleFormatter?.Invoke(entry.Key) ?? (label is null ? key : $"{label} · {key}");
|
|
<tr data-href="@Href(entry)" class="@(active ? "active" : 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>
|
|
@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>
|
|
<td class="num">@Formatting.Duration(entry.HoldTime)</td>
|
|
</tr>
|
|
}
|
|
</tbody>
|
|
</table>
|
|
}
|
|
|
|
@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, EditorRequired] public required Func<TopEntry, string> Href { get; set; }
|
|
|
|
[Parameter, EditorRequired] public required Func<TopEntry, bool> IsActive { get; set; }
|
|
}
|