diff --git a/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor b/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor index 860fa2f..989f430 100644 --- a/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor +++ b/src/Flypaper.Web/Components/Pages/Settings/HoldMethodSection.razor @@ -9,80 +9,83 @@ @inject RuntimeSettingsStore Store @inject NavigationManager Navigation -
-
-

Haltemethode

- @if (_hasOverrides) - { - Überschrieben - } -
- + @if (Saved == "saved") { - + Gespeichert. Gilt ab dem nächsten Fang. } else if (Saved == "reset") { - + Haltemethode auf Standard zurückgesetzt. } - - - - - - - - + +
+
+ Inhalt + +
+ @foreach (var choice in Choices) + { + + } +
+
+ @if (_errors.TryGetValue(nameof(HoldMethodModel.Content), out var contentError)) + { +

@contentError

+ } +
-
-
- - - +
+ + + + + + + + + + + + + + +
-
- - - -
-
- - - -
-
- - - -
-
- - - -
-
-

- Pause 10 ms bis 30 s, Paket 1 bis 4096 Bytes. Ø ca. @Bandwidth Bytes/s pro gefangener Verbindung. -

- -
- +
+ Ø @Bandwidth Bytes/s + pro gefangener Verbindung, berechnet aus Pausen und Paketgrößen +
- -
- -
-
-
+ + @code { + private static readonly (string Value, string Title, string Text)[] Choices = + [ + (nameof(DripContent.Html), "HTML-Fülltext", "Eine endlose Webseite mit Überschriften, Absätzen und Links. Wirkt auf Crawler am echtesten."), + (nameof(DripContent.Text), "Zufallstext", "Schlichter Text ohne Markup, ausgeliefert als text/plain."), + (nameof(DripContent.Alternating), "Wechselnd", "Pro Fang zufällig eine der beiden. Gut, um zu vergleichen, was Bots länger hält.") + ]; + private readonly object _resetModel = new(); private IReadOnlyDictionary _errors = new Dictionary(); private bool _hasOverrides; diff --git a/src/Flypaper.Web/Components/Pages/Settings/McpSection.razor b/src/Flypaper.Web/Components/Pages/Settings/McpSection.razor index 6caa071..0f75d2a 100644 --- a/src/Flypaper.Web/Components/Pages/Settings/McpSection.razor +++ b/src/Flypaper.Web/Components/Pages/Settings/McpSection.razor @@ -5,74 +5,76 @@ @inject McpTokenStore Store @inject NavigationManager Navigation -
-

MCP-Zugriff

-

- KI-Assistenten wie Claude lesen die Fänge über @Endpoint (nur lesend, nur im LAN). - Jeder Zugriff braucht einen Token im Header Authorization: Bearer …. -

- + @if (Revoked == "revoked") { - + Token widerrufen. } @if (_newToken is not null) { - + } - @if (Tokens.UsesEnvironmentToken) - { -

Zusätzlich gilt ein fester Token aus der Umgebungsvariable Flypaper__Mcp__Token.

- } +
+
+
Endpunkt
@Endpoint
+
Header
Authorization: Bearer <Token>
+ @if (Tokens.UsesEnvironmentToken) + { +
Fester Token
per Umgebungsvariable Flypaper__Mcp__Token
+ } +
- @if (_tokens.Count > 0) - { - - - - - - - - - - - @foreach (var token in _tokens) - { + @if (_tokens.Count > 0) + { +
NameErstelltZuletzt genutzt
+ - - - - + + + + - } - -
@token.Name@token.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm")@(token.LastUsedAt?.ToLocalTime().ToString("dd.MM.yyyy HH:mm") ?? "nie") -
- - - -
NameErstelltZuletzt genutzt
- } - else - { -

Noch keine Tokens.

- } + + + @foreach (var token in _tokens) + { + + @token.Name + @token.CreatedAt.ToLocalTime().ToString("dd.MM.yyyy HH:mm") + @(token.LastUsedAt?.ToLocalTime().ToString("dd.MM.yyyy HH:mm") ?? "nie") + +
+ + + + + + } + + + } + else + { +

Noch keine Tokens.

+ } +
- - - - -
- + +
+ + @if (_errors.TryGetValue(nameof(McpTokenModel.Name), out var nameError)) + { + @nameError + }
+
-
+ @code { private IReadOnlyList _tokens = []; diff --git a/src/Flypaper.Web/Components/Pages/Settings/Notice.razor b/src/Flypaper.Web/Components/Pages/Settings/Notice.razor new file mode 100644 index 0000000..96042d7 --- /dev/null +++ b/src/Flypaper.Web/Components/Pages/Settings/Notice.razor @@ -0,0 +1,7 @@ +
@ChildContent
+ +@code { + [Parameter] public string Kind { get; set; } = "ok"; + + [Parameter] public RenderFragment? ChildContent { get; set; } +} diff --git a/src/Flypaper.Web/Components/Pages/Settings/PasswordSection.razor b/src/Flypaper.Web/Components/Pages/Settings/PasswordSection.razor index ff5cf44..73e78a1 100644 --- a/src/Flypaper.Web/Components/Pages/Settings/PasswordSection.razor +++ b/src/Flypaper.Web/Components/Pages/Settings/PasswordSection.razor @@ -2,38 +2,31 @@ @inject AdminAuthenticator Admin @inject NavigationManager Navigation -
-

Admin-Passwort

- + @if (Changed == "changed") { - + Passwort geändert. } - @if (Admin.UsesEnvironmentPassword) - { -

Das Passwort kommt aus der Umgebungsvariable Flypaper__Admin__Password und lässt sich nur dort ändern.

- } - else - { - - - - - - - - - - - - -
- + +
+
+ + + + + + + + +
- - } -
+ + +
+ +
+ @code { private readonly Dictionary _errors = []; @@ -58,6 +51,6 @@ return; } - Navigation.NavigateTo("/settings?password=changed"); + Navigation.NavigateTo("/settings?password=changed#password"); } } diff --git a/src/Flypaper.Web/Components/Pages/Settings/SettingsField.razor b/src/Flypaper.Web/Components/Pages/Settings/SettingsField.razor new file mode 100644 index 0000000..4a7f0a8 --- /dev/null +++ b/src/Flypaper.Web/Components/Pages/Settings/SettingsField.razor @@ -0,0 +1,36 @@ +
+ +
+ @ChildContent + @if (Unit is not null) + { + @Unit + } +
+ @if (Errors is not null && Key is not null && Errors.TryGetValue(Key, out var error)) + { +

@error

+ } + else if (Hint is not null) + { +

@Hint

+ } +
+ +@code { + [Parameter, EditorRequired] public required string Label { get; set; } + + [Parameter, EditorRequired] public required string For { get; set; } + + [Parameter] public string? Unit { get; set; } + + [Parameter] public string? Hint { get; set; } + + [Parameter] public IReadOnlyDictionary? Errors { get; set; } + + [Parameter] public string? Key { get; set; } + + [Parameter] public bool Wide { get; set; } + + [Parameter] public RenderFragment? ChildContent { get; set; } +} diff --git a/src/Flypaper.Web/Components/Pages/Settings/SettingsPage.razor b/src/Flypaper.Web/Components/Pages/Settings/SettingsPage.razor index e1021bb..5eb82f5 100644 --- a/src/Flypaper.Web/Components/Pages/Settings/SettingsPage.razor +++ b/src/Flypaper.Web/Components/Pages/Settings/SettingsPage.razor @@ -18,87 +18,103 @@ Flypaper · Einstellungen -
-

Einstellungen

- @if (_hasOverrides) - { - Überschrieben - } -
+
+
+

Einstellungen

+

Änderungen gelten sofort, ohne Neustart. Werte aus Umgebungsvariablen dienen als Standard.

+
-@if (Saved == "1") -{ - -} -else if (Saved == "reset") -{ - -} +
+ - +
+ - -

Allgemein

+ + @if (Saved == "1") + { + Gespeichert. Gilt ab sofort. + } -
-
- - - -
-
- - - -
-
- - - + +
+
+ + + + + + + + + +
+ + +
+
+
+ +
+ + + + + @if (!Admin.UsesEnvironmentPassword) + { + + } + + + + + @if (Saved == "reset") + { + Alle gespeicherten Einstellungen wurden zurückgesetzt. + } + +
+
+
Version
@AppVersion.Current
+
Ports
Falle @Ports.Value.Trap · Dashboard @Ports.Value.Dashboard
+
Datenbank
@DatabasePath
+
Vertrauenswürdige Proxies
@TrustedProxies
+
Admin-Passwort
@(Admin.UsesEnvironmentPassword ? "per Umgebungsvariable" : "im Dashboard festgelegt")
+
+
+ +
+ Alle im Dashboard gespeicherten Einstellungen löschen. Danach gelten wieder die Standardwerte. + + + +
+
- - - -
- -
-
- - -

Standard

-

Löscht alle gespeicherten Änderungen. Danach gelten wieder die Werte aus Umgebungsvariablen und appsettings.

-
- -
-
- - - - - - - -
-

Nur per Umgebungsvariable

-

Gelten ab Containerstart und lassen sich hier nicht ändern.

- - - - - - - -
Datenbank@DatabasePath
Vertrauenswürdige Proxies@(Configuration.GetSection("Flypaper:Http:TrustedProxies").Get()?.Where(p => !string.IsNullOrWhiteSpace(p)).ToArray() is { Length: > 0 } proxies ? string.Join(", ", proxies) : "private Netze (Standard)")
Admin-Passwort@(Admin.UsesEnvironmentPassword ? "per Umgebungsvariable" : "im Dashboard festgelegt")
PortsFalle @Ports.Value.Trap, Dashboard @Ports.Value.Dashboard
-
+
@code { private readonly object _resetModel = new(); private IReadOnlyDictionary _errors = new Dictionary(); private bool _hasOverrides; + private bool _generalOverrides; [SupplyParameterFromForm(FormName = "settings")] private SettingsModel? Model { get; set; } @@ -111,6 +127,7 @@ else if (Saved == "reset") { Model ??= CurrentValues(); _hasOverrides = await Store.HasOverridesAsync(); + _generalOverrides = await Store.HasOverridesAsync(SettingKeys.General.ToArray()); } private async Task Save() @@ -128,13 +145,13 @@ else if (Saved == "reset") } await Store.SaveAsync(result.Settings); - Navigation.NavigateTo("/settings?saved=1"); + Navigation.NavigateTo("/settings?saved=1#connections"); } private async Task Reset() { await Store.ResetAsync(); - Navigation.NavigateTo("/settings?saved=reset"); + Navigation.NavigateTo("/settings?saved=reset#system"); } private SettingsModel CurrentValues() @@ -149,5 +166,8 @@ else if (Saved == "reset") }; } - private static string Format(string[]? values) => values is { Length: > 0 } ? string.Join(", ", values) : "–"; + private string TrustedProxies => + Configuration.GetSection("Flypaper:Http:TrustedProxies").Get()?.Where(p => !string.IsNullOrWhiteSpace(p)).ToArray() is { Length: > 0 } proxies + ? string.Join(", ", proxies) + : "private Netze (Standard)"; } diff --git a/src/Flypaper.Web/Components/Pages/Settings/SettingsSection.razor b/src/Flypaper.Web/Components/Pages/Settings/SettingsSection.razor new file mode 100644 index 0000000..686d9ab --- /dev/null +++ b/src/Flypaper.Web/Components/Pages/Settings/SettingsSection.razor @@ -0,0 +1,30 @@ +
+
+

+ @Title + @if (Badge is not null) + { + @Badge + } +

+ @if (Description is not null) + { +

@Description

+ } +
+ @ChildContent +
+ +@code { + [Parameter, EditorRequired] public required string Id { get; set; } + + [Parameter, EditorRequired] public required string Title { get; set; } + + [Parameter] public string? Description { get; set; } + + [Parameter] public string? Badge { get; set; } + + [Parameter] public bool Danger { get; set; } + + [Parameter] public RenderFragment? ChildContent { get; set; } +} diff --git a/src/Flypaper.Web/Components/Pages/Settings/TrapDataSection.razor b/src/Flypaper.Web/Components/Pages/Settings/TrapDataSection.razor index 8101217..d5b5cda 100644 --- a/src/Flypaper.Web/Components/Pages/Settings/TrapDataSection.razor +++ b/src/Flypaper.Web/Components/Pages/Settings/TrapDataSection.razor @@ -2,46 +2,57 @@ @inject TrapDataMaintenance Maintenance @inject NavigationManager Navigation -
-

Daten

- + @if (Deleted is { } deleted) { - + @deleted.ToString("N0") @(deleted == 1 ? "Fang" : "Fänge") gelöscht. } - - - - - - -
Fänge@_stats?.Count.ToString("N0")
Ältester Fang@(_stats?.Oldest?.ToLocalTime().ToString("dd.MM.yyyy HH:mm") ?? "–")
Größe der Datenbank@Formatting.Bytes(_stats?.DatabaseBytes)
-

Einstellungen und GeoIP-Dateien bleiben beim Löschen erhalten.

- - -

Fänge aus privaten Netzen löschen

-

Loopback, 10/8, 172.16/12, 192.168/16, Link-Local und ULA, zum Beispiel lokale Testaufrufe.

- - -
- +
+
+
Fänge@(_stats?.Count.ToString("N0") ?? "–")
+
Ältester Fang@(_stats?.Oldest?.ToLocalTime().ToString("dd.MM.yyyy") ?? "–")
+
Datenbank@Formatting.Bytes(_stats?.DatabaseBytes)
- +
- -

Alle Fänge löschen

- - - -
- -
-
-
+
+

Gefahrenzone

+ + +
+ Fänge aus privaten Netzen löschen + Loopback, 10/8, 172.16/12, 192.168/16, Link-Local und ULA, etwa eigene Testaufrufe. + @if (_errors.TryGetValue(nameof(DeletePrivateModel.Confirmed), out var privateError)) + { + @privateError + } +
+
+ + +
+
+ + +
+ Alle Fänge löschen + Zum Bestätigen LÖSCHEN eingeben. Lässt sich nicht rückgängig machen. + @if (_errors.TryGetValue(nameof(DeleteAllModel.Confirmation), out var allError)) + { + @allError + } +
+
+ + +
+
+
+ @code { private const string ConfirmationWord = "LÖSCHEN"; @@ -91,6 +102,6 @@ await Maintenance.VacuumAsync(); } - Navigation.NavigateTo($"/settings?deleted={deleted}"); + Navigation.NavigateTo($"/settings?deleted={deleted}#data"); } } diff --git a/src/Flypaper.Web/Mcp/McpExtensions.cs b/src/Flypaper.Web/Mcp/McpExtensions.cs index c3a30dd..3e8787e 100644 --- a/src/Flypaper.Web/Mcp/McpExtensions.cs +++ b/src/Flypaper.Web/Mcp/McpExtensions.cs @@ -51,7 +51,7 @@ public static class McpExtensions } await store.RevokeAsync(id, context.RequestAborted); - return Results.LocalRedirect("/settings?mcp=revoked"); + return Results.LocalRedirect("/settings?mcp=revoked#mcp"); }); return app; diff --git a/src/Flypaper.Web/wwwroot/app.css b/src/Flypaper.Web/wwwroot/app.css index b9cf09b..748c595 100644 --- a/src/Flypaper.Web/wwwroot/app.css +++ b/src/Flypaper.Web/wwwroot/app.css @@ -382,7 +382,7 @@ tr.open .clip { gap: 0 16px; } -input, +input:not([type="radio"], [type="checkbox"]), textarea { width: 100%; padding: 8px 10px; @@ -393,12 +393,18 @@ textarea { font: inherit; } -input:focus, +input:not([type="radio"], [type="checkbox"]):focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; } +input[type="radio"]:focus-visible, +input[type="checkbox"]:focus-visible { + outline: 2px solid var(--accent); + outline-offset: 2px; +} + textarea { resize: vertical; } @@ -586,36 +592,6 @@ tr.open .detail { color: inherit; } -.check { - display: flex; - align-items: center; - gap: 8px; - font-weight: 400; -} - -.check input { - width: auto; - accent-color: var(--accent); -} - -.danger-zone { - display: flex; - flex-direction: column; - gap: 6px; - margin-top: 16px; - padding-top: 16px; - border-top: 1px solid var(--border); -} - -.danger-zone h3 { - margin: 0; - font-size: 14px; -} - -.danger-zone p { - margin: 0; -} - button.danger { background: var(--bad); } @@ -626,6 +602,478 @@ button.danger { } } +select { + width: 100%; + padding: 8px 10px; + border: 1px solid var(--border); + border-radius: 6px; + background: var(--bg); + color: var(--text); + font: inherit; +} + +.settings-head { + margin-bottom: 24px; +} + +.settings-head h1 { + margin: 0 0 6px; + font-size: 24px; +} + +.settings-head p { + margin: 0; + color: var(--muted); +} + +.settings-layout { + display: grid; + grid-template-columns: 200px minmax(0, 1fr); + gap: 32px; + align-items: start; +} + +.settings-nav { + position: sticky; + top: 24px; + display: flex; + flex-direction: column; + gap: 2px; +} + +.settings-nav a { + padding: 7px 12px; + border-radius: 6px; + color: var(--muted); + text-decoration: none; + font-weight: 500; +} + +.settings-nav a:hover, +.settings-nav a.active { + background: var(--surface); + color: var(--text); +} + +.settings-nav a.active { + box-shadow: inset 2px 0 0 var(--accent); +} + +.settings-sections { + display: flex; + flex-direction: column; + gap: 24px; + min-width: 0; +} + +.s-section { + scroll-margin-top: 24px; + background: var(--surface); + border: 1px solid var(--border); + border-radius: 10px; +} + +.s-head { + padding: 20px 24px 0; +} + +.s-head h2 { + display: flex; + align-items: center; + gap: 10px; + margin: 0; + font-size: 17px; +} + +.s-head p { + max-width: 60ch; + margin: 6px 0 0; + color: var(--muted); +} + +.s-badge { + padding: 2px 8px; + border: 1px solid var(--accent); + border-radius: 999px; + color: var(--accent); + font-size: 11px; + font-weight: 600; + letter-spacing: 0.02em; +} + +.s-body { + display: flex; + flex-direction: column; + gap: 20px; + padding: 20px 24px 24px; +} + +.s-foot { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: flex-end; + gap: 12px; + padding: 14px 24px; + border-top: 1px solid var(--border); + background: color-mix(in srgb, var(--bg) 45%, var(--surface)); + border-radius: 0 0 10px 10px; +} + +.s-foot > form:first-child:not(:only-child) { + margin-right: auto; +} + +.s-foot-text { + margin-right: auto; + color: var(--muted); + font-size: 13px; +} + +.s-section > .notice { + margin: 16px 24px 0; +} + +.notice { + padding: 10px 14px; + border: 1px solid color-mix(in srgb, var(--ok) 45%, var(--border)); + border-left: 3px solid var(--ok); + border-radius: 6px; + background: color-mix(in srgb, var(--ok) 8%, var(--surface)); +} + +.notice.bad { + border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); + border-left-color: var(--bad); + background: color-mix(in srgb, var(--bad) 8%, var(--surface)); +} + +.fields { + display: grid; + grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); + gap: 18px 20px; +} + +.field { + display: flex; + flex-direction: column; + gap: 6px; + min-width: 0; +} + +.field label, +.choices legend { + font-size: 13px; + font-weight: 600; +} + +.field-control { + position: relative; +} + +.field-control.has-unit input { + padding-right: 52px; +} + +.field-unit { + position: absolute; + top: 50%; + right: 12px; + transform: translateY(-50%); + color: var(--muted); + font-size: 12px; + pointer-events: none; +} + +.field-hint, +.field-error { + margin: 0; + font-size: 12px; +} + +.field-hint { + color: var(--muted); +} + +.field-error { + color: var(--bad); +} + +.field:has(.field-error) input { + border-color: var(--bad); +} + +.settings input { + font-variant-numeric: tabular-nums; +} + +.choices { + margin: 0; + padding: 0; + border: 0; +} + +.choices legend { + margin-bottom: 8px; + padding: 0; +} + +.choice-grid { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); + gap: 12px; +} + +.choice { + position: relative; + display: flex; + gap: 10px; + padding: 14px; + border: 1px solid var(--border); + border-radius: 8px; + background: var(--bg); + cursor: pointer; +} + +.choice:hover { + border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); +} + +.choice:has(input:checked) { + border-color: var(--accent); + background: color-mix(in srgb, var(--accent) 8%, var(--bg)); +} + +.choice input { + flex: none; + width: 16px; + height: 16px; + margin: 2px 0 0; + accent-color: var(--accent); +} + +.choice-body { + display: flex; + flex-direction: column; + gap: 4px; +} + +.choice-body span { + color: var(--muted); + font-size: 13px; +} + +.estimate { + display: flex; + flex-wrap: wrap; + align-items: baseline; + gap: 6px 12px; + padding: 12px 14px; + border-radius: 8px; + background: var(--bg); +} + +.estimate-value { + font-size: 15px; +} + +.estimate-value strong { + color: var(--accent); + font-size: 20px; + font-variant-numeric: tabular-nums; +} + +.switch-row { + display: flex; + align-items: flex-start; + gap: 12px; + cursor: pointer; +} + +.switch-row > span { + display: flex; + flex-direction: column; + gap: 2px; +} + +.switch-row .muted { + font-size: 13px; +} + +input.switch { + flex: none; + position: relative; + width: 38px; + height: 22px; + margin: 0; + padding: 0; + border: 1px solid var(--border); + border-radius: 999px; + background: var(--bg); + appearance: none; + cursor: pointer; + transition: background 0.15s; +} + +input.switch::after { + content: ""; + position: absolute; + top: 2px; + left: 2px; + width: 16px; + height: 16px; + border-radius: 50%; + background: var(--muted); + transition: transform 0.15s, background 0.15s; +} + +input.switch:checked { + border-color: var(--accent); + background: var(--accent); +} + +input.switch:checked::after { + background: #fff; + transform: translateX(16px); +} + +.stat-row { + display: grid; + grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); + gap: 12px; +} + +.stat { + display: flex; + flex-direction: column; + gap: 4px; + padding: 12px 14px; + border-radius: 8px; + background: var(--bg); +} + +.stat-label { + color: var(--muted); + font-size: 12px; +} + +.stat-value { + font-size: 18px; + font-weight: 600; + font-variant-numeric: tabular-nums; +} + +.danger-box { + margin: 0 24px 24px; + border: 1px solid color-mix(in srgb, var(--bad) 40%, var(--border)); + border-radius: 8px; +} + +.danger-box h3 { + margin: 0; + padding: 10px 16px; + border-bottom: 1px solid color-mix(in srgb, var(--bad) 25%, var(--border)); + color: var(--bad); + font-size: 13px; +} + +.action-row { + display: flex; + flex-wrap: wrap; + align-items: center; + justify-content: space-between; + gap: 12px 20px; + padding: 14px 16px; +} + +.action-row + .action-row { + border-top: 1px solid var(--border); +} + +.action-text { + display: flex; + flex-direction: column; + gap: 3px; + min-width: 0; + flex: 1 1 280px; +} + +.action-text .muted { + font-size: 13px; +} + +.action-controls { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 10px; +} + +.action-controls input[type="text"], +.action-controls input:not([type]) { + width: 130px; +} + +.inline-check { + display: flex; + align-items: center; + gap: 6px; + font-size: 13px; + cursor: pointer; +} + +.inline-check input { + width: auto; + accent-color: var(--bad); +} + +.inline-field { + display: flex; + flex: 1 1 240px; + flex-direction: column; + gap: 4px; +} + +.kv { + display: grid; + gap: 0; + margin: 0; +} + +.kv > div { + display: grid; + grid-template-columns: minmax(140px, 220px) minmax(0, 1fr); + gap: 12px; + padding: 9px 0; + border-bottom: 1px solid var(--border); +} + +.kv > div:last-child { + border-bottom: 0; +} + +.kv dt { + color: var(--muted); +} + +.kv dd { + margin: 0; + overflow-wrap: anywhere; +} + +.s-table th { + font-size: 12px; +} + +.empty { + margin: 0; + padding: 14px; + border: 1px dashed var(--border); + border-radius: 8px; + color: var(--muted); + text-align: center; +} + .token { display: block; margin-top: 8px; @@ -637,22 +1085,68 @@ button.danger { user-select: all; } -.section-head { - display: flex; - align-items: center; - gap: 8px; +button.ghost { + padding: 8px 12px; + background: transparent; + color: var(--muted); } -.section-head h2 { - margin: 0; -} - -select { - width: 100%; - padding: 8px 10px; - border: 1px solid var(--border); - border-radius: 6px; - background: var(--bg); +button.ghost:hover:not(:disabled) { color: var(--text); - font: inherit; +} + +button.danger-text { + color: var(--bad); +} + +@media (max-width: 899px) { + .settings-layout { + grid-template-columns: minmax(0, 1fr); + gap: 16px; + } + + .settings-nav { + position: static; + flex-direction: row; + gap: 6px; + overflow-x: auto; + padding-bottom: 4px; + } + + .settings-nav a { + flex: none; + border: 1px solid var(--border); + font-size: 13px; + } + + .settings-nav a.active { + border-color: var(--accent); + box-shadow: none; + } + + .s-head, + .s-body { + padding-left: 16px; + padding-right: 16px; + } + + .s-foot { + padding-left: 16px; + padding-right: 16px; + } + + .s-section > .notice { + margin-left: 16px; + margin-right: 16px; + } + + .danger-box { + margin-left: 16px; + margin-right: 16px; + } + + .kv > div { + grid-template-columns: minmax(0, 1fr); + gap: 2px; + } } diff --git a/src/Flypaper.Web/wwwroot/settings.js b/src/Flypaper.Web/wwwroot/settings.js index 39774ae..6679650 100644 --- a/src/Flypaper.Web/wwwroot/settings.js +++ b/src/Flypaper.Web/wwwroot/settings.js @@ -1,3 +1,47 @@ +(() => { + const links = new Map([...document.querySelectorAll(".settings-nav a")].map(link => [link.hash.slice(1), link])); + if (links.size === 0) { + return; + } + + const lastId = [...links.keys()].at(-1); + const atBottom = () => window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 4; + const activate = id => { + links.forEach(link => link.classList.toggle("active", link === links.get(id))); + }; + + const observer = new IntersectionObserver(entries => { + if (atBottom()) { + activate(lastId); + return; + } + + const visible = entries.find(entry => entry.isIntersecting); + if (visible) { + activate(visible.target.id); + } + }, { rootMargin: "-20% 0px -70% 0px" }); + + links.forEach((link, id) => { + const section = document.getElementById(id); + if (section) { + observer.observe(section); + } + + link.addEventListener("click", () => activate(id)); + }); + + window.addEventListener("scroll", () => { + if (atBottom()) { + activate(lastId); + } + }, { passive: true }); + + if (location.hash && links.has(location.hash.slice(1))) { + activate(location.hash.slice(1)); + } +})(); + (() => { const value = id => Number.parseInt(document.getElementById(id)?.value ?? "", 10); const output = document.getElementById("drip-bandwidth");