feat: merge Survey into Scanning and harden live recon

- Delete the Survey stack (sampler, handlers, routes, view, recordings);
  Scanning gains AP compare (cap 6), whole-page selection filter, channel
  map (20 MHz lobes, the radio does not report width), and auto-follow
  that prefers the newest non-empty scan
- Richer HTML scan reports: stat cards, band/encryption breakdowns,
  channel occupancy, color-coded signal cells, GPS line only on a fix
- Harden live recon: bounded + retried scan-detail reads (503 on lock),
  serialize recon starts (409 + scan_remaining while running), GPS and
  archive discovery move to a 30s poll, GPS_GET skipped when gpsd is down
- Read-only history for pineapd-rotated databases (error-*/diagnostic-*):
  archives list/detail/download endpoints, Previous Scans optgroup,
  delete disabled, traversal-guarded
- Status flags: hopper-radio-offline and history-reset banners; empty
  scans greyed in the picker
- Tests: recon suite grows to 99 cases; all 14 modules green

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
This commit is contained in:
2026-08-18 14:55:02 -05:00
co-authored by factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
parent 251b1f6261
commit d8a7074e1f
6 changed files with 1169 additions and 1071 deletions
@@ -136,5 +136,114 @@ const MiniChart = (() => {
});
}
return { draw, doughnut, bar };
function chanToMhz(band, ch) {
const n = Number(ch);
if (band === '2.4') return 2407 + 5 * n;
if (band === '5') return 5000 + 5 * n;
if (band === '6') return 5950 + 5 * n;
return null;
}
function bandRange(band) {
if (band === '2.4') return [2400, 2500];
if (band === '5') return [5150, 5900];
if (band === '6') return [5925, 7125];
return null;
}
function hexA(hex, alpha) {
const m = /^#([0-9a-f]{6})$/i.exec(hex || '');
if (!m) return hex;
const n = parseInt(m[1], 16);
return 'rgba(' + ((n >> 16) & 255) + ',' + ((n >> 8) & 255) + ',' + (n & 255) + ',' + alpha + ')';
}
// Channel map: each AP is a raised-cosine lobe at its reported center
// frequency with the peak at its signal strength. The radio does not report
// channel width, so every lobe assumes 20 MHz (half-width +-10 MHz).
function channelMap(canvas, aps, opts) {
const o = opts || {};
const dpr = window.devicePixelRatio || 1;
const H = o.height || 180;
canvas.width = canvas.clientWidth * dpr;
canvas.height = H * dpr;
const ctx = canvas.getContext('2d');
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
const w = canvas.clientWidth, h = H;
ctx.clearRect(0, 0, w, h);
if (!aps || !aps.length) return;
const pts = aps
.map((a) => ({
freq: a.freq != null ? Number(a.freq) : chanToMhz(a.band, a.channel),
sig: a.signal
}))
.filter((p) => p.freq != null && p.sig != null);
if (!pts.length) return;
const def = bandRange(aps[0].band);
const lo = Math.min(def ? def[0] : Infinity, ...pts.map((p) => p.freq));
const hi = Math.max(def ? def[1] : -Infinity, ...pts.map((p) => p.freq));
const fMin = lo - 10, fMax = hi + 10;
const padL = 42, padR = 10, padT = 14, padB = 24;
const plotW = w - padL - padR, plotH = h - padT - padB;
const YMIN = -100, YMAX = -30;
const x = (f) => padL + (f - fMin) / (fMax - fMin) * plotW;
const y = (dbm) => padT + (1 - (dbm - YMIN) / (YMAX - YMIN)) * plotH;
ctx.font = '10px Roboto, "Segoe UI", Arial, sans-serif';
ctx.textAlign = 'right';
for (let dbm = YMIN; dbm <= YMAX; dbm += 10) {
const yy = y(dbm);
ctx.strokeStyle = o.grid || '#e0e0e0';
ctx.lineWidth = 1;
ctx.beginPath(); ctx.moveTo(padL, yy); ctx.lineTo(w - padR, yy); ctx.stroke();
ctx.fillStyle = '#888';
ctx.fillText(String(dbm), padL - 6, yy + 3);
}
ctx.strokeStyle = o.grid || '#e0e0e0';
for (let f = Math.ceil(fMin / 20) * 20; f <= fMax; f += 20) {
ctx.beginPath(); ctx.moveTo(x(f), padT); ctx.lineTo(x(f), h - padB); ctx.stroke();
}
const baseY = h - padB;
aps.forEach((a) => {
const freq = a.freq != null ? Number(a.freq) : chanToMhz(a.band, a.channel);
if (freq == null || a.signal == null) return;
const color = a.color || '#1976d2';
const cx = x(freq);
const topY = y(a.signal);
const peakH = Math.max(2, baseY - topY);
const half = Math.max(4, (10 / (fMax - fMin)) * plotW);
ctx.beginPath();
for (let i = 0; i <= 28; i++) {
const t = -1 + i / 14;
const lift = Math.max(0, 0.5 + 0.5 * Math.cos(Math.PI * t));
const px = cx + t * half;
const py = baseY - lift * peakH;
if (i === 0) ctx.moveTo(px, py);
else ctx.lineTo(px, py);
}
ctx.closePath();
ctx.fillStyle = hexA(color, 0.35);
ctx.fill();
ctx.strokeStyle = color;
ctx.lineWidth = 1.5;
ctx.stroke();
});
let lastLabelX = -Infinity;
ctx.textAlign = 'center';
aps.forEach((a) => {
const freq = a.freq != null ? Number(a.freq) : chanToMhz(a.band, a.channel);
if (freq == null || a.channel == null) return;
const cx = x(freq);
if (cx - lastLabelX < 34) return;
lastLabelX = cx;
ctx.strokeStyle = '#999';
ctx.beginPath(); ctx.moveTo(cx, h - padB); ctx.lineTo(cx, h - padB + 4); ctx.stroke();
ctx.fillStyle = '#666';
ctx.fillText('CH ' + a.channel, cx, h - 7);
});
ctx.textAlign = 'left';
ctx.fillStyle = '#888';
ctx.fillText((aps[0].band || '?') + ' GHz', padL + 4, padT + 2);
}
return { draw, doughnut, bar, channelMap };
})();