From b62b97ab570034edb31f16da17710df64f2e6366 Mon Sep 17 00:00:00 2001 From: James Smith Date: Thu, 19 Mar 2026 15:59:58 +0000 Subject: [PATCH] Wire satellite capture handoff --- static/css/satellite_dashboard.css | 5 ++-- templates/index.html | 38 ++++++++++++++++++++++++++---- templates/satellite_dashboard.html | 11 +++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) diff --git a/static/css/satellite_dashboard.css b/static/css/satellite_dashboard.css index d151845..99dbf51 100644 --- a/static/css/satellite_dashboard.css +++ b/static/css/satellite_dashboard.css @@ -280,7 +280,7 @@ body { .primary-layout { display: grid; grid-template-columns: 300px minmax(0, 1.6fr) 360px; - gap: 12px; + gap: 10px; min-height: 520px; min-width: 0; } @@ -295,9 +295,10 @@ body { .command-rail { display: grid; grid-template-rows: auto auto auto minmax(260px, 340px); - gap: 12px; + gap: 6px; min-width: 0; align-items: start; + align-content: start; } .data-grid { diff --git a/templates/index.html b/templates/index.html index e1e30f3..f09b6ac 100644 --- a/templates/index.html +++ b/templates/index.html @@ -16401,11 +16401,11 @@ if (typeof KeyboardShortcuts !== 'undefined') KeyboardShortcuts.init(); }); - // ── Weather-satellite handoff from the satellite dashboard iframe ───────── - window.addEventListener('message', (event) => { - if (!event.data || event.data.type !== 'weather-sat-handoff') return; + // ── Weather-satellite handoff from the satellite dashboard iframe/tab ───── + function processWeatherSatHandoff(payload) { + if (!payload || payload.type !== 'weather-sat-handoff') return; - const { satellite, aosTime, tcaEl, duration } = event.data; + const { satellite, aosTime, tcaEl, duration } = payload; if (!satellite) return; // Determine how far away the pass is @@ -16426,6 +16426,32 @@ } } }); + } + + function consumePendingWeatherSatHandoff() { + let raw = null; + try { + raw = window.sessionStorage?.getItem('intercept.pendingWeatherSatHandoff') + || window.localStorage?.getItem('intercept.pendingWeatherSatHandoff'); + } catch (_) { + raw = null; + } + if (!raw) return; + + try { + window.sessionStorage?.removeItem('intercept.pendingWeatherSatHandoff'); + window.localStorage?.removeItem('intercept.pendingWeatherSatHandoff'); + } catch (_) {} + + try { + processWeatherSatHandoff(JSON.parse(raw)); + } catch (err) { + console.warn('Failed to consume weather-satellite handoff payload:', err); + } + } + + window.addEventListener('message', (event) => { + processWeatherSatHandoff(event.data); }); function showHandoffBanner(satellite, minsAway, tcaEl, duration) { @@ -16463,6 +16489,10 @@ // Auto-dismiss after 2 minutes setTimeout(() => { if (banner.parentNode) banner.remove(); }, 120000); } + + window.addEventListener('DOMContentLoaded', () => { + setTimeout(consumePendingWeatherSatHandoff, 250); + }); diff --git a/templates/satellite_dashboard.html b/templates/satellite_dashboard.html index ab531f9..2cd270e 100644 --- a/templates/satellite_dashboard.html +++ b/templates/satellite_dashboard.html @@ -2041,7 +2041,18 @@ const target = window.parent !== window ? window.parent : window.opener; if (target) { target.postMessage(msg, '*'); + return; } + + try { + if (window.sessionStorage) { + window.sessionStorage.setItem('intercept.pendingWeatherSatHandoff', JSON.stringify(msg)); + } else if (window.localStorage) { + window.localStorage.setItem('intercept.pendingWeatherSatHandoff', JSON.stringify(msg)); + } + } catch (_) {} + + window.location.assign('/?mode=weathersat'); } function selectPass(idx) {