324 lines
11 KiB
HTML
324 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>m3u8-downloader status</title>
|
|
<style>
|
|
:root {
|
|
--bg: #0f1115;
|
|
--panel: #161922;
|
|
--border: #262b38;
|
|
--text: #e6e8ee;
|
|
--muted: #8b909e;
|
|
--green: #3ecf8e;
|
|
--red: #f2545b;
|
|
--amber: #f2b705;
|
|
--blue: #4f8ef7;
|
|
}
|
|
* { box-sizing: border-box; }
|
|
body {
|
|
margin: 0;
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
|
|
background: var(--bg);
|
|
color: var(--text);
|
|
}
|
|
header {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
flex-wrap: wrap;
|
|
gap: 12px;
|
|
padding: 16px 24px;
|
|
border-bottom: 1px solid var(--border);
|
|
}
|
|
header h1 {
|
|
font-size: 18px;
|
|
margin: 0;
|
|
font-weight: 600;
|
|
}
|
|
.header-meta {
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 16px;
|
|
color: var(--muted);
|
|
font-size: 13px;
|
|
}
|
|
.badge {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
gap: 6px;
|
|
padding: 4px 12px;
|
|
border-radius: 999px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.03em;
|
|
}
|
|
.badge-dot { width: 8px; height: 8px; border-radius: 50%; }
|
|
.badge.healthy { background: rgba(62,207,142,0.15); color: var(--green); }
|
|
.badge.healthy .badge-dot { background: var(--green); }
|
|
.badge.degraded { background: rgba(242,84,91,0.15); color: var(--red); }
|
|
.badge.degraded .badge-dot { background: var(--red); }
|
|
.badge.unknown { background: rgba(139,144,158,0.15); color: var(--muted); }
|
|
.badge.unknown .badge-dot { background: var(--muted); }
|
|
|
|
#conn-banner {
|
|
display: none;
|
|
background: var(--red);
|
|
color: #fff;
|
|
text-align: center;
|
|
padding: 8px;
|
|
font-size: 13px;
|
|
font-weight: 600;
|
|
}
|
|
#conn-banner.show { display: block; }
|
|
|
|
main {
|
|
padding: 24px;
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
|
|
gap: 20px;
|
|
max-width: 1400px;
|
|
margin: 0 auto;
|
|
}
|
|
.card {
|
|
background: var(--panel);
|
|
border: 1px solid var(--border);
|
|
border-radius: 10px;
|
|
padding: 18px 20px;
|
|
}
|
|
.card h2 {
|
|
font-size: 14px;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.05em;
|
|
color: var(--muted);
|
|
margin: 0 0 14px 0;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
|
|
th { color: var(--muted); font-weight: 500; font-size: 12px; }
|
|
tr.failed-row { background: rgba(242,84,91,0.08); }
|
|
tr.inactive-row { opacity: 0.5; }
|
|
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
|
|
.dot.on { background: var(--green); }
|
|
.dot.off { background: var(--red); }
|
|
|
|
.stat-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(3, 1fr);
|
|
gap: 10px;
|
|
margin-bottom: 14px;
|
|
}
|
|
.stat {
|
|
background: rgba(255,255,255,0.03);
|
|
border-radius: 8px;
|
|
padding: 10px 12px;
|
|
}
|
|
.stat .value { font-size: 20px; font-weight: 600; }
|
|
.stat .label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
|
|
.stat.failed .value { color: var(--red); }
|
|
|
|
.state-pill {
|
|
display: inline-block;
|
|
padding: 3px 10px;
|
|
border-radius: 999px;
|
|
font-size: 12px;
|
|
font-weight: 600;
|
|
text-transform: uppercase;
|
|
}
|
|
.state-idle { background: rgba(139,144,158,0.15); color: var(--muted); }
|
|
.state-scanning, .state-running { background: rgba(79,142,247,0.15); color: var(--blue); }
|
|
.state-completed { background: rgba(62,207,142,0.15); color: var(--green); }
|
|
.state-failed { background: rgba(242,84,91,0.15); color: var(--red); }
|
|
|
|
.kv { display: flex; justify-content: space-between; padding: 4px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
|
|
.kv:last-child { border-bottom: none; }
|
|
.kv .k { color: var(--muted); }
|
|
|
|
.error-list { margin: 10px 0 0 0; padding: 0; list-style: none; }
|
|
.error-list li {
|
|
font-size: 12px;
|
|
padding: 6px 8px;
|
|
margin-bottom: 4px;
|
|
background: rgba(242,84,91,0.08);
|
|
border-left: 3px solid var(--red);
|
|
border-radius: 4px;
|
|
color: var(--text);
|
|
}
|
|
.error-list .err-time { color: var(--muted); margin-right: 6px; }
|
|
.empty-note { color: var(--muted); font-size: 13px; font-style: italic; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="conn-banner">Lost connection to status endpoint - retrying...</div>
|
|
|
|
<header>
|
|
<h1>m3u8-downloader</h1>
|
|
<div class="header-meta">
|
|
<span id="overall-badge" class="badge unknown"><span class="badge-dot"></span>unknown</span>
|
|
<span id="uptime">uptime: -</span>
|
|
<span id="last-updated">last updated: -</span>
|
|
</div>
|
|
</header>
|
|
|
|
<main>
|
|
<section class="card">
|
|
<h2>Download</h2>
|
|
<table>
|
|
<thead>
|
|
<tr><th>Resolution</th><th>Active</th><th>OK</th><th>Failed</th><th>Last activity</th></tr>
|
|
</thead>
|
|
<tbody id="variant-rows"></tbody>
|
|
</table>
|
|
<div id="download-empty" class="empty-note" style="display:none;">No variants reporting yet.</div>
|
|
<ul id="download-errors" class="error-list"></ul>
|
|
</section>
|
|
|
|
<section class="card">
|
|
<h2>Transfer</h2>
|
|
<div class="kv"><span class="k">NAS connection</span><span><span id="nas-dot" class="dot off"></span><span id="nas-text">unknown</span></span></div>
|
|
<div class="stat-grid" style="margin-top:12px;">
|
|
<div class="stat"><div class="value" id="t-added">-</div><div class="label">Added</div></div>
|
|
<div class="stat"><div class="value" id="t-completed">-</div><div class="label">Completed</div></div>
|
|
<div class="stat failed"><div class="value" id="t-failed">-</div><div class="label">Failed</div></div>
|
|
<div class="stat"><div class="value" id="t-pending">-</div><div class="label">Pending</div></div>
|
|
<div class="stat"><div class="value" id="t-queue">-</div><div class="label">Queue size</div></div>
|
|
<div class="stat"><div class="value" id="t-cleanup">-</div><div class="label">Cleanup pending</div></div>
|
|
</div>
|
|
<div class="kv"><span class="k">Transferred</span><span id="t-bytes">-</span></div>
|
|
<ul id="transfer-errors" class="error-list"></ul>
|
|
</section>
|
|
|
|
<section class="card">
|
|
<h2>Processing</h2>
|
|
<div class="kv"><span class="k">State</span><span id="p-state" class="state-pill state-idle">idle</span></div>
|
|
<div class="kv"><span class="k">Event</span><span id="p-event">-</span></div>
|
|
<div class="kv"><span class="k">Segments found</span><span id="p-segments">-</span></div>
|
|
<div class="kv"><span class="k">Started</span><span id="p-started">-</span></div>
|
|
<div class="kv"><span class="k">Finished</span><span id="p-finished">-</span></div>
|
|
<ul id="processing-errors" class="error-list"></ul>
|
|
</section>
|
|
</main>
|
|
|
|
<script>
|
|
const POLL_INTERVAL_MS = 3000;
|
|
const connBanner = document.getElementById('conn-banner');
|
|
|
|
function fmtBytes(n) {
|
|
if (!n || n <= 0) return '0 B';
|
|
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
|
|
let i = 0;
|
|
while (n >= 1024 && i < units.length - 1) { n /= 1024; i++; }
|
|
return n.toFixed(i === 0 ? 0 : 1) + ' ' + units[i];
|
|
}
|
|
|
|
function fmtDuration(sec) {
|
|
sec = Math.floor(sec || 0);
|
|
const h = Math.floor(sec / 3600);
|
|
const m = Math.floor((sec % 3600) / 60);
|
|
const s = sec % 60;
|
|
const parts = [];
|
|
if (h) parts.push(h + 'h');
|
|
if (m || h) parts.push(m + 'm');
|
|
parts.push(s + 's');
|
|
return parts.join(' ');
|
|
}
|
|
|
|
function fmtTime(iso) {
|
|
if (!iso) return '-';
|
|
const d = new Date(iso);
|
|
if (isNaN(d.getTime()) || d.getFullYear() < 1971) return '-';
|
|
return d.toLocaleTimeString();
|
|
}
|
|
|
|
function renderErrors(listEl, errors) {
|
|
listEl.innerHTML = '';
|
|
(errors || []).slice().reverse().forEach(e => {
|
|
const li = document.createElement('li');
|
|
const t = document.createElement('span');
|
|
t.className = 'err-time';
|
|
t.textContent = fmtTime(e.time);
|
|
li.appendChild(t);
|
|
li.appendChild(document.createTextNode(e.message));
|
|
listEl.appendChild(li);
|
|
});
|
|
}
|
|
|
|
function render(data) {
|
|
const badge = document.getElementById('overall-badge');
|
|
badge.className = 'badge ' + (data.status === 'healthy' ? 'healthy' : 'degraded');
|
|
badge.innerHTML = '<span class="badge-dot"></span>' + data.status;
|
|
|
|
document.getElementById('uptime').textContent = 'uptime: ' + fmtDuration(data.uptime_seconds);
|
|
document.getElementById('last-updated').textContent = 'last updated: ' + new Date().toLocaleTimeString();
|
|
|
|
// Download
|
|
const variants = (data.download && data.download.variants) || [];
|
|
const rows = document.getElementById('variant-rows');
|
|
rows.innerHTML = '';
|
|
document.getElementById('download-empty').style.display = variants.length ? 'none' : 'block';
|
|
variants.forEach(v => {
|
|
const tr = document.createElement('tr');
|
|
if (v.segments_failed > 0) tr.classList.add('failed-row');
|
|
if (!v.active) tr.classList.add('inactive-row');
|
|
tr.innerHTML =
|
|
'<td>' + v.resolution + '</td>' +
|
|
'<td><span class="dot ' + (v.active ? 'on' : 'off') + '"></span>' + (v.active ? 'active' : 'stopped') + '</td>' +
|
|
'<td>' + v.segments_ok + '</td>' +
|
|
'<td>' + v.segments_failed + '</td>' +
|
|
'<td>' + fmtTime(v.last_activity) + '</td>';
|
|
rows.appendChild(tr);
|
|
});
|
|
renderErrors(document.getElementById('download-errors'), data.download && data.download.recent_errors);
|
|
|
|
// Transfer
|
|
const t = data.transfer || {};
|
|
const nasDot = document.getElementById('nas-dot');
|
|
nasDot.className = 'dot ' + (t.nas_connected ? 'on' : 'off');
|
|
document.getElementById('nas-text').textContent = t.nas_connected ? 'connected' : 'disconnected';
|
|
document.getElementById('t-added').textContent = t.added ?? '-';
|
|
document.getElementById('t-completed').textContent = t.completed ?? '-';
|
|
document.getElementById('t-failed').textContent = t.failed ?? '-';
|
|
document.getElementById('t-pending').textContent = t.pending ?? '-';
|
|
document.getElementById('t-queue').textContent = t.queue_size ?? '-';
|
|
document.getElementById('t-cleanup').textContent = t.cleanup_pending ?? '-';
|
|
document.getElementById('t-bytes').textContent = fmtBytes(t.bytes_transferred);
|
|
renderErrors(document.getElementById('transfer-errors'), t.recent_errors);
|
|
|
|
// Processing
|
|
const p = data.processing || {};
|
|
const stateEl = document.getElementById('p-state');
|
|
const state = p.state || 'idle';
|
|
stateEl.textContent = state;
|
|
stateEl.className = 'state-pill state-' + state;
|
|
document.getElementById('p-event').textContent = p.event_name || '-';
|
|
document.getElementById('p-segments').textContent = p.segments_found ?? '-';
|
|
document.getElementById('p-started').textContent = fmtTime(p.started_at);
|
|
document.getElementById('p-finished').textContent = fmtTime(p.finished_at);
|
|
renderErrors(document.getElementById('processing-errors'), p.recent_errors);
|
|
}
|
|
|
|
async function poll() {
|
|
try {
|
|
const resp = await fetch('/status', { cache: 'no-store' });
|
|
if (!resp.ok) throw new Error('status ' + resp.status);
|
|
const data = await resp.json();
|
|
connBanner.classList.remove('show');
|
|
render(data);
|
|
} catch (e) {
|
|
connBanner.classList.add('show');
|
|
}
|
|
}
|
|
|
|
poll();
|
|
setInterval(poll, POLL_INTERVAL_MS);
|
|
</script>
|
|
|
|
</body>
|
|
</html>
|