Channel 11 defaults, ESP-NOW driver config and rig/desktop updates
Moves the controller, bridge and led-driver default ESP-NOW channel to 11 and updates the led-driver and led-tool submodule pointers. Includes the rest of the working tree: web UI, desktop and sim-controller changes, API and bridge code, graphify output, and the .gitea and fixture-driver folders. Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
35207a868a
commit
edf35e9c71
280 files changed
+24043
-1756
No files matched your search
+264
-141
@@ -111,9 +111,11 @@
|
||||
el.hidden = !can(need[0], LEVELS.indexOf(need[1]));
|
||||
});
|
||||
var btn = document.getElementById('auth-button');
|
||||
var label = !state.enabled ? 'Set up users' : state.user ? state.user + ' (' + state.role + ')' : 'Sign in';
|
||||
if (btn) {
|
||||
btn.textContent = !state.enabled ? 'Set up users' : state.user ? state.user + ' (' + state.role + ')' : 'Sign in';
|
||||
btn.textContent = label;
|
||||
}
|
||||
renderUsersTab();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ sign in */
|
||||
@@ -193,148 +195,257 @@
|
||||
|
||||
/* ------------------------------------------------------------ users and roles */
|
||||
|
||||
function usersAndRoles() {
|
||||
dialog('Users & roles', function (body) {
|
||||
body.innerHTML = '<div class="auth-err" id="auth-err"></div><div id="auth-content">Loading…</div>';
|
||||
var err = body.querySelector('#auth-err');
|
||||
var content = body.querySelector('#auth-content');
|
||||
var roles = [];
|
||||
// The lists of users and roles, drawn into `urHost` (the Users tab of Settings or a dialog).
|
||||
// Each row opens its editor: the user and role editors are modals in the page.
|
||||
var urHost = null;
|
||||
var urRoles = [];
|
||||
var urUsers = [];
|
||||
var urEditing = null; // { kind: 'user' | 'role', name: '' when adding }
|
||||
|
||||
function req(method, url, data) {
|
||||
err.textContent = '';
|
||||
return origFetch(url, {
|
||||
method: method, credentials: 'same-origin',
|
||||
headers: data ? { 'Content-Type': 'application/json' } : undefined,
|
||||
body: data ? JSON.stringify(data) : undefined,
|
||||
}).then(function (res) {
|
||||
if (!res.ok) {
|
||||
return errorText(res).then(function (m) { err.textContent = m; throw new Error(m); });
|
||||
}
|
||||
return res.json().catch(function () { return {}; });
|
||||
});
|
||||
function byId(id) { return document.getElementById(id); }
|
||||
|
||||
function showModal(id) { byId(id).classList.add('active'); }
|
||||
function hideModal(id) { byId(id).classList.remove('active'); }
|
||||
|
||||
function editorError(id, message) {
|
||||
var p = byId(id + '-error');
|
||||
p.textContent = message || '';
|
||||
p.hidden = !message;
|
||||
}
|
||||
|
||||
// One call to the auth API. A failure rejects with the server's message.
|
||||
function urRequest(method, url, data) {
|
||||
return origFetch(url, {
|
||||
method: method, credentials: 'same-origin',
|
||||
headers: data ? { 'Content-Type': 'application/json' } : undefined,
|
||||
body: data ? JSON.stringify(data) : undefined,
|
||||
}).then(function (res) {
|
||||
if (!res.ok) {
|
||||
return errorText(res).then(function (m) { throw new Error(m); });
|
||||
}
|
||||
|
||||
function roleOptions(selected) {
|
||||
return roles.map(function (r) {
|
||||
return '<option value="' + esc(r.name) + '"' + (r.name === selected ? ' selected' : '') + '>' + esc(r.name) + '</option>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
function render(users) {
|
||||
var userRows = users.map(function (u) {
|
||||
return '<tr><td>' + esc(u.username) + '</td>' +
|
||||
'<td><select data-user-role="' + esc(u.username) + '">' + roleOptions(u.role) + '</select></td>' +
|
||||
'<td class="auth-row"><button data-reset="' + esc(u.username) + '">Set password</button>' +
|
||||
'<button class="danger" data-delete-user="' + esc(u.username) + '">Delete</button></td></tr>';
|
||||
}).join('');
|
||||
var head = '<tr><th>Area</th>' + roles.map(function (r) { return '<th>' + esc(r.name) + '</th>'; }).join('') + '</tr>';
|
||||
var matrix = AREAS.map(function (a) {
|
||||
return '<tr><td>' + esc(AREA_LABELS[a]) + '</td>' + roles.map(function (r) {
|
||||
var lvl = (r.perms && r.perms[a]) || 0;
|
||||
var locked = r.name === 'admin';
|
||||
return '<td><select data-perm-role="' + esc(r.name) + '" data-area="' + a + '"' + (locked ? ' disabled' : '') + '>' +
|
||||
LEVELS.map(function (l, i) { return '<option value="' + i + '"' + (i === lvl ? ' selected' : '') + '>' + l + '</option>'; }).join('') +
|
||||
'</select></td>';
|
||||
}).join('') + '</tr>';
|
||||
}).join('');
|
||||
content.innerHTML = [
|
||||
'<h4>Users</h4>',
|
||||
'<table><tr><th>Username</th><th>Role</th><th></th></tr>' + (userRows || '<tr><td colspan="3">No users yet</td></tr>') + '</table>',
|
||||
'<div class="auth-row"><input id="new-user" placeholder="username" style="width:140px">',
|
||||
'<input id="new-pass" type="password" placeholder="password (8+)" style="width:160px">',
|
||||
'<select id="new-role" style="width:140px">' + roleOptions('guest') + '</select>',
|
||||
'<button class="primary" id="add-user">Add user</button></div>',
|
||||
'<h4 style="margin-top:18px">Permissions</h4>',
|
||||
'<p style="font-size:12px;opacity:.75;margin:4px 0">none: hidden · view: read · control: play, stop, brightness, identify · edit: change anything.</p>',
|
||||
'<div style="overflow:auto"><table>' + head + matrix + '</table></div>',
|
||||
'<div class="auth-row"><input id="new-role-name" placeholder="new role name" style="width:180px">',
|
||||
'<button id="add-role">New role</button><span style="flex:1"></span>',
|
||||
'<button class="primary" id="save-roles">Save permissions</button></div>',
|
||||
'<div class="auth-row" style="margin-top:10px">' + roles.filter(function (r) { return !r.builtin; }).map(function (r) {
|
||||
return '<button class="danger" data-delete-role="' + esc(r.name) + '">Delete role ' + esc(r.name) + '</button>';
|
||||
}).join(' ') + '</div>',
|
||||
].join('');
|
||||
wire();
|
||||
}
|
||||
|
||||
function wire() {
|
||||
content.querySelectorAll('[data-user-role]').forEach(function (sel) {
|
||||
sel.onchange = function () {
|
||||
req('PUT', '/auth/users/' + encodeURIComponent(sel.dataset.userRole), { role: sel.value })
|
||||
.then(load, function () { load(); });
|
||||
};
|
||||
});
|
||||
content.querySelectorAll('[data-reset]').forEach(function (b) {
|
||||
b.onclick = function () {
|
||||
var pw = window.prompt('New password for ' + b.dataset.reset + ' (8 to 128 characters)');
|
||||
if (pw) {
|
||||
req('PUT', '/auth/users/' + encodeURIComponent(b.dataset.reset), { password: pw }).then(load, function () {});
|
||||
}
|
||||
};
|
||||
});
|
||||
content.querySelectorAll('[data-delete-user]').forEach(function (b) {
|
||||
b.onclick = function () {
|
||||
if (window.confirm('Delete user ' + b.dataset.deleteUser + '?')) {
|
||||
req('DELETE', '/auth/users/' + encodeURIComponent(b.dataset.deleteUser)).then(load, function () {});
|
||||
}
|
||||
};
|
||||
});
|
||||
content.querySelector('#add-user').onclick = function () {
|
||||
req('POST', '/auth/users', {
|
||||
username: content.querySelector('#new-user').value.trim(),
|
||||
password: content.querySelector('#new-pass').value,
|
||||
role: content.querySelector('#new-role').value,
|
||||
}).then(load, function () {});
|
||||
};
|
||||
content.querySelector('#add-role').onclick = function () {
|
||||
var name = content.querySelector('#new-role-name').value.trim();
|
||||
var perms = {};
|
||||
AREAS.forEach(function (a) { perms[a] = 0; });
|
||||
req('POST', '/auth/roles', { name: name, perms: perms }).then(load, function () {});
|
||||
};
|
||||
content.querySelector('#save-roles').onclick = function () {
|
||||
var jobs = roles.filter(function (r) { return r.name !== 'admin'; }).map(function (r) {
|
||||
var perms = {};
|
||||
AREAS.forEach(function (a) {
|
||||
var sel = content.querySelector('[data-perm-role="' + r.name + '"][data-area="' + a + '"]');
|
||||
perms[a] = sel ? parseInt(sel.value, 10) : 0;
|
||||
});
|
||||
return req('PUT', '/auth/roles/' + encodeURIComponent(r.name), { perms: perms });
|
||||
});
|
||||
Promise.all(jobs).then(function () { toast('Permissions saved'); load(); }, function () { load(); });
|
||||
};
|
||||
content.querySelectorAll('[data-delete-role]').forEach(function (b) {
|
||||
b.onclick = function () {
|
||||
if (window.confirm('Delete role ' + b.dataset.deleteRole + '?')) {
|
||||
req('DELETE', '/auth/roles/' + encodeURIComponent(b.dataset.deleteRole)).then(load, function () {});
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function load() {
|
||||
Promise.all([req('GET', '/auth/roles'), req('GET', '/auth/users')]).then(function (res) {
|
||||
try {
|
||||
roles = res[0];
|
||||
render(res[1]);
|
||||
} catch (e) {
|
||||
err.textContent = 'Could not show users and roles: ' + e.message;
|
||||
}
|
||||
}, function () {
|
||||
if (!err.textContent) {
|
||||
err.textContent = 'Could not load users and roles';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
load();
|
||||
return res.json().catch(function () { return {}; });
|
||||
});
|
||||
}
|
||||
|
||||
// The users and roles lists in a dialog, for when there is no Settings window
|
||||
function openUsersDialog() {
|
||||
dialog('Users & roles', function (body) { usersAndRoles(body); });
|
||||
}
|
||||
|
||||
// The users and roles lists, drawn into `host` (the Users tab of Settings)
|
||||
function usersAndRoles(host) {
|
||||
urHost = host;
|
||||
host.innerHTML = '<div class="auth-err" id="auth-err"></div><div id="auth-content">Loading…</div>';
|
||||
var content = host.querySelector('#auth-content');
|
||||
content.onclick = function (e) {
|
||||
var b = e.target.closest('button');
|
||||
if (!b) return;
|
||||
if (b.id === 'add-user') openUserEditor('');
|
||||
else if (b.id === 'add-role') openRoleEditor('');
|
||||
else if (b.dataset.editUser !== undefined) openUserEditor(b.dataset.editUser);
|
||||
else if (b.dataset.editRole !== undefined) openRoleEditor(b.dataset.editRole);
|
||||
};
|
||||
loadLists();
|
||||
}
|
||||
|
||||
function listError(message) {
|
||||
var err = urHost.querySelector('#auth-err');
|
||||
if (err) err.textContent = message;
|
||||
}
|
||||
|
||||
function loadLists() {
|
||||
Promise.all([urRequest('GET', '/auth/roles'), urRequest('GET', '/auth/users')]).then(function (res) {
|
||||
urRoles = res[0];
|
||||
urUsers = res[1];
|
||||
drawLists();
|
||||
}, function (e) {
|
||||
urHost.querySelector('#auth-content').innerHTML = '';
|
||||
listError(e.message || 'Could not load users and roles');
|
||||
});
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ lists */
|
||||
|
||||
function drawLists() {
|
||||
var content = urHost.querySelector('#auth-content');
|
||||
listError('');
|
||||
content.innerHTML = [
|
||||
listHead('Users', 'add-user', 'Add user'),
|
||||
urUsers.length ? urUsers.map(userRow).join('') : '<p class="muted-text">No users yet, so anyone can edit. Add the first admin to turn sign-in on.</p>',
|
||||
listHead('Roles', 'add-role', 'New role', 'margin-top:18px;'),
|
||||
urRoles.map(roleRow).join(''),
|
||||
].join('');
|
||||
}
|
||||
|
||||
function listHead(title, id, label, style) {
|
||||
return '<div class="profiles-actions" style="align-items:center;' + (style || '') + '">' +
|
||||
'<h4 style="margin:0;">' + title + '</h4><span style="flex:1"></span>' +
|
||||
'<button type="button" class="btn btn-primary btn-small" id="' + id + '">' + label + '</button></div>';
|
||||
}
|
||||
|
||||
// The same row as the device groups list: title and detail on the left, Edit on the right
|
||||
function listRow(title, meta, attr) {
|
||||
return '<div class="group-list-row row-inline"><div class="group-list-row-info">' +
|
||||
'<div class="group-list-row-title">' + esc(title) + '</div>' +
|
||||
'<div class="group-list-row-meta muted-text">' + esc(meta) + '</div></div>' +
|
||||
'<div class="group-list-row-actions"><button type="button" class="btn btn-secondary btn-small" ' + attr + '>Edit</button></div></div>';
|
||||
}
|
||||
|
||||
function userRow(u) {
|
||||
return listRow(u.username, 'Role: ' + (u.role || 'none'), 'data-edit-user="' + esc(u.username) + '"');
|
||||
}
|
||||
|
||||
function roleRow(r) {
|
||||
var open = AREAS.filter(function (a) { return ((r.perms && r.perms[a]) || 0) > 0; }).length;
|
||||
var meta = (r.builtin ? 'Built-in · ' : '') + open + ' of ' + AREAS.length + ' areas visible';
|
||||
return listRow(r.name, meta, 'data-edit-role="' + esc(r.name) + '"');
|
||||
}
|
||||
|
||||
function roleOptions(selected) {
|
||||
return urRoles.map(function (r) {
|
||||
return '<option value="' + esc(r.name) + '"' + (r.name === selected ? ' selected' : '') + '>' + esc(r.name) + '</option>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ user editor */
|
||||
|
||||
function openUserEditor(name) {
|
||||
var u = name ? urUsers.find(function (x) { return x.username === name; }) : null;
|
||||
urEditing = { kind: 'user', name: u ? u.username : '' };
|
||||
byId('edit-user-title').textContent = u ? 'Edit user' : 'Add user';
|
||||
byId('edit-user-name').value = u ? u.username : '';
|
||||
byId('edit-user-name').readOnly = !!u;
|
||||
// The first user is the admin, which turns sign-in on; later users start as guests
|
||||
byId('edit-user-role').innerHTML = roleOptions(u ? u.role : urUsers.length ? 'guest' : 'admin');
|
||||
byId('edit-user-pass').value = '';
|
||||
byId('edit-user-pass').required = !u;
|
||||
byId('edit-user-pass-help').textContent = u ? 'Leave empty to keep the current password.' : '8 to 128 characters.';
|
||||
byId('edit-user-delete-btn').hidden = !u;
|
||||
editorError('edit-user', '');
|
||||
showModal('edit-user-modal');
|
||||
}
|
||||
|
||||
function saveUser(e) {
|
||||
e.preventDefault();
|
||||
var name = byId('edit-user-name').value.trim();
|
||||
var role = byId('edit-user-role').value;
|
||||
var pw = byId('edit-user-pass').value;
|
||||
var isNew = !urEditing.name;
|
||||
var url = '/auth/users/' + encodeURIComponent(urEditing.name);
|
||||
var job = isNew
|
||||
? urRequest('POST', '/auth/users', { username: name, password: pw, role: role })
|
||||
: urRequest('PUT', url, { role: role }).then(function () {
|
||||
return pw ? urRequest('PUT', url, { password: pw }) : null;
|
||||
});
|
||||
job.then(function () {
|
||||
hideModal('edit-user-modal');
|
||||
toast(isNew ? 'User added' : 'User saved');
|
||||
loadLists();
|
||||
}, function (err) {
|
||||
editorError('edit-user', err.message);
|
||||
loadLists();
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteUser() {
|
||||
if (!await uiConfirm('Delete user ' + urEditing.name + '?')) return;
|
||||
urRequest('DELETE', '/auth/users/' + encodeURIComponent(urEditing.name)).then(function () {
|
||||
hideModal('edit-user-modal');
|
||||
loadLists();
|
||||
}, function (err) {
|
||||
editorError('edit-user', err.message);
|
||||
});
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ role editor */
|
||||
|
||||
function openRoleEditor(name) {
|
||||
var r = name ? urRoles.find(function (x) { return x.name === name; }) : null;
|
||||
var admin = !!r && r.name === 'admin'; // the admin role's permissions are fixed
|
||||
urEditing = { kind: 'role', name: r ? r.name : '' };
|
||||
byId('edit-role-title').textContent = r ? 'Edit role' : 'New role';
|
||||
byId('edit-role-name').value = r ? r.name : '';
|
||||
byId('edit-role-name').readOnly = !!r;
|
||||
byId('edit-role-perms').innerHTML = AREAS.map(function (a) {
|
||||
var lvl = (r && r.perms && r.perms[a]) || 0;
|
||||
return '<div class="group-list-row row-inline"><div class="group-list-row-info">' +
|
||||
'<div class="group-list-row-title">' + esc(AREA_LABELS[a]) + '</div></div>' +
|
||||
'<div class="group-list-row-actions"><select data-area="' + a + '"' + (admin ? ' disabled' : '') + '>' +
|
||||
LEVELS.map(function (l, i) { return '<option value="' + i + '"' + (i === lvl ? ' selected' : '') + '>' + l + '</option>'; }).join('') +
|
||||
'</select></div></div>';
|
||||
}).join('');
|
||||
byId('edit-role-save-btn').hidden = admin;
|
||||
byId('edit-role-delete-btn').hidden = !r || !!r.builtin;
|
||||
editorError('edit-role', '');
|
||||
showModal('edit-role-modal');
|
||||
}
|
||||
|
||||
function saveRole(e) {
|
||||
e.preventDefault();
|
||||
var name = byId('edit-role-name').value.trim();
|
||||
var perms = {};
|
||||
AREAS.forEach(function (a) {
|
||||
perms[a] = parseInt(byId('edit-role-perms').querySelector('[data-area="' + a + '"]').value, 10);
|
||||
});
|
||||
var isNew = !urEditing.name;
|
||||
var job = isNew
|
||||
? urRequest('POST', '/auth/roles', { name: name, perms: perms })
|
||||
: urRequest('PUT', '/auth/roles/' + encodeURIComponent(urEditing.name), { perms: perms });
|
||||
job.then(function () {
|
||||
hideModal('edit-role-modal');
|
||||
toast(isNew ? 'Role added' : 'Permissions saved');
|
||||
loadLists();
|
||||
}, function (err) {
|
||||
editorError('edit-role', err.message);
|
||||
});
|
||||
}
|
||||
|
||||
async function deleteRole() {
|
||||
if (!await uiConfirm('Delete role ' + urEditing.name + '?')) return;
|
||||
urRequest('DELETE', '/auth/roles/' + encodeURIComponent(urEditing.name)).then(function () {
|
||||
hideModal('edit-role-modal');
|
||||
loadLists();
|
||||
}, function (err) {
|
||||
editorError('edit-role', err.message);
|
||||
});
|
||||
}
|
||||
|
||||
// Wired once: the editors are modals in the page, opened from the lists
|
||||
function wireEditors() {
|
||||
byId('edit-user-form').addEventListener('submit', saveUser);
|
||||
byId('edit-user-delete-btn').addEventListener('click', deleteUser);
|
||||
byId('edit-user-close-btn').addEventListener('click', function () { hideModal('edit-user-modal'); });
|
||||
byId('edit-role-form').addEventListener('submit', saveRole);
|
||||
byId('edit-role-delete-btn').addEventListener('click', deleteRole);
|
||||
byId('edit-role-close-btn').addEventListener('click', function () { hideModal('edit-role-modal'); });
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ header button */
|
||||
|
||||
function accountMenu() {
|
||||
dialog(state.user ? 'Signed in as ' + state.user : 'Users', function (body, close) {
|
||||
if (window.openSettingsTab) {
|
||||
window.openSettingsTab('users');
|
||||
return;
|
||||
}
|
||||
dialog(state.user ? 'Signed in as ' + state.user : 'Users', buildAccount);
|
||||
}
|
||||
|
||||
// The Users tab of Settings: the same actions, drawn in the tab
|
||||
function renderUsersTab() {
|
||||
var body = document.getElementById('settings-users-body');
|
||||
if (body) {
|
||||
buildAccount(body, renderUsersTab, true);
|
||||
if (can('users', AREA_EDIT_LEVEL)) {
|
||||
var roles = document.createElement('div');
|
||||
roles.className = 'settings-roles';
|
||||
body.appendChild(roles);
|
||||
usersAndRoles(roles);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function buildAccount(body, close, inline) {
|
||||
{
|
||||
var rows = [];
|
||||
if (!state.enabled) {
|
||||
rows.push('<p style="font-size:13px;opacity:.85">No users yet, so anyone can edit. Create the first admin to turn sign-in on.</p>');
|
||||
@@ -347,7 +458,7 @@
|
||||
rows.push('<button id="auth-do-pass">Change password</button>');
|
||||
rows.push('<button id="auth-do-out">Sign out</button>');
|
||||
}
|
||||
if (can('users', AREA_EDIT_LEVEL)) {
|
||||
if (!inline && can('users', AREA_EDIT_LEVEL)) {
|
||||
rows.push('<button id="auth-do-users">Users & roles</button>');
|
||||
}
|
||||
rows.push('<button id="auth-do-close">Close</button></div>');
|
||||
@@ -356,15 +467,20 @@
|
||||
bind('auth-do-login', askLogin);
|
||||
bind('auth-do-pass', changePassword);
|
||||
bind('auth-do-out', signOut);
|
||||
bind('auth-do-users', usersAndRoles);
|
||||
body.querySelector('#auth-do-close').onclick = close;
|
||||
});
|
||||
bind('auth-do-users', openUsersDialog);
|
||||
if (inline) {
|
||||
body.querySelector('#auth-do-close').remove();
|
||||
body.insertAdjacentHTML('afterbegin', '<p style="font-size:13px;opacity:.85">' + (state.user ? 'Signed in as ' + esc(state.user) + ' (' + esc(state.role) + ').' : state.enabled ? 'Not signed in.' : '') + '</p>');
|
||||
} else {
|
||||
body.querySelector('#auth-do-close').onclick = close;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var AREA_EDIT_LEVEL = 3;
|
||||
|
||||
function addHeaderButton() {
|
||||
// Beside the Menu button, which stays visible; the header actions inside the menu are hidden until it opens
|
||||
// The button itself stays hidden; its click opens the Users tab of Settings
|
||||
var menu = document.getElementById('main-menu-btn');
|
||||
var host = menu ? menu.parentElement : document.querySelector('header');
|
||||
if (!host || document.getElementById('auth-button')) {
|
||||
@@ -376,7 +492,13 @@
|
||||
btn.className = 'auth-button';
|
||||
btn.title = 'Sign in, change password, users and roles';
|
||||
btn.onclick = accountMenu;
|
||||
btn.hidden = true;
|
||||
host.insertBefore(btn, menu || host.firstChild);
|
||||
document.addEventListener('settings-tab', function (e) {
|
||||
if (e.detail === 'users') {
|
||||
renderUsersTab();
|
||||
}
|
||||
});
|
||||
applyPerms();
|
||||
}
|
||||
|
||||
@@ -407,12 +529,13 @@
|
||||
|
||||
function start() {
|
||||
injectStyle();
|
||||
wireEditors();
|
||||
addHeaderButton();
|
||||
refresh();
|
||||
window.authPerms = {
|
||||
can: can,
|
||||
refresh: refresh,
|
||||
usersAndRoles: usersAndRoles,
|
||||
usersAndRoles: openUsersDialog,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+97
-5
@@ -173,7 +173,9 @@ async function runEspnowPing({ btn, dot, statusEl } = {}) {
|
||||
const res = await fetch('/devices/ping', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ timeout_s: 3 }),
|
||||
// Broadcast: one frame every driver hears. A unicast to each known device makes the radio wait out every
|
||||
// absent board's retries, and the frames queued behind them (live drivers' among them) are dropped.
|
||||
body: JSON.stringify({ timeout_s: 3, broadcast: true }),
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok || !data.ok) {
|
||||
@@ -301,6 +303,14 @@ function applyTransportVisibility(transport) {
|
||||
if (drvWrap) drvWrap.hidden = !isWifi;
|
||||
}
|
||||
|
||||
/** A whole number from an input, clamped to lo..hi, or null when it is blank. */
|
||||
function readIntInRange(id, lo, hi) {
|
||||
const el = document.getElementById(id);
|
||||
if (!el || el.value === '') return null;
|
||||
const n = parseInt(el.value, 10);
|
||||
return Number.isNaN(n) ? null : Math.max(lo, Math.min(hi, n));
|
||||
}
|
||||
|
||||
function readMaxBrightness(id) {
|
||||
const el = document.getElementById(id);
|
||||
if (!el || el.value === '') return null;
|
||||
@@ -389,6 +399,14 @@ function collectDeviceEditPayload() {
|
||||
if (!Number.isNaN(n) && n >= 1) payload.num_leds = n;
|
||||
}
|
||||
if (co && co.value) payload.color_order = co.value;
|
||||
// Sent to the driver over ESP-NOW (device_config); blank leaves the driver's own value
|
||||
const pin = readIntInRange('edit-device-espnow-pin', 0, 21);
|
||||
if (pin != null) {
|
||||
if (pin > 10 && pin < 20) return { devId, payload, error: 'Data pin must be 0–10, 20 or 21 (11–19 are the flash and USB)' };
|
||||
payload.pin = pin;
|
||||
}
|
||||
const ch = readIntInRange('edit-device-espnow-channel', 1, 13);
|
||||
if (ch != null) payload.espnow_channel = ch;
|
||||
}
|
||||
return { devId, payload };
|
||||
}
|
||||
@@ -501,6 +519,35 @@ function createDeviceIdentifyButton(devId) {
|
||||
return identifyBtn;
|
||||
}
|
||||
|
||||
// "Hide sim devices": a class on the list hides its sim rows (style.css), so it holds across the live
|
||||
// refresh's re-renders and works alongside the search. Remembered in this browser.
|
||||
const HIDE_SIM_KEY = 'devices.hideSim';
|
||||
|
||||
function readHideSim() {
|
||||
try {
|
||||
return localStorage.getItem(HIDE_SIM_KEY) === '1';
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function applyHideSim(hide) {
|
||||
const list = document.getElementById('devices-list-modal');
|
||||
if (list) list.classList.toggle('hide-sim', hide);
|
||||
try {
|
||||
localStorage.setItem(HIDE_SIM_KEY, hide ? '1' : '0');
|
||||
} catch (e) {
|
||||
// private window or blocked storage: the choice lasts until the page reloads
|
||||
}
|
||||
}
|
||||
|
||||
function updateSimDeviceCount(container) {
|
||||
const el = document.getElementById('devices-sim-count');
|
||||
if (!el) return;
|
||||
const n = container.querySelectorAll(':scope > .profiles-row[data-device-kind="sim"]').length;
|
||||
el.textContent = n ? `(${n})` : '';
|
||||
}
|
||||
|
||||
function renderDevicesList(devices) {
|
||||
const container = document.getElementById('devices-list-modal');
|
||||
if (!container) return;
|
||||
@@ -551,12 +598,17 @@ function renderDevicesList(devices) {
|
||||
label.style.minWidth = '100px';
|
||||
|
||||
// Simulated (a driver of the rig page at /sim/, heard on the browser bridge) or a real board
|
||||
// or a fixture of a DMX bridge (a driver the controller runs, sent out as DMX)
|
||||
const isSim = !!(dev && dev.sim);
|
||||
const isDmx = !isSim && !!(dev && dev.dmx_fixture);
|
||||
const kindName = isSim ? 'sim' : isDmx ? 'dmx' : 'real';
|
||||
row.dataset.deviceKind = kindName; // "Hide sim devices" hides rows by this (style.css)
|
||||
const kind = document.createElement('span');
|
||||
kind.className = `device-kind-badge device-kind-badge--${isSim ? 'sim' : 'real'}`;
|
||||
kind.textContent = isSim ? 'sim' : 'real';
|
||||
kind.className = `device-kind-badge device-kind-badge--${kindName}`;
|
||||
kind.textContent = kindName === 'dmx' ? 'DMX' : kindName;
|
||||
kind.title = isSim
|
||||
? 'Simulated: a driver on the rig page (/sim/), reached over the browser bridge'
|
||||
: isDmx ? `A DMX fixture of the bridge ${dev.bridge || ''}: a driver the controller runs, sent out as DMX`
|
||||
: 'A real board';
|
||||
|
||||
const editBtn = document.createElement('button');
|
||||
@@ -570,7 +622,7 @@ function renderDevicesList(devices) {
|
||||
deleteBtn.className = 'btn btn-secondary btn-small';
|
||||
deleteBtn.textContent = 'Delete';
|
||||
deleteBtn.addEventListener('click', async () => {
|
||||
if (!confirm(`Delete device "${(dev && dev.name) || devId}"?`)) return;
|
||||
if (!await uiConfirm(`Delete device "${(dev && dev.name) || devId}"?`)) return;
|
||||
try {
|
||||
const res = await fetch(`/devices/${encodeURIComponent(devId)}`, { method: 'DELETE' });
|
||||
if (res.ok) await loadDevicesModal();
|
||||
@@ -592,6 +644,7 @@ function renderDevicesList(devices) {
|
||||
row.appendChild(deleteBtn);
|
||||
container.appendChild(row);
|
||||
});
|
||||
updateSimDeviceCount(container);
|
||||
// Do not re-apply lastTcpSnapshotIps here: it is only updated on WS open and
|
||||
// device_tcp events; re-applying after each /devices poll overwrites correct
|
||||
// API "connected" with a stale list and leaves Wi-Fi rows stuck online.
|
||||
@@ -630,6 +683,11 @@ function openEditDeviceModal(devId, dev) {
|
||||
? String(co).toLowerCase()
|
||||
: 'rgb';
|
||||
}
|
||||
// What the driver last announced (blank for a driver whose firmware does not report them)
|
||||
const ePin = document.getElementById('edit-device-espnow-pin');
|
||||
const eCh = document.getElementById('edit-device-espnow-channel');
|
||||
if (ePin) ePin.value = tr === 'espnow' && dev && dev.pin != null ? String(dev.pin) : '';
|
||||
if (eCh) eCh.value = tr === 'espnow' && dev && dev.espnow_channel != null ? String(dev.espnow_channel) : '';
|
||||
const wName = document.getElementById('edit-device-wifi-driver-name');
|
||||
const wLeds = document.getElementById('edit-device-wifi-num-leds');
|
||||
const wCo = document.getElementById('edit-device-wifi-color-order');
|
||||
@@ -813,7 +871,37 @@ async function pushWifiDriverConfig(devId, fields) {
|
||||
}
|
||||
}
|
||||
|
||||
// The Menu's "Hide sim devices" item and the Devices modal's checkbox show the same setting
|
||||
function syncHideSimControls() {
|
||||
const hide = readHideSim();
|
||||
const hideSim = document.getElementById('devices-hide-sim');
|
||||
if (hideSim) hideSim.checked = hide;
|
||||
const menuBtn = document.getElementById('menu-hide-sim-btn');
|
||||
if (menuBtn) {
|
||||
menuBtn.textContent = hide ? 'Show sim devices' : 'Hide sim devices';
|
||||
menuBtn.setAttribute('aria-pressed', hide ? 'true' : 'false');
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const hideSim = document.getElementById('devices-hide-sim');
|
||||
if (hideSim) {
|
||||
hideSim.checked = readHideSim();
|
||||
applyHideSim(hideSim.checked);
|
||||
hideSim.addEventListener('change', () => {
|
||||
applyHideSim(hideSim.checked);
|
||||
syncHideSimControls();
|
||||
});
|
||||
}
|
||||
const menuHideSim = document.getElementById('menu-hide-sim-btn');
|
||||
if (menuHideSim) {
|
||||
applyHideSim(readHideSim());
|
||||
syncHideSimControls();
|
||||
menuHideSim.addEventListener('click', () => {
|
||||
applyHideSim(!readHideSim());
|
||||
syncHideSimControls();
|
||||
});
|
||||
}
|
||||
window.addEventListener('deviceTcpStatus', (ev) => {
|
||||
const { ip, connected } = ev.detail || {};
|
||||
if (ip == null || typeof connected !== 'boolean') return;
|
||||
@@ -926,8 +1014,12 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (editForm) {
|
||||
editForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const { devId, payload } = collectDeviceEditPayload();
|
||||
const { devId, payload, error } = collectDeviceEditPayload();
|
||||
if (!devId) return;
|
||||
if (error) {
|
||||
alert(error);
|
||||
return;
|
||||
}
|
||||
const ok = await updateDevice(devId, payload);
|
||||
if (!ok) return;
|
||||
// Before the brightness push: a driver's brightness includes its groups' factors.
|
||||
|
||||
@@ -0,0 +1,372 @@
|
||||
// DMX bridges in Settings > Bridges: the DMX part of the bridge dialog (universes, their outputs and fixtures) and
|
||||
// the DMX definitions dialog. The records are /dmx-bridges and /dmx-definitions; a bridge runs while "dmx:<id>" is
|
||||
// in the bridge list (/settings/bridge). help.js owns the bridge dialog and calls window.DmxBridges.
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const OUTPUT_TYPES = [['artnet', 'Art-Net'], ['sacn', 'sACN (E1.31)'], ['dmx_serial', 'USB-DMX'], ['sim', 'Simulator']];
|
||||
const DMX_MODES = [['enttec_pro', 'Enttec DMX USB Pro'], ['open_dmx', 'Open DMX']];
|
||||
|
||||
let defs = {}; // id -> definition
|
||||
let ports = []; // serial ports the controller sees
|
||||
let editing = null; // {id|null, rec}
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
|
||||
async function json(url, opts) {
|
||||
const r = await fetch(url, Object.assign({ cache: 'no-store' }, opts || {}));
|
||||
let body = {};
|
||||
try {
|
||||
body = await r.json();
|
||||
} catch (e) {
|
||||
body = {};
|
||||
}
|
||||
if (!r.ok) throw new Error(body.error || `${r.status} ${r.statusText}`);
|
||||
return body;
|
||||
}
|
||||
|
||||
const send = (url, method, body) => json(url, {
|
||||
method, headers: { 'Content-Type': 'application/json' }, body: body === undefined ? undefined : JSON.stringify(body),
|
||||
});
|
||||
|
||||
async function loadDefs() {
|
||||
defs = await json('/dmx-definitions');
|
||||
return defs;
|
||||
}
|
||||
|
||||
const channelCount = (defId) => ((defs[defId] && defs[defId].channels) || []).length;
|
||||
|
||||
function el(tag, props, ...children) {
|
||||
const e = document.createElement(tag);
|
||||
Object.entries(props || {}).forEach(([k, v]) => {
|
||||
if (k === 'class') e.className = v;
|
||||
else if (k === 'on') Object.entries(v).forEach(([ev, fn]) => e.addEventListener(ev, fn));
|
||||
else if (k in e) e[k] = v;
|
||||
else e.setAttribute(k, v);
|
||||
});
|
||||
children.flat().forEach((c) => e.append(c));
|
||||
return e;
|
||||
}
|
||||
|
||||
function select(options, value, onChange) {
|
||||
const s = el('select', { on: { change: () => onChange(s.value) } });
|
||||
options.forEach(([v, label]) => s.append(el('option', { value: v, textContent: label })));
|
||||
s.value = value;
|
||||
return s;
|
||||
}
|
||||
|
||||
function error(id, text) {
|
||||
const e = $(id);
|
||||
e.textContent = text || '';
|
||||
e.hidden = !text;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------- bridge */
|
||||
|
||||
// The first address after the universe's fixtures that fits n channels
|
||||
function nextAddress(u, n) {
|
||||
let end = 0;
|
||||
(u.fixtures || []).forEach((f) => {
|
||||
end = Math.max(end, (parseInt(f.address, 10) || 1) + channelCount(f.definition) - 1);
|
||||
});
|
||||
return Math.min(end + 1, Math.max(1, 513 - n));
|
||||
}
|
||||
|
||||
function outputRow(u, o, i) {
|
||||
const row = el('div', { class: 'dmx-row' });
|
||||
const serial = o.type === 'dmx_serial';
|
||||
row.append(select(OUTPUT_TYPES, o.type || 'artnet', (v) => { o.type = v; render(); }));
|
||||
if (serial) {
|
||||
const portIn = el('input', {
|
||||
type: 'text', value: o.serial_port || '', placeholder: '/dev/ttyUSB0', list: 'dmx-serial-ports', 'aria-label': 'Serial port',
|
||||
on: { input: () => { o.serial_port = portIn.value.trim(); } },
|
||||
});
|
||||
row.append(portIn, select(DMX_MODES, o.dmx_mode || 'enttec_pro', (v) => { o.dmx_mode = v; }));
|
||||
} else {
|
||||
const host = el('input', {
|
||||
type: 'text', value: o.host || '', 'aria-label': 'Host',
|
||||
placeholder: o.type === 'sacn' ? 'host (blank = multicast)' : 'host (blank = broadcast)',
|
||||
on: { input: () => { o.host = host.value.trim(); } },
|
||||
});
|
||||
const port = el('input', {
|
||||
type: 'number', class: 'dmx-num', min: 1, max: 65535, value: o.port == null ? '' : o.port,
|
||||
placeholder: o.type === 'sacn' ? '5568' : '6454', 'aria-label': 'Port', title: 'Port (blank = default)',
|
||||
on: { input: () => { o.port = port.value === '' ? null : Number(port.value); } },
|
||||
});
|
||||
const uni = el('input', {
|
||||
type: 'number', class: 'dmx-num', min: 0, max: 63999, value: o.universe == null ? '' : o.universe,
|
||||
placeholder: `univ ${u.number || 0}`, 'aria-label': 'Universe on the wire',
|
||||
title: 'Universe on the wire (blank = the universe number)',
|
||||
on: { input: () => { o.universe = uni.value === '' ? null : Number(uni.value); } },
|
||||
});
|
||||
if (o.type === 'sim') { // straight to the rig simulator's page: no host or port
|
||||
row.append(el('span', { class: 'dmx-info', textContent: 'to the rig simulator' }), uni);
|
||||
} else {
|
||||
row.append(host, port, uni);
|
||||
}
|
||||
}
|
||||
const on = el('input', { type: 'checkbox', checked: o.enabled !== false, on: { change: () => { o.enabled = on.checked; } } });
|
||||
row.append(el('label', { class: 'dmx-check' }, on, 'on'));
|
||||
row.append(el('button', {
|
||||
type: 'button', class: 'btn btn-danger btn-small', textContent: 'Remove',
|
||||
on: { click: () => { u.outputs.splice(i, 1); render(); } },
|
||||
}));
|
||||
return row;
|
||||
}
|
||||
|
||||
function fixtureRow(u, f, i) {
|
||||
const row = el('div', { class: 'dmx-row' });
|
||||
const info = el('span', { class: 'dmx-info' });
|
||||
const updateInfo = () => {
|
||||
const n = channelCount(f.definition);
|
||||
const a = parseInt(f.address, 10) || 1;
|
||||
info.textContent = n ? `${n} ch · ${a}–${a + n - 1}` : 'no definition';
|
||||
};
|
||||
const name = el('input', {
|
||||
type: 'text', value: f.name || '', placeholder: 'Fixture name', maxLength: 63, 'aria-label': 'Fixture name',
|
||||
on: { input: () => { f.name = name.value; } },
|
||||
});
|
||||
const defOpts = Object.entries(defs).map(([id, d]) => [id, d.name]);
|
||||
if (!defOpts.length) defOpts.push(['', '(no definitions)']);
|
||||
const def = select(defOpts, f.definition || defOpts[0][0], (v) => { f.definition = v; updateInfo(); });
|
||||
f.definition = def.value;
|
||||
const addr = el('input', {
|
||||
type: 'number', class: 'dmx-num', min: 1, max: 512, value: f.address || 1, 'aria-label': 'Start address',
|
||||
title: 'Start address (1 to 512)',
|
||||
on: { input: () => { f.address = addr.value === '' ? '' : Number(addr.value); updateInfo(); } },
|
||||
});
|
||||
const mac = el('input', {
|
||||
type: 'text', class: 'dmx-mac', value: f.mac || '', placeholder: 'new MAC on save', maxLength: 17,
|
||||
'aria-label': 'MAC', title: 'The fixture driver\'s MAC (blank: a new one is made)',
|
||||
on: { input: () => { f.mac = mac.value.trim(); } },
|
||||
});
|
||||
const renew = el('button', {
|
||||
type: 'button', class: 'btn btn-secondary btn-small', textContent: 'New MAC',
|
||||
title: 'Clear the MAC: a new one is made when the bridge is saved (the fixture shows up as a new device)',
|
||||
on: { click: () => { f.mac = ''; mac.value = ''; } },
|
||||
});
|
||||
const del = el('button', {
|
||||
type: 'button', class: 'btn btn-danger btn-small', textContent: 'Remove',
|
||||
on: { click: () => { u.fixtures.splice(i, 1); render(); } },
|
||||
});
|
||||
updateInfo();
|
||||
row.append(name, def, addr, info, mac, renew, del);
|
||||
return row;
|
||||
}
|
||||
|
||||
function universeCard(u, ui) {
|
||||
const rec = editing.rec;
|
||||
const card = el('div', { class: 'dmx-universe' });
|
||||
const name = el('input', {
|
||||
type: 'text', value: u.name || '', placeholder: `Universe ${ui + 1}`, maxLength: 63,
|
||||
on: { input: () => { u.name = name.value; } },
|
||||
});
|
||||
const number = el('input', {
|
||||
type: 'number', min: 0, max: 63999, value: u.number == null ? ui : u.number,
|
||||
on: { input: () => { u.number = number.value === '' ? null : Number(number.value); } },
|
||||
});
|
||||
card.append(el('div', { class: 'dmx-universe-head' },
|
||||
el('div', {}, el('label', { textContent: 'Universe name' }), name),
|
||||
el('div', { class: 'dmx-narrow' }, el('label', { textContent: 'Number' }), number),
|
||||
el('button', {
|
||||
type: 'button', class: 'btn btn-danger btn-small', textContent: 'Remove universe',
|
||||
on: { click: () => { rec.universes.splice(ui, 1); render(); } },
|
||||
})));
|
||||
|
||||
card.append(el('h4', { textContent: 'Outputs' }));
|
||||
if (!u.outputs.length) card.append(el('small', { class: 'muted-text', textContent: 'No outputs: the universe is built but not sent.' }));
|
||||
u.outputs.forEach((o, i) => card.append(outputRow(u, o, i)));
|
||||
card.append(el('div', { class: 'profiles-actions' }, el('button', {
|
||||
type: 'button', class: 'btn btn-secondary btn-small', textContent: 'Add output',
|
||||
on: { click: () => { u.outputs.push({ type: 'artnet', host: '', port: null, universe: null, enabled: true }); render(); } },
|
||||
})));
|
||||
|
||||
card.append(el('h4', { textContent: 'Fixtures' }));
|
||||
if (!u.fixtures.length) card.append(el('small', { class: 'muted-text', textContent: 'No fixtures yet.' }));
|
||||
u.fixtures.forEach((f, i) => card.append(fixtureRow(u, f, i)));
|
||||
card.append(el('div', { class: 'profiles-actions' }, el('button', {
|
||||
type: 'button', class: 'btn btn-secondary btn-small', textContent: 'Add fixture',
|
||||
on: {
|
||||
click: () => {
|
||||
const defId = (u.fixtures.length && u.fixtures[u.fixtures.length - 1].definition) || Object.keys(defs)[0] || '';
|
||||
u.fixtures.push({
|
||||
name: `${u.name || 'Fixture'} ${u.fixtures.length + 1}`, definition: defId,
|
||||
address: nextAddress(u, channelCount(defId)), mac: '',
|
||||
});
|
||||
render();
|
||||
},
|
||||
},
|
||||
})));
|
||||
return card;
|
||||
}
|
||||
|
||||
function render() {
|
||||
const box = $('edit-bridge-dmx-universes');
|
||||
box.textContent = '';
|
||||
let dl = $('dmx-serial-ports');
|
||||
if (!dl) {
|
||||
dl = el('datalist', { id: 'dmx-serial-ports' });
|
||||
document.body.append(dl);
|
||||
}
|
||||
dl.textContent = '';
|
||||
ports.forEach((p) => dl.append(el('option', { value: p })));
|
||||
editing.rec.universes.forEach((u, ui) => box.append(universeCard(u, ui)));
|
||||
if (!editing.rec.universes.length) {
|
||||
box.append(el('p', { class: 'muted-text', textContent: 'Add a universe, then its outputs and fixtures.' }));
|
||||
}
|
||||
}
|
||||
|
||||
const newUniverse = (n) => ({
|
||||
name: `Universe ${n + 1}`, number: n, fixtures: [],
|
||||
outputs: n ? [] : [{ type: 'artnet', host: '', port: null, universe: null, enabled: true }],
|
||||
});
|
||||
|
||||
// Load bridge id (null: a new one) into the dialog's DMX section; returns its name
|
||||
async function load(id) {
|
||||
await loadDefs();
|
||||
const br = await json('/settings/bridge');
|
||||
ports = br.ports || [];
|
||||
const rec = id ? await json(`/dmx-bridges/${encodeURIComponent(id)}`) : { name: '', universes: [newUniverse(0)] };
|
||||
rec.universes = (rec.universes || []).map((u) => Object.assign({ outputs: [], fixtures: [] }, u));
|
||||
editing = { id: id || null, rec };
|
||||
render();
|
||||
return rec.name || '';
|
||||
}
|
||||
|
||||
// Save what the dialog holds under this name. A new bridge is started (its address added to the bridges).
|
||||
// Throws with the server's message when a check fails.
|
||||
async function save(name) {
|
||||
if (!editing) throw new Error('Nothing to save');
|
||||
const rec = editing.rec;
|
||||
rec.name = (name || '').trim();
|
||||
if (!rec.name) throw new Error('The bridge needs a name');
|
||||
const body = { name: rec.name, universes: rec.universes };
|
||||
if (editing.id) {
|
||||
await send(`/dmx-bridges/${encodeURIComponent(editing.id)}`, 'PUT', body);
|
||||
return { id: editing.id, created: false };
|
||||
}
|
||||
const id = String((await send('/dmx-bridges', 'POST', body)).id);
|
||||
editing.id = id; // a failed start below must not make a second record on the next save
|
||||
await start(id);
|
||||
return { id, created: true };
|
||||
}
|
||||
|
||||
function addUniverse() {
|
||||
if (!editing) return;
|
||||
editing.rec.universes.push(newUniverse(editing.rec.universes.length));
|
||||
render();
|
||||
}
|
||||
|
||||
async function remove(id) {
|
||||
await send(`/dmx-bridges/${encodeURIComponent(id)}`, 'DELETE'); // also takes it off the running bridges
|
||||
}
|
||||
|
||||
async function start(id) {
|
||||
const br = await json('/settings/bridge');
|
||||
const addrs = (br.bridges || []).map((b) => b.addr);
|
||||
await send('/settings/bridge', 'PUT', { bridges: [...addrs, `dmx:${id}`] });
|
||||
}
|
||||
|
||||
/* --------------------------------------------------------- definitions */
|
||||
|
||||
let defEditing = null; // id, '' for a new one, null when the form is closed
|
||||
|
||||
function renderDefs() {
|
||||
const list = $('dmx-defs-list');
|
||||
list.textContent = '';
|
||||
const ids = Object.keys(defs).sort((a, b) => defs[a].name.localeCompare(defs[b].name));
|
||||
ids.forEach((id) => {
|
||||
const d = defs[id];
|
||||
const meta = [d.manufacturer, d.model, d.mode].filter(Boolean).join(' · ');
|
||||
list.append(el('div', { class: 'group-list-row' },
|
||||
el('div', { class: 'group-list-row-info' },
|
||||
el('div', { class: 'group-list-row-title', textContent: d.name }),
|
||||
el('div', { class: 'group-list-row-meta muted-text', textContent: `${d.channels.length} channels${meta ? ' · ' + meta : ''}` })),
|
||||
el('div', { class: 'group-list-row-actions' }, el('button', {
|
||||
type: 'button', class: 'btn btn-secondary btn-small', textContent: 'Edit', on: { click: () => editDef(id) },
|
||||
}))));
|
||||
});
|
||||
if (!ids.length) list.append(el('small', { class: 'muted-text', textContent: 'No definitions.' }));
|
||||
}
|
||||
|
||||
function editDef(id) {
|
||||
defEditing = id;
|
||||
const d = id ? defs[id] : { name: '', manufacturer: '', model: '', mode: '', channels: ['Dimmer', 'Red', 'Green', 'Blue'], defaults: {} };
|
||||
$('dmx-def-title').textContent = id ? `Edit ${d.name}` : 'New definition';
|
||||
$('dmx-def-name').value = d.name || '';
|
||||
$('dmx-def-manufacturer').value = d.manufacturer || '';
|
||||
$('dmx-def-model').value = d.model || '';
|
||||
$('dmx-def-mode').value = d.mode || '';
|
||||
$('dmx-def-channels').value = (d.channels || []).join('\n');
|
||||
$('dmx-def-defaults').value = Object.entries(d.defaults || {}).map(([k, v]) => `${k} = ${v}`).join('\n');
|
||||
$('dmx-def-delete-btn').hidden = !id;
|
||||
error('dmx-def-error', '');
|
||||
$('dmx-def-form').hidden = false;
|
||||
$('dmx-def-name').focus();
|
||||
}
|
||||
|
||||
async function saveDef(e) {
|
||||
e.preventDefault();
|
||||
const channels = $('dmx-def-channels').value.split('\n').map((s) => s.trim()).filter(Boolean);
|
||||
const defaults = {};
|
||||
for (const line of $('dmx-def-defaults').value.split('\n')) {
|
||||
if (!line.trim()) continue;
|
||||
const m = /^(.+?)\s*=\s*(\d+)\s*$/.exec(line.trim());
|
||||
if (!m) {
|
||||
error('dmx-def-error', `Not "Channel = value": ${line.trim()}`);
|
||||
return;
|
||||
}
|
||||
defaults[m[1].trim()] = Number(m[2]);
|
||||
}
|
||||
const body = {
|
||||
name: $('dmx-def-name').value.trim(), manufacturer: $('dmx-def-manufacturer').value.trim(),
|
||||
model: $('dmx-def-model').value.trim(), mode: $('dmx-def-mode').value.trim(), channels, defaults,
|
||||
};
|
||||
try {
|
||||
if (defEditing) await send(`/dmx-definitions/${encodeURIComponent(defEditing)}`, 'PUT', body);
|
||||
else await send('/dmx-definitions', 'POST', body);
|
||||
await loadDefs();
|
||||
$('dmx-def-form').hidden = true;
|
||||
renderDefs();
|
||||
if (editing && !$('edit-bridge-dmx-field').hidden) render();
|
||||
} catch (err) {
|
||||
error('dmx-def-error', err.message);
|
||||
}
|
||||
}
|
||||
|
||||
async function openDefs() {
|
||||
try {
|
||||
await loadDefs();
|
||||
} catch (e) {
|
||||
alert(`Could not read the DMX definitions: ${e.message}`);
|
||||
return;
|
||||
}
|
||||
$('dmx-def-form').hidden = true;
|
||||
renderDefs();
|
||||
$('dmx-defs-modal').classList.add('active');
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const addUni = $('edit-bridge-dmx-add-universe');
|
||||
if (addUni) addUni.addEventListener('click', addUniverse);
|
||||
if (!$('dmx-def-form')) return;
|
||||
$('dmx-def-form').addEventListener('submit', saveDef);
|
||||
$('dmx-defs-new-btn').addEventListener('click', () => editDef(''));
|
||||
$('dmx-defs-close-btn').addEventListener('click', () => $('dmx-defs-modal').classList.remove('active'));
|
||||
$('dmx-def-delete-btn').addEventListener('click', async () => {
|
||||
if (!defEditing || !await uiConfirm(`Delete definition "${defs[defEditing].name}"?`)) return;
|
||||
try {
|
||||
await send(`/dmx-definitions/${encodeURIComponent(defEditing)}`, 'DELETE');
|
||||
await loadDefs();
|
||||
$('dmx-def-form').hidden = true;
|
||||
renderDefs();
|
||||
} catch (err) {
|
||||
error('dmx-def-error', err.message);
|
||||
}
|
||||
});
|
||||
const defsBtn = $('dmx-defs-btn');
|
||||
if (defsBtn) defsBtn.addEventListener('click', openDefs);
|
||||
});
|
||||
|
||||
window.DmxBridges = { load, save, remove, start, openDefs };
|
||||
})();
|
||||
@@ -372,7 +372,7 @@ function renderGroupsList(groups) {
|
||||
delBtn.className = 'btn btn-danger btn-small';
|
||||
delBtn.textContent = 'Delete';
|
||||
delBtn.addEventListener('click', async () => {
|
||||
if (!confirm(`Delete group "${g.name || gid}"? Zones referencing it may need updating.`)) return;
|
||||
if (!await uiConfirm(`Delete group "${g.name || gid}"? Zones referencing it may need updating.`)) return;
|
||||
try {
|
||||
const res = await fetch(`/groups/${encodeURIComponent(gid)}`, {
|
||||
method: 'DELETE',
|
||||
|
||||
+156
-61
@@ -84,7 +84,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const rebootButton = document.getElementById('reboot-btn');
|
||||
if (rebootButton) {
|
||||
rebootButton.addEventListener('click', async () => {
|
||||
if (!confirm('Reboot the controller now? The page will be unavailable for a few seconds.')) return;
|
||||
if (!await uiConfirm('Reboot the controller now? The page will be unavailable for a few seconds.')) return;
|
||||
rebootButton.disabled = true;
|
||||
try {
|
||||
await fetch('/reboot', { method: 'POST' });
|
||||
@@ -266,7 +266,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const bridgeSection = document.getElementById('bridge-section');
|
||||
const bridgeList = document.getElementById('bridge-list');
|
||||
const bridgeAddBtn = document.getElementById('bridge-add-btn');
|
||||
const bridgeAddInput = document.getElementById('bridge-add-input');
|
||||
const bridgePorts = document.getElementById('bridge-ports');
|
||||
const bridgeRefresh = document.getElementById('bridge-refresh-btn');
|
||||
let bridgeAddrs = [];
|
||||
@@ -279,18 +278,29 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
function bridgeName(b) {
|
||||
if (b.kind === 'dmx') return (b.status && b.status.name) || b.addr;
|
||||
return bridgeMac(b) || b.addr;
|
||||
}
|
||||
|
||||
const dmxId = (b) => b.addr.slice(4); // "dmx:<id>"
|
||||
|
||||
// 'up' (linked), 'down' (not linked yet) or 'local' (the rig page of this controller)
|
||||
function bridgeState(b) {
|
||||
if (b.kind === 'browser') return 'local';
|
||||
if (b.kind === 'stopped') return 'down';
|
||||
return b.status && b.status.linked ? 'up' : 'down';
|
||||
}
|
||||
|
||||
function describeBridge(b) {
|
||||
const st = b.status || {};
|
||||
if (b.kind === 'browser') return 'Rig page of this controller · sent ' + (st.tx || 0) + ' · received ' + (st.rx || 0);
|
||||
if (b.kind === 'stopped') return 'DMX bridge, not running';
|
||||
if (b.kind === 'dmx') {
|
||||
const parts = ['DMX', (st.universes || 0) + (st.universes === 1 ? ' universe' : ' universes'),
|
||||
(st.running || 0) + '/' + (st.fixtures || 0) + ' fixtures', (st.hz || 40) + ' Hz', 'sent ' + (st.packets || 0)];
|
||||
if (st.last_error) parts.push('last error: ' + st.last_error);
|
||||
return parts.join(' · ');
|
||||
}
|
||||
if (b.kind === 'udp' || (b.kind !== 'serial' && !b.addr.startsWith('usb:'))) {
|
||||
if (!st.linked) return 'Not connected (no answer from ' + b.addr + ')';
|
||||
return ['Connected', 'channel ' + st.channel, 'microphone ' + (st.mic ? 'yes' : 'no'),
|
||||
@@ -327,15 +337,48 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
editBtn.type = 'button';
|
||||
editBtn.className = 'btn btn-secondary btn-small';
|
||||
editBtn.textContent = 'Edit';
|
||||
const dmx = b.kind === 'dmx' || b.kind === 'stopped';
|
||||
editBtn.addEventListener('click', () => openBridgeEditor(b));
|
||||
if (b.kind === 'stopped') {
|
||||
const startBtn = document.createElement('button');
|
||||
startBtn.type = 'button';
|
||||
startBtn.className = 'btn btn-primary btn-small';
|
||||
startBtn.textContent = 'Start';
|
||||
startBtn.addEventListener('click', async () => {
|
||||
try {
|
||||
await window.DmxBridges.start(dmxId(b));
|
||||
showSettingsMessage('DMX bridge started.', 'success');
|
||||
} catch (error) {
|
||||
showSettingsMessage(`Error: ${error.message}`, 'error');
|
||||
}
|
||||
loadBridgeSettings();
|
||||
});
|
||||
actions.append(startBtn);
|
||||
}
|
||||
actions.append(editBtn);
|
||||
if (b.kind !== 'browser') { // the rig page's own bridge is not removable
|
||||
if (dmx) {
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.type = 'button';
|
||||
delBtn.className = 'btn btn-danger btn-small';
|
||||
delBtn.textContent = 'Delete';
|
||||
delBtn.addEventListener('click', () => {
|
||||
if (!confirm(`Delete bridge "${bridgeName(b)}"?`)) return;
|
||||
delBtn.addEventListener('click', async () => {
|
||||
if (!await uiConfirm(`Delete DMX bridge "${bridgeName(b)}" and its fixtures?`)) return;
|
||||
try {
|
||||
await window.DmxBridges.remove(dmxId(b));
|
||||
showSettingsMessage('DMX bridge deleted.', 'success');
|
||||
} catch (error) {
|
||||
showSettingsMessage(`Error: ${error.message}`, 'error');
|
||||
}
|
||||
loadBridgeSettings();
|
||||
});
|
||||
actions.append(delBtn);
|
||||
} else if (b.kind !== 'browser') { // the rig page's own bridge is not removable
|
||||
const delBtn = document.createElement('button');
|
||||
delBtn.type = 'button';
|
||||
delBtn.className = 'btn btn-danger btn-small';
|
||||
delBtn.textContent = 'Delete';
|
||||
delBtn.addEventListener('click', async () => {
|
||||
if (!await uiConfirm(`Delete bridge "${bridgeName(b)}"?`)) return;
|
||||
putBridges(bridgeAddrs.filter((a) => a !== b.addr), 'Bridge removed.');
|
||||
});
|
||||
actions.append(delBtn);
|
||||
@@ -367,6 +410,17 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (bridgeTab) bridgeTab.hidden = !data.supported; // nothing to show where bridges are not supported
|
||||
if (!data.supported) return;
|
||||
bridgeAddrs = (data.bridges || []).map((b) => b.addr);
|
||||
// DMX bridge records that are not running are listed too, with a Start button
|
||||
try {
|
||||
const recs = await fetch('/dmx-bridges', { cache: 'no-store' }).then((r) => (r.ok ? r.json() : {}));
|
||||
for (const [id, rec] of Object.entries(recs)) {
|
||||
if (!bridgeAddrs.includes('dmx:' + id)) {
|
||||
data.bridges = (data.bridges || []).concat([{ addr: 'dmx:' + id, kind: 'stopped', name: '', status: { name: rec.name } }]);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
// no DMX bridges to add
|
||||
}
|
||||
renderBridges(data);
|
||||
filterBridges();
|
||||
} catch (error) {
|
||||
@@ -445,27 +499,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
if (bridgeRefresh) bridgeRefresh.addEventListener('click', loadBridgeSettings);
|
||||
|
||||
// Add: the address in the box at the top goes straight onto the list (Edit changes it later)
|
||||
function addBridgeFromBox() {
|
||||
const addr = bridgeAddInput.value.trim();
|
||||
if (!addr) return;
|
||||
if (bridgeAddrs.includes(addr)) {
|
||||
showSettingsMessage('That bridge is already in the list', 'error');
|
||||
return;
|
||||
}
|
||||
bridgeAddInput.value = '';
|
||||
putBridges([...bridgeAddrs, addr], 'Bridge added.');
|
||||
}
|
||||
if (bridgeAddBtn) bridgeAddBtn.addEventListener('click', addBridgeFromBox);
|
||||
if (bridgeAddInput) {
|
||||
bridgeAddInput.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
addBridgeFromBox();
|
||||
}
|
||||
});
|
||||
}
|
||||
if (bridgeAddBtn) bridgeAddBtn.addEventListener('click', () => openBridgeEditor(null));
|
||||
|
||||
const bridgeSearch = document.getElementById('bridge-search');
|
||||
function filterBridges() {
|
||||
@@ -476,12 +510,30 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
if (bridgeSearch) bridgeSearch.addEventListener('input', filterBridges);
|
||||
|
||||
// The bridge editor: add a bridge, or change one's address and radio channel
|
||||
// The bridge dialog, for every kind of bridge: a type picker (USB board, network board, DMX) shows the fields of
|
||||
// that type. Adding starts with the type; an existing bridge keeps its type.
|
||||
const bridgeEditModal = document.getElementById('edit-bridge-modal');
|
||||
const bridgeEditForm = document.getElementById('edit-bridge-form');
|
||||
const bridgeTypeSel = document.getElementById('edit-bridge-type');
|
||||
let bridgeEditing = null; // the bridge being edited, or null when adding
|
||||
let dmxLoaded = false; // the DMX section holds the bridge being edited (or a new one)
|
||||
|
||||
const isBoardAddr = (addr) => /^(serial:)?\/dev\//.test(addr) || addr.startsWith("usb:");
|
||||
const isBoardAddr = (addr) => /^(serial:)?\/dev\//.test(addr) || addr.startsWith('usb:');
|
||||
|
||||
const TYPE_HELP = {
|
||||
usb: 'A bridge board on USB: its serial port (/dev/ttyACM1). Once it answers it is known by its MAC, on whichever port it is plugged into.',
|
||||
network: 'A bridge board or led-simulator on the network: host:port (UDP, default port 8766).',
|
||||
dmx: 'Universes sent to Art-Net, sACN, USB-DMX or the rig simulator 40 times a second. Each fixture is a led-driver of its own.',
|
||||
browser: 'The rig page of this controller. It has nothing to set and cannot be removed.',
|
||||
};
|
||||
|
||||
function bridgeType(b) {
|
||||
if (!b) return 'usb';
|
||||
if (b.kind === 'dmx' || b.kind === 'stopped') return 'dmx';
|
||||
if (b.kind === 'browser') return 'browser';
|
||||
if (b.kind === 'serial' || isBoardAddr(b.addr)) return 'usb';
|
||||
return 'network';
|
||||
}
|
||||
|
||||
function bridgeEditError(text) {
|
||||
const el = document.getElementById('edit-bridge-error');
|
||||
@@ -489,58 +541,101 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
el.hidden = !text;
|
||||
}
|
||||
|
||||
function syncBridgeEditor() {
|
||||
const addr = document.getElementById('edit-bridge-addr').value.trim();
|
||||
const browser = bridgeEditing && bridgeEditing.kind === 'browser';
|
||||
const usb = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
document.getElementById('edit-bridge-channel-field').hidden = browser || !(usb || isBoardAddr(addr));
|
||||
async function syncBridgeEditor() {
|
||||
const type = bridgeTypeSel.value;
|
||||
const usbKnown = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
document.getElementById('edit-bridge-type-help').textContent = TYPE_HELP[type] || '';
|
||||
document.getElementById('edit-bridge-addr-field').hidden = type === 'dmx' || type === 'browser';
|
||||
document.getElementById('edit-bridge-channel-field').hidden = type !== 'usb';
|
||||
document.getElementById('edit-bridge-dmx-field').hidden = type !== 'dmx';
|
||||
document.getElementById('edit-bridge-name').maxLength = type === 'dmx' ? 63 : 40;
|
||||
document.getElementById('edit-bridge-name').placeholder = type === 'dmx' ? 'e.g. Stage' : 'e.g. Stage left';
|
||||
const addr = document.getElementById('edit-bridge-addr');
|
||||
addr.placeholder = type === 'network' ? '192.168.1.50:8766' : '/dev/ttyACM1';
|
||||
addr.disabled = type === 'browser' || usbKnown; // a USB board is found by its MAC wherever it is plugged in
|
||||
bridgeEditModal.querySelector('.modal-content').classList.toggle('bridge-modal-wide', type === 'dmx');
|
||||
if (type === 'dmx' && !dmxLoaded && window.DmxBridges) {
|
||||
dmxLoaded = true;
|
||||
try {
|
||||
const name = await window.DmxBridges.load(bridgeEditing ? bridgeEditing.addr.slice(4) : null);
|
||||
if (bridgeEditing) document.getElementById('edit-bridge-name').value = name;
|
||||
} catch (error) {
|
||||
dmxLoaded = false;
|
||||
bridgeEditError(`Could not load the DMX bridge: ${error.message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openBridgeEditor(b) {
|
||||
bridgeEditing = b || null;
|
||||
const browser = !!b && b.kind === 'browser';
|
||||
dmxLoaded = false;
|
||||
const type = bridgeType(b);
|
||||
const browser = type === 'browser';
|
||||
const usbKnown = !!b && b.addr.startsWith('usb:');
|
||||
document.getElementById('edit-bridge-title').textContent = b ? 'Edit bridge' : 'Add bridge';
|
||||
document.getElementById('edit-bridge-name').value = b && b.name ? b.name : '';
|
||||
document.getElementById('edit-bridge-name').disabled = false;
|
||||
const addr = document.getElementById('edit-bridge-addr');
|
||||
addr.value = b ? (bridgeMac(b) || b.addr) : '';
|
||||
const usb = !!b && b.addr.startsWith('usb:');
|
||||
addr.disabled = browser || usb; // a USB board is found by its MAC wherever it is plugged in
|
||||
bridgeTypeSel.value = type;
|
||||
bridgeTypeSel.disabled = !!b; // a bridge keeps its type; delete it and add another to change it
|
||||
bridgeTypeSel.querySelector('option[value="browser"]').hidden = !browser;
|
||||
document.getElementById('edit-bridge-name').value = b ? (type === 'dmx' ? (b.status && b.status.name) || '' : b.name || '') : '';
|
||||
document.getElementById('edit-bridge-addr').value = b && type !== 'dmx' ? (bridgeMac(b) || b.addr) : '';
|
||||
const ch = document.getElementById('edit-bridge-channel');
|
||||
ch.value = b && b.status && b.status.channel ? String(b.status.channel) : '';
|
||||
document.getElementById('edit-bridge-status').textContent = b
|
||||
? (usb ? 'A USB board, found by its MAC wherever it is plugged in' + (b.status && b.status.port ? ' (now on ' + b.status.port + ')' : '') + '. ' : '') + (browser ? 'The rig page of this controller. It has nothing to set and cannot be removed. ' : '') + describeBridge(b)
|
||||
? (usbKnown && b.status && b.status.port ? 'Now on ' + b.status.port + '. ' : '') + describeBridge(b)
|
||||
: '';
|
||||
document.getElementById('edit-bridge-save-btn').hidden = browser;
|
||||
bridgeEditError('');
|
||||
document.getElementById('edit-bridge-dmx-universes').textContent = '';
|
||||
bridgeEditError('');
|
||||
syncBridgeEditor();
|
||||
bridgeEditModal.classList.add('active');
|
||||
}
|
||||
|
||||
// Save a USB or network board: its place in the list, its name and its radio channel
|
||||
async function saveBoard() {
|
||||
const usbKnown = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
const addr = usbKnown ? bridgeEditing.addr : document.getElementById('edit-bridge-addr').value.trim();
|
||||
const type = bridgeTypeSel.value;
|
||||
if (!addr) return type === 'network' ? 'Enter the board\'s host:port' : 'Enter the board\'s port (/dev/...)';
|
||||
if (type === 'network' && (isBoardAddr(addr) || !/^[^\s:]+:\d+$/.test(addr))) return 'A network bridge is host:port, e.g. 192.168.1.50:8766';
|
||||
if (type === 'usb' && !isBoardAddr(addr)) return 'A USB bridge is its port, e.g. /dev/ttyACM1';
|
||||
if (addr !== (bridgeEditing && bridgeEditing.addr) && bridgeAddrs.includes(addr)) return 'That bridge is already in the list';
|
||||
const raw = document.getElementById('edit-bridge-channel').value.trim();
|
||||
const list = bridgeEditing ? bridgeAddrs.map((a) => (a === bridgeEditing.addr ? addr : a)) : [...bridgeAddrs, addr];
|
||||
const channelChanged = type === 'usb' && raw !== '' &&
|
||||
raw !== String(bridgeEditing && bridgeEditing.status && bridgeEditing.status.channel || '');
|
||||
const name = document.getElementById('edit-bridge-name').value.trim();
|
||||
let err = '';
|
||||
if (!bridgeEditing || addr !== bridgeEditing.addr) {
|
||||
err = await putBridges(list, bridgeEditing ? 'Bridge updated.' : 'Bridge added.');
|
||||
}
|
||||
if (!err && name !== ((bridgeEditing && bridgeEditing.name) || '')) err = await setBridgeName(addr, name);
|
||||
if (!err && channelChanged) err = await setBridgeChannel(addr, raw);
|
||||
return err;
|
||||
}
|
||||
|
||||
async function saveDmx() {
|
||||
try {
|
||||
const r = await window.DmxBridges.save(document.getElementById('edit-bridge-name').value);
|
||||
showSettingsMessage(r.created ? 'DMX bridge added.' : 'DMX bridge saved.', 'success');
|
||||
} catch (error) {
|
||||
return error.message;
|
||||
}
|
||||
loadBridgeSettings();
|
||||
setTimeout(loadBridgeSettings, 1500); // the fixtures come up a moment later
|
||||
return '';
|
||||
}
|
||||
|
||||
if (bridgeEditModal && bridgeEditForm) {
|
||||
const close = () => bridgeEditModal.classList.remove('active');
|
||||
document.getElementById('edit-bridge-close-btn').addEventListener('click', close);
|
||||
document.getElementById('edit-bridge-addr').addEventListener('input', syncBridgeEditor);
|
||||
bridgeTypeSel.addEventListener('change', () => {
|
||||
bridgeEditError('');
|
||||
syncBridgeEditor();
|
||||
});
|
||||
bridgeEditForm.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
const usb = !!bridgeEditing && bridgeEditing.addr.startsWith('usb:');
|
||||
const addr = usb ? bridgeEditing.addr : document.getElementById('edit-bridge-addr').value.trim();
|
||||
const raw = document.getElementById('edit-bridge-channel').value.trim();
|
||||
if (!addr) return;
|
||||
if (addr !== (bridgeEditing && bridgeEditing.addr) && bridgeAddrs.includes(addr)) {
|
||||
bridgeEditError('That bridge is already in the list');
|
||||
return;
|
||||
}
|
||||
const list = bridgeEditing ? bridgeAddrs.map((a) => (a === bridgeEditing.addr ? addr : a)) : [...bridgeAddrs, addr];
|
||||
const channelChanged = isBoardAddr(addr) && raw !== '' &&
|
||||
raw !== String(bridgeEditing && bridgeEditing.status && bridgeEditing.status.channel || '');
|
||||
const name = document.getElementById('edit-bridge-name').value.trim();
|
||||
let err = '';
|
||||
if (!bridgeEditing || addr !== bridgeEditing.addr) {
|
||||
err = await putBridges(list, bridgeEditing ? 'Bridge updated.' : 'Bridge added.');
|
||||
}
|
||||
if (!err && name !== ((bridgeEditing && bridgeEditing.name) || '')) err = await setBridgeName(addr, name);
|
||||
if (!err && channelChanged) err = await setBridgeChannel(addr, raw);
|
||||
bridgeEditError('');
|
||||
const err = bridgeTypeSel.value === 'dmx' ? await saveDmx() : await saveBoard();
|
||||
if (err) bridgeEditError(err);
|
||||
else close();
|
||||
});
|
||||
|
||||
@@ -93,7 +93,7 @@ function renderOutputsList(outputs) {
|
||||
delBtn.className = 'btn btn-danger btn-small';
|
||||
delBtn.textContent = 'Delete';
|
||||
delBtn.addEventListener('click', async () => {
|
||||
if (!confirm(`Delete output "${out.name}"?`)) return;
|
||||
if (!await uiConfirm(`Delete output "${out.name}"?`)) return;
|
||||
const res = await fetch(`/outputs/${encodeURIComponent(id)}`, { method: 'DELETE' });
|
||||
if (!res.ok) {
|
||||
alert('Failed to delete output.');
|
||||
@@ -183,16 +183,15 @@ function readOutputForm() {
|
||||
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const btn = document.getElementById('outputs-btn');
|
||||
const modal = document.getElementById('outputs-modal');
|
||||
const editModal = document.getElementById('edit-output-modal');
|
||||
const form = document.getElementById('edit-output-form');
|
||||
if (!btn || !modal || !form) return;
|
||||
if (!btn || !form) return;
|
||||
|
||||
btn.addEventListener('click', () => {
|
||||
modal.classList.add('active');
|
||||
loadOutputsModal();
|
||||
// The Outputs tab of Settings: the page's Outputs button (kept hidden) opens Settings on it
|
||||
btn.addEventListener('click', () => window.openSettingsTab && window.openSettingsTab('outputs'));
|
||||
document.addEventListener('settings-tab', (e) => {
|
||||
if (e.detail === 'outputs') loadOutputsModal();
|
||||
});
|
||||
document.getElementById('outputs-close-btn').addEventListener('click', () => modal.classList.remove('active'));
|
||||
document.getElementById('output-add-btn').addEventListener('click', () => openOutputEditor(null, null));
|
||||
document.getElementById('edit-output-close-btn').addEventListener('click', () => editModal.classList.remove('active'));
|
||||
document.getElementById('edit-output-protocol').addEventListener('change', syncOutputProtocolFields);
|
||||
|
||||
@@ -538,13 +538,10 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
? zoneData.group_ids.map((g) => String(g).trim()).filter((g) => g.length > 0)
|
||||
: [];
|
||||
|
||||
const sequence = [
|
||||
{ v: '1', clear_presets: true, save: true },
|
||||
{ v: '1', presets: wirePresets, save: true },
|
||||
];
|
||||
// No clear_presets here: drivers keep their stored presets unless the Clear Devices button is used
|
||||
const sequence = [{ v: '1', presets: wirePresets, save: true }];
|
||||
if (groupIds.length) {
|
||||
sequence[0].groups = groupIds;
|
||||
sequence[1].groups = groupIds;
|
||||
}
|
||||
if (deviceNames.length > 0 && zonePresetIds.length > 0) {
|
||||
const sel = { v: '1', select: zonePresetIds.slice() };
|
||||
|
||||
+32
-21
@@ -1235,7 +1235,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
deleteButton.className = 'btn btn-danger btn-small';
|
||||
deleteButton.textContent = 'Delete';
|
||||
deleteButton.addEventListener('click', async () => {
|
||||
const confirmed = confirm(`Delete preset "${label.textContent}"?`);
|
||||
const confirmed = await uiConfirm(`Delete preset "${label.textContent}"?`);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
@@ -1339,32 +1339,43 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
openEditor();
|
||||
});
|
||||
}
|
||||
const presetSyncButton = document.getElementById('preset-sync-btn');
|
||||
if (presetSyncButton) {
|
||||
presetSyncButton.addEventListener('click', async () => {
|
||||
presetSyncButton.disabled = true;
|
||||
try {
|
||||
const res = await fetch('/presets/sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: '{}',
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.error || `HTTP ${res.status}`);
|
||||
alert(`Synced ${data.presets_sent} preset(s) to all drivers.`);
|
||||
} catch (err) {
|
||||
alert(`Preset sync failed: ${err.message}`);
|
||||
} finally {
|
||||
presetSyncButton.disabled = false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (presetClearDeviceButton) {
|
||||
presetClearDeviceButton.addEventListener('click', async () => {
|
||||
const section = document.querySelector('.presets-section[data-zone-id]');
|
||||
const deviceNames = tabDeviceNamesFromSection(section);
|
||||
if (!deviceNames.length) {
|
||||
alert('No devices found in the current zone.');
|
||||
return;
|
||||
}
|
||||
if (!window.confirm('Clear all presets on current zone devices?')) {
|
||||
if (!await uiConfirm('Clear the stored presets on every device? Sync to Devices sends them again.')) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
const zoneId = section && section.dataset.zoneId;
|
||||
let groupIds = [];
|
||||
if (zoneId) {
|
||||
const zr = await fetch(`/zones/${zoneId}`, { headers: { Accept: 'application/json' } });
|
||||
if (zr.ok) {
|
||||
groupIds = zoneGroupIdsFromTabData(await zr.json());
|
||||
}
|
||||
}
|
||||
const clearMsg = { v: '1', clear_presets: true, save: true };
|
||||
if (groupIds.length) clearMsg.groups = groupIds;
|
||||
await postDriverSequence([clearMsg], [], 0.05, { groupIds });
|
||||
const res = await fetch('/presets/clear', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: '{}',
|
||||
});
|
||||
const data = await res.json().catch(() => ({}));
|
||||
if (!res.ok) throw new Error(data.error || `HTTP ${res.status}`);
|
||||
alert('Cleared presets on all devices.');
|
||||
} catch (error) {
|
||||
console.error('Clear device presets failed:', error);
|
||||
alert('Failed to clear presets on devices.');
|
||||
alert(`Clear devices failed: ${error.message}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1816,7 +1827,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (presetRemoveFromTabButton) {
|
||||
presetRemoveFromTabButton.addEventListener('click', async () => {
|
||||
if (!currentEditTabId || !currentEditId) return;
|
||||
if (!window.confirm('Remove this preset from this zone?')) return;
|
||||
if (!await uiConfirm('Remove this preset from this zone?')) return;
|
||||
await removePresetFromTab(currentEditTabId, currentEditId);
|
||||
clearForm();
|
||||
closeEditor();
|
||||
|
||||
@@ -179,7 +179,7 @@ document.addEventListener("DOMContentLoaded", () => {
|
||||
deleteButton.className = "btn btn-danger btn-small";
|
||||
deleteButton.textContent = "Delete";
|
||||
deleteButton.addEventListener("click", async () => {
|
||||
const confirmed = confirm(`Delete profile "${label.textContent}"?`);
|
||||
const confirmed = await uiConfirm(`Delete profile "${label.textContent}"?`);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
|
||||
+210
-19
@@ -32,6 +32,8 @@ const seqTl = {
|
||||
raf: 0,
|
||||
drag: null,
|
||||
hoverX: null, // the pointer's last x over the timeline: where the zoom buttons zoom around
|
||||
clipboard: null, // a copied or cut clip {play, len, timed, bpm}: kept while the page is open, for any sequence
|
||||
cursor: null, // {uid, at}: the last empty spot clicked on a track, where Paste puts a clip
|
||||
};
|
||||
|
||||
/* ------------------------------------------------------------------ basics */
|
||||
@@ -381,10 +383,17 @@ function seqTlOnOpen(doc) {
|
||||
function tlNotice(text) {
|
||||
const n = tlEl('tl-notice');
|
||||
if (!n) return;
|
||||
clearTimeout(tlFlash.timer);
|
||||
n.textContent = text;
|
||||
n.hidden = !text;
|
||||
}
|
||||
|
||||
/** A notice that goes away by itself after a few seconds */
|
||||
function tlFlash(text) {
|
||||
tlNotice(text);
|
||||
tlFlash.timer = setTimeout(() => tlNotice(''), 3500);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------ render */
|
||||
|
||||
function tlHeadWidth() {
|
||||
@@ -420,6 +429,19 @@ function tlSelect(sel) {
|
||||
document.querySelectorAll('#tl-canvas .tl-clip').forEach((el) => el.classList.toggle('sel', !!sel && sel.clip === parseInt(el.dataset.id, 10)));
|
||||
document.querySelectorAll('#tl-canvas .tl-track .tl-head').forEach((el) => el.classList.toggle('sel', !!sel && sel.track === parseInt(el.dataset.uid, 10)));
|
||||
tlRenderInspector();
|
||||
requestAnimationFrame(tlRevealSelection); // after the inspector has taken its height
|
||||
}
|
||||
|
||||
/** The inspector takes height under the tracks, so a clip or track picked near the bottom can end up below the
|
||||
* tracks' scroll area: scroll that area (only it, and only up or down) just enough to show it again. */
|
||||
function tlRevealSelection() {
|
||||
const el = document.querySelector('#tl-canvas .tl-clip.sel, #tl-canvas .tl-track .tl-head.sel');
|
||||
const scroller = el && el.closest('.tl-scroll');
|
||||
if (!scroller) return;
|
||||
const view = scroller.getBoundingClientRect();
|
||||
const box = el.getBoundingClientRect();
|
||||
const bottom = view.top + scroller.clientHeight; // above a horizontal scrollbar
|
||||
if (box.bottom > bottom) scroller.scrollTop += box.bottom - bottom + 4;
|
||||
}
|
||||
|
||||
function tlRender() {
|
||||
@@ -527,14 +549,19 @@ function tlRender() {
|
||||
head.appendChild(id);
|
||||
}
|
||||
head.dataset.uid = String(t.uid);
|
||||
head.addEventListener('click', () => tlSelect({ track: t.uid }));
|
||||
head.addEventListener('click', () => {
|
||||
seqTl.cursor = null; // Paste then goes to this track's first free place
|
||||
tlSelect({ track: t.uid });
|
||||
});
|
||||
|
||||
const lane = document.createElement('div');
|
||||
lane.className = 'tl-lane';
|
||||
lane.dataset.uid = String(t.uid);
|
||||
lane.style.width = `${W}px`;
|
||||
lane.addEventListener('pointerdown', (e) => {
|
||||
if (e.target === lane && seqTl.sel) tlSelect(null);
|
||||
if (e.target !== lane) return;
|
||||
seqTl.cursor = { uid: t.uid, at: tlQ(tlLaneX(lane, e.clientX) / seqTl.ppb, true) }; // where Paste goes
|
||||
if (seqTl.sel) tlSelect(null);
|
||||
});
|
||||
lane.addEventListener('dblclick', (e) => {
|
||||
if (e.target !== lane) return;
|
||||
@@ -793,6 +820,9 @@ function tlInspectClip(host, c) {
|
||||
const btns = document.createElement('div');
|
||||
btns.className = 'tl-insp-btns';
|
||||
btns.appendChild(tlBtn('Edit', 'Edit the preset or sequence', () => tlEditPlay(c.play)));
|
||||
btns.appendChild(tlBtn('Copy', 'Copy the clip (Ctrl+C)', () => tlCopy(c, false)));
|
||||
btns.appendChild(tlBtn('Cut', 'Cut the clip (Ctrl+X)', () => tlCopy(c, true)));
|
||||
if (seqTl.clipboard) btns.appendChild(tlBtn('Paste', 'Paste the copied clip after this one (Ctrl+V)', tlPaste));
|
||||
btns.appendChild(tlBtn('Delete', 'Remove the clip (Delete)', () => tlDelete(c), 'btn btn-danger btn-small'));
|
||||
host.appendChild(btns);
|
||||
}
|
||||
@@ -861,6 +891,9 @@ function tlInspectTrack(host, t) {
|
||||
down.disabled = i >= seqEd.targets.length - 1;
|
||||
btns.appendChild(up);
|
||||
btns.appendChild(down);
|
||||
if (seqTl.clipboard) {
|
||||
btns.appendChild(tlBtn('Paste', 'Paste the copied clip at the first free place on this track (Ctrl+V)', tlPaste));
|
||||
}
|
||||
btns.appendChild(
|
||||
tlBtn(
|
||||
'Remove track',
|
||||
@@ -968,11 +1001,23 @@ function tlDelete(c) {
|
||||
tlRender();
|
||||
}
|
||||
|
||||
/** The first start at or after `from` where a clip of length len fits on the track; null when none does before the end. */
|
||||
function tlFreeFrom(uid, from, len) {
|
||||
let start = tlR(Math.max(0, from));
|
||||
for (let guard = 0; guard < 256; guard++) {
|
||||
if (start + len > tlLoopLen() + TL_EPS) return null;
|
||||
if (tlFits(uid, start, len)) return start;
|
||||
const blocker = tlClipsOn(uid).find((x) => x.start + x.len > start + TL_EPS && x.start < start + len - TL_EPS);
|
||||
start = tlR(blocker ? blocker.start + blocker.len : start + len);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function tlDuplicate(c) {
|
||||
let start = tlR(c.start + c.len);
|
||||
for (let guard = 0; guard < 256 && !tlFits(c.uid, start, c.len); guard++) {
|
||||
const blocker = tlClipsOn(c.uid).find((x) => x.start + x.len > start + TL_EPS && x.start < start + c.len - TL_EPS);
|
||||
start = tlR(blocker ? blocker.start + blocker.len : start + c.len);
|
||||
const start = tlFreeFrom(c.uid, c.start + c.len, c.len);
|
||||
if (start === null) {
|
||||
tlFlash('No room after this clip before the end of the sequence.');
|
||||
return;
|
||||
}
|
||||
const d = { ...c, id: seqTl.nextId++, start };
|
||||
seqTl.clips.push(d);
|
||||
@@ -980,6 +1025,50 @@ function tlDuplicate(c) {
|
||||
tlRender();
|
||||
}
|
||||
|
||||
/** Copy the clip (what it plays and its length); cut also removes it. */
|
||||
function tlCopy(c, cut) {
|
||||
seqTl.clipboard = { play: c.play, len: c.len, timed: tlTimed(), bpm: tlBpm() };
|
||||
if (cut) tlDelete(c);
|
||||
else tlRenderInspector(); // shows Paste
|
||||
}
|
||||
|
||||
/** Paste the copied clip: after the selected clip on its track, else at the spot last clicked on a track, else at
|
||||
* the first free place on the selected track. The pasted clip is selected, so pasting again lines copies up. */
|
||||
function tlPaste() {
|
||||
const cb = seqTl.clipboard;
|
||||
if (!cb) return;
|
||||
let len = cb.len;
|
||||
if (cb.timed !== tlTimed()) len = cb.timed ? (len * tlBpm()) / 60 : (len * 60) / cb.bpm; // seconds <-> beats
|
||||
len = tlR(Math.max(tlMin(), len));
|
||||
const sel = seqTl.sel;
|
||||
const after = sel && sel.clip ? tlClip(sel.clip) : null;
|
||||
let uid;
|
||||
let from;
|
||||
if (after) {
|
||||
uid = after.uid;
|
||||
from = after.start + after.len;
|
||||
} else if (seqTl.cursor && tlTrack(seqTl.cursor.uid)) {
|
||||
uid = seqTl.cursor.uid;
|
||||
from = seqTl.cursor.at;
|
||||
} else if (sel && sel.track && tlTrack(sel.track)) {
|
||||
uid = sel.track;
|
||||
from = 0;
|
||||
} else {
|
||||
tlFlash('Click a track (or a clip) to paste on, then paste again.');
|
||||
return;
|
||||
}
|
||||
const start = tlFreeFrom(uid, from, len);
|
||||
if (start === null) {
|
||||
tlFlash('No room for the clip there before the end of the sequence.');
|
||||
return;
|
||||
}
|
||||
const c = { id: seqTl.nextId++, uid, start, len, play: cb.play };
|
||||
seqTl.clips.push(c);
|
||||
seqTl.sel = { clip: c.id };
|
||||
seqTl.cursor = null;
|
||||
tlRender();
|
||||
}
|
||||
|
||||
async function tlEditPlay(play) {
|
||||
const id = String(play || '').slice(2);
|
||||
if (!id) return;
|
||||
@@ -1283,6 +1372,93 @@ function tlDragEnd(e, cancelled) {
|
||||
tlRender();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------- where Play plays it */
|
||||
|
||||
// "sim": the simulated bars only (/sequences/<id>/preview), the real fixtures keep their show. "both": the
|
||||
// zone's normal playback. The switch shows on host builds with the simulator; elsewhere Play is "both".
|
||||
const TL_TARGET_KEY = 'seqTlTarget';
|
||||
seqTl.target = 'both';
|
||||
seqTl.simAvail = false;
|
||||
|
||||
function tlSimOnly() {
|
||||
return seqTl.simAvail && seqTl.target === 'sim';
|
||||
}
|
||||
|
||||
function tlSetTarget(t) {
|
||||
seqTl.target = t === 'both' ? 'both' : 'sim';
|
||||
const box = tlEl('tl-target');
|
||||
if (box) {
|
||||
box.querySelectorAll('button[data-target]').forEach((b) => {
|
||||
const on = b.dataset.target === seqTl.target;
|
||||
b.classList.toggle('on', on);
|
||||
b.setAttribute('aria-pressed', String(on));
|
||||
});
|
||||
}
|
||||
const play = tlEl('tl-play');
|
||||
if (play) {
|
||||
play.title = tlSimOnly()
|
||||
? 'Save, then play it on the simulator only'
|
||||
: 'Save, then play it in the current zone';
|
||||
}
|
||||
const stop = tlEl('tl-stop');
|
||||
if (stop) stop.title = tlSimOnly() ? 'Stop the preview on the simulator' : 'Stop the sequence';
|
||||
}
|
||||
|
||||
async function tlInitTarget() {
|
||||
const box = tlEl('tl-target');
|
||||
if (!box) return;
|
||||
box.querySelectorAll('button[data-target]').forEach((b) =>
|
||||
b.addEventListener('click', () => {
|
||||
tlSetTarget(b.dataset.target);
|
||||
try {
|
||||
localStorage.setItem(TL_TARGET_KEY, seqTl.target);
|
||||
} catch (_) {
|
||||
/* private mode */
|
||||
}
|
||||
}));
|
||||
let saved = null;
|
||||
try {
|
||||
saved = localStorage.getItem(TL_TARGET_KEY);
|
||||
} catch (_) {
|
||||
/* private mode */
|
||||
}
|
||||
try {
|
||||
const r = await fetch('/sim/api/config', { cache: 'no-store' });
|
||||
seqTl.simAvail = r.ok; // the board: no simulator
|
||||
} catch (_) {
|
||||
seqTl.simAvail = false;
|
||||
}
|
||||
box.hidden = !seqTl.simAvail;
|
||||
tlSetTarget(saved === 'both' ? 'both' : 'sim');
|
||||
}
|
||||
|
||||
/** Save the edited sequence, then play it: on the simulator only, or in the current zone. */
|
||||
async function tlPlay() {
|
||||
const ok = await saveSequenceEditor();
|
||||
if (ok === false || !sequenceEditorId) return;
|
||||
const zid = resolveZoneIdForPresetStripRefresh();
|
||||
try {
|
||||
if (tlSimOnly()) {
|
||||
// The rig shows it: open the simulator beside the editor if it is closed
|
||||
if (!document.getElementById('sim-pane') && window.simSplit) window.simSplit.open('rig');
|
||||
const res = await fetch(`/sequences/${encodeURIComponent(sequenceEditorId)}/preview`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
|
||||
body: JSON.stringify({ zone_id: zid ? String(zid) : '' }),
|
||||
});
|
||||
if (!res.ok) {
|
||||
const j = await res.json().catch(() => ({}));
|
||||
throw new Error(j.error || `Preview failed (${res.status})`);
|
||||
}
|
||||
} else if (!tlLoop()) await fireOneShot(sequenceEditorId, zid);
|
||||
else await requestBackendSequencePlay(sequenceEditorId, zid, null);
|
||||
} catch (err) {
|
||||
alert(err.message || 'Could not play it.');
|
||||
}
|
||||
}
|
||||
|
||||
window.seqTlPlay = tlPlay;
|
||||
|
||||
/* --------------------------------------------------------------- playhead */
|
||||
|
||||
function tlStartPoll() {
|
||||
@@ -1302,7 +1478,11 @@ async function tlPoll() {
|
||||
const r = await fetch('/sequences/status', { cache: 'no-store', headers: { Accept: 'application/json' } });
|
||||
const st = r.ok ? await r.json() : null;
|
||||
let lanes = null;
|
||||
if (st && st.overlay && st.overlay.active && String(st.overlay.sequence_id) === sequenceEditorId) lanes = st.overlay.lanes;
|
||||
let looping = !!(st && st.active && String(st.sequence_id) === sequenceEditorId);
|
||||
if (st && st.preview && st.preview.active && String(st.preview.sequence_id) === sequenceEditorId) {
|
||||
lanes = st.preview.lanes; // the simulator's preview of this sequence
|
||||
looping = !!st.preview.loop;
|
||||
} else if (st && st.overlay && st.overlay.active && String(st.overlay.sequence_id) === sequenceEditorId) lanes = st.overlay.lanes;
|
||||
else if (st && st.active && String(st.sequence_id) === sequenceEditorId) lanes = st.lanes;
|
||||
if (Array.isArray(lanes)) {
|
||||
const { map } = tlToLanes();
|
||||
@@ -1313,7 +1493,6 @@ async function tlPoll() {
|
||||
const timed = l.mode === 'time';
|
||||
const s = m.starts[l.step] != null ? m.starts[l.step] : 0;
|
||||
const into = timed ? (l.elapsed_ms || 0) / 1000 : l.beat_in_step || 0;
|
||||
const looping = !!(st && st.active && String(st.sequence_id) === sequenceEditorId);
|
||||
const now = performance.now();
|
||||
const next = {
|
||||
pos: s + into,
|
||||
@@ -1456,18 +1635,18 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
e.target.value = timed ? 'beats' : 'time';
|
||||
tlSetUnits(timed);
|
||||
});
|
||||
on('tl-play', 'click', async () => {
|
||||
const ok = await saveSequenceEditor();
|
||||
if (ok === false || !sequenceEditorId) return;
|
||||
const zid = resolveZoneIdForPresetStripRefresh();
|
||||
try {
|
||||
if (!tlLoop()) await fireOneShot(sequenceEditorId, zid);
|
||||
else await requestBackendSequencePlay(sequenceEditorId, zid, null);
|
||||
} catch (err) {
|
||||
alert(err.message || 'Could not play it.');
|
||||
}
|
||||
});
|
||||
on('tl-play', 'click', tlPlay);
|
||||
tlInitTarget();
|
||||
on('tl-stop', 'click', async () => {
|
||||
if (tlSimOnly()) {
|
||||
// Only the preview stops: the real fixtures keep their show
|
||||
try {
|
||||
await fetch('/sequences/preview/stop', { method: 'POST', headers: { Accept: 'application/json' } });
|
||||
} catch (_) {
|
||||
/* nothing to stop */
|
||||
}
|
||||
return;
|
||||
}
|
||||
// A one-shot plays over the zone: end it as well as the looping sequence
|
||||
try {
|
||||
await fetch('/sequences/overlay/stop', { method: 'POST', headers: { Accept: 'application/json' } });
|
||||
@@ -1493,8 +1672,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
else tlUndo();
|
||||
return;
|
||||
}
|
||||
if ((e.ctrlKey || e.metaKey) && k === 'v') {
|
||||
if (!seqTl.clipboard) return;
|
||||
e.preventDefault();
|
||||
tlPaste();
|
||||
return;
|
||||
}
|
||||
const c = seqTl.sel && seqTl.sel.clip ? tlClip(seqTl.sel.clip) : null;
|
||||
if (!c) return;
|
||||
if ((e.ctrlKey || e.metaKey) && (k === 'c' || k === 'x')) {
|
||||
if (k === 'c' && String(window.getSelection ? window.getSelection() : '')) return; // copying page text
|
||||
e.preventDefault();
|
||||
tlCopy(c, k === 'x');
|
||||
return;
|
||||
}
|
||||
if (e.key === 'Delete' || e.key === 'Backspace') {
|
||||
e.preventDefault();
|
||||
tlDelete(c);
|
||||
|
||||
+4
-12
@@ -604,7 +604,7 @@ async function refreshEditTabSequencesUi(zoneId) {
|
||||
rm.className = 'btn btn-danger btn-small';
|
||||
rm.textContent = 'Remove';
|
||||
rm.addEventListener('click', async () => {
|
||||
if (!window.confirm(`Remove this sequence from the zone?\n\n${name}`)) return;
|
||||
if (!await uiConfirm(`Remove this sequence from the zone?\n\n${name}`)) return;
|
||||
await removeSequenceFromTab(zoneId, sid);
|
||||
});
|
||||
row.appendChild(span);
|
||||
@@ -924,7 +924,7 @@ async function saveSequenceEditor() {
|
||||
async function deleteCurrentSequence() {
|
||||
const idToDelete = sequenceEditorId;
|
||||
if (!idToDelete) return;
|
||||
if (!window.confirm('Delete this sequence? It will be removed from the server.')) return;
|
||||
if (!await uiConfirm('Delete this sequence? It will be removed from the server.')) return;
|
||||
try {
|
||||
const res = await fetch(`/sequences/${idToDelete}`, { method: 'DELETE' });
|
||||
if (!res.ok) throw new Error('Delete failed');
|
||||
@@ -1057,16 +1057,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
const tryBtn = document.getElementById('sequence-editor-try-btn');
|
||||
if (tryBtn) {
|
||||
tryBtn.addEventListener('click', async () => {
|
||||
if (!sequenceEditorId) return;
|
||||
if ((await saveSequenceEditor()) === false) return;
|
||||
const zid = resolveZoneIdForPresetStripRefresh();
|
||||
const loopCb = document.getElementById('sequence-editor-loop');
|
||||
try {
|
||||
if (loopCb && !loopCb.checked) await fireOneShot(sequenceEditorId, zid);
|
||||
else await requestBackendSequencePlay(sequenceEditorId, zid, null);
|
||||
} catch (e) {
|
||||
alert(e.message || 'Could not play it.');
|
||||
}
|
||||
// The timeline's Play: saves, then plays where its Sim only / Both switch says
|
||||
if (typeof window.seqTlPlay === 'function') await window.seqTlPlay();
|
||||
});
|
||||
}
|
||||
});
|
||||
+10
-26
@@ -68,7 +68,7 @@
|
||||
frame.src = VIEWS[view];
|
||||
}
|
||||
if (pane) {
|
||||
pane.querySelectorAll('.sim-pane-tabs button').forEach((b) =>
|
||||
pane.querySelectorAll('.sim-pane-tabs button[data-view]').forEach((b) =>
|
||||
b.setAttribute('aria-pressed', String(b.dataset.view === view)));
|
||||
}
|
||||
save({ view });
|
||||
@@ -222,13 +222,18 @@
|
||||
'<div class="sim-pane-tabs" role="group" aria-label="Show the rig or the preset editor">' +
|
||||
'<button type="button" data-view="rig">Rig</button>' +
|
||||
'<button type="button" data-view="presets">Presets</button>' +
|
||||
'<span class="sim-pane-tabs-gap"></span>' +
|
||||
'<button type="button" data-act="popout" title="Open the simulator in its own window">Pop out ↗</button>' +
|
||||
'<button type="button" data-act="close" title="Close the simulator">Close</button>' +
|
||||
'</div>' +
|
||||
'<iframe class="sim-pane-frame" title="Simulator"></iframe>' +
|
||||
'</div>';
|
||||
pane.querySelectorAll('.sim-pane-tabs button').forEach((b) => {
|
||||
pane.querySelectorAll('.sim-pane-tabs button[data-view]').forEach((b) => {
|
||||
b.setAttribute('aria-pressed', String(b.dataset.view === view));
|
||||
b.addEventListener('click', () => setView(b.dataset.view));
|
||||
});
|
||||
pane.querySelector('[data-act="popout"]').addEventListener('click', popOut);
|
||||
pane.querySelector('[data-act="close"]').addEventListener('click', close);
|
||||
|
||||
// Swipes that start in the rig (same origin, so its document can be listened to)
|
||||
frame = pane.querySelector('iframe');
|
||||
@@ -332,15 +337,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
// The Menu's Preset editor entry: open the pane on the presets, or switch the open pane to them
|
||||
function openPresets() {
|
||||
if (!isOpen()) {
|
||||
open('presets');
|
||||
return;
|
||||
}
|
||||
setView('presets'); // the controller stays on screen; on a phone the pager switches to it
|
||||
}
|
||||
const paneItems = []; // the Menu's Pop out and Close entries
|
||||
const paneItems = []; // the Menu's Close entry
|
||||
|
||||
function addMenuEntries() {
|
||||
// A header button for the Menu item to forward to, as the other entries do (help.js)
|
||||
@@ -363,22 +360,9 @@
|
||||
item.textContent = 'Simulator';
|
||||
const settingsItem = menu.querySelector('[data-target="settings-btn"]');
|
||||
menu.insertBefore(item, settingsItem);
|
||||
const presetsReal = document.createElement('button');
|
||||
presetsReal.id = 'sim-presets-btn';
|
||||
presetsReal.hidden = true;
|
||||
presetsReal.addEventListener('click', openPresets);
|
||||
document.body.appendChild(presetsReal);
|
||||
const presetsItem = document.createElement('button');
|
||||
presetsItem.type = 'button';
|
||||
presetsItem.className = 'edit-mode-only';
|
||||
presetsItem.dataset.target = 'sim-presets-btn';
|
||||
presetsItem.textContent = 'Preset editor';
|
||||
menu.insertBefore(presetsItem, settingsItem);
|
||||
|
||||
// Pop out and Close: in the Menu only while the pane is open (syncMenu). The menu forwards its clicks to
|
||||
// the real buttons with these ids (help.js)
|
||||
// Close: in the Menu only while the pane is open (syncMenu). The menu forwards its clicks to
|
||||
// the real button with this id (help.js)
|
||||
for (const [label, id, action] of [
|
||||
['Pop out ↗', 'sim-popout-btn', popOut],
|
||||
['Close simulator', 'sim-close-btn', close],
|
||||
]) {
|
||||
const real = document.createElement('button');
|
||||
|
||||
+108
-1
@@ -886,6 +886,12 @@ body.preset-ui-run .edit-mode-only {
|
||||
letter-spacing: 0.04em;
|
||||
}
|
||||
|
||||
.device-kind-badge--dmx {
|
||||
color: #ffd38e;
|
||||
border-color: #86622f;
|
||||
background-color: #3a2e1d;
|
||||
}
|
||||
|
||||
.device-kind-badge--sim {
|
||||
color: #8ec5ff;
|
||||
border-color: #2f5b86;
|
||||
@@ -1495,12 +1501,23 @@ html.simulated-bpm-mode .seq-switch-toggle-wrap {
|
||||
|
||||
/* Editors opened from Settings (the Bridges and Outputs tabs) */
|
||||
#edit-bridge-modal.active,
|
||||
#dmx-defs-modal.active,
|
||||
#edit-output-modal.active,
|
||||
#edit-user-modal.active,
|
||||
#edit-role-modal.active {
|
||||
z-index: 1090;
|
||||
}
|
||||
|
||||
/* uiConfirm (ui_confirm.js): opened from inside any other modal, so above them all */
|
||||
.modal.ui-confirm-modal.active {
|
||||
z-index: 1200;
|
||||
}
|
||||
|
||||
.ui-confirm-message {
|
||||
white-space: pre-line;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
/* JS-appended overlays (e.g. preset “From Palette”, add-preset-to-zone) — must sit above #preset-editor-modal */
|
||||
.modal.modal-child-overlay.active {
|
||||
z-index: 1080;
|
||||
@@ -2641,6 +2658,37 @@ html.simulated-bpm-mode .seq-switch-toggle-wrap {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Devices modal: search plus "Hide sim devices" (devices.js) */
|
||||
.devices-list-filters {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.75rem;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.devices-list-filters .list-search-input {
|
||||
flex: 1 1 12rem;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.devices-hide-sim {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.devices-hide-sim input {
|
||||
width: auto;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
/* !important: the rows set display: flex inline */
|
||||
.profiles-list.hide-sim > .profiles-row[data-device-kind="sim"] {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* Sequence editor: the timeline inspector's group and driver checkboxes */
|
||||
.seq-chip {
|
||||
display: inline-flex;
|
||||
@@ -2764,8 +2812,40 @@ html.simulated-bpm-mode .seq-switch-toggle-wrap {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
/* The editor is a column: the timeline takes the height left under the header, its tracks and browser
|
||||
* reaching the bottom of the window (the inspector stays its own height under them) */
|
||||
#sequence-editor-modal .modal-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#sequence-editor-modal .tl:not([hidden]) {
|
||||
flex: 1 1 auto;
|
||||
min-height: 20rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
#sequence-editor-modal .tl-main {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* The clip inspector takes its own height under the tracks: the tracks area shrinks and scrolls instead of
|
||||
* the inspector covering the bottom tracks (seq_timeline.js keeps the selected clip in view) */
|
||||
#sequence-editor-modal .tl-inspector {
|
||||
flex: 0 0 auto;
|
||||
border-top: 1px solid #444;
|
||||
}
|
||||
|
||||
#sequence-editor-modal .tl-scroll,
|
||||
#sequence-editor-modal .tl-browser-list {
|
||||
max-height: none;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.tl {
|
||||
--tl-head-w: 11rem;
|
||||
--tl-head-w: 7.5rem;
|
||||
--tl-track-h: 3.5rem;
|
||||
margin: 0.5rem 0 0.75rem 0;
|
||||
border: 1px solid #111;
|
||||
@@ -2809,6 +2889,10 @@ html.simulated-bpm-mode .seq-switch-toggle-wrap {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.tl-tgroup[hidden] {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.tl-tgroup > :last-child {
|
||||
border-right: 0;
|
||||
}
|
||||
@@ -3696,3 +3780,26 @@ body.sim-swipe .sim-pager {
|
||||
transition: none;
|
||||
}
|
||||
}
|
||||
|
||||
/* DMX bridge editor: universes with their outputs and fixtures (dmx_bridge.js) */
|
||||
.dmx-modal-content, #edit-bridge-modal .modal-content.bridge-modal-wide { max-width: min(860px, calc(100vw - 32px)); width: 100%; max-height: calc(100vh - 32px); overflow-y: auto; }
|
||||
#edit-bridge-modal .modal-content { max-height: calc(100vh - 32px); overflow-y: auto; }
|
||||
.modal-content select.bridge-type-select { width: 100%; padding: 0.5rem; background-color: #3a3a3a; color: white; border: 1px solid #4a4a4a; border-radius: 4px; font-size: 1rem; }
|
||||
.dmx-universe { border: 1px solid #4a4a4a; border-radius: 6px; padding: 0.75rem; margin-top: 1rem; background: #333; }
|
||||
.dmx-universe-head { display: flex; gap: 0.5rem; align-items: flex-end; flex-wrap: wrap; }
|
||||
.dmx-universe-head > div { flex: 1 1 10rem; }
|
||||
.dmx-universe-head > div.dmx-narrow { flex: 0 0 7rem; }
|
||||
.dmx-universe h4 { margin: 0.9rem 0 0.4rem; font-size: 0.95rem; }
|
||||
.dmx-row { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; padding: 0.35rem 0; border-top: 1px solid #3f3f3f; }
|
||||
.dmx-row:first-of-type { border-top: 0; }
|
||||
.modal-content .dmx-row input, .dmx-row select { width: auto; flex: 1 1 8rem; min-width: 0; padding: 0.35rem 0.45rem; font-size: 0.9rem; }
|
||||
.modal-content .dmx-row input.dmx-num { flex: 0 0 5.5rem; }
|
||||
.modal-content .dmx-row input.dmx-mac { flex: 1 1 9rem; font-family: monospace; }
|
||||
.dmx-row select { background-color: #3a3a3a; color: white; border: 1px solid #4a4a4a; border-radius: 4px; }
|
||||
.dmx-row .dmx-check { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; font-weight: normal; white-space: nowrap; }
|
||||
.modal-content .dmx-row .dmx-check input { flex: 0 0 auto; width: auto; }
|
||||
.dmx-row .dmx-info { flex: 0 0 auto; font-size: 0.8rem; color: #aaa; white-space: nowrap; }
|
||||
.dmx-row-label { flex: 0 0 100%; font-size: 0.75rem; color: #999; }
|
||||
.dmx-def-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; }
|
||||
.dmx-def-meta > div { flex: 1 1 9rem; }
|
||||
.dmx-textarea { width: 100%; padding: 0.5rem; background-color: #3a3a3a; color: white; border: 1px solid #4a4a4a; border-radius: 4px; font-family: monospace; font-size: 0.9rem; }
|
||||
@@ -0,0 +1,62 @@
|
||||
// In-page confirmation dialog: uiConfirm(message, { okLabel }) resolves true (OK) or false (Cancel).
|
||||
// Used instead of window.confirm(), which some browsers and webviews block (it then returns false at
|
||||
// once, so a Delete button silently does nothing). Enter confirms, Escape or a click outside cancels.
|
||||
|
||||
(function () {
|
||||
let modal = null;
|
||||
let pending = null; // the open dialog's resolve; a new one cancels it
|
||||
|
||||
function build() {
|
||||
modal = document.createElement('div');
|
||||
modal.className = 'modal ui-confirm-modal';
|
||||
modal.setAttribute('role', 'alertdialog');
|
||||
modal.setAttribute('aria-modal', 'true');
|
||||
modal.innerHTML =
|
||||
'<div class="modal-content">' +
|
||||
'<p class="ui-confirm-message" id="ui-confirm-message"></p>' +
|
||||
'<div class="modal-actions">' +
|
||||
'<button type="button" class="btn btn-secondary" data-ui-confirm="cancel">Cancel</button>' +
|
||||
'<button type="button" class="btn btn-danger" data-ui-confirm="ok">OK</button>' +
|
||||
'</div></div>';
|
||||
modal.setAttribute('aria-labelledby', 'ui-confirm-message');
|
||||
modal.addEventListener('click', (e) => {
|
||||
const which = e.target && e.target.dataset ? e.target.dataset.uiConfirm : undefined;
|
||||
if (which === 'ok') close(true);
|
||||
else if (which === 'cancel' || e.target === modal) close(false);
|
||||
});
|
||||
modal.addEventListener('keydown', (e) => {
|
||||
if (e.key === 'Escape') {
|
||||
e.preventDefault();
|
||||
e.stopPropagation(); // not the modal underneath
|
||||
close(false);
|
||||
} else if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
close(true);
|
||||
}
|
||||
});
|
||||
document.body.appendChild(modal);
|
||||
}
|
||||
|
||||
function close(result) {
|
||||
if (modal) modal.classList.remove('active');
|
||||
const resolve = pending;
|
||||
pending = null;
|
||||
if (resolve) resolve(result);
|
||||
}
|
||||
|
||||
window.uiConfirm = function (message, opts) {
|
||||
if (!modal) build();
|
||||
if (pending) close(false);
|
||||
const o = opts || {};
|
||||
modal.querySelector('.ui-confirm-message').textContent = String(message);
|
||||
const ok = modal.querySelector('[data-ui-confirm="ok"]');
|
||||
// "Delete group …?" gets a Delete button, unless the caller names one
|
||||
const verb = /^(Delete|Remove|Clear|Reboot)\b/.exec(String(message));
|
||||
ok.textContent = o.okLabel || (verb ? verb[1] : 'OK');
|
||||
modal.classList.add('active');
|
||||
ok.focus();
|
||||
return new Promise((resolve) => {
|
||||
pending = resolve;
|
||||
});
|
||||
};
|
||||
})();
|
||||
+2
-2
@@ -788,7 +788,7 @@ function renderZonesListModal(tabs, tabOrder, currentZoneId) {
|
||||
deleteButton.className = "btn btn-danger btn-small";
|
||||
deleteButton.textContent = "Delete";
|
||||
deleteButton.addEventListener("click", async () => {
|
||||
const confirmed = confirm(`Delete zone "${label.textContent}"?`);
|
||||
const confirmed = await uiConfirm(`Delete zone "${label.textContent}"?`);
|
||||
if (!confirmed) {
|
||||
return;
|
||||
}
|
||||
@@ -1008,7 +1008,7 @@ async function refreshEditTabPresetsUi(zoneId) {
|
||||
removeBtn.textContent = "Remove";
|
||||
removeBtn.addEventListener("click", async () => {
|
||||
if (typeof window.removePresetFromTab !== "function") return;
|
||||
if (!window.confirm(`Remove this preset from the zone?\n\n${name}`)) return;
|
||||
if (!await uiConfirm(`Remove this preset from the zone?\n\n${name}`)) return;
|
||||
await window.removePresetFromTab(zoneId, presetId);
|
||||
await refreshEditTabPresetsUi(zoneId);
|
||||
});
|
||||
|
||||
+185
-85
@@ -65,14 +65,13 @@
|
||||
</div>
|
||||
<button type="button" data-target="profiles-btn">Profiles</button>
|
||||
<button type="button" class="edit-mode-only" data-target="devices-btn">Devices</button>
|
||||
<button type="button" class="edit-mode-only" id="menu-hide-sim-btn" aria-pressed="false" title="Hide the rig page's simulated drivers (/sim/) in the Devices list">Hide sim devices</button>
|
||||
<button type="button" class="edit-mode-only" data-target="groups-btn">Groups</button>
|
||||
<button type="button" class="edit-mode-only" data-target="outputs-btn">Outputs</button>
|
||||
<button type="button" class="edit-mode-only" data-target="sequences-btn">Sequences</button>
|
||||
<button type="button" class="edit-mode-only" data-target="zones-btn">Zones</button>
|
||||
<button type="button" class="edit-mode-only" data-target="presets-btn">Presets</button>
|
||||
<button type="button" class="edit-mode-only" data-target="patterns-btn">Patterns</button>
|
||||
<button type="button" class="edit-mode-only" data-target="color-palette-btn">Colour Palette</button>
|
||||
<button type="button" class="edit-mode-only" data-target="audio-btn">Audio</button>
|
||||
<button type="button" class="edit-mode-only" data-target="settings-btn">Settings</button>
|
||||
<button type="button" data-target="help-btn">Help</button>
|
||||
</div>
|
||||
@@ -186,7 +185,10 @@
|
||||
</div>
|
||||
<small id="devices-add-status" class="muted-text" aria-live="polite"></small>
|
||||
</div>
|
||||
<input type="search" id="devices-search" class="list-search-input" placeholder="Search devices…" autocomplete="off">
|
||||
<div class="devices-list-filters">
|
||||
<input type="search" id="devices-search" class="list-search-input" placeholder="Search devices…" autocomplete="off">
|
||||
<label class="devices-hide-sim" title="Hide the rig page's simulated drivers (/sim/)"><input type="checkbox" id="devices-hide-sim"> Hide sim devices <span id="devices-sim-count" class="muted-text"></span></label>
|
||||
</div>
|
||||
<div id="devices-list-modal" class="profiles-list"></div>
|
||||
<div class="modal-actions" style="align-items:center;gap:0.75rem;flex-wrap:wrap;">
|
||||
<button type="button" class="btn btn-secondary" id="devices-ping-btn" title="ESP-NOW broadcast ping (3 s)">Ping drivers</button>
|
||||
@@ -294,6 +296,11 @@
|
||||
<option value="brg">BRG</option>
|
||||
<option value="bgr">BGR</option>
|
||||
</select>
|
||||
<label for="edit-device-espnow-pin" style="margin-top:0.5rem;display:block;">Data pin (GPIO 0–10, 20, 21)</label>
|
||||
<input type="number" id="edit-device-espnow-pin" min="0" max="21" step="1" placeholder="10">
|
||||
<label for="edit-device-espnow-channel" style="margin-top:0.5rem;display:block;">ESP-NOW channel (1–13)</label>
|
||||
<input type="number" id="edit-device-espnow-channel" min="1" max="13" step="1" placeholder="11">
|
||||
<small class="muted-text">Changing the channel restarts the driver onto it: move the bridge to the same channel too, or the driver is out of reach.</small>
|
||||
</div>
|
||||
<div id="edit-device-address-wifi-wrap" style="margin-top:0.75rem;" hidden>
|
||||
<label for="edit-device-address-wifi">Address (IP or hostname)</label>
|
||||
@@ -348,7 +355,8 @@
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-primary" id="preset-add-btn">Add</button>
|
||||
<button type="button" class="btn btn-secondary" id="import-preset-btn">Import</button>
|
||||
<button class="btn btn-danger" id="preset-clear-device-btn">Clear Device Presets</button>
|
||||
<button type="button" class="btn btn-secondary" id="preset-sync-btn" title="Send every preset to every driver and save it there">Sync to Devices</button>
|
||||
<button type="button" class="btn btn-secondary" id="preset-clear-device-btn" title="Delete every stored preset on every device">Clear Devices</button>
|
||||
</div>
|
||||
<input type="search" id="presets-search" class="list-search-input" placeholder="Search presets…" autocomplete="off">
|
||||
<div id="presets-list" class="profiles-list"></div>
|
||||
@@ -392,6 +400,11 @@
|
||||
<button type="button" class="tl-tbtn" id="tl-play" title="Save, then play it in the current zone">▶</button>
|
||||
<button type="button" class="tl-tbtn" id="tl-stop" title="Stop the sequence">■</button>
|
||||
</div>
|
||||
<!-- Where Play plays it (host builds with the simulator): the simulated bars only, or everywhere -->
|
||||
<div class="tl-tgroup tl-seg" id="tl-target" role="group" aria-label="Where Play plays the sequence" hidden>
|
||||
<button type="button" data-target="sim" aria-pressed="true" title="Play it on the simulator only: the real fixtures keep their show">Sim only</button>
|
||||
<button type="button" data-target="both" aria-pressed="false" title="Play it on the simulator and the real fixtures, in the current zone">Both</button>
|
||||
</div>
|
||||
<div class="tl-lcd" title="Playhead position"><span id="tl-pos">1.1</span></div>
|
||||
<!-- What clips are measured in -->
|
||||
<label class="tl-tfield" title="Clips last beats, or seconds"><select id="sequence-editor-mode">
|
||||
@@ -1114,7 +1127,7 @@
|
||||
<li><strong>Settings</strong> (Edit mode): the controller's name, the ESP-NOW channel, its mDNS hostname and the static IPs it tries on the Ethernet link.</li>
|
||||
<li>Network changes apply after the controller restarts.</li>
|
||||
<li>The controller talks to the drivers over ESP-NOW itself; there is no bridge to set up.</li>
|
||||
<li>Configure a driver with <strong>Driver</strong> in Settings, over ESP-NOW, or over USB with <code>led-cli</code> on a computer.</li>
|
||||
<li>Configure a driver over ESP-NOW, or over USB with <code>led-cli</code> on a computer.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
@@ -1122,14 +1135,35 @@
|
||||
</div>
|
||||
|
||||
<!-- Audio Modal -->
|
||||
<div id="audio-modal" class="modal">
|
||||
<div class="modal-content audio-modal-content">
|
||||
<!-- Settings Modal -->
|
||||
<div id="settings-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-head">
|
||||
<h2>Audio Beat Detection</h2>
|
||||
<h2>Device Settings</h2>
|
||||
<div class="modal-top-actions">
|
||||
<button type="button" class="btn btn-secondary" id="audio-close-btn">Close</button>
|
||||
<button type="button" class="btn btn-secondary" id="settings-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="settings-tabs" role="tablist" aria-label="Settings sections">
|
||||
<button type="button" class="settings-tab-btn active" role="tab" id="settings-tab-network" data-settings-tab="network" aria-selected="true" aria-controls="settings-panel-network">Network</button>
|
||||
<button type="button" class="settings-tab-btn" role="tab" id="settings-tab-bridges" data-settings-tab="bridges" aria-selected="false" aria-controls="settings-panel-bridges">Bridges</button>
|
||||
<button type="button" class="settings-tab-btn" role="tab" id="settings-tab-outputs" data-settings-tab="outputs" aria-selected="false" aria-controls="settings-panel-outputs">Outputs</button>
|
||||
<button type="button" class="settings-tab-btn" role="tab" id="settings-tab-audio" data-settings-tab="audio" aria-selected="false" aria-controls="settings-panel-audio">Audio</button>
|
||||
<button type="button" class="settings-tab-btn" role="tab" id="settings-tab-users" data-settings-tab="users" aria-selected="false" aria-controls="settings-panel-users">Users</button>
|
||||
</div>
|
||||
|
||||
<div id="settings-message" class="message"></div>
|
||||
|
||||
<div id="settings-panel-outputs" class="settings-tab-panel" data-settings-panel="outputs" role="tabpanel" aria-labelledby="settings-tab-outputs" hidden>
|
||||
<p class="muted-text">Network pixel fixtures (DDP, Art-Net, sACN). Test sends a red, green, blue and white pattern; zones do not render to outputs on this controller.</p>
|
||||
<div id="outputs-list-modal" class="profiles-list"></div>
|
||||
<div class="modal-actions">
|
||||
<button type="button" class="btn btn-primary" id="output-add-btn">Add output</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings-panel-audio" class="settings-tab-panel" data-settings-panel="audio" role="tabpanel" aria-labelledby="settings-tab-audio" hidden>
|
||||
<div id="audio-modal" class="audio-modal-content">
|
||||
<div class="form-group audio-device-block">
|
||||
<label for="audio-device-select">Input device</label>
|
||||
<div class="profiles-actions audio-device-select-row">
|
||||
@@ -1177,69 +1211,34 @@
|
||||
<button type="button" class="btn btn-secondary" id="audio-stop-btn">Stop</button>
|
||||
<button type="button" class="btn btn-secondary" id="audio-reset-btn" disabled title="Clear stuck BPM / beat tracking">Reset detector</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Settings Modal -->
|
||||
<div id="settings-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2>Device Settings</h2>
|
||||
<div class="settings-tabs" role="tablist" aria-label="Settings sections">
|
||||
<button type="button" class="settings-tab-btn active" role="tab" id="settings-tab-controller" data-settings-tab="controller" aria-selected="true" aria-controls="settings-panel-controller">Controller</button>
|
||||
<button type="button" class="settings-tab-btn" role="tab" id="settings-tab-network" data-settings-tab="network" aria-selected="false" aria-controls="settings-panel-network">Network</button>
|
||||
<button type="button" class="settings-tab-btn" role="tab" id="settings-tab-led-tool" data-settings-tab="led-tool" aria-selected="false" aria-controls="settings-panel-led-tool">Driver</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings-panel-controller" class="settings-tab-panel active" data-settings-panel="controller" role="tabpanel" aria-labelledby="settings-tab-controller">
|
||||
<p class="muted-text">Controller name and ESP-NOW channel.</p>
|
||||
|
||||
<div id="settings-message" class="message"></div>
|
||||
|
||||
<!-- Device Name -->
|
||||
<div class="settings-section">
|
||||
<h3>Device</h3>
|
||||
<form id="device-form">
|
||||
<div class="form-group">
|
||||
<label for="device-name-input">Device Name</label>
|
||||
<input type="text" id="device-name-input" name="device_name" placeholder="e.g. led-controller" required>
|
||||
<small>This name may be used for mDNS (e.g. <code>name.local</code>) and UI display.</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="wifi-channel-input">WiFi channel (ESP-NOW)</label>
|
||||
<input type="number" id="wifi-channel-input" name="wifi_channel" min="1" max="11" required>
|
||||
<small>Stored for reference: the controller's ESP-NOW channel is set at build time (<code>make menuconfig</code>).</small>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="submit" class="btn btn-primary btn-full">Save device settings</button>
|
||||
</div>
|
||||
</form>
|
||||
<div id="settings-panel-users" class="settings-tab-panel" data-settings-panel="users" role="tabpanel" aria-labelledby="settings-tab-users" hidden>
|
||||
<div id="settings-users-body" class="auth-body"></div>
|
||||
</div>
|
||||
|
||||
<div id="settings-panel-bridges" class="settings-tab-panel" data-settings-panel="bridges" role="tabpanel" aria-labelledby="settings-tab-bridges" hidden>
|
||||
<!-- Bridges: USB boards and network boards that carry the radio frames (hidden where not supported) -->
|
||||
<div id="bridge-section" hidden>
|
||||
<div class="profiles-actions">
|
||||
<button type="button" class="btn btn-primary" id="bridge-add-btn">Add bridge</button>
|
||||
<button type="button" class="btn btn-secondary" id="bridge-refresh-btn">Refresh</button>
|
||||
<button type="button" class="btn btn-secondary" id="dmx-defs-btn">DMX definitions</button>
|
||||
</div>
|
||||
<datalist id="bridge-ports"></datalist>
|
||||
<input type="search" id="bridge-search" class="list-search-input" placeholder="Search bridges…" autocomplete="off">
|
||||
<div id="bridge-list" class="profiles-list"></div>
|
||||
<small class="muted-text">Every ESP-NOW frame goes to each bridge, and a frame that several bridges hear arrives once. A USB board is its port (<code>/dev/ttyACM1</code>); a network board is <code>host:port</code> (UDP). A DMX bridge sends its universes to Art-Net, sACN or USB-DMX 40 times a second; each of its fixtures is a driver of its own, listed under Devices.</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings-panel-network" class="settings-tab-panel" data-settings-panel="network" role="tabpanel" aria-labelledby="settings-tab-network" hidden>
|
||||
<div id="settings-panel-network" class="settings-tab-panel active" data-settings-panel="network" role="tabpanel" aria-labelledby="settings-tab-network">
|
||||
<div class="settings-section">
|
||||
<h3>Connected</h3>
|
||||
<div id="network-status" class="muted-text">Loading…</div>
|
||||
</div>
|
||||
|
||||
<!-- Bridges: USB boards and network boards that carry the radio frames (hidden where not supported) -->
|
||||
<div class="settings-section" id="bridge-section" hidden>
|
||||
<h3>Bridges</h3>
|
||||
<small>Every ESP-NOW frame goes to each bridge, and a frame that several bridges hear arrives once. A USB board is its port (<code>/dev/ttyACM1</code>); a network board is <code>host:port</code> (UDP).</small>
|
||||
<div id="bridge-list"></div>
|
||||
<form id="bridge-add-form">
|
||||
<div class="form-group">
|
||||
<label for="bridge-add-input">Add a bridge</label>
|
||||
<input type="text" id="bridge-add-input" list="bridge-ports" placeholder="/dev/ttyACM1 or 192.168.1.50:8766" maxlength="79" autocomplete="off">
|
||||
<datalist id="bridge-ports"></datalist>
|
||||
</div>
|
||||
<div class="btn-group">
|
||||
<button type="button" class="btn btn-secondary btn-full" id="bridge-refresh-btn">Refresh</button>
|
||||
<button type="submit" class="btn btn-primary btn-full">Add</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Network -->
|
||||
<div class="settings-section">
|
||||
@@ -1264,11 +1263,6 @@
|
||||
<input type="text" id="ap-password-input" placeholder="open (no password)" minlength="8" maxlength="63" autocomplete="off">
|
||||
<small>8 to 63 characters (WPA2). Leave empty for an open network.</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="bridge-input">Bridges</label>
|
||||
<input type="text" id="bridge-input" placeholder="off (drivers over the radio)" maxlength="400" autocomplete="off">
|
||||
<small>Comma-separated: USB boards (<code>/dev/ttyACM1</code>) and <code>host:port</code> (UDP, e.g. led-simulator on port 8766). While any are set, the controller sends its frames to them instead of the radio. Applied on the next restart; the list above applies at once.</small>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Static IPs</label>
|
||||
<small>Tried in order each time the Ethernet link comes up; the first whose gateway answers is used. If none does, or the list is empty, DHCP is used. With no DHCP server, as on a cable straight to a PC, the controller is at <code>192.168.4.1</code>; give the PC a static IP such as <code>192.168.4.2</code>.</small>
|
||||
@@ -1286,29 +1280,10 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="settings-panel-led-tool" class="settings-tab-panel" data-settings-panel="led-tool" role="tabpanel" aria-labelledby="settings-tab-led-tool" hidden>
|
||||
<iframe id="led-tool-iframe" title="LED device settings editor" src="about:blank" class="settings-led-tool-iframe"></iframe>
|
||||
</div>
|
||||
|
||||
<div class="modal-actions">
|
||||
<button class="btn btn-secondary" id="settings-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Outputs Modal (network pixel fixtures: DDP, Art-Net, sACN; USB-DMX is stored only) -->
|
||||
<div id="outputs-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2>Outputs</h2>
|
||||
<p class="muted-text">Network pixel fixtures (DDP, Art-Net, sACN). Test sends a red, green, blue and white pattern; zones do not render to outputs on this controller.</p>
|
||||
<div id="outputs-list-modal" class="profiles-list"></div>
|
||||
<div class="modal-actions">
|
||||
<button type="button" class="btn btn-primary" id="output-add-btn">Add output</button>
|
||||
<button type="button" class="btn btn-secondary" id="outputs-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-output-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<h2 id="edit-output-title">Output</h2>
|
||||
@@ -1378,11 +1353,136 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-bridge-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-head">
|
||||
<h2 id="edit-bridge-title">Edit bridge</h2>
|
||||
<div class="modal-top-actions">
|
||||
<button type="submit" form="edit-bridge-form" class="btn btn-primary" id="edit-bridge-save-btn">Save</button>
|
||||
<button type="button" class="btn btn-secondary" id="edit-bridge-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<form id="edit-bridge-form" novalidate>
|
||||
<label for="edit-bridge-type">Type</label>
|
||||
<select id="edit-bridge-type" class="bridge-type-select">
|
||||
<option value="usb">USB bridge board</option>
|
||||
<option value="network">Network bridge board (UDP)</option>
|
||||
<option value="dmx">DMX bridge (Art-Net, sACN, USB-DMX)</option>
|
||||
<option value="browser" hidden>Rig page of this controller</option>
|
||||
</select>
|
||||
<small id="edit-bridge-type-help" class="muted-text" style="display:block;margin-top:0.35rem;"></small>
|
||||
<label for="edit-bridge-name">Name</label>
|
||||
<input type="text" id="edit-bridge-name" placeholder="e.g. Stage left" maxlength="40" autocomplete="off">
|
||||
<div id="edit-bridge-addr-field">
|
||||
<label for="edit-bridge-addr">Address</label>
|
||||
<input type="text" id="edit-bridge-addr" list="bridge-ports" placeholder="/dev/ttyACM1" maxlength="79" autocomplete="off">
|
||||
</div>
|
||||
<div id="edit-bridge-channel-field">
|
||||
<label for="edit-bridge-channel">Radio channel (1 to 13)</label>
|
||||
<input type="number" id="edit-bridge-channel" min="1" max="13" placeholder="leave as it is">
|
||||
</div>
|
||||
<div id="edit-bridge-dmx-field" hidden>
|
||||
<div id="edit-bridge-dmx-universes"></div>
|
||||
<div class="profiles-actions" style="margin-top:0.75rem;">
|
||||
<button type="button" class="btn btn-secondary" id="edit-bridge-dmx-add-universe">Add universe</button>
|
||||
</div>
|
||||
<small class="muted-text" style="display:block;margin-top:0.75rem;">Each universe's 512 channels go to each of its outputs 40 times a second. Each fixture is a driver of its own, listed under Devices; one without a MAC gets one when the bridge is saved.</small>
|
||||
</div>
|
||||
<small id="edit-bridge-status" class="muted-text" style="display:block;margin-top:0.75rem;"></small>
|
||||
<p id="edit-bridge-error" class="engine-error" hidden></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="dmx-defs-modal" class="modal">
|
||||
<div class="modal-content dmx-modal-content">
|
||||
<div class="modal-head">
|
||||
<h2>DMX definitions</h2>
|
||||
<div class="modal-top-actions">
|
||||
<button type="button" class="btn btn-primary" id="dmx-defs-new-btn">New</button>
|
||||
<button type="button" class="btn btn-secondary" id="dmx-defs-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<div id="dmx-defs-list" class="profiles-list"></div>
|
||||
<form id="dmx-def-form" hidden novalidate>
|
||||
<h3 id="dmx-def-title" style="margin-top:1rem;">Definition</h3>
|
||||
<label for="dmx-def-name">Name</label>
|
||||
<input type="text" id="dmx-def-name" maxlength="63" autocomplete="off">
|
||||
<div class="dmx-def-meta">
|
||||
<div><label for="dmx-def-manufacturer">Manufacturer</label><input type="text" id="dmx-def-manufacturer" maxlength="63" autocomplete="off"></div>
|
||||
<div><label for="dmx-def-model">Model</label><input type="text" id="dmx-def-model" maxlength="63" autocomplete="off"></div>
|
||||
<div><label for="dmx-def-mode">Mode</label><input type="text" id="dmx-def-mode" maxlength="63" autocomplete="off"></div>
|
||||
</div>
|
||||
<label for="dmx-def-channels">Channels, one per line, in order</label>
|
||||
<textarea id="dmx-def-channels" rows="8" class="dmx-textarea" spellcheck="false"></textarea>
|
||||
<small class="muted-text">Red, Green, Blue and White (or "Red 1", "Red 2"… for each pixel) take the pattern's colours. Dimmer and Intensity are set full, Strobe and Shutter open. Any other channel holds its default.</small>
|
||||
<label for="dmx-def-defaults">Defaults, one "Channel = value" (0 to 255) per line</label>
|
||||
<textarea id="dmx-def-defaults" rows="3" class="dmx-textarea" spellcheck="false" placeholder="Tilt = 127"></textarea>
|
||||
<div class="profiles-actions" style="margin-top:0.75rem;">
|
||||
<button type="submit" class="btn btn-primary">Save definition</button>
|
||||
<button type="button" class="btn btn-danger" id="dmx-def-delete-btn">Delete</button>
|
||||
</div>
|
||||
<p id="dmx-def-error" class="engine-error" hidden></p>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-user-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-head">
|
||||
<h2 id="edit-user-title">Edit user</h2>
|
||||
<div class="modal-top-actions">
|
||||
<button type="submit" form="edit-user-form" class="btn btn-primary" id="edit-user-save-btn">Save</button>
|
||||
<button type="button" class="btn btn-secondary" id="edit-user-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<form id="edit-user-form">
|
||||
<label for="edit-user-name">Username</label>
|
||||
<input type="text" id="edit-user-name" maxlength="32" autocomplete="off" required>
|
||||
<small class="muted-text">1 to 32 letters, digits, _ . -</small>
|
||||
<label for="edit-user-role" style="margin-top:0.75rem;display:block;">Role</label>
|
||||
<select id="edit-user-role"></select>
|
||||
<label for="edit-user-pass" style="margin-top:0.75rem;display:block;">Password</label>
|
||||
<input type="password" id="edit-user-pass" maxlength="128" autocomplete="new-password">
|
||||
<small id="edit-user-pass-help" class="muted-text">8 to 128 characters.</small>
|
||||
<p id="edit-user-error" class="engine-error" hidden></p>
|
||||
<div class="profiles-actions" style="margin-top:1rem;">
|
||||
<button type="button" class="btn btn-danger" id="edit-user-delete-btn">Delete user</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="edit-role-modal" class="modal">
|
||||
<div class="modal-content">
|
||||
<div class="modal-head">
|
||||
<h2 id="edit-role-title">Edit role</h2>
|
||||
<div class="modal-top-actions">
|
||||
<button type="submit" form="edit-role-form" class="btn btn-primary" id="edit-role-save-btn">Save</button>
|
||||
<button type="button" class="btn btn-secondary" id="edit-role-close-btn">Close</button>
|
||||
</div>
|
||||
</div>
|
||||
<form id="edit-role-form">
|
||||
<label for="edit-role-name">Role name</label>
|
||||
<input type="text" id="edit-role-name" maxlength="32" autocomplete="off" required>
|
||||
<label class="zone-devices-label">Permissions</label>
|
||||
<small class="muted-text">none: hidden · view: read · control: play, stop, brightness, identify · edit: change anything.</small>
|
||||
<div id="edit-role-perms" class="profiles-list" style="margin-top:0.5rem;"></div>
|
||||
<p id="edit-role-error" class="engine-error" hidden></p>
|
||||
<div class="profiles-actions" style="margin-top:1rem;">
|
||||
<button type="button" class="btn btn-danger" id="edit-role-delete-btn">Delete role</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="/static/ui_confirm.js"></script>
|
||||
<script src="/static/auth.js"></script>
|
||||
<script src="/static/fetch_cache.js"></script>
|
||||
<script src="/static/zone-devices-panel.js"></script>
|
||||
<script src="/static/groups.js"></script>
|
||||
<script src="/static/zones.js"></script>
|
||||
<script src="/static/dmx_bridge.js"></script>
|
||||
<script src="/static/help.js"></script>
|
||||
<script src="/static/color_palette.js"></script>
|
||||
<script src="/static/bundle_io.js"></script>
|
||||
|
||||
Reference in new issue
Block a user