0.1.17
build / test (push) Waiting to run

This commit is contained in:
Mateusz Gruszczyński committed 2026-11-17 16:50:28 +01:00
1 parent 528017b0e6
commit 9e65aa0103
27 files changed
+1053 -101

No files matched your search

+46 -4
View File
@@ -157,6 +157,7 @@
recordings: ['Recordings', pageRecordings],
tuners: ['Tuners & scanning', pageTuners],
stats: ['Statistics', pageStats],
pair: ['Pair a TV', pagePair],
signal: ['Antenna meter', pageSignal],
access: ['Access & sharing', pageAccess],
logs: ['Logs', pageLogs],
@@ -380,7 +381,8 @@
return '<div class="kv ts-kv">' +
(tu ? '<span>Transmission</span><span class="mono">' + esc([tu.modulation, tu.code_rate && 'FEC ' + tu.code_rate, tu.guard_interval && 'GI ' + tu.guard_interval, tu.transmission_mode].filter(Boolean).join(' · ')) + '</span>' : '') +
'<span>Packets</span><span class="mono">' + ts.packets.toLocaleString() + ' · ' + ts.pids + ' PIDs · ' + esc(T('stuffing')) + ' ' + pct(ts.null_packets) + (ts.scrambled ? ' · ' + esc(T('scrambled')) + ' ' + pct(ts.scrambled) : '') + '</span>' +
'<span>Errors</span><span class="mono ' + (ts.cc_errors || ts.tei_errors ? 'warn-text' : '') + '">CC ' + ts.cc_errors + ' · TEI ' + ts.tei_errors + '</span></div>';
'<span>Errors</span><span class="mono ' + (ts.cc_errors || ts.tei_errors ? 'warn-text' : '') + '">CC ' + ts.cc_errors + ' · TEI ' + ts.tei_errors + '</span>' +
'<span title="' + esc(T('Time of the last signal statistics read from the demodulator and the longest pause between reads of the stream. High values point to a slow driver (I2C) and can make playback stutter.')) + '">' + esc(T('Driver timing')) + '</span><span class="mono ' + (a.status_ms > 150 || a.read_gap_ms > 300 ? 'warn-text' : '') + '">' + esc(T('stats')) + ' ' + (a.status_ms || 0) + ' ms · ' + esc(T('max gap')) + ' ' + (a.read_gap_ms || 0) + ' ms</span></div>';
}
/** Adapter hardware: bus, driver, product, ids, frequency range, capabilities. */
function hardwareBlock(t) {
@@ -468,7 +470,7 @@
add('ber', 'Bit error rate (BER)', [{ name: 'BER', values: pick(TS, 'ber') }], { unit: 'ber', min: 0, floor: 1e-6, noArea: true });
add('tserr', 'Stream errors', [{ name: 'CC', values: pick(TS, 'cc') }, { name: 'TEI', values: pick(TS, 'tei') }], { min: 0, floor: 1, bars: true });
return '<div class="panel tuner"><div class="t-head"><div><h3>' + esc(t.name) + '</h3><div class="t-meta">' + esc(t.id) + ' · ' + esc(t.delivery_systems.join(' / ')) + ' · ' + esc(t.path) + '</div></div>' +
'<div class="actions">' + (!t.enabled ? '<span class="pill">disabled</span>' : t.busy ? '<span class="pill warn">scanning</span>' :
'<div class="actions">' + (!t.enabled ? '<span class="pill">disabled</span>' : t.busy ? (t.idle_scan ? '<span class="pill blue" title="' + esc(T('Background scan of saved muxes while the tuner is free – stops at once when someone watches.')) + '">' + esc(T('background scan')) + '</span>' : '<span class="pill warn">scanning</span>') :
a ? '<span class="pill ' + (a.state === 'locked' ? 'ok' : a.state === 'tuning' ? 'warn' : 'err') + '">' + esc(a.state === 'locked' ? 'LOCK' : a.state) + '</span>' : '<span class="pill">idle</span>') + '</div></div>' +
(a ? '<div class="kv"><span>Mux</span><span>' + esc(a.tuning) + (a.network_name ? ' · ' + esc(a.network_name) : '') + '</span>' +
'<span>Clients</span><span>' + a.subscribers + (a.top_priority ? ' · priority ' + esc(a.top_priority) : '') + '</span>' +
@@ -1267,7 +1269,7 @@
api('GET', '/api/adapters').then(function (list) {
$('#ad-list').innerHTML = list.length ? '<table><tbody>' + list.map(function (a) {
return '<tr><td><b>' + esc(a.name) + '</b><div class="small muted mono">' + esc(a.id + ' · ' + a.path) + '</div></td><td class="small">' + esc(a.delivery_systems.join(' / ')) + '</td>' +
'<td>' + (a.active ? '<span class="pill ok">' + esc(a.active.tuning) + '</span>' : a.busy ? '<span class="pill warn">scanning</span>' : '<span class="pill">idle</span>') + '</td>' +
'<td>' + (a.active ? '<span class="pill ok">' + esc(a.active.tuning) + '</span>' : a.busy ? (a.idle_scan ? '<span class="pill blue" title="' + esc(T('Background scan of saved muxes while the tuner is free – stops at once when someone watches.')) + '">' + esc(T('background scan')) + '</span>' : '<span class="pill warn">scanning</span>') : '<span class="pill">idle</span>') + '</td>' +
'<td>' + sw(a.enabled, 'data-ad="' + esc(a.id) + '"' + (isAdmin() ? '' : ' disabled')) + '</td></tr>';
}).join('') + '</tbody></table>' : '<div class="empty">No DVB cards detected. Check <code>ls /dev/dvb</code>, the driver and firmware (for Si2168: <code>dvb-demod-si2168-*.fw</code>) and membership in group <code>video</code>.</div>';
$$('[data-ad]').forEach(function (i) { i.addEventListener('change', function () { api('PUT', '/api/adapters/' + i.getAttribute('data-ad'), { enabled: i.checked }).then(adapters).catch(fail); }); });
@@ -1416,7 +1418,7 @@
function pageAccess(view) {
view.innerHTML = head('Security', 'Access & sharing', 'Playlists for TVs, tokens, access control (ACL) and panel accounts.') +
'<div class="panel"><header><h2>Playlists & EPG</h2></header><div id="links"></div></div>' +
'<div class="grid g2" style="margin-top:10px"><div class="panel"><header><h2>Access tokens</h2>' + (isAdmin() ? '<button class="btn small" id="tok-add">+ New token</button>' : '') + '</header><div id="tokens"></div>' +
'<div class="grid g2" style="margin-top:10px"><div class="panel"><header><h2>Access tokens</h2>' + (isAdmin() ? '<span class="row"><button class="btn small" id="tok-pair">' + esc(T('Pair a TV')) + '</button><button class="btn small" id="tok-add">+ New token</button></span>' : '') + '</header><div id="tokens"></div>' +
'<p class="hint">A token allows playing streams from outside the local network (e.g. a TV at your family’s place). It can be limited to selected addresses/networks.</p></div>' +
'<div class="panel"><header><h2>Panel users</h2>' + (isAdmin() ? '<button class="btn small" id="usr-add">+ New user</button>' : '') + '</header><div id="users"></div>' +
'<div class="row" style="margin-top:10px"><button class="btn small" id="pw-change">Change my password</button></div></div></div>' +
@@ -1507,6 +1509,7 @@
});
});
if (isAdmin()) {
$('#tok-pair').addEventListener('click', function () { location.hash = '#/pair'; });
$('#tok-add').addEventListener('click', function () {
var body = modal('New token', '<div class="form-grid"><label class="full">Name<input name="name" placeholder="e.g. Living room Sony TV"></label><label class="full">Allowed networks (optional)<input name="cidrs" placeholder="e.g. 83.1.2.3, 10.8.0.0/24, myhome.ddns.net"></label></div><div class="modal-foot"><button class="btn primary" id="tok-save">Create</button></div>');
$('#tok-save', body).addEventListener('click', function () {
@@ -1726,6 +1729,45 @@
app.cleanup.push(function () { release(); clearTimeout(beepTimer); if (audio) try { audio.close(); } catch (e) {} });
}
// ------------------------------------------------------------ TV PAIRING (QR code)
/** Opened from the QR code the simply-tv app shows (#/pair/CODE) or by typing the code. */
function pagePair(view, args) {
var code = (args[0] || '').toUpperCase();
view.innerHTML = head('Access', 'Pair a TV', 'The simply-tv app on the TV shows a QR code and a 6-character code. Confirming creates an access token for the TV – nothing has to be typed on the remote.') +
'<div class="panel pair-box" id="pair-box"></div>';
var box = $('#pair-box');
function ask() {
box.innerHTML = '<div class="form-grid"><label class="full">' + esc(T('Code shown on the TV')) + '<input id="pair-code" class="pair-code" maxlength="7" autocomplete="off" autocapitalize="characters" value="' + esc(code) + '"></label></div>' +
'<div class="modal-foot"><button class="btn primary" id="pair-next">' + esc(T('Continue')) + '</button></div>';
var go = function () { var c = $('#pair-code').value.replace(/[^a-z0-9]/gi, '').toUpperCase(); if (c.length === 6) location.hash = '#/pair/' + c; };
$('#pair-next').addEventListener('click', go);
$('#pair-code').addEventListener('keydown', function (e) { if (e.key === 'Enter') go(); });
$('#pair-code').focus();
}
if (!isAdmin()) { box.innerHTML = '<div class="alert err">' + esc(T('Only an administrator can pair devices.')) + '</div>'; return; }
if (!code) { ask(); return; }
api('GET', '/api/pair/' + encodeURIComponent(code)).then(function (p) {
if (p.confirmed) { box.innerHTML = '<div class="alert">' + esc(T('This TV is already paired – it finishes the setup by itself.')) + '</div>'; return; }
box.innerHTML = '<div class="kv"><span>' + esc(T('Device')) + '</span><span><b>' + esc(p.device) + '</b></span>' +
'<span>' + esc(T('Code')) + '</span><span class="mono">' + esc(p.code) + '</span>' +
'<span>' + esc(T('Address')) + '</span><span class="mono">' + esc(p.ip) + '</span></div>' +
'<div class="form-grid" style="margin-top:12px"><label>' + esc(T('Token name')) + '<input id="pair-name" value="' + esc(p.device) + '"></label>' +
'<label>' + esc(T('Allowed from (optional)')) + '<input id="pair-allow" placeholder="' + esc(T('e.g. 83.1.2.3, 10.8.0.0/24, myhome.ddns.net')) + '"></label></div>' +
'<p class="hint">' + esc(T('Check that the code matches the one on the TV screen. The token can be disabled or deleted any time in Access.')) + '</p>' +
'<div class="modal-foot"><a class="btn" href="#/access">' + esc(T('Cancel')) + '</a><button class="btn primary" id="pair-ok">' + ico('check') + esc(T('Pair this TV')) + '</button></div>';
$('#pair-ok').addEventListener('click', function () {
$('#pair-ok').disabled = true;
api('POST', '/api/pair/' + encodeURIComponent(code) + '/confirm', { name: $('#pair-name').value, allow_cidrs: $('#pair-allow').value }).then(function (r) {
box.innerHTML = '<div class="alert ok-alert">' + ico('check') + esc(T('Paired. The TV loads channels and the guide now – you can close this page.')) + ' (' + esc(r.name) + ')</div>';
}).catch(function (e) { $('#pair-ok').disabled = false; fail(e); });
});
}).catch(function (e) {
code = '';
ask();
box.insertAdjacentHTML('afterbegin', '<div class="alert err" style="margin-bottom:10px">' + esc(T(e.message)) + '</div>');
});
}
// ------------------------------------------------------------ STATISTICS
function pageStats(view) {
var days = +(SDVB_STORE.get('sdvb-statdays') || 7);