async function loadDashboard() { const res = await apiFetch('/api/dashboard'); if (!res) return; const d = await res.json(); function setDaemon(id, running) { document.getElementById(id).innerHTML = ` ${running ? 'Running' : 'Stopped'}`; } setDaemon('statusSmbd', d.status.smbd); setDaemon('statusNfsd', d.status.nfsd); if (d.disk && !d.disk.error) { const p = d.disk.percent; const bar = document.getElementById('diskBar'); bar.style.width = p + '%'; bar.style.background = p > 90 ? 'var(--red)' : p > 75 ? 'var(--yellow)' : 'var(--accent)'; document.getElementById('diskLabel').textContent = `${d.disk.used_gb} GB / ${d.disk.total_gb} GB — ${d.disk.free_gb} GB free`; } else if (d.disk?.error) { document.getElementById('diskLabel').textContent = 'Error: ' + d.disk.error; } const sb = document.getElementById('dashSharesBody'); if (!d.shares?.length) { sb.innerHTML = `No shares configured.`; } else { sb.innerHTML = d.shares.map(s => ` ${s.type.toUpperCase()} ${esc(s.name ?? '—')} ${esc(s.path)} ${esc(s.access || '—')} ${s.size_gb} GB `).join(''); } // Persist quota support flag for shares.js to read window._quotaSupported = d.quota_supported !== false; window._quotaReason = d.quota_reason || ''; const qb = document.getElementById('dashQuotasBody'); if (!d.quota_supported) { qb.innerHTML = `${esc(d.quota_reason)}`; } else if (!d.quotas?.length) { qb.innerHTML = `No quotas set.`; } else { qb.innerHTML = d.quotas.map(q => { const p = Math.min(q.percent, 100); const col = p > 90 ? 'var(--red)' : p > 75 ? 'var(--yellow)' : 'var(--green)'; return ` ${esc(q.user)} ${q.used_gb} GB ${q.soft_gb} GB
${p.toFixed(1)}%
`; }).join(''); } _startRefreshCountdown(); }