Polish dashboard layout and use German number formats
Build and deploy / build (push) Successful in 1m27s
Build and deploy / deploy (push) Successful in 20s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TomandClaude Opus 5.5 committed 2026-11-15 21:09:52 +01:00
1 parent e86518cab1
commit 8eeb7894a3
10 files changed
+131 -59

No files matched your search

+4
View File
@@ -22,6 +22,10 @@ All notable changes to Flypaper are documented in this file. The format follows
24 hours, and the catch list marks them with an "Abgelehnt" badge. Outcomes are shown in 24 hours, and the catch list marks them with an "Abgelehnt" badge. Outcomes are shown in
German. Top lists and hold times still count only real catches. German. Top lists and hold times still count only real catches.
- The "Haltezeit gesamt" metric shows the average hold time per catch below it. - The "Haltezeit gesamt" metric shows the average hold time per catch below it.
- Dashboard polish: equal metric tiles with a one-line note each (unique IPs show the last
24 hours), map and top 10 card of equal height with a larger legend and visible
small-country markers, country and provider names in the regular font with a separate share
column, and German number formats throughout (e.g. `1.675` bytes, `15.11. 20:01:50`).
## [0.3.1] - 2026-11-15 ## [0.3.1] - 2026-11-15
@@ -8,6 +8,7 @@ public sealed record DashboardData(
int Rejected, int Rejected,
int RejectedLast24Hours, int RejectedLast24Hours,
int UniqueIps, int UniqueIps,
int UniqueIpsLast24Hours,
TimeSpan TotalHoldTime, TimeSpan TotalHoldTime,
IReadOnlyList<TrapEventEntity> Recent, IReadOnlyList<TrapEventEntity> Recent,
IReadOnlyList<TopEntry> TopIps, IReadOnlyList<TopEntry> TopIps,
@@ -39,6 +39,7 @@ public sealed class DashboardQueries(IDbContextFactory<FlypaperDbContext> dbCont
await events.CountAsync(e => e.Outcome == TrapOutcome.Rejected, ct), await events.CountAsync(e => e.Outcome == TrapOutcome.Rejected, ct),
await events.CountAsync(e => e.Outcome == TrapOutcome.Rejected && e.StartedAt >= since, ct), await events.CountAsync(e => e.Outcome == TrapOutcome.Rejected && e.StartedAt >= since, ct),
await events.Select(e => e.RemoteIp).Distinct().CountAsync(ct), await events.Select(e => e.RemoteIp).Distinct().CountAsync(ct),
await events.Where(e => e.StartedAt >= since).Select(e => e.RemoteIp).Distinct().CountAsync(ct),
TimeSpan.FromMilliseconds(await catches.SumAsync(e => e.DurationMs, ct)), TimeSpan.FromMilliseconds(await catches.SumAsync(e => e.DurationMs, ct)),
await events.OrderByDescending(e => e.Id).Take(RecentCount).ToListAsync(ct), await events.OrderByDescending(e => e.Id).Take(RecentCount).ToListAsync(ct),
await TopAsync(catches.GroupBy(e => e.RemoteIp), ct), await TopAsync(catches.GroupBy(e => e.RemoteIp), ct),
@@ -24,19 +24,20 @@
var active = Governor.ActiveConnections; var active = Governor.ActiveConnections;
var tabs = TopTabs(data); var tabs = TopTabs(data);
<section class="metrics"> <section class="metrics">
<div class="metric metric-hero @(active > 0 ? "live" : null)"> <div class="metric @(active > 0 ? "live" : null)">
<span class="label">Gerade in der Falle</span> <span class="label">Gerade in der Falle</span>
<span class="value">@active.ToString("N0")</span> <span class="value">@Formatting.Number(active)</span>
<span class="sub">@(active == 1 ? "Bot wird festgehalten" : "Bots werden festgehalten")</span> <span class="sub">@(active == 1 ? "Bot festgehalten" : "Bots festgehalten")</span>
</div> </div>
<div class="metric metric-hero"> <div class="metric">
<span class="label">Fänge gesamt</span> <span class="label">Fänge gesamt</span>
<span class="value">@data.TotalCatches.ToString("N0")</span> <span class="value">@Formatting.Number(data.TotalCatches)</span>
<span class="sub">+@data.CatchesLast24Hours.ToString("N0") in den letzten 24 h</span> <span class="sub">+@Formatting.Number(data.CatchesLast24Hours) in 24 h</span>
</div> </div>
<div class="metric"> <div class="metric">
<span class="label">Eindeutige IPs</span> <span class="label">Eindeutige IPs</span>
<span class="value">@data.UniqueIps.ToString("N0")</span> <span class="value">@Formatting.Number(data.UniqueIps)</span>
<span class="sub">@Formatting.Number(data.UniqueIpsLast24Hours) in 24 h aktiv</span>
</div> </div>
<div class="metric"> <div class="metric">
<span class="label">Haltezeit gesamt</span> <span class="label">Haltezeit gesamt</span>
@@ -45,8 +46,8 @@
</div> </div>
<div class="metric"> <div class="metric">
<span class="label">Abgelehnt</span> <span class="label">Abgelehnt</span>
<span class="value">@data.Rejected.ToString("N0")</span> <span class="value">@Formatting.Number(data.Rejected)</span>
<span class="sub">+@data.RejectedLast24Hours.ToString("N0") in 24 h · Verbindungslimit erreicht</span> <span class="sub">+@Formatting.Number(data.RejectedLast24Hours) in 24 h · Limit erreicht</span>
</div> </div>
</section> </section>
@@ -112,9 +113,9 @@
var provider = Formatting.Provider(trapEvent.Asn, trapEvent.Provider); var provider = Formatting.Provider(trapEvent.Asn, trapEvent.Provider);
var target = Formatting.Target(trapEvent.Target); var target = Formatting.Target(trapEvent.Target);
var duration = Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs)); var duration = Formatting.Duration(TimeSpan.FromMilliseconds(trapEvent.DurationMs));
var bytes = trapEvent.BytesSent.ToString("N0"); var bytes = Formatting.Number(trapEvent.BytesSent);
<tr data-expand="event:@trapEvent.Id" tabindex="0" aria-expanded="false" class="@(trapEvent.Outcome == TrapOutcome.Rejected ? "rejected" : null)"> <tr data-expand="event:@trapEvent.Id" tabindex="0" aria-expanded="false" class="@(trapEvent.Outcome == TrapOutcome.Rejected ? "rejected" : null)">
<td class="c-time"><span class="c-date">@started.ToString("dd.MM.") </span>@started.ToString("HH:mm:ss")</td> <td class="c-time"><span class="c-date">@started.ToString("dd.MM.")&nbsp;</span>@started.ToString("HH:mm:ss")</td>
<td class="c-ip mono" title="@trapEvent.RemoteIp">@trapEvent.RemoteIp</td> <td class="c-ip mono" title="@trapEvent.RemoteIp">@trapEvent.RemoteIp</td>
<td class="c-origin" title="@Origin(trapEvent)"> <td class="c-origin" title="@Origin(trapEvent)">
@if (trapEvent.CountryCode is { } countryCode) @if (trapEvent.CountryCode is { } countryCode)
@@ -10,12 +10,14 @@ else
<table class="top-table"> <table class="top-table">
<colgroup> <colgroup>
<col /> <col />
<col class="share" />
<col class="count" /> <col class="count" />
<col class="hold" /> <col class="hold" />
</colgroup> </colgroup>
<thead> <thead>
<tr> <tr>
<th>@KeyLabel</th> <th>@KeyLabel</th>
<th><span class="sr-only">Anteil</span></th>
<th class="num">Fänge</th> <th class="num">Fänge</th>
<th class="num">Haltezeit</th> <th class="num">Haltezeit</th>
</tr> </tr>
@@ -23,10 +25,27 @@ else
<tbody> <tbody>
@foreach (var entry in Entries) @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 share = (entry.Count * 100.0 / Entries[0].Count).ToString("0.#", CultureInfo.InvariantCulture);
<tr data-expand="@($"{KeyLabel}:{entry.Key}")" tabindex="0" aria-expanded="false" style="--share: @(share)%"> <tr data-expand="@($"{KeyLabel}:{entry.Key}")" tabindex="0" aria-expanded="false">
<td class="mono clip bar" title="@Display(entry)">@(ShowFlags ? $"{Formatting.Flag(entry.Key)} " : "")@Display(entry)</td> <td class="clip" title="@(label is null ? key : $"{label} · {key}")">
<td class="num">@entry.Count.ToString("N0")</td> @if (ShowFlags)
{
<span class="flag">@Formatting.Flag(entry.Key)</span>
}
@if (label is not null)
{
<span class="top-label">@label</span>
<span class="top-key mono">@key</span>
}
else
{
<span class="mono">@key</span>
}
</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> <td class="num">@Formatting.Duration(entry.HoldTime)</td>
</tr> </tr>
} }
@@ -44,11 +63,4 @@ else
[Parameter] public Func<string?, string?>? KeyFormatter { get; set; } [Parameter] public Func<string?, string?>? KeyFormatter { get; set; }
[Parameter] public Func<string?, string?, string?>? LabelFormatter { get; set; } [Parameter] public Func<string?, string?, string?>? LabelFormatter { get; set; }
private string Display(TopEntry entry)
{
var key = KeyFormatter?.Invoke(entry.Key) ?? entry.Key;
var label = LabelFormatter is null ? entry.Label : LabelFormatter(entry.Key, entry.Label);
return label is null ? key : $"{key} · {label}";
}
} }
@@ -12,7 +12,7 @@
{ {
<span class="swatch @($"level-{level}")"></span> <span class="swatch @($"level-{level}")"></span>
} }
<span>@_max.ToString("N0")</span> <span>@Formatting.Number(_max)</span>
</div> </div>
} }
</div> </div>
@@ -107,7 +107,7 @@
var bytesPerSecond = HoldMethodSettings.AverageBytesPerSecond( var bytesPerSecond = HoldMethodSettings.AverageBytesPerSecond(
TimeSpan.FromMilliseconds(minDelay), TimeSpan.FromMilliseconds(maxDelay), minChunk, maxChunk); TimeSpan.FromMilliseconds(minDelay), TimeSpan.FromMilliseconds(maxDelay), minChunk, maxChunk);
return bytesPerSecond.ToString(bytesPerSecond < 10 ? "0.0" : "N0", CultureInfo.GetCultureInfo("de-DE")); return bytesPerSecond.ToString(bytesPerSecond < 10 ? "0.0" : "N0", Formatting.German);
} }
} }
@@ -5,12 +5,12 @@
<SettingsSection Id="data" Title="Daten" Description="Gespeicherte Fänge. Einstellungen und GeoIP-Dateien bleiben beim Löschen erhalten."> <SettingsSection Id="data" Title="Daten" Description="Gespeicherte Fänge. Einstellungen und GeoIP-Dateien bleiben beim Löschen erhalten.">
@if (Deleted is { } deleted) @if (Deleted is { } deleted)
{ {
<Notice>@deleted.ToString("N0") @(deleted == 1 ? "Fang" : "Fänge") gelöscht.</Notice> <Notice>@Formatting.Number(deleted) @(deleted == 1 ? "Fang" : "Fänge") gelöscht.</Notice>
} }
<div class="s-body"> <div class="s-body">
<div class="stat-row"> <div class="stat-row">
<div class="stat"><span class="stat-label">Fänge</span><span class="stat-value">@(_stats?.Count.ToString("N0") ?? "–")</span></div> <div class="stat"><span class="stat-label">Fänge</span><span class="stat-value">@((_stats is null ? null : Formatting.Number(_stats.Count)) ?? "–")</span></div>
<div class="stat"><span class="stat-label">Ältester Fang</span><span class="stat-value">@(_stats?.Oldest?.ToLocalTime().ToString("dd.MM.yyyy") ?? "–")</span></div> <div class="stat"><span class="stat-label">Ältester Fang</span><span class="stat-value">@(_stats?.Oldest?.ToLocalTime().ToString("dd.MM.yyyy") ?? "–")</span></div>
<div class="stat"><span class="stat-label">Datenbank</span><span class="stat-value">@Formatting.Bytes(_stats?.DatabaseBytes)</span></div> <div class="stat"><span class="stat-label">Datenbank</span><span class="stat-value">@Formatting.Bytes(_stats?.DatabaseBytes)</span></div>
</div> </div>
@@ -1,7 +1,13 @@
using System.Globalization;
namespace Flypaper.Web.Components.Shared; namespace Flypaper.Web.Components.Shared;
public static class Formatting public static class Formatting
{ {
public static readonly CultureInfo German = CultureInfo.GetCultureInfo("de-DE");
public static string Number(long value) => value.ToString("N0", German);
public static string Duration(TimeSpan duration) => duration switch public static string Duration(TimeSpan duration) => duration switch
{ {
{ TotalDays: >= 1 } => $"{(int)duration.TotalDays}\u00a0d {duration.Hours}\u00a0h", { TotalDays: >= 1 } => $"{(int)duration.TotalDays}\u00a0d {duration.Hours}\u00a0h",
+81 -34
View File
@@ -42,7 +42,7 @@ h1:focus {
} }
.page { .page {
max-width: 1280px; max-width: 1440px;
margin: 0 auto; margin: 0 auto;
padding: 24px 16px 48px; padding: 24px 16px 48px;
} }
@@ -58,7 +58,7 @@ h2 {
.metrics { .metrics {
display: grid; display: grid;
grid-template-columns: repeat(2, minmax(0, 1.4fr)) repeat(3, minmax(0, 1fr)); grid-template-columns: repeat(5, minmax(0, 1fr));
gap: 12px; gap: 12px;
margin-bottom: 16px; margin-bottom: 16px;
} }
@@ -85,33 +85,32 @@ h2 {
} }
.metric .value { .metric .value {
margin-top: 4px; margin: 6px 0 2px;
font-size: 22px; font-size: 28px;
font-weight: 600; font-weight: 600;
line-height: 1.15;
font-variant-numeric: tabular-nums; font-variant-numeric: tabular-nums;
white-space: nowrap; white-space: nowrap;
} }
.metric .sub { .metric .sub {
overflow: hidden;
color: var(--muted); color: var(--muted);
font-size: 12px; font-size: 12px;
white-space: nowrap;
text-overflow: ellipsis;
} }
.metric-hero .value { .metric.live {
font-size: 32px;
line-height: 1.15;
}
.metric-hero.live {
border-color: color-mix(in srgb, var(--accent) 55%, var(--border)); border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
background: color-mix(in srgb, var(--accent) 8%, var(--surface)); background: color-mix(in srgb, var(--accent) 8%, var(--surface));
} }
.metric-hero.live .value { .metric.live .value {
color: var(--accent); color: var(--accent);
} }
.metric-hero.live .label::before, .metric.live .label::before,
.live-dot { .live-dot {
content: ""; content: "";
display: inline-block; display: inline-block;
@@ -135,7 +134,7 @@ h2 {
} }
@media (prefers-reduced-motion: reduce) { @media (prefers-reduced-motion: reduce) {
.metric-hero.live .label::before, .metric.live .label::before,
.live-dot { .live-dot {
animation: none; animation: none;
} }
@@ -182,9 +181,18 @@ code {
.origin { .origin {
display: grid; display: grid;
grid-template-columns: minmax(0, 1.8fr) minmax(0, 1fr); grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr);
gap: 16px; gap: 16px;
align-items: start; margin-bottom: 16px;
}
.origin > .card {
margin-bottom: 0;
}
.map-card {
display: flex;
flex-direction: column;
} }
.origin > * { .origin > * {
@@ -236,12 +244,33 @@ code {
table-layout: fixed; table-layout: fixed;
} }
.top-table .count { .top-table .share {
width: 64px; width: 64px;
} }
.top-table .count {
width: 60px;
}
.top-table .hold { .top-table .hold {
width: 104px; width: 96px;
}
.top-table .flag {
margin-right: 6px;
}
.top-key {
margin-left: 6px;
color: var(--muted);
font-size: 12px;
}
.share-bar {
display: block;
height: 6px;
border-radius: 3px;
background: linear-gradient(to right, var(--accent) var(--share), color-mix(in srgb, var(--text) 8%, transparent) var(--share));
} }
.top-table .clip { .top-table .clip {
@@ -669,8 +698,9 @@ tbody th {
} }
.world-map .marker .dot { .world-map .marker .dot {
stroke: var(--surface); stroke: var(--text);
stroke-width: 1.5; stroke-width: 1.5;
stroke-opacity: 0.85;
} }
.world-map .marker:hover .dot { .world-map .marker:hover .dot {
@@ -715,9 +745,10 @@ tbody th {
.map-legend { .map-legend {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 4px; gap: 5px;
color: var(--muted); color: var(--muted);
font-size: 12px; font-size: 13px;
font-variant-numeric: tabular-nums;
} }
.map-legend .level-0 { .map-legend .level-0 {
@@ -726,6 +757,9 @@ tbody th {
.map-wrap { .map-wrap {
position: relative; position: relative;
display: flex;
flex: 1;
align-items: center;
} }
.map-empty { .map-empty {
@@ -743,17 +777,10 @@ tbody th {
white-space: nowrap; white-space: nowrap;
} }
td.bar {
background-image: linear-gradient(to right, color-mix(in srgb, var(--accent) 70%, transparent) var(--share), transparent var(--share));
background-repeat: no-repeat;
background-size: 100% 3px;
background-position: 0 calc(100% - 3px);
}
.map-legend .swatch { .map-legend .swatch {
width: 18px; width: 22px;
height: 10px; height: 12px;
border-radius: 2px; border-radius: 3px;
} }
.detail { .detail {
@@ -789,7 +816,7 @@ button.danger {
grid-column: span 2; grid-column: span 2;
} }
.metric-hero { .metric:nth-child(n + 4) {
grid-column: span 3; grid-column: span 3;
} }
@@ -804,7 +831,7 @@ button.danger {
} }
.metric, .metric,
.metric-hero { .metric:nth-child(n + 4) {
grid-column: span 1; grid-column: span 1;
} }
@@ -812,8 +839,19 @@ button.danger {
grid-column: span 2; grid-column: span 2;
} }
.metric-hero .value { .metric .value {
font-size: 26px; font-size: 24px;
}
.top-table .share,
.top-table th:nth-child(2),
.top-table td:nth-child(2),
.top-key {
display: none;
}
.top-table .hold {
width: 84px;
} }
.nav .brand { .nav .brand {
@@ -1379,3 +1417,12 @@ button.danger-text {
gap: 2px; gap: 2px;
} }
} }
.sr-only {
position: absolute;
width: 1px;
height: 1px;
overflow: hidden;
clip-path: inset(50%);
white-space: nowrap;
}