Arrs: remote host cards via SSH cache, vv_arrs_local_node(), 2h refresh schedule

This commit is contained in:
Gmer4Lfe
2026-06-03 18:16:56 -04:00
parent 6c0164713b
commit 2223cf80f7
4 changed files with 245 additions and 23 deletions
+44 -5
View File
@@ -248,16 +248,41 @@ function _arrCard(arr) {
}
// ── Node section ──────────────────────────────────────────────────────────────
function _nodeSection(node, ownerHost) {
function _nodeSection(node) {
const isLocal = node.local;
const tag = isLocal ? '<span class="vv-arr-node-tag">local</span>' : '';
const cards = node.arrs.map(_arrCard).join('');
const isMiss = node.cache_miss;
let tag, body;
if (isLocal) {
tag = '<span class="vv-arr-node-tag">local</span>';
body = `<div class="vv-arr-cards">${node.arrs.map(_arrCard).join('')}</div>`;
} else if (isMiss) {
tag = `<span class="vv-arr-node-tag" style="background:#111;border-color:#222;color:#333;">no data</span>
<button id="vv-arr-rfsh-${node.host}" onclick="vvArrsRefreshRemote('${node.host}')"
style="font-size:9px;color:#4a9eff;background:#0a1a2a;border:1px solid #1a3a5a;
border-radius:3px;padding:1px 8px;cursor:pointer;margin-left:6px;">↻ Fetch now</button>`;
body = `<div style="color:#333;font-size:11px;padding:10px 0;">
No remote data yet — first fetch runs within 2 hours, or click ↻ Fetch now.
</div>`;
} else {
const age = node.cache_age || 0;
const ageStr = age < 3600 ? Math.floor(age/60) + 'm ago'
: age < 86400 ? Math.floor(age/3600) + 'h ago'
: Math.floor(age/86400) + 'd ago';
tag = `<span class="vv-arr-node-tag" style="background:#1a1000;border-color:#3a2800;color:#b87;">cached ${ageStr}</span>
<button id="vv-arr-rfsh-${node.host}" onclick="vvArrsRefreshRemote('${node.host}')"
style="font-size:9px;color:#666;background:none;border:1px solid #2a2a2a;
border-radius:3px;padding:1px 8px;cursor:pointer;margin-left:6px;">↻</button>`;
body = `<div class="vv-arr-cards" style="opacity:.85;">${node.arrs.map(_arrCard).join('')}</div>`;
}
return `<div class="vv-arr-node">
<div class="vv-arr-node-hdr">
<span class="vv-arr-node-id">${node.host.toUpperCase()}</span>
<span class="vv-arr-node-host">${node.name}</span>${tag}
</div>
<div class="vv-arr-cards">${cards}</div>
${body}
</div>`;
}
@@ -372,7 +397,7 @@ function _render(data) {
}
let html = '';
for (const node of nodes) html += _nodeSection(node, data.host);
for (const node of nodes) html += _nodeSection(node);
html += _syncSection(data.sync || {}, data.recovery || {}, data.settings);
html += _settingsCard(data.settings);
@@ -393,6 +418,20 @@ setInterval(vvArrsLoad, 60000);
})();
// ── Remote node refresh ───────────────────────────────────────────────────────
function vvArrsRefreshRemote(host) {
const btn = document.getElementById('vv-arr-rfsh-' + host);
if (btn) { btn.disabled = true; btn.textContent = '↻…'; }
fetch(`/plugins/varaverk/api/arrs.php?action=refresh_remote&host=${host}&_=` + Date.now())
.then(r => r.json())
.then(d => {
if (btn) { btn.disabled = false; btn.textContent = d.ok ? '↻' : '✗'; }
// Main cache was busted — reload to show fresh data
setTimeout(vvArrsLoad, 500);
})
.catch(() => { if (btn) { btn.disabled = false; btn.textContent = '↻'; } });
}
// ── Toggle handler ────────────────────────────────────────────────────────────
function vvArrToggle(track, key, file) {
const on = !track.classList.contains('on');