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
+11 -4
View File
@@ -17,17 +17,19 @@ require_once __DIR__ . '/config.php';
// ── Fallback tracking ─────────────────────────────────────────────────────────
function &_vv_api_fallbacks(): array { static $f = []; return $f; }
function &_vv_api_key_missing(): bool { static $m = false; return $m; }
function vv_api_record_fallback(string $fn): void {
$f = &_vv_api_fallbacks();
$f = &_vv_api_fallbacks();
$f[] = $fn;
}
function vv_api_get_status(): array {
$fallbacks = array_unique(_vv_api_fallbacks());
return [
'available' => empty($fallbacks),
'fallbacks' => $fallbacks,
'available' => empty($fallbacks),
'key_missing' => _vv_api_key_missing(),
'fallbacks' => $fallbacks,
];
}
@@ -43,7 +45,12 @@ function vv_api_data(): ?array {
$hostId = vv_detect_host();
$vars = vv_conf_vars();
$key = $vars[strtoupper($hostId) . '_UNRAID_API_KEY'] ?? '';
if (!$key) { $cache = null; return null; }
if (!$key) {
$m = &_vv_api_key_missing();
$m = true;
$cache = null;
return null;
}
// Fields verified against live schema introspection (2026-05-29).
// array.parities / .disks / .caches are SEPARATE lists — .disks is DATA only.