Show SABnzbd's queue in the header on every page
All checks were successful
Deploy / deploy (push) Successful in 21s
All checks were successful
Deploy / deploy (push) Successful in 21s
Adds a live download figure next to the header clock, present on every page (not just Activity/System). It's populated by the same /api/sabnzbd poll those pages already use, extended to run unconditionally and to fill in a new #head-dl span — never a server-rendered fetch, so an unreachable SABnzbd can't add latency to pages that don't otherwise touch it. Quiet ink at "0 IN QUEUE" when idle, live cyan with a speed reading once something's moving.
This commit is contained in:
parent
cef66e7361
commit
d672c3f02d
3 changed files with 29 additions and 7 deletions
|
|
@ -160,14 +160,15 @@
|
|||
The queue and the active streams are the only two numbers
|
||||
that must be accurate to the second, so they are the only
|
||||
two that poll. Everything else is cached server-side and
|
||||
arrives with the page. */
|
||||
arrives with the page. The queue also drives the header's
|
||||
download row, present on every page, so it polls
|
||||
unconditionally rather than only where #sab-queue exists. */
|
||||
function setText(id, value) {
|
||||
var el = document.getElementById(id);
|
||||
if (el) el.textContent = value;
|
||||
}
|
||||
|
||||
function pollSab() {
|
||||
if (!document.getElementById('sab-queue')) return;
|
||||
fetch(BASE + '/api/sabnzbd')
|
||||
.then(function (r) { return r.json(); })
|
||||
.then(function (d) {
|
||||
|
|
@ -175,6 +176,14 @@
|
|||
setText('sab-queue', d.queue_count);
|
||||
setText('sab-speed', d.speed || '0');
|
||||
setText('sab-remaining', d.sizeleft || '—');
|
||||
var dl = document.getElementById('head-dl');
|
||||
if (dl) {
|
||||
var active = d.queue_count > 0;
|
||||
dl.textContent = active
|
||||
? d.queue_count + ' IN QUEUE · ' + (d.speed || '0')
|
||||
: '0 IN QUEUE';
|
||||
dl.classList.toggle('live', active);
|
||||
}
|
||||
})
|
||||
.catch(function () { /* offline is the dev baseline, not an error */ });
|
||||
}
|
||||
|
|
@ -190,10 +199,8 @@
|
|||
.catch(function () { /* as above */ });
|
||||
}
|
||||
|
||||
if (document.getElementById('sab-queue')) {
|
||||
pollSab();
|
||||
setInterval(pollSab, 5000);
|
||||
}
|
||||
pollSab();
|
||||
setInterval(pollSab, 5000);
|
||||
if (document.getElementById('tt-streams')) {
|
||||
pollTautulli();
|
||||
setInterval(pollTautulli, 15000);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue