diff --git a/docs/help.md b/docs/help.md index 6485f7b..88719bd 100644 --- a/docs/help.md +++ b/docs/help.md @@ -10,16 +10,16 @@ Figures below are **schematic** (layout and ideas), not pixel-perfect screenshot ## Run mode and Edit mode -The header has a mode toggle (desktop and mobile menu). The **label on the button is the mode you switch to**. +**Edit mode** is in the header and **Run mode** is in the **Menu** (on narrow screens, both are in the Menu). The **label on the button is the mode you switch to**. -![Schematic: zone buttons on the left; management buttons and the mode toggle on the right.](images/help/header-toolbar.svg) +![Schematic: zone buttons on the left; Profiles, Help and Menu on the right.](images/help/header-toolbar.svg) | Mode | Purpose | |------|--------| -| **Run mode** | Day-to-day control: choose a zone, tap presets, apply profiles. Management buttons are hidden. | -| **Edit mode** | Full setup: devices, groups, zones, presets, sequences, outputs, patterns, colour palette and settings, plus per-tile **Edit** on the strip. | +| **Run mode** | Day-to-day control: choose a zone, tap presets, apply profiles. The setup actions are hidden. | +| **Edit mode** | Full setup from the **Menu**: devices, groups, outputs, sequences, zones, presets, patterns, colour palette, audio and settings, plus per-tile **Edit** on the strip. | -On narrow screens, **Menu** reaches the same actions as the desktop header. +On narrow screens, **Menu** also holds the header actions, so it is there in Run mode too. --- @@ -64,14 +64,14 @@ The preset editor: ## Devices and groups -- **Devices** (Edit mode) lists the LED drivers by MAC. Drivers appear by themselves when they boot or answer a ping; you can also add them by hand. +- **Devices** (Edit mode) lists the LED drivers by name; **Edit** shows a driver's MAC. Drivers appear by themselves when they boot or answer a ping; you can also add them by hand. - **Ping drivers** checks which drivers answer (green dot with the round-trip time) and adds new ones. - **Identify** blinks a driver red for two seconds. - **Update groups** sends every driver its group membership. - - **Edit** a device for its name, brightness and driver settings (LED count, colour order, power-on pattern). + - **Edit** a device for its name, brightness, driver settings (LED count, colour order, power-on pattern) and the groups it is in. - **Groups** (Edit mode): put drivers in a group, set the group's brightness and driver defaults once, then attach the group to zones and sequence lanes. - Groups are shared by every profile unless you tick **this profile only**. - - **Identify devices in group** blinks all members together. + - **Identify** on a device, in the group or in the list to add from, blinks just that driver; **Identify devices in group** blinks all members together. --- @@ -88,7 +88,7 @@ The preset editor: ## Audio - The controller listens through its microphone and detects the tempo and the bar. -- While **Audio** is started, the microphone's beats time sequences and go to the drivers, so manual presets step on the music. +- **Audio** is in the Menu in Edit mode. While it is started, the microphone's beats time sequences and go to the drivers, so manual presets step on the music. - While it is stopped, a clock at the **simulated BPM** does both instead. - **Reset detector** forgets a stuck tempo. The **/audio** page has a full readout, a tap for beat 1 and a live listen. diff --git a/docs/images/help/header-toolbar.svg b/docs/images/help/header-toolbar.svg index c727a74..4d88954 100644 --- a/docs/images/help/header-toolbar.svg +++ b/docs/images/help/header-toolbar.svg @@ -13,12 +13,8 @@ Profiles - Tabs - - Presets - - Patterns - - Run mode - Active tab highlighted. Mode button shows the mode you switch to next. + Help + + Menu + Active tab highlighted. Run mode is in the Menu. diff --git a/web/static/devices.js b/web/static/devices.js index 3caaeaf..d1b6146 100644 --- a/web/static/devices.js +++ b/web/static/devices.js @@ -463,6 +463,32 @@ async function createDeviceFromModal() { } } +function createDeviceIdentifyButton(devId) { + const identifyBtn = document.createElement('button'); + identifyBtn.className = 'btn btn-primary btn-small'; + identifyBtn.type = 'button'; + identifyBtn.textContent = 'Identify'; + identifyBtn.title = 'Red blink at 10 Hz (~50% brightness) for 2 s, then off (not saved as a preset)'; + identifyBtn.addEventListener('click', async () => { + try { + const res = await fetch(`/devices/${encodeURIComponent(devId)}/identify`, { + method: 'POST', + credentials: 'same-origin', + headers: { Accept: 'application/json' }, + }); + const data = await res.json().catch(() => ({})); + if (!res.ok) { + alert(data.error || 'Identify failed'); + return; + } + } catch (err) { + console.error(err); + alert('Identify failed'); + } + }); + return identifyBtn; +} + function renderDevicesList(devices) { const container = document.getElementById('devices-list-modal'); if (!container) return; @@ -477,10 +503,8 @@ function renderDevicesList(devices) { } ids.forEach((devId) => { const dev = devices[devId]; - const t = (dev && dev.type) || 'led'; const tr = (dev && dev.transport) || 'espnow'; const addrRaw = (dev && dev.address) != null ? String(dev.address).trim() : ''; - const addrDisplay = addrRaw || '—'; const row = document.createElement('div'); row.className = 'profiles-row'; @@ -514,43 +538,12 @@ function renderDevicesList(devices) { label.style.flex = '1'; label.style.minWidth = '100px'; - const macEl = document.createElement('code'); - macEl.className = 'device-row-mac'; - macEl.textContent = devId; - macEl.title = 'MAC (registry id)'; - - const meta = document.createElement('span'); - meta.className = 'muted-text'; - meta.style.fontSize = '0.85em'; - meta.textContent = `${t} · ${tr} · ${addrDisplay}`; - const editBtn = document.createElement('button'); editBtn.className = 'btn btn-secondary btn-small'; editBtn.textContent = 'Edit'; editBtn.addEventListener('click', () => openEditDeviceModal(devId, dev)); - const identifyBtn = document.createElement('button'); - identifyBtn.className = 'btn btn-primary btn-small'; - identifyBtn.type = 'button'; - identifyBtn.textContent = 'Identify'; - identifyBtn.title = 'Red blink at 10 Hz (~50% brightness) for 2 s, then off (not saved as a preset)'; - identifyBtn.addEventListener('click', async () => { - try { - const res = await fetch(`/devices/${encodeURIComponent(devId)}/identify`, { - method: 'POST', - credentials: 'same-origin', - headers: { Accept: 'application/json' }, - }); - const data = await res.json().catch(() => ({})); - if (!res.ok) { - alert(data.error || 'Identify failed'); - return; - } - } catch (err) { - console.error(err); - alert('Identify failed'); - } - }); + const identifyBtn = createDeviceIdentifyButton(devId); const deleteBtn = document.createElement('button'); deleteBtn.className = 'btn btn-secondary btn-small'; @@ -572,8 +565,6 @@ function renderDevicesList(devices) { row.appendChild(dot); row.appendChild(label); - row.appendChild(macEl); - row.appendChild(meta); row.appendChild(editBtn); row.appendChild(identifyBtn); row.appendChild(deleteBtn); @@ -661,9 +652,78 @@ function openEditDeviceModal(devId, dev) { obr.value = String(bv); if (obv) obv.textContent = String(bv); } + void renderEditDeviceGroups(devId); modal.classList.add('active'); } +/** One checkbox per group in the edit modal, ticked when the group lists this device. */ +async function renderEditDeviceGroups(devId) { + const listEl = document.getElementById('edit-device-groups'); + if (!listEl) return; + listEl.innerHTML = ''; + const groups = await fetchGroupsMap(); + const idInput = document.getElementById('edit-device-id'); + if (!idInput || idInput.value !== devId) return; + listEl.innerHTML = ''; + const entries = Object.entries(groups).sort(([a, ga], [b, gb]) => + String((ga && ga.name) || a).localeCompare(String((gb && gb.name) || b)), + ); + if (!entries.length) { + const empty = document.createElement('span'); + empty.className = 'muted-text'; + empty.textContent = 'No groups yet. Add one under Groups.'; + listEl.appendChild(empty); + return; + } + entries.forEach(([gid, g]) => { + const lbl = document.createElement('label'); + lbl.style.cssText = + 'display:flex;align-items:center;justify-content:flex-start;gap:0.5rem;margin:0.25rem 0;font-weight:normal;'; + const cb = document.createElement('input'); + cb.type = 'checkbox'; + cb.style.cssText = 'width:auto;flex:none;margin:0;'; + cb.value = gid; + cb.checked = Array.isArray(g && g.devices) && g.devices.includes(devId); + const name = document.createElement('span'); + name.textContent = (g && g.name) || gid; + lbl.appendChild(cb); + lbl.appendChild(name); + listEl.appendChild(lbl); + }); +} + +/** Add the device to the ticked groups and take it out of the rest; only changed groups are sent. */ +async function saveEditDeviceGroups(devId) { + const boxes = document.querySelectorAll('#edit-device-groups input[type="checkbox"]'); + if (!boxes.length) return true; + // Fresh copies, so a member added elsewhere since the modal opened is kept. + const groups = await fetchGroupsMap(); + try { + for (const cb of boxes) { + const g = groups[cb.value]; + if (!g) throw new Error(`Group ${cb.value} not found`); + const devices = Array.isArray(g.devices) ? g.devices : []; + if (devices.includes(devId) === cb.checked) continue; + const res = await fetch(`/groups/${encodeURIComponent(cb.value)}`, { + method: 'PUT', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify({ + devices: cb.checked ? [...devices, devId] : devices.filter((mac) => mac !== devId), + }), + }); + if (!res.ok) { + const data = await res.json().catch(() => ({})); + throw new Error(data.error || `Group ${cb.value} not saved`); + } + } + return true; + } catch (e) { + console.error('saveEditDeviceGroups:', e); + alert(e.message || 'Failed to update groups'); + return false; + } +} + async function updateDevice(devId, payload) { try { const res = await fetch(`/devices/${encodeURIComponent(devId)}`, { @@ -829,6 +889,8 @@ document.addEventListener('DOMContentLoaded', () => { if (!devId) return; const ok = await updateDevice(devId, payload); if (!ok) return; + // Before the brightness push: a driver's brightness includes its groups' factors. + if (!(await saveEditDeviceGroups(devId))) return; try { const brRes = await fetch(`/devices/${encodeURIComponent(devId)}/brightness`, { method: 'POST', diff --git a/web/static/groups.js b/web/static/groups.js index a2ab3a1..6ea8a68 100644 --- a/web/static/groups.js +++ b/web/static/groups.js @@ -63,11 +63,6 @@ function renderGroupDevicesEditor(containerEl, macRows, devicesMap) { const strong = document.createElement('strong'); strong.textContent = row.label || row.mac || '—'; label.appendChild(strong); - label.appendChild(document.createTextNode(' ')); - const sub = document.createElement('span'); - sub.className = 'muted-text'; - sub.textContent = row.mac || ''; - label.appendChild(sub); const rm = document.createElement('button'); rm.type = 'button'; @@ -78,6 +73,7 @@ function renderGroupDevicesEditor(containerEl, macRows, devicesMap) { renderGroupDevicesEditor(containerEl, macRows, devicesMap); }); div.appendChild(label); + if (row.mac) div.appendChild(createDeviceIdentifyButton(row.mac)); div.appendChild(rm); listEl.appendChild(div); }); @@ -92,7 +88,7 @@ function renderGroupDevicesEditor(containerEl, macRows, devicesMap) { excludeIds: macsInRows, labelFor: (mac, d) => { const labelName = d && d.name ? String(d.name).trim() : ''; - return labelName ? `${labelName} — ${mac}` : mac; + return labelName || mac; }, searchTextFor: (mac, d) => { const labelName = d && d.name ? String(d.name).trim() : ''; @@ -104,6 +100,7 @@ function renderGroupDevicesEditor(containerEl, macRows, devicesMap) { macRows.push({ mac, label: n }); renderGroupDevicesEditor(containerEl, macRows, devicesMap); }, + actionFor: (mac) => createDeviceIdentifyButton(mac), placeholder: 'Search devices to add…', emptyMessage: 'No devices match your search.', noItemsMessage: 'All devices are already in this group.', diff --git a/web/static/help.js b/web/static/help.js index da7cf9d..0493825 100644 --- a/web/static/help.js +++ b/web/static/help.js @@ -43,7 +43,7 @@ document.addEventListener('DOMContentLoaded', () => { }); } - // Mobile main menu: forward clicks to existing header buttons + // Main menu: forward clicks to existing header buttons if (mainMenuBtn && mainMenuDropdown) { mainMenuBtn.addEventListener('click', () => { mainMenuDropdown.classList.toggle('open'); diff --git a/web/static/style.css b/web/static/style.css index 4e2a903..6ecf21a 100644 --- a/web/static/style.css +++ b/web/static/style.css @@ -31,12 +31,6 @@ body { align-items: end; } -.device-row-mac { - font-size: 0.82em; - color: #b0b0b0; - letter-spacing: 0.02em; -} - .device-form-actions { display: flex; align-items: flex-end; @@ -68,7 +62,7 @@ body { height: 100vh; } -/* One header row: zone tabs, the BPM readout, then the buttons (or, on narrow screens, the Menu) */ +/* One header row: zone tabs, the BPM readout, the buttons, then the Menu (on narrow screens, just the Menu) */ header { background-color: #1a1a1a; padding: 0.75rem 1rem; @@ -131,6 +125,23 @@ header h1 { background-color: #333; } +/* Wide screens: the Menu holds the Edit mode actions and Run mode, the header keeps the rest */ +@media (min-width: 1001px) { + .header-actions .edit-mode-only, + body.preset-ui-edit #ui-mode-toggle, + #main-menu-dropdown > :not(.edit-mode-only):not(.ui-mode-toggle) { + display: none; + } + + .header-menu-mobile { + display: block; + } + + body.preset-ui-run .header-menu-mobile { + display: none; + } +} + .menu-brightness-control { padding: 0.45rem 0.75rem 0.55rem; border-bottom: 1px solid #333; @@ -1875,6 +1886,25 @@ html.simulated-bpm-mode .seq-switch-toggle-wrap { outline: none; } +.zone-device-add-row { + display: flex; + align-items: center; + gap: 0.5rem; + padding-right: 0.5rem; + border-bottom: 1px solid #4a4a4a; +} + +.zone-device-add-row:last-child { + border-bottom: none; +} + +.zone-device-add-row .zone-device-add-result { + flex: 1; + width: auto; + min-width: 0; + border-bottom: none; +} + .zone-devices-add { margin-top: 0; flex-wrap: wrap; diff --git a/web/static/zone-devices-panel.js b/web/static/zone-devices-panel.js index 8eacfd5..0f346ce 100644 --- a/web/static/zone-devices-panel.js +++ b/web/static/zone-devices-panel.js @@ -31,6 +31,7 @@ function createSearchableAddPicker({ labelFor, searchTextFor, onPick, + actionFor, placeholder = 'Search…', emptyMessage = 'No matches.', noItemsMessage = 'Nothing to add.', @@ -93,7 +94,16 @@ function createSearchableAddPicker({ btn.setAttribute('role', 'option'); btn.textContent = labelFor(id, item); btn.addEventListener('click', () => pickEntry(id, item)); - results.appendChild(btn); + if (!actionFor) { + results.appendChild(btn); + return; + } + const row = document.createElement('div'); + row.className = 'zone-device-add-row'; + row.setAttribute('role', 'none'); + row.appendChild(btn); + row.appendChild(actionFor(id, item)); + results.appendChild(row); }); }; diff --git a/web/templates/index.html b/web/templates/index.html index ef1d7a9..0983b63 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -38,13 +38,13 @@ - + - - + + @@ -67,13 +67,13 @@ - + - - + + @@ -319,6 +319,8 @@ 255 + +
@@ -632,11 +634,8 @@ - - - - - + +
@@ -648,12 +647,12 @@
-

Zone buttons on the left of the header; brightness and the other buttons on the right (Menu on narrow screens).

+

Zone buttons on the left of the header; brightness, Profiles and Help on the right. In Edit mode, Menu holds the setup actions and Run mode.

Run mode and Edit mode

    -
  • Run mode: day-to-day control — choose a zone, tap presets, apply profiles. Management buttons are hidden.
  • -
  • Edit mode: full setup — zones, presets, sequences, patterns, colour palette, and per-tile Edit on the strip.
  • -
  • Switch modes: use the mode button in the header or mobile menu. The label shows the mode you will switch to.
  • +
  • Run mode: day-to-day control — choose a zone, tap presets, apply profiles. The setup actions are hidden.
  • +
  • Edit mode: full setup from the Menu — devices, groups, outputs, sequences, zones, presets, patterns, colour palette, audio and settings — plus per-tile Edit on the strip.
  • +
  • Switch modes: Edit mode is in the header and Run mode is in the Menu (on narrow screens, both are in the Menu). The label shows the mode you will switch to.
-

On narrow screens, Menu reaches the same actions as the desktop header.

+

On narrow screens, Menu also holds the header actions, so it is there in Run mode too.

@@ -838,7 +833,7 @@
  • Assign drivers to a group, set Wi‑Fi defaults once per group, then attach groups to a zone.
  • Standalone presets use the zone’s device groups. Sequence lanes each target their own group.
  • New groups are shared across profiles by default; tick this profile only to hide a group elsewhere.
  • -
  • In the group editor, search and pick devices from the list to add members; Identify devices in group blinks them together.
  • +
  • In the group editor, search and pick devices from the list to add members; Identify on a device, in the group or in the list, blinks just that one and Identify devices in group blinks them all together.
  • @@ -1051,7 +1046,7 @@
      -
    • Audio: beat detection from the controller's microphone. While it is running, its beats time sequences and go to the drivers; while it is stopped, a clock at the simulated BPM does.
    • +
    • Audio (Edit mode): beat detection from the controller's microphone. While it is running, its beats time sequences and go to the drivers; while it is stopped, a clock at the simulated BPM does.
    • BPM and beat indicators appear in the header and Audio modal while detection is running.
    • The level meter shows the microphone's live input. /audio has a full readout, a tap for beat 1 and a live listen.
    • Start / Stop detection; Reset detector clears stuck BPM tracking.