mirror of
https://github.com/smittix/intercept.git
synced 2026-04-24 06:40:00 -07:00
fix: make ADS-B auto-start opt-in
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
<link rel="stylesheet" href="{{ url_for('static', filename='css/adsb_dashboard.css') }}">
|
||||
<script>
|
||||
window.INTERCEPT_SHARED_OBSERVER_LOCATION = {{ shared_observer_location | tojson }};
|
||||
window.INTERCEPT_ADSB_AUTO_START = {{ adsb_auto_start | tojson }};
|
||||
</script>
|
||||
<script src="{{ url_for('static', filename='js/core/observer-location.js') }}"></script>
|
||||
</head>
|
||||
@@ -2541,28 +2542,32 @@ sudo make install</code>
|
||||
}
|
||||
}
|
||||
|
||||
async function syncTrackingStatus() {
|
||||
// This function checks LOCAL tracking status on page load
|
||||
// For local mode: auto-start if session is already running OR SDR is available
|
||||
// For agent mode: don't auto-start (user controls agent tracking)
|
||||
|
||||
const useAgent = typeof adsbCurrentAgent !== 'undefined' && adsbCurrentAgent !== 'local';
|
||||
if (useAgent) {
|
||||
console.log('[ADS-B] Agent mode on page load - not auto-starting local');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/adsb/session');
|
||||
if (!response.ok) {
|
||||
// No session info - try to auto-start if SDR available
|
||||
console.log('[ADS-B] No session found, attempting auto-start...');
|
||||
await tryAutoStartLocal();
|
||||
return;
|
||||
}
|
||||
const data = await response.json();
|
||||
|
||||
if (data.tracking_active) {
|
||||
async function syncTrackingStatus() {
|
||||
// This function checks LOCAL tracking status on page load
|
||||
// For local mode: auto-start if session is already running OR SDR is available
|
||||
// For agent mode: don't auto-start (user controls agent tracking)
|
||||
|
||||
const useAgent = typeof adsbCurrentAgent !== 'undefined' && adsbCurrentAgent !== 'local';
|
||||
if (useAgent) {
|
||||
console.log('[ADS-B] Agent mode on page load - not auto-starting local');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const response = await fetch('/adsb/session');
|
||||
if (!response.ok) {
|
||||
// No session info - only auto-start if enabled
|
||||
if (window.INTERCEPT_ADSB_AUTO_START) {
|
||||
console.log('[ADS-B] No session found, attempting auto-start...');
|
||||
await tryAutoStartLocal();
|
||||
} else {
|
||||
console.log('[ADS-B] No session found; auto-start disabled');
|
||||
}
|
||||
return;
|
||||
}
|
||||
const data = await response.json();
|
||||
|
||||
if (data.tracking_active) {
|
||||
// Session is running - auto-connect to stream
|
||||
console.log('[ADS-B] Local session already active - auto-connecting to stream');
|
||||
|
||||
@@ -2598,18 +2603,24 @@ sudo make install</code>
|
||||
document.getElementById('trackingDot').classList.add('active');
|
||||
const statusEl = document.getElementById('trackingStatus');
|
||||
statusEl.textContent = 'TRACKING';
|
||||
} else {
|
||||
// Session not active - try to auto-start
|
||||
console.log('[ADS-B] No active session, attempting auto-start...');
|
||||
await tryAutoStartLocal();
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.warn('[ADS-B] Failed to sync tracking status:', err);
|
||||
// Try auto-start anyway
|
||||
await tryAutoStartLocal();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Session not active - only auto-start if enabled
|
||||
if (window.INTERCEPT_ADSB_AUTO_START) {
|
||||
console.log('[ADS-B] No active session, attempting auto-start...');
|
||||
await tryAutoStartLocal();
|
||||
} else {
|
||||
console.log('[ADS-B] No active session; auto-start disabled');
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
console.warn('[ADS-B] Failed to sync tracking status:', err);
|
||||
// Try auto-start only if enabled
|
||||
if (window.INTERCEPT_ADSB_AUTO_START) {
|
||||
await tryAutoStartLocal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function tryAutoStartLocal() {
|
||||
// Try to auto-start local ADS-B tracking if SDR is available
|
||||
|
||||
@@ -431,28 +431,34 @@
|
||||
now.toISOString().substring(11, 19) + ' UTC';
|
||||
}
|
||||
|
||||
function initGroundMap() {
|
||||
groundMap = L.map('groundMap', {
|
||||
center: [20, 0],
|
||||
zoom: 2,
|
||||
minZoom: 1,
|
||||
maxZoom: 10,
|
||||
worldCopyJump: true
|
||||
});
|
||||
function initGroundMap() {
|
||||
groundMap = L.map('groundMap', {
|
||||
center: [20, 0],
|
||||
zoom: 2,
|
||||
minZoom: 1,
|
||||
maxZoom: 10,
|
||||
worldCopyJump: true
|
||||
});
|
||||
|
||||
// Use settings manager for tile layer (allows runtime changes)
|
||||
window.groundMap = groundMap;
|
||||
if (typeof Settings !== 'undefined' && Settings.createTileLayer) {
|
||||
Settings.createTileLayer().addTo(groundMap);
|
||||
Settings.registerMap(groundMap);
|
||||
} else {
|
||||
L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OSM</a> © <a href="https://carto.com/">CARTO</a>',
|
||||
maxZoom: 19,
|
||||
subdomains: 'abcd'
|
||||
}).addTo(groundMap);
|
||||
}
|
||||
}
|
||||
if (typeof Settings !== 'undefined' && Settings.createTileLayer) {
|
||||
Settings.createTileLayer().addTo(groundMap);
|
||||
Settings.registerMap(groundMap);
|
||||
} else {
|
||||
L.tileLayer('https://cartodb-basemaps-{s}.global.ssl.fastly.net/dark_all/{z}/{x}/{y}.png', {
|
||||
attribution: '© <a href="https://www.openstreetmap.org/copyright">OSM</a> © <a href="https://carto.com/">CARTO</a>',
|
||||
maxZoom: 19,
|
||||
subdomains: 'abcd'
|
||||
}).addTo(groundMap);
|
||||
}
|
||||
|
||||
const lat = parseFloat(document.getElementById('obsLat')?.value);
|
||||
const lon = parseFloat(document.getElementById('obsLon')?.value);
|
||||
if (!Number.isNaN(lat) && !Number.isNaN(lon)) {
|
||||
groundMap.setView([lat, lon], 3);
|
||||
}
|
||||
}
|
||||
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
|
||||
Reference in New Issue
Block a user