From bbe8a73775004f51155ce9eaa83c3c208c003a30 Mon Sep 17 00:00:00 2001 From: Givou Date: Mon, 2 Nov 2026 21:20:40 +0100 Subject: [PATCH] Reset: nicer dialog, only in the desktop apps Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 2 +- README.md | 2 +- server.py | 4 ++-- static/app.js | 23 ++++++++++++++--------- static/i18n.js | 14 ++++++++++++-- static/style.css | 35 ++++++++++++++++++++++++++++++----- 6 files changed, 60 insertions(+), 20 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index f0da26c..b237fe4 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -64,7 +64,7 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system Its settings sit in the access section; in the apps it needs remote access, since the app itself only listens on 127.0.0.1. * **Preset looks** – `Device.looks` keeps `colors`/`linknames` per preset name; `sync_look` swaps them whenever a read of the DSP shows another name (the DSP has no preset IDs: same name = same look). Preset files carry them as `look`. -* **Reset** (`App.reset_config`, `POST /api/reset`) – stops all devices before anything else and sends them nothing, then defaults from +* **Reset** (`App.reset_config`, `POST /api/reset`, app window only, never remote) – stops all devices before anything else and sends them nothing, then defaults from a fresh `App`. Refused during an audio test or mute all, because the DSP would stay changed. Keeps `config.before-reset.json`. * **Network search** – `App.scan_network` probes the local /24 networks on TCP 9761 (handshake + device info), skipping DSPs this app is connected to. diff --git a/README.md b/README.md index 70cb144..9cfc080 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ Control both devices at the same time from your phone, tablet or computer – ov * **Custom logo** – your own logo top left and as the browser icon (settings → Logo; PNG/JPG/WebP/SVG, ideally square, ≥ 64×64 px) * **Fits every screen** – menu in the top bar on wide screens, a sidebar when the window gets narrow, a bottom bar on phones * **Mute all** – one button mutes every channel of every connected DSP; releasing it unmutes only what was open before -* **Reset app settings** – back to a fresh app (⚙ → Backup); DSPs are disconnected first and nothing on them changes +* **Reset app settings** – desktop apps only: back to a fresh app (⚙ → Backup); DSPs are disconnected first and nothing on them changes * **Settings backup** – devices, amplifier data, SoundField plan, PIN and remote access in one file * **Device lock** – DSPs locked with their 4-character code (e.g. `A1BA`) are detected on connect and the app asks for the code; optionally it remembers the code and unlocks automatically. A new code can be set under ⚙ diff --git a/server.py b/server.py index 6088396..7d1a28c 100644 --- a/server.py +++ b/server.py @@ -1323,8 +1323,8 @@ class App: await self.respond_json(writer, *await self.change_pin(session, data)) return if path == "/api/reset" and method == "POST": - if not is_app and not self.check_pin(str(data.get("pin", ""))): - await self.respond_json(writer, 400, {"error": "Wrong PIN"}) + if not is_app: + await self.respond_json(writer, 403, {"error": "desktop app only"}) else: try: await self.reset_config() diff --git a/static/app.js b/static/app.js index a6b00f8..767d2a5 100644 --- a/static/app.js +++ b/static/app.js @@ -2232,19 +2232,24 @@ async function resetDialog() { const matches = () => input.value.trim().toUpperCase() === code; const input = h("input", { type: "text", class: "code resetcode", maxlength: 2, autocomplete: "off", autocapitalize: "characters", spellcheck: "false", "aria-label": t("Letters"), oninput: () => { document.querySelector("#modal .dlg-actions button:last-child").disabled = !matches(); } }); - const pin = h("input", { type: "password", inputmode: "numeric", maxlength: 4, autocomplete: "off", placeholder: "••••" }); const stuck = S.order.map(id => S.devices[id]).filter(d => !d.demo && d.test_saved && d.status !== "online").map(d => d.name); const open = modal({ title: t("Reset all app settings?"), - body: h("div", { class: "form" }, - h("p", { class: "dlg-text" }, t("All DSPs are disconnected at once, then this app starts fresh: DSP list, colours and group names, amplifiers, SoundField plan, dashboard, DJ Brake, remote access and language are gone, and the PIN is 1234 again.")), - h("p", { class: "dlg-text" }, h("b", {}, t("Nothing changes on the DSPs: their settings and presets stay as they are."))), - stuck.length ? h("p", { class: "dlg-text resetwarn" }, t("{names} still has the lowered levels of an interrupted audio test. The app can no longer undo that after the reset.", { names: stuck.join(", ") })) : null, - S.isApp ? null : h("label", {}, t("Current PIN"), pin), - h("div", { class: "resetcheck" }, h("span", {}, t("To confirm, type these letters:")), h("b", { class: "resetletters", "aria-label": code }, code), input)), + body: h("div", { class: "resetbody" }, + h("p", { class: "resetlead" }, t("All DSPs are disconnected first, then the app starts fresh.")), + h("div", { class: "resetlists" }, + h("div", { class: "resetlist gone" }, h("b", {}, t("Removed from the app")), h("ul", {}, + [t("DSP list"), t("Colours and group names"), t("Amplifiers and SoundField plan"), t("Dashboard and DJ Brake"), t("Remote access and language"), t("PIN, back to 1234")].map(x => h("li", {}, x)))), + h("div", { class: "resetlist stays" }, h("b", {}, t("Stays as it is")), h("ul", {}, + [t("All settings in the DSPs"), t("Presets in the DSPs"), t("A copy of the old app settings")].map(x => h("li", {}, x))))), + stuck.length ? h("p", { class: "resetwarn" }, t("{names} still has the lowered levels of an interrupted audio test. The app can no longer undo that after the reset.", { names: stuck.join(", ") })) : null, + h("div", { class: "resetcheck" }, h("span", {}, t("To confirm, type these letters:")), + h("div", { class: "resetrow" }, + h("div", { class: "resetletters", role: "img", "aria-label": code }, [...code].map(c => h("i", {}, c))), + h("span", { class: "resetarrow", "aria-hidden": "true" }, "→"), input))), actions: [{ label: t("Cancel") }, { label: t("Reset"), primary: true, cls: "danger-on", value: () => matches() ? true : undefined }] }); document.querySelector("#modal .dlg-actions button:last-child").disabled = true; if (!await open) return; - try { await api("POST", "/api/reset", { pin: pin.value }); appWasReset(); } + try { await api("POST", "/api/reset"); appWasReset(); } catch (e) { toast(t("Error: ") + trMsg(e.message)); } } @@ -2277,7 +2282,7 @@ function backupCard() { h("p", { class: "info" }, t("Saves devices, amplifiers & limiter calculator, PIN and remote access to a file. ") + t("The settings inside the DSPs are saved per device via “File…” at the top.")), h("div", { class: "row" }, h("button", { onclick: exportCfg }, t("Back up…")), h("button", { onclick: restore }, t("Restore…")), - h("button", { class: "danger", onclick: resetDialog }, t("Reset all app settings…")))); + S.isApp ? h("button", { class: "danger", onclick: resetDialog }, t("Reset all app settings…")) : null)); } // Desktop app only: let phones/tablets on the LAN use this PC as server (they need the PIN) diff --git a/static/i18n.js b/static/i18n.js index 379675f..ead7f1a 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -709,14 +709,24 @@ const DE = { "Widget settings": "Widget-Einstellungen", "Reset all app settings…": "Alle App-Einstellungen zurücksetzen…", "Reset all app settings?": "Alle App-Einstellungen zurücksetzen?", - "All DSPs are disconnected at once, then this app starts fresh: DSP list, colours and group names, amplifiers, SoundField plan, dashboard, DJ Brake, remote access and language are gone, and the PIN is 1234 again.": "Alle DSPs werden sofort getrennt, dann startet die App frisch: DSP-Liste, Farben und Gruppennamen, Verstärker, SoundField-Plan, Dashboard, DJ Brake, Fernzugriff und Sprache sind weg, und die PIN ist wieder 1234.", - "Nothing changes on the DSPs: their settings and presets stay as they are.": "An den DSPs ändert sich nichts: Ihre Einstellungen und Presets bleiben, wie sie sind.", "{names} still has the lowered levels of an interrupted audio test. The app can no longer undo that after the reset.": "{names} hat noch die abgesenkten Pegel eines abgebrochenen Audiotests. Nach dem Zurücksetzen kann die App das nicht mehr rückgängig machen.", "To confirm, type these letters:": "Zum Bestätigen diese Buchstaben eingeben:", "Letters": "Buchstaben", "Nothing here yet – you can add modules on a computer.": "Noch nichts da – Module kannst du am Computer hinzufügen.", "End the audio test first: the DSP would stay at the lowered level": "Beende zuerst den Audiotest: Der DSP würde sonst auf dem abgesenkten Pegel bleiben", "Release mute all first: the DSPs would stay muted": "Hebe zuerst „Alle stumm“ auf: Die DSPs würden sonst stumm bleiben", + "All DSPs are disconnected first, then the app starts fresh.": "Zuerst werden alle DSPs getrennt, dann startet die App frisch.", + "Removed from the app": "Wird aus der App gelöscht", + "DSP list": "DSP-Liste", + "Colours and group names": "Farben und Gruppennamen", + "Amplifiers and SoundField plan": "Verstärker und SoundField-Plan", + "Dashboard and DJ Brake": "Dashboard und DJ Brake", + "Remote access and language": "Fernzugriff und Sprache", + "PIN, back to 1234": "PIN, zurück auf 1234", + "Stays as it is": "Bleibt, wie es ist", + "All settings in the DSPs": "Alle Einstellungen in den DSPs", + "Presets in the DSPs": "Presets in den DSPs", + "A copy of the old app settings": "Eine Kopie der alten App-Einstellungen", }; const DE_PATTERNS = [ diff --git a/static/style.css b/static/style.css index 8e4f82a..a704dcb 100644 --- a/static/style.css +++ b/static/style.css @@ -1045,8 +1045,33 @@ label.chk input { flex: none; width: 18px; height: 18px; margin: 1px 0 0; accent .docui { padding: 0 4px; } html { touch-action: pan-x pan-y; } .djlim > button.small { margin-top: 8px; } -.resetcheck { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 12px; } -.resetcheck > span { flex: 1 1 100%; color: var(--dim); } -.resetletters { padding: 6px 14px; border-radius: 8px; font: 700 22px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .25em; color: var(--text); background: var(--panel3); user-select: none; -webkit-user-select: none; } -input.resetcode { width: 4.5em; font-size: 20px; text-transform: uppercase; } -.resetwarn { color: var(--warn); } +.dialog:has(> .resetbody) { width: min(520px, 100%); padding: 22px; } +.dialog:has(> .resetbody) > h2 { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 19px; } +.dialog:has(> .resetbody) > h2::before { content: "!"; flex: none; display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; font-size: 19px; font-weight: 800; + color: #fca5a5; background: color-mix(in srgb, #ef4444 18%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, #ef4444 45%, transparent); } +.resetlead { margin: 0 0 14px; color: var(--dim); } +.resetlists { display: grid; grid-template-columns: 1.25fr 1fr; gap: 10px; } +.resetlist { padding: 12px 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--line); } +.resetlist > b { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 650; } +.resetlist ul { margin: 0; padding: 0; list-style: none; font-size: 13px; line-height: 1.35; color: var(--dim); } +.resetlist li { position: relative; margin-top: 6px; padding-left: 20px; } +.resetlist li::before { position: absolute; left: 0; top: 0; width: 14px; text-align: center; font-weight: 800; } +.resetlist.gone > b { color: #fca5a5; } +.resetlist.gone li::before { content: "×"; color: #f87171; } +.resetlist.stays { border-color: color-mix(in srgb, var(--ok, #22c55e) 35%, var(--line)); } +.resetlist.stays > b { color: #86efac; } +.resetlist.stays li { color: var(--text); } +.resetlist.stays li::before { content: "✓"; color: #4ade80; } +.resetwarn { margin: 12px 0 0; padding: 9px 12px; border-radius: 10px; font-size: 13px; color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, transparent); } +.resetcheck { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; } +.resetcheck > span { display: block; margin-bottom: 10px; font-size: 13px; color: var(--dim); } +.resetrow { display: flex; align-items: center; justify-content: center; gap: 12px; } +.resetletters { display: flex; gap: 6px; user-select: none; -webkit-user-select: none; } +.resetletters i { display: grid; place-items: center; width: 42px; height: 48px; border-radius: 10px; font: 700 23px ui-monospace, Menlo, Consolas, monospace; color: var(--text); background: var(--panel3); border: 1px solid var(--line2); } +.resetarrow { color: var(--dim); font-size: 18px; } +input.resetcode { width: 90px; height: 48px; padding: 0 0 0 .3em; border-radius: 10px; text-align: center; font: 700 23px ui-monospace, Menlo, Consolas, monospace; letter-spacing: .3em; text-transform: uppercase; } +.dialog:has(> .resetbody) > .dlg-actions { margin-top: 18px; } +.dialog:has(> .resetbody) > .dlg-actions button { flex: 1 1 0; } +.dialog:has(> .resetbody) > .dlg-actions button:disabled { color: var(--dim); background: var(--panel2); border-color: var(--line); opacity: 1; } +@media (max-width: 480px) { .resetlists { grid-template-columns: 1fr; } } +.dialog input.resetcode { flex: none; margin: 0; }