2 Commits
Author SHA1 Message Date
TomandClaude Opus 5.5 570ac20a5c Prepare changelog for 0.3.1
Build and deploy / build (push) Successful in 1m29s
Release / image (push) Successful in 1m51s
Build and deploy / deploy (push) Successful in 20s
Release / release (push) Successful in 6s
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 20:25:03 +01:00
TomandClaude Opus 5.5 393ebcdf0c Combine dashboard top 10 lists into one tabbed card
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-15 20:24:02 +01:00
5 changed files with 142 additions and 29 deletions

No files matched your search

+9 -1
View File
@@ -6,6 +6,13 @@ All notable changes to Flypaper are documented in this file. The format follows
## [Unreleased] ## [Unreleased]
## [0.3.1] - 2026-11-15
### Changed
- The dashboard's top 10 lists share one card with tabs (Länder, Provider, IPs, Ziele); the
selected tab survives the auto-refresh.
## [0.3.0] - 2026-11-15 ## [0.3.0] - 2026-11-15
### Added ### Added
@@ -85,7 +92,8 @@ First release.
- Unraid Docker template; when started as root, the container hands `/data` to its app user - Unraid Docker template; when started as root, the container hands `/data` to its app user
and drops privileges. and drops privileges.
[Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.3.0...main [Unreleased]: https://gitea.anticarnist.de/Tom/Flypaper/compare/v0.3.1...main
[0.3.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.3.1
[0.3.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.3.0 [0.3.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.3.0
[0.2.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.2.0 [0.2.0]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.2.0
[0.1.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.1.1 [0.1.1]: https://gitea.anticarnist.de/Tom/Flypaper/releases/tag/v0.1.1
@@ -21,6 +21,7 @@
@if (_data is { } data) @if (_data is { } data)
{ {
var active = Governor.ActiveConnections; var active = Governor.ActiveConnections;
var tabs = TopTabs(data);
<section class="metrics"> <section class="metrics">
<div class="metric metric-hero @(active > 0 ? "live" : null)"> <div class="metric metric-hero @(active > 0 ? "live" : null)">
<span class="label">Gerade in der Falle</span> <span class="label">Gerade in der Falle</span>
@@ -62,17 +63,26 @@
<section class="origin"> <section class="origin">
<WorldMap CatchesByCountry="data.CatchesByCountry" /> <WorldMap CatchesByCountry="data.CatchesByCountry" />
<TopTable Title="Top 10 Länder" KeyLabel="Land" Entries="data.TopCountries" ShowFlags="true" LabelFormatter="CountryNames.Display" /> <section class="card tops-card">
<h2 id="tops-title">Top 10</h2>
<div class="tabs" role="tablist" aria-labelledby="tops-title">
@foreach (var tab in tabs)
{
var first = tab == tabs[0];
<button type="button" role="tab" id="tab-@tab.Id" aria-controls="panel-@tab.Id" aria-selected="@(first ? "true" : "false")" tabindex="@(first ? 0 : -1)">@tab.Label</button>
}
</div>
@foreach (var tab in tabs)
{
<div role="tabpanel" id="panel-@tab.Id" aria-labelledby="tab-@tab.Id" tabindex="0" hidden="@(tab != tabs[0])">
<TopTable KeyLabel="@tab.KeyLabel" Entries="tab.Entries" ShowFlags="tab.ShowFlags" KeyFormatter="tab.KeyFormatter" LabelFormatter="tab.LabelFormatter" />
</div>
}
</section>
</section> </section>
@if (data.TotalCatches > 0) @if (data.TotalCatches > 0)
{ {
<section class="tops">
<TopTable Title="Top 10 Provider" KeyLabel="Provider" Entries="data.TopProviders" />
<TopTable Title="Top 10 IPs" KeyLabel="IP" Entries="data.TopIps" />
<TopTable Title="Top 10 Ziele" KeyLabel="Ziel" Entries="data.TopTargets" KeyFormatter="Formatting.Target" />
</section>
<section class="card"> <section class="card">
<div class="card-head"> <div class="card-head">
<h2>Letzte 50 Fänge</h2> <h2>Letzte 50 Fänge</h2>
@@ -148,6 +158,23 @@
_loadedAt = DateTime.Now; _loadedAt = DateTime.Now;
} }
private static IReadOnlyList<TopTab> TopTabs(DashboardData data) =>
[
new("countries", "Länder", "Land", data.TopCountries, ShowFlags: true, LabelFormatter: CountryNames.Display),
new("providers", "Provider", "Provider", data.TopProviders),
new("ips", "IPs", "IP", data.TopIps),
new("targets", "Ziele", "Ziel", data.TopTargets, KeyFormatter: Formatting.Target)
];
private static string Origin(TrapEventEntity trapEvent) => private static string Origin(TrapEventEntity trapEvent) =>
string.Join(", ", new[] { trapEvent.City, CountryNames.Display(trapEvent.CountryCode, trapEvent.Country) }.Where(part => !string.IsNullOrEmpty(part))); string.Join(", ", new[] { trapEvent.City, CountryNames.Display(trapEvent.CountryCode, trapEvent.Country) }.Where(part => !string.IsNullOrEmpty(part)));
private sealed record TopTab(
string Id,
string Label,
string KeyLabel,
IReadOnlyList<TopEntry> Entries,
bool ShowFlags = false,
Func<string?, string?>? KeyFormatter = null,
Func<string?, string?, string?>? LabelFormatter = null);
} }
@@ -1,13 +1,12 @@
@using System.Globalization @using System.Globalization
@using Flypaper.Storage.Dashboard @using Flypaper.Storage.Dashboard
<section class="card">
<h2>@Title</h2> @if (Entries.Count == 0)
@if (Entries.Count == 0) {
{
<p class="empty">Noch keine Einträge.</p> <p class="empty">Noch keine Einträge.</p>
} }
else else
{ {
<table class="top-table"> <table class="top-table">
<colgroup> <colgroup>
<col /> <col />
@@ -33,12 +32,9 @@
} }
</tbody> </tbody>
</table> </table>
} }
</section>
@code { @code {
[Parameter, EditorRequired] public required string Title { get; set; }
[Parameter, EditorRequired] public required string KeyLabel { get; set; } [Parameter, EditorRequired] public required string KeyLabel { get; set; }
[Parameter, EditorRequired] public required IReadOnlyList<TopEntry> Entries { get; set; } [Parameter, EditorRequired] public required IReadOnlyList<TopEntry> Entries { get; set; }
+36 -10
View File
@@ -191,18 +191,45 @@ code {
min-width: 0; min-width: 0;
} }
.tops { .tops-card h2 {
display: grid; margin-bottom: 10px;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 16px;
} }
.tops > :last-child { .tabs {
grid-column: 1 / -1; display: flex;
gap: 2px;
margin: 0 -4px 8px;
padding: 0 4px;
overflow-x: auto;
border-bottom: 1px solid var(--border);
scrollbar-width: none;
} }
.tops > * { .tabs button[role="tab"] {
min-width: 0; flex: none;
margin-bottom: -1px;
padding: 7px 12px;
border: 0;
border-bottom: 2px solid transparent;
border-radius: 6px 6px 0 0;
background: none;
color: var(--muted);
font-weight: 500;
}
.tabs button[role="tab"]:hover {
color: var(--text);
}
.tabs button[role="tab"][aria-selected="true"] {
border-bottom-color: var(--accent);
color: var(--text);
}
.tabs button[role="tab"]:focus-visible,
[role="tabpanel"]:focus-visible {
outline: 2px solid var(--accent);
outline-offset: -2px;
} }
.top-table { .top-table {
@@ -754,8 +781,7 @@ button.danger {
grid-column: span 3; grid-column: span 3;
} }
.origin, .origin {
.tops {
grid-template-columns: minmax(0, 1fr); grid-template-columns: minmax(0, 1fr);
} }
} }
+56
View File
@@ -52,3 +52,59 @@
save(expanded); save(expanded);
})(); })();
(() => {
const storageKey = "flypaper.tab";
const tabs = [...document.querySelectorAll('[role="tab"]')];
if (tabs.length === 0) {
return;
}
const select = (tab, focus) => {
for (const other of tabs) {
const selected = other === tab;
other.setAttribute("aria-selected", String(selected));
other.tabIndex = selected ? 0 : -1;
document.getElementById(other.getAttribute("aria-controls")).hidden = !selected;
}
if (focus) {
tab.focus();
}
try {
sessionStorage.setItem(storageKey, tab.id);
} catch {
}
};
let stored = null;
try {
stored = sessionStorage.getItem(storageKey);
} catch {
}
const initial = tabs.find(tab => tab.id === stored);
if (initial) {
select(initial, false);
}
for (const tab of tabs) {
tab.addEventListener("click", () => select(tab, false));
tab.addEventListener("keydown", event => {
const index = tabs.indexOf(tab);
const target = {
ArrowRight: tabs[(index + 1) % tabs.length],
ArrowLeft: tabs[(index - 1 + tabs.length) % tabs.length],
Home: tabs[0],
End: tabs.at(-1)
}[event.key];
if (target) {
event.preventDefault();
select(target, true);
}
});
}
})();