fix: add /api/obd/status endpoint, dashboard OBD fallback on page load, fix GPS string-to-number crash
This commit is contained in:
+17
-2
@@ -235,8 +235,8 @@ function renderGpsStatus(status) {
|
||||
badgeClass = stale ? 'text-bg-warning' : 'text-bg-success';
|
||||
detail = formatGpsAge(status.fix_age_seconds);
|
||||
// Show lat/lon from API response (not just socket events)
|
||||
if (locX) locX.textContent = status.latitude != null ? status.latitude.toFixed(6) : '—';
|
||||
if (locY) locY.textContent = status.longitude != null ? status.longitude.toFixed(6) : '—';
|
||||
if (locX) locX.textContent = status.latitude != null ? Number(status.latitude).toFixed(6) : '—';
|
||||
if (locY) locY.textContent = status.longitude != null ? Number(status.longitude).toFixed(6) : '—';
|
||||
} else {
|
||||
label = 'No fix';
|
||||
badgeClass = 'text-bg-warning';
|
||||
@@ -305,3 +305,18 @@ window.setInterval(function () {
|
||||
if (fixDetail) fixDetail.textContent = error.message;
|
||||
});
|
||||
}, 15000);
|
||||
|
||||
async function refreshObdStatus() {
|
||||
try {
|
||||
const resp = await fetch('/api/obd/status');
|
||||
const status = await resp.json();
|
||||
const el = document.getElementById('obd-status');
|
||||
if (el) el.textContent = status.adapter_present
|
||||
? (status.car_connected ? 'Connected' : 'Adapter only')
|
||||
: 'Not detected';
|
||||
} catch (e) {
|
||||
// Socket events will eventually update it
|
||||
}
|
||||
}
|
||||
refreshObdStatus();
|
||||
window.setInterval(refreshObdStatus, 15000);
|
||||
|
||||
Reference in New Issue
Block a user