fix: dashboard integration, remove port 8081, countdown persistence
This commit is contained in:
+12
-6
@@ -333,6 +333,8 @@ header {
|
||||
lastPoll: null
|
||||
};
|
||||
|
||||
let countdownRemaining = 0;
|
||||
|
||||
const $ = (sel) => document.querySelector(sel);
|
||||
|
||||
function fmtBytes(b) {
|
||||
@@ -502,7 +504,7 @@ header {
|
||||
$("#stackedLegend").innerHTML =
|
||||
'<div class="legend-item"><span class="legend-dot" style="background:var(--green)"></span>Added: ' + added + "</div>" +
|
||||
'<div class="legend-item"><span class="legend-dot" style="background:var(--blue)"></span>Updated: ' + updated + "</div>" +
|
||||
'<div class="legend-item"><span class="legend-dot" style="background:var(--purple)"></span>Deleted: " + deleted + "</div>" +
|
||||
'<div class="legend-item"><span class="legend-dot" style="background:var(--purple)"></span>Deleted: ' + deleted + "</div>" +
|
||||
'<div class="legend-item"><span class="legend-dot" style="background:var(--text-secondary)"></span>Skipped: ' + skipped + "</div>";
|
||||
}
|
||||
|
||||
@@ -673,14 +675,12 @@ header {
|
||||
const fill = $("#progressFill");
|
||||
if (!el || !fill) return;
|
||||
|
||||
let remaining = (state.data.next_sync_in || 0) - 1;
|
||||
if (remaining < 0) remaining = 0;
|
||||
el.textContent = fmtCountdown(remaining);
|
||||
countdownRemaining = Math.max(0, countdownRemaining - 1);
|
||||
el.textContent = fmtCountdown(countdownRemaining);
|
||||
|
||||
const freq = state.data.config ? state.data.config.sync_frequency * 60 : 600;
|
||||
const pct = freq > 0 ? Math.max(0, Math.min(100, ((freq - remaining) / freq) * 100)) : 100;
|
||||
const pct = freq > 0 ? Math.max(0, Math.min(100, ((freq - countdownRemaining) / freq) * 100)) : 100;
|
||||
fill.style.width = pct + "%";
|
||||
state.data.next_sync_in = remaining;
|
||||
}
|
||||
|
||||
async function poll() {
|
||||
@@ -689,6 +689,12 @@ header {
|
||||
if (!res.ok) throw new Error("HTTP " + res.status);
|
||||
state.data = await res.json();
|
||||
state.lastPoll = Date.now();
|
||||
if (state.data.last_sync && state.data.config && state.data.config.sync_frequency) {
|
||||
const syncEpoch = new Date(state.data.last_sync).getTime();
|
||||
const freqSec = state.data.config.sync_frequency * 60;
|
||||
const now = Date.now();
|
||||
countdownRemaining = Math.max(0, Math.round(((syncEpoch + freqSec * 1000) - now) / 1000));
|
||||
}
|
||||
renderStatusBar(state.data);
|
||||
renderStats(state.data);
|
||||
renderStackedBar(state.data);
|
||||
|
||||
Reference in New Issue
Block a user