mirror of
https://github.com/smittix/intercept.git
synced 2026-05-27 02:04:45 -07:00
Refresh embedded satellite dashboard state
This commit is contained in:
@@ -8,7 +8,7 @@ import urllib.request
|
|||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from flask import Blueprint, Response, jsonify, render_template, request
|
from flask import Blueprint, Response, jsonify, make_response, render_template, request
|
||||||
|
|
||||||
from config import DEFAULT_LATITUDE, DEFAULT_LONGITUDE, SHARED_OBSERVER_LOCATION_ENABLED
|
from config import DEFAULT_LATITUDE, DEFAULT_LONGITUDE, SHARED_OBSERVER_LOCATION_ENABLED
|
||||||
from utils.sse import sse_stream_fanout
|
from utils.sse import sse_stream_fanout
|
||||||
@@ -398,11 +398,15 @@ def _fetch_iss_realtime(observer_lat: float | None = None, observer_lon: float |
|
|||||||
def satellite_dashboard():
|
def satellite_dashboard():
|
||||||
"""Popout satellite tracking dashboard."""
|
"""Popout satellite tracking dashboard."""
|
||||||
embedded = request.args.get('embedded', 'false') == 'true'
|
embedded = request.args.get('embedded', 'false') == 'true'
|
||||||
return render_template(
|
response = make_response(render_template(
|
||||||
'satellite_dashboard.html',
|
'satellite_dashboard.html',
|
||||||
shared_observer_location=SHARED_OBSERVER_LOCATION_ENABLED,
|
shared_observer_location=SHARED_OBSERVER_LOCATION_ENABLED,
|
||||||
embedded=embedded,
|
embedded=embedded,
|
||||||
)
|
))
|
||||||
|
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'
|
||||||
|
response.headers['Pragma'] = 'no-cache'
|
||||||
|
response.headers['Expires'] = '0'
|
||||||
|
return response
|
||||||
|
|
||||||
|
|
||||||
@satellite_bp.route('/predict', methods=['POST'])
|
@satellite_bp.route('/predict', methods=['POST'])
|
||||||
|
|||||||
@@ -4574,6 +4574,10 @@
|
|||||||
if (btLayoutContainer) btLayoutContainer.classList.toggle('active', mode === 'bluetooth');
|
if (btLayoutContainer) btLayoutContainer.classList.toggle('active', mode === 'bluetooth');
|
||||||
if (satelliteVisuals) satelliteVisuals.style.display = mode === 'satellite' ? 'block' : 'none';
|
if (satelliteVisuals) satelliteVisuals.style.display = mode === 'satellite' ? 'block' : 'none';
|
||||||
const satFrame = document.getElementById('satelliteDashboardFrame');
|
const satFrame = document.getElementById('satelliteDashboardFrame');
|
||||||
|
if (satFrame && mode === 'satellite') {
|
||||||
|
const baseSrc = '/satellite/dashboard?embedded=true&v={{ version }}';
|
||||||
|
satFrame.src = `${baseSrc}&ts=${Date.now()}`;
|
||||||
|
}
|
||||||
if (satFrame && satFrame.contentWindow) {
|
if (satFrame && satFrame.contentWindow) {
|
||||||
satFrame.contentWindow.postMessage({type: 'satellite-visibility', visible: mode === 'satellite'}, '*');
|
satFrame.contentWindow.postMessage({type: 'satellite-visibility', visible: mode === 'satellite'}, '*');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -762,12 +762,7 @@
|
|||||||
|
|
||||||
function handleLivePositions(positions) {
|
function handleLivePositions(positions) {
|
||||||
// Find the selected satellite by name or norad_id
|
// Find the selected satellite by name or norad_id
|
||||||
const satName = satellites[selectedSatellite]?.name;
|
const pos = findSelectedPosition(positions);
|
||||||
const pos = positions.find(p =>
|
|
||||||
parseInt(p.norad_id) === selectedSatellite ||
|
|
||||||
p.satellite === satName ||
|
|
||||||
p.satellite === satellites[selectedSatellite]?.name
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update visible count from all positions
|
// Update visible count from all positions
|
||||||
const visibleCount = positions.filter(p => p.visible).length;
|
const visibleCount = positions.filter(p => p.visible).length;
|
||||||
@@ -775,7 +770,6 @@
|
|||||||
if (visEl) visEl.textContent = visibleCount;
|
if (visEl) visEl.textContent = visibleCount;
|
||||||
|
|
||||||
if (!pos) {
|
if (!pos) {
|
||||||
clearTelemetry();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -821,6 +815,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findSelectedPosition(positions) {
|
||||||
|
if (!Array.isArray(positions)) return null;
|
||||||
|
const satName = satellites[selectedSatellite]?.name;
|
||||||
|
return positions.find(p =>
|
||||||
|
parseInt(p.norad_id) === selectedSatellite ||
|
||||||
|
p.satellite === satName ||
|
||||||
|
p.satellite === satellites[selectedSatellite]?.name
|
||||||
|
) || null;
|
||||||
|
}
|
||||||
|
|
||||||
function clearTelemetry() {
|
function clearTelemetry() {
|
||||||
const telLat = document.getElementById('telLat');
|
const telLat = document.getElementById('telLat');
|
||||||
const telLon = document.getElementById('telLon');
|
const telLon = document.getElementById('telLon');
|
||||||
@@ -855,6 +859,10 @@
|
|||||||
if (!response.ok) return;
|
if (!response.ok) return;
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data.status !== 'success' || !Array.isArray(data.positions)) return;
|
if (data.status !== 'success' || !Array.isArray(data.positions)) return;
|
||||||
|
if (!findSelectedPosition(data.positions)) {
|
||||||
|
clearTelemetry();
|
||||||
|
return;
|
||||||
|
}
|
||||||
handleLivePositions(data.positions);
|
handleLivePositions(data.positions);
|
||||||
} catch (_) {}
|
} catch (_) {}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user