feat: sequences can step on time; searchable group pickers
- Sequences: advance_mode "time" makes each step last its `seconds` (0.1–3600) instead of beats; editor gets a "Steps last" selector. - UI: search box in the groups modal; searchable add pickers for zone groups and presets. - Preset "try" sends only to the current zone's groups, never broadcast. - led-driver: max_brightness ceiling from device config; follow a controller that restarted its beat counter. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
38162d4b89
commit
d664026ee5
10 files changed
+229
-92
No files matched your search
@@ -1,4 +1,4 @@
|
||||
// Client-side search filter for modal lists (devices, zones, presets).
|
||||
// Client-side search filter for modal lists (devices, groups, zones, presets).
|
||||
// Hides .profiles-row children whose text doesn't match; re-applies when the list re-renders.
|
||||
|
||||
function rowSearchText(row) {
|
||||
@@ -75,6 +75,7 @@ function initListSearch(inputId, listId, modalId) {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
initListSearch('devices-search', 'devices-list-modal', 'devices-modal');
|
||||
initListSearch('groups-search', 'groups-list-modal', 'groups-modal');
|
||||
initListSearch('zones-search', 'zones-list-modal', 'zones-modal');
|
||||
initListSearch('presets-search', 'presets-list', 'presets-modal');
|
||||
});
|
||||
+18
-1
@@ -1769,8 +1769,25 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
// Send current editor values to zone devices (if any); never persist on device.
|
||||
const presetId = currentEditId || payload.name;
|
||||
const deviceNames = await deviceNamesForPresetOnCurrentZone(presetId);
|
||||
// Only the current zone's groups; never broadcast to every driver.
|
||||
const section = document.querySelector('.presets-section[data-zone-id]');
|
||||
let groupIds = [];
|
||||
if (section && section.dataset.zoneId) {
|
||||
try {
|
||||
const zr = await fetch(`/zones/${section.dataset.zoneId}`, {
|
||||
headers: { Accept: 'application/json' },
|
||||
});
|
||||
if (zr.ok) groupIds = zoneGroupIdsFromTabData(await zr.json());
|
||||
} catch (_) {
|
||||
groupIds = [];
|
||||
}
|
||||
}
|
||||
if (!groupIds.length) {
|
||||
alert('The current zone has no groups to try this preset on.');
|
||||
return;
|
||||
}
|
||||
// Auto: load + immediate select. Manual: load only; first advance on the next audio beat.
|
||||
await sendPresetViaEspNow(presetId, payload, deviceNames, false, false, '2');
|
||||
await sendPresetViaEspNow(presetId, payload, deviceNames, false, false, '2', { groupIds });
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+48
-4
@@ -185,6 +185,7 @@ function normalizeSequenceLanes(doc) {
|
||||
.map((s) => ({
|
||||
preset_id: s.preset_id != null ? String(s.preset_id) : String(s.presetId || ''),
|
||||
beats: Math.max(1, parseInt(String(s.beats != null ? s.beats : 1), 10) || 1),
|
||||
seconds: Math.max(0.1, parseFloat(String(s.seconds != null ? s.seconds : 3)) || 3),
|
||||
group_ids: Array.isArray(s.group_ids)
|
||||
? s.group_ids.map((x) => String(x).trim()).filter(Boolean)
|
||||
: [],
|
||||
@@ -776,6 +777,26 @@ function renderSequenceStepRow(presetsMap, step) {
|
||||
beatsInp.style.width = '4rem';
|
||||
beatWrap.appendChild(bl);
|
||||
beatWrap.appendChild(beatsInp);
|
||||
beatWrap.classList.add('sequence-step-beats-wrap');
|
||||
|
||||
const secWrap = document.createElement('div');
|
||||
secWrap.className = 'sequence-step-seconds-wrap';
|
||||
secWrap.style.cssText = 'display:flex;align-items:center;gap:0.35rem;';
|
||||
const sl = document.createElement('label');
|
||||
sl.textContent = 'Seconds';
|
||||
const secInp = document.createElement('input');
|
||||
secInp.type = 'number';
|
||||
secInp.className = 'sequence-step-seconds';
|
||||
secInp.autocomplete = 'off';
|
||||
secInp.min = '0.1';
|
||||
secInp.max = '3600';
|
||||
secInp.step = '0.1';
|
||||
secInp.value = String(
|
||||
step && step.seconds != null ? Math.max(0.1, parseFloat(String(step.seconds)) || 3) : 3,
|
||||
);
|
||||
secInp.style.width = '5rem';
|
||||
secWrap.appendChild(sl);
|
||||
secWrap.appendChild(secInp);
|
||||
|
||||
const editPresetBtn = document.createElement('button');
|
||||
editPresetBtn.type = 'button';
|
||||
@@ -806,6 +827,7 @@ function renderSequenceStepRow(presetsMap, step) {
|
||||
top.appendChild(dragHandle);
|
||||
top.appendChild(presetWrap);
|
||||
top.appendChild(beatWrap);
|
||||
top.appendChild(secWrap);
|
||||
top.appendChild(editPresetBtn);
|
||||
row.appendChild(top);
|
||||
|
||||
@@ -839,7 +861,8 @@ function renderSequenceLane(laneIndex, laneSteps, laneGroupIds, presetsMap, grou
|
||||
addStep.addEventListener('click', () => {
|
||||
const stepsHost = wrap.querySelector('.sequence-lane-steps');
|
||||
if (stepsHost) {
|
||||
stepsHost.appendChild(renderSequenceStepRow(presetsMap, { preset_id: '', beats: 1 }));
|
||||
stepsHost.appendChild(renderSequenceStepRow(presetsMap, { preset_id: '', beats: 1, seconds: 3 }));
|
||||
applySequenceEditorMode();
|
||||
}
|
||||
});
|
||||
const rmLane = document.createElement('button');
|
||||
@@ -862,7 +885,7 @@ function renderSequenceLane(laneIndex, laneSteps, laneGroupIds, presetsMap, grou
|
||||
|
||||
const stepsHost = document.createElement('div');
|
||||
stepsHost.className = 'sequence-lane-steps';
|
||||
const steps = Array.isArray(laneSteps) && laneSteps.length ? laneSteps : [{ preset_id: '', beats: 1 }];
|
||||
const steps = Array.isArray(laneSteps) && laneSteps.length ? laneSteps : [{ preset_id: '', beats: 1, seconds: 3 }];
|
||||
steps.forEach((s) => {
|
||||
stepsHost.appendChild(renderSequenceStepRow(presetsMap, s));
|
||||
});
|
||||
@@ -883,6 +906,18 @@ function refreshSequenceEditorLaneTitles() {
|
||||
});
|
||||
}
|
||||
|
||||
/** Show the Beats or Seconds field on every step, to match the sequence's advance mode. */
|
||||
function applySequenceEditorMode() {
|
||||
const sel = document.getElementById('sequence-editor-mode');
|
||||
const timed = !!sel && sel.value === 'time';
|
||||
document.querySelectorAll('#sequence-editor-lanes .sequence-step-beats-wrap').forEach((e) => {
|
||||
e.style.display = timed ? 'none' : 'flex';
|
||||
});
|
||||
document.querySelectorAll('#sequence-editor-lanes .sequence-step-seconds-wrap').forEach((e) => {
|
||||
e.style.display = timed ? 'flex' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
function collectLanesFromEditor() {
|
||||
const host = document.getElementById('sequence-editor-lanes');
|
||||
const laneEls = host ? [...host.querySelectorAll('.sequence-lane')] : [];
|
||||
@@ -903,7 +938,9 @@ function collectLanesFromEditor() {
|
||||
const presetId = presetSel && presetSel.value ? String(presetSel.value) : '';
|
||||
if (!presetId) return;
|
||||
const beats = Math.max(1, parseInt(beatsInp && beatsInp.value ? beatsInp.value : '1', 10) || 1);
|
||||
steps.push({ preset_id: presetId, beats });
|
||||
const secInp = row.querySelector('.sequence-step-seconds');
|
||||
const seconds = Math.max(0.1, parseFloat(secInp && secInp.value ? secInp.value : '3') || 3);
|
||||
steps.push({ preset_id: presetId, beats, seconds });
|
||||
});
|
||||
lanes.push(steps);
|
||||
});
|
||||
@@ -961,6 +998,8 @@ async function openSequenceEditor(sequenceId, existing) {
|
||||
doc = {};
|
||||
}
|
||||
nameInput.value = doc.name || '';
|
||||
const modeSelOpen = document.getElementById('sequence-editor-mode');
|
||||
if (modeSelOpen) modeSelOpen.value = doc.advance_mode === 'time' ? 'time' : 'beats';
|
||||
|
||||
const lanes = normalizeSequenceLanes(doc);
|
||||
lanesHost.innerHTML = '';
|
||||
@@ -974,6 +1013,7 @@ async function openSequenceEditor(sequenceId, existing) {
|
||||
});
|
||||
}
|
||||
refreshSequenceEditorLaneTitles();
|
||||
applySequenceEditorMode();
|
||||
|
||||
const edDel = document.getElementById('sequence-editor-delete-btn');
|
||||
if (edDel) edDel.style.display = sequenceEditorId ? 'inline-block' : 'none';
|
||||
@@ -997,6 +1037,7 @@ function resolveZoneIdForPresetStripRefresh() {
|
||||
}
|
||||
|
||||
async function saveSequenceEditor() {
|
||||
const modeSel = document.getElementById('sequence-editor-mode');
|
||||
const nameInput = document.getElementById('sequence-editor-name');
|
||||
const { lanes, lanes_group_ids } = collectLanesFromEditor();
|
||||
const idxs = [];
|
||||
@@ -1014,7 +1055,7 @@ async function saveSequenceEditor() {
|
||||
lanes: nonEmpty,
|
||||
lanes_group_ids: nonEmptyLg,
|
||||
group_ids: nonEmptyLg[0] ? [...nonEmptyLg[0]] : [],
|
||||
advance_mode: 'beats',
|
||||
advance_mode: modeSel && modeSel.value === 'time' ? 'time' : 'beats',
|
||||
loop: true,
|
||||
steps: nonEmpty.length === 1 ? nonEmpty[0] : [],
|
||||
};
|
||||
@@ -1205,6 +1246,9 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const idx = host.querySelectorAll('.sequence-lane').length;
|
||||
host.appendChild(renderSequenceLane(idx, [], [], presetsMap, groupsMap));
|
||||
refreshSequenceEditorLaneTitles();
|
||||
applySequenceEditorMode();
|
||||
});
|
||||
}
|
||||
const edMode = document.getElementById('sequence-editor-mode');
|
||||
if (edMode) edMode.addEventListener('change', applySequenceEditorMode);
|
||||
});
|
||||
@@ -2561,3 +2561,25 @@ html.simulated-bpm-mode .seq-switch-toggle-wrap {
|
||||
margin-top: 0.75rem;
|
||||
color: #ff6b6b;
|
||||
}
|
||||
|
||||
/* Modal list search (list_search.js) */
|
||||
.list-search-input {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
margin: 0.5rem 0;
|
||||
padding: 0.5rem;
|
||||
background-color: #3a3a3a;
|
||||
border: 1px solid #4a4a4a;
|
||||
border-radius: 4px;
|
||||
color: white;
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.list-search-input:focus {
|
||||
outline: none;
|
||||
border-color: #6a5acd;
|
||||
}
|
||||
|
||||
.list-search-hidden {
|
||||
display: none !important;
|
||||
}
|
||||
+42
-49
@@ -457,29 +457,29 @@ function renderZoneGroupsEditor(containerEl, rows, groupsMap) {
|
||||
const idsInRows = new Set(rows.map((r) => String(r.id)));
|
||||
const addWrap = document.createElement("div");
|
||||
addWrap.className = "zone-devices-add profiles-actions";
|
||||
const sel = document.createElement("select");
|
||||
sel.className = "zone-device-add-select";
|
||||
sel.appendChild(new Option("Add group…", ""));
|
||||
entries.forEach(([gid, g]) => {
|
||||
if (idsInRows.has(gid)) return;
|
||||
const groupLabel = (gid, g) => {
|
||||
const gn = g && g.name ? String(g.name).trim() : "";
|
||||
const optLabel = gn ? `${gn} (${gid})` : `Group ${gid}`;
|
||||
sel.appendChild(new Option(optLabel, gid));
|
||||
});
|
||||
const addBtn = document.createElement("button");
|
||||
addBtn.type = "button";
|
||||
addBtn.className = "btn btn-primary btn-small";
|
||||
addBtn.textContent = "Add";
|
||||
addBtn.addEventListener("click", () => {
|
||||
const gid = sel.value;
|
||||
if (!gid || !groupsMap[gid]) return;
|
||||
const gn = groupsMap[gid].name ? String(groupsMap[gid].name).trim() : gid;
|
||||
rows.push({ id: gid, name: gn });
|
||||
sel.value = "";
|
||||
renderZoneGroupsEditor(containerEl, rows, groupsMap);
|
||||
});
|
||||
addWrap.appendChild(sel);
|
||||
addWrap.appendChild(addBtn);
|
||||
return gn ? `${gn} (${gid})` : `Group ${gid}`;
|
||||
};
|
||||
const picker =
|
||||
typeof window.createSearchableAddPicker === "function"
|
||||
? window.createSearchableAddPicker({
|
||||
entries,
|
||||
excludeIds: idsInRows,
|
||||
labelFor: groupLabel,
|
||||
searchTextFor: (gid, g) => `${(g && g.name) || ""} ${gid}`,
|
||||
onPick: (gid) => {
|
||||
if (!gid || !groupsMap[gid]) return;
|
||||
const gn = groupsMap[gid].name ? String(groupsMap[gid].name).trim() : gid;
|
||||
rows.push({ id: gid, name: gn });
|
||||
renderZoneGroupsEditor(containerEl, rows, groupsMap);
|
||||
},
|
||||
placeholder: "Search groups to add…",
|
||||
emptyMessage: "No groups match your search.",
|
||||
noItemsMessage: "All groups are already on this zone.",
|
||||
})
|
||||
: null;
|
||||
if (picker) addWrap.appendChild(picker);
|
||||
if (panel) {
|
||||
panel.addSlot.appendChild(addWrap);
|
||||
} else {
|
||||
@@ -1027,35 +1027,28 @@ async function refreshEditTabPresetsUi(zoneId) {
|
||||
} else {
|
||||
const addWrap = document.createElement("div");
|
||||
addWrap.className = "zone-devices-add profiles-actions";
|
||||
const sel = document.createElement("select");
|
||||
sel.className = "zone-device-add-select";
|
||||
sel.setAttribute("aria-label", "Preset to add to this zone");
|
||||
sel.appendChild(new Option("Add preset…", ""));
|
||||
const sorted = availableToAdd.slice().sort((a, b) => {
|
||||
const na = (allPresets[a] && allPresets[a].name) || a;
|
||||
const nb = (allPresets[b] && allPresets[b].name) || b;
|
||||
return String(na).localeCompare(String(nb), undefined, { sensitivity: "base" });
|
||||
});
|
||||
sorted.forEach((presetId) => {
|
||||
const preset = allPresets[presetId] || {};
|
||||
const name = preset.name || presetId;
|
||||
sel.appendChild(new Option(`${name} — ${presetId}`, presetId));
|
||||
});
|
||||
const addBtn = document.createElement("button");
|
||||
addBtn.type = "button";
|
||||
addBtn.className = "btn btn-primary btn-small";
|
||||
addBtn.textContent = "Add";
|
||||
addBtn.addEventListener("click", async () => {
|
||||
const presetId = sel.value;
|
||||
if (!presetId) return;
|
||||
if (typeof window.addPresetToTab === "function") {
|
||||
await window.addPresetToTab(presetId, zoneId);
|
||||
sel.value = "";
|
||||
const sorted = availableToAdd
|
||||
.slice()
|
||||
.sort((x, y) => {
|
||||
const nx = (allPresets[x] && allPresets[x].name) || x;
|
||||
const ny = (allPresets[y] && allPresets[y].name) || y;
|
||||
return String(nx).localeCompare(String(ny), undefined, { sensitivity: "base" });
|
||||
})
|
||||
.map((id) => [id, allPresets[id] || {}]);
|
||||
const picker = window.createSearchableAddPicker({
|
||||
entries: sorted,
|
||||
labelFor: (id, p) => `${p.name || id} — ${id}`,
|
||||
searchTextFor: (id, p) => `${p.name || ""} ${id} ${p.pattern || ""}`,
|
||||
onPick: async (id) => {
|
||||
if (typeof window.addPresetToTab !== "function") return;
|
||||
await window.addPresetToTab(id, zoneId);
|
||||
await refreshEditTabPresetsUi(zoneId);
|
||||
}
|
||||
},
|
||||
placeholder: "Search presets to add…",
|
||||
emptyMessage: "No presets match your search.",
|
||||
noItemsMessage: "No presets to add.",
|
||||
});
|
||||
addWrap.appendChild(sel);
|
||||
addWrap.appendChild(addBtn);
|
||||
addWrap.appendChild(picker);
|
||||
addEl.appendChild(addWrap);
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
@@ -214,6 +214,7 @@
|
||||
</label>
|
||||
<button class="btn btn-primary" id="create-group-btn">Create</button>
|
||||
</div>
|
||||
<input type="search" id="groups-search" class="list-search-input" placeholder="Search groups…" autocomplete="off">
|
||||
<div id="groups-list-modal" class="profiles-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -375,6 +376,13 @@
|
||||
<label for="sequence-editor-name">Name</label>
|
||||
<input type="text" id="sequence-editor-name" placeholder="Sequence name" style="width:100%;max-width:24rem;">
|
||||
</div>
|
||||
<div class="preset-editor-field">
|
||||
<label for="sequence-editor-mode">Steps last</label>
|
||||
<select id="sequence-editor-mode" class="zone-device-add-select">
|
||||
<option value="beats">Beats</option>
|
||||
<option value="time">Time (seconds)</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="sequence-editor-beats-panel" style="margin:0 0 0.75rem 0;">
|
||||
<label style="display:block;">
|
||||
<input type="checkbox" id="sequence-editor-loop" checked>
|
||||
|
||||
Reference in new issue
Block a user