Reset all app settings, dashboard starts empty

The reset disconnects all DSPs first and sends them nothing, asks for two random
letters (and the PIN on the web), keeps a copy of the old config and reloads
a fresh app. Refused during an audio test or mute all.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
GivouandClaude Opus 5.5 committed 2026-11-02 21:14:08 +01:00
1 parent 6d53069380
commit 29a89af562
8 files changed
+117 -7

No files matched your search

+32 -1
View File
@@ -2220,6 +2220,34 @@ function deviceForm(d) {
}
// App settings backup: devices, amplifiers/limiter data, PIN, remote access (not the DSP presets)
// a fresh app: what this browser remembers goes as well
function appWasReset() {
try { Object.keys(localStorage).filter(k => k.startsWith("dsp.")).forEach(k => localStorage.removeItem(k)); sessionStorage.clear(); } catch { /* private mode */ }
location.replace(S.isApp ? "/?start=app&lang=en" : "/");
}
async function resetDialog() {
const letters = "ABCDEFGHJKMNPQRSTUVWXYZ"; // no I, L and O: easy to mistake
const code = [0, 1].map(() => letters[Math.floor(Math.random() * letters.length)]).join("");
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)),
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(); }
catch (e) { toast(t("Error: ") + trMsg(e.message)); }
}
function backupCard() {
const exportCfg = async () => {
try { if (await saveFile(`DSP-Control-${t("Settings")}_${today()}.json`, await api("GET", "/api/backup"))) toast(t("Settings backed up")); }
@@ -2248,7 +2276,8 @@ function backupCard() {
return h("div", { class: "card" }, h("h3", {}, t("App settings")),
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("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…"))));
}
// Desktop app only: let phones/tablets on the LAN use this PC as server (they need the PIN)
@@ -2727,6 +2756,8 @@ function connectEvents() {
sfOnRemote(ev.data); break;
case "dashboard":
dashRemote(ev.data); break;
case "reset":
appWasReset(); break;
case "djbrake":
S.djbrake = ev.enabled; S.djIgnore = ev.ignore; S.djHint = ev.hint; S.djHintEn = ev.hint_en; S.djMargin = ev.margin; if (S.settings && !S.busy) render(); break;
case "logo":