From 28624caeadef51ea56a7a314e8d2fa93a9c7eea3 Mon Sep 17 00:00:00 2001 From: Givou Date: Mon, 2 Nov 2026 18:51:28 +0100 Subject: [PATCH] DJ Brake settings move next to remote access In the apps the page is only reachable through remote access, so it can only be switched on while that runs. All its addresses are listed there. Co-Authored-By: Claude Opus 5.5 --- CLAUDE.md | 1 + static/app.js | 24 ++++++++++++------------ static/i18n.js | 2 +- static/style.css | 2 ++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index aaf4761..42bdb41 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -60,6 +60,7 @@ pi_writer.py → pi_image.py (cloud-init SD card, installs server.py as a system * **DJ Brake** (`static/djbrake.html`, `App.dj_stream`) – the only page without a login, off by default. It may only ever learn `{on, ready, room, hint}` from `/djbrake/state`: never add device data or controls there. `dj_margin` moves its limit down on purpose, so the page must never reveal it. On its own on purpose, without `app.js`. + 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. * **Network search** – `App.scan_network` probes the local /24 networks on TCP 9761 (handshake + device info), skipping DSPs this app is connected to. * **Copy settings / mute all** – `App.copy_settings` (`POST /api/copy`, groups level/filters/eq/dynamics/routing) and diff --git a/static/app.js b/static/app.js index 9ad3132..241aa74 100644 --- a/static/app.js +++ b/static/app.js @@ -2370,24 +2370,24 @@ function logoCard() { function djBrakeCard() { // the app's own address only works on this computer: other devices come through remote access const r = S.remote || {}; - const base = S.isApp ? (r.enabled && r.urls && r.urls[0]) || "" : location.origin; - const url = base ? `${base}/djbrake` : ""; - const box = h("input", { type: "checkbox", checked: !!S.djbrake, onchange: async () => { + const reachable = !S.isApp || !!r.running; + const urls = (S.isApp ? r.urls || [] : [location.origin]).map(u => `${u}/djbrake`); + const box = h("input", { type: "checkbox", checked: !!S.djbrake, disabled: !reachable, onchange: async () => { try { S.djbrake = (await api("PUT", "/api/djbrake", { enabled: box.checked })).enabled; render(); } catch (e) { box.checked = !!S.djbrake; toast(t("Error: ") + trMsg(e.message)); } } }); return h("div", { class: "card" }, h("h3", {}, "DJ Brake"), h("p", { class: "info" }, t("A page for a tablet at the DJ booth: a big red light comes on when a limiter is working, so turning up more won't help.")), h("label", { class: "chk" }, box, t("Share the page /djbrake")), - S.djbrake && url ? h("div", { class: "row djurl" }, h("code", {}, url), + !reachable ? h("p", { class: "info djwarn" }, t("Only reachable while remote access is on.")) : null, + S.djbrake && reachable ? urls.map(url => h("div", { class: "row djurl" }, h("code", {}, url), h("button", { class: "small", "data-view-ok": "", onclick: async () => { try { await navigator.clipboard.writeText(url); toast(t("Address copied")); } catch { toast(url); } - } }, t("Copy"))) : null, - S.djbrake && !url ? h("p", { class: "info djwarn" }, t("Switch on remote access below so other devices can reach it.")) : null, - S.djbrake ? djLimiters() : null, - S.djbrake ? djMarginOption() : null, - S.djbrake ? djHintOptions() : null, - S.djbrake ? h("p", { class: "info" }, t("Anyone in your network can open it without a PIN. It shows only the light and the distance to the limiter and changes nothing.")) : null); + } }, t("Copy")))) : null, + S.djbrake && reachable ? djLimiters() : null, + S.djbrake && reachable ? djMarginOption() : null, + S.djbrake && reachable ? djHintOptions() : null, + S.djbrake && reachable ? h("p", { class: "info" }, t("Anyone in your network can open it without a PIN. It shows only the light and the distance to the limiter and changes nothing.")) : null); } function djMarginOption() { @@ -2488,11 +2488,11 @@ function scanCard() { function viewSettings() { const sections = [ - ["general", t("General"), t("Language, demo mode and your logo."), "", [langCard(), demoCard(), logoCard(), djBrakeCard()]], + ["general", t("General"), t("Language, demo mode and your logo."), "", [langCard(), demoCard(), logoCard()]], ["devices", t("Devices"), t("Several DSPs can be connected at the same time – pick one at the top. A DSP accepts only one connection: close the Thomann editor first."), "wide", [...S.order.filter(id => !S.devices[id].demo).map(id => deviceForm(S.devices[id])), scanCard(), addDeviceCard()]], ["access", S.isApp ? t("Remote access") : t("Security"), S.isApp ? t("Let phones and tablets in your network control this computer – they log in with the PIN.") : t("Who may use this web interface."), - "wide", [S.isApp ? remoteCard() : null, pinCard()]], + "wide", [S.isApp ? remoteCard() : null, djBrakeCard(), pinCard()]], ["backup", t("Backup"), t("Save and restore the settings of this app."), "wide", [backupCard()]], ]; const nav = h("nav", { class: "setnav", "aria-label": t("Settings") }, sections.map(([id, title]) => diff --git a/static/i18n.js b/static/i18n.js index e7c4846..f619ddf 100644 --- a/static/i18n.js +++ b/static/i18n.js @@ -677,7 +677,7 @@ const DE = { "A page for a tablet at the DJ booth: a big red light comes on when a limiter is working, so turning up more won't help.": "Eine Seite für ein Tablet am DJ-Pult: Ein großes rotes Licht geht an, wenn ein Limiter arbeitet, mehr Gas also nichts mehr bringt.", "Share the page /djbrake": "Seite /djbrake freigeben", "Address copied": "Adresse kopiert", - "Switch on remote access below so other devices can reach it.": "Schalte unten den Fernzugriff ein, damit andere Geräte sie erreichen.", + "Only reachable while remote access is on.": "Nur erreichbar, solange der Fernzugriff an ist.", "Anyone in your network can open it without a PIN. It shows only the light and the distance to the limiter and changes nothing.": "Jeder in deinem Netzwerk kann sie ohne PIN öffnen. Sie zeigt nur das Licht und den Abstand zum Limiter und ändert nichts.", "Limiters that count": "Diese Limiter zählen", "Connect a DSP to choose.": "Verbinde einen DSP, um auszuwählen.", diff --git a/static/style.css b/static/style.css index 6442672..7bb5bcf 100644 --- a/static/style.css +++ b/static/style.css @@ -994,3 +994,5 @@ body.dashonly .dlink { cursor: default; } .djlim label.chk { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; } .djlim label.chk input { flex: none; margin: 3px 0 0; } .djlim input[type=range] { width: 100%; margin: 8px 0 4px; } +.row.djurl button.small { flex: 0 0 auto; width: auto; padding-inline: 14px; } +.row.djurl code { flex: 1 1 auto; }