diff --git a/app/static/index.html b/app/static/index.html index acca754..956f4d5 100644 --- a/app/static/index.html +++ b/app/static/index.html @@ -1508,6 +1508,23 @@ function setLayerCount(id, value) { } } +function applyFeedConfig(s) { + // Hide only when /api/stats says the key is unset. Missing feeds (old image) + // leaves both rows visible. Never infer from a zero count. Never touch WFIGS or trains. + const feeds = (s && typeof s.feeds === 'object' && s.feeds) ? s.feeds : null; + setFeedRow('lp-vessels-on', feeds && feeds.vessels); + setFeedRow('lp-fires-on', feeds && feeds.fires); +} +function setFeedRow(id, flag) { + const el = document.getElementById(id); + const row = el && el.closest ? el.closest('.lp-layer') : null; + if (!row) return; + const hide = !!(flag && flag.configured === false); + row.hidden = hide; + // .lp-layer { display:flex } beats the UA [hidden] rule — inline display is what hides it. + row.style.display = hide ? 'none' : ''; +} + async function pollLayerStats() { if (statsPollDisabled) return; try { @@ -1516,6 +1533,7 @@ async function pollLayerStats() { if (!r.ok) return; const s = await r.json(); if (!s || typeof s !== 'object') return; + applyFeedConfig(s); statsRailActive = true; const skipIfOn = { fires: firesOn, diff --git a/tests/test_feed_rail.py b/tests/test_feed_rail.py new file mode 100644 index 0000000..cde7d53 --- /dev/null +++ b/tests/test_feed_rail.py @@ -0,0 +1,152 @@ +"""Layer rail hides Vessels and FIRMS only when /api/stats says the key is unset.""" + +from __future__ import annotations + +import json +import subprocess +from pathlib import Path + +ROOT = Path(__file__).resolve().parent.parent +HTML = (ROOT / "app/static/index.html").read_text() + + +def _between(start: str, end: str) -> str: + return HTML.split(start, 1)[1].split(end, 1)[0] + + +def _feed_fns() -> str: + return _between("function applyFeedConfig", "async function pollLayerStats") + + +def _layer_chunk(elem_id: str) -> str: + idx = HTML.index(f'id="{elem_id}"') + start = HTML.rfind('