Differentiate API key missing vs API unreachable in monitor banner

unraid_api.php: track key_missing separately from general fallbacks.
  vv_api_data() sets key_missing=true when HOST*_UNRAID_API_KEY is empty.
  vv_api_get_status() includes key_missing in the status payload.

monitor.php: two distinct banner states instead of one orange warning.
  key_missing → subtle dark/grey note: "API key not configured — add
    HOST1_UNRAID_API_KEY in Scheduler → host conf to enable enhanced monitoring"
  key present but unreachable → existing orange ⚠ with fallback list.
  No banner at all when API is working correctly.
This commit is contained in:
Gmer4Lfe
2026-05-30 16:26:51 -04:00
parent 10fc703e57
commit 7e01f6d3db
2 changed files with 27 additions and 13 deletions
+16 -9
View File
@@ -1,10 +1,6 @@
<?php require_once dirname(__DIR__) . '/include/monitor.php'; ?>
<div id="vv-api-banner" style="display:none;background:#1a1200;border:1px solid #3a2800;border-radius:4px;
padding:5px 10px;margin-bottom:8px;font-size:11px;color:#ff9800;">
⚠ Unraid API unavailable — using local reads. Check API key in host conf.
<span id="vv-api-fallback-list" style="color:#666;margin-left:6px;"></span>
</div>
<div id="vv-api-banner" style="display:none;border-radius:4px;padding:5px 10px;margin-bottom:8px;font-size:11px;"></div>
<div id="vv-monitor" style="display:grid;grid-template-columns:repeat(8,1fr);gap:12px;width:100%;box-sizing:border-box;">
@@ -467,10 +463,21 @@ function vvPollMonitor() {
const apiStatus = d._api_status ?? {};
const banner = document.getElementById('vv-api-banner');
if (banner) {
const hasFallbacks = apiStatus.fallbacks && apiStatus.fallbacks.length > 0;
banner.style.display = hasFallbacks ? '' : 'none';
const listEl = document.getElementById('vv-api-fallback-list');
if (listEl && hasFallbacks) listEl.textContent = '(' + apiStatus.fallbacks.join(', ') + ')';
const fallbacks = apiStatus.fallbacks ?? [];
if (fallbacks.length === 0) {
banner.style.display = 'none';
} else if (apiStatus.key_missing) {
// Key not configured — informational, not alarming
Object.assign(banner.style, {display:'', background:'#111', border:'1px solid #2a2a2a', color:'#555'});
banner.textContent = 'API key not configured — add HOST' +
(typeof vvLocalHostConf !== 'undefined' ? vvLocalHostConf.replace(/\D/g,'') : '1') +
'_UNRAID_API_KEY in Scheduler → host conf to enable enhanced monitoring.';
} else {
// Key present but API unreachable — genuine problem
Object.assign(banner.style, {display:'', background:'#1a1200', border:'1px solid #3a2800', color:'#ff9800'});
banner.innerHTML = '⚠ Unraid API unreachable — using local reads. Check API key in host conf.' +
(fallbacks.length ? ' <span style="color:#666">(' + fallbacks.join(', ') + ')</span>' : '');
}
}
// ── Thresholds (from dynamix.cfg via backend) ────────────────────────────