Add local settings management
Add cellular-first ntfy delivery with WiFi fallback and safe SIM868 HTTP header framing. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -285,59 +285,3 @@ scanForDashcam();
|
||||
refreshDashcamFiles();
|
||||
|
||||
// --- Remote server upload status/toggle ---
|
||||
|
||||
const uploadStatusEl = document.getElementById('upload-status');
|
||||
const dashcamToggle = document.getElementById('dashcam-upload-toggle');
|
||||
|
||||
function describeUploadStatus(status) {
|
||||
if (!status.configured) {
|
||||
return 'Remote server not configured on this device (see db/upload_creds.env).';
|
||||
}
|
||||
let text = `Pending trip-log rows to upload: ${status.pending_tracking_rows}.`;
|
||||
if (status.last_success_at) {
|
||||
text += ` Last successful upload: ${status.last_success_at}`;
|
||||
if (status.last_network_path) {
|
||||
text += ` (via ${status.last_network_path === 'cellular' ? 'cellular fallback' : 'WiFi/Ethernet'})`;
|
||||
}
|
||||
text += '.';
|
||||
}
|
||||
if (status.cellular_fallback_configured) {
|
||||
text += ' Cellular (SIM868) fallback is enabled for trip logs if WiFi/Ethernet is unreachable.';
|
||||
}
|
||||
if (status.last_error) {
|
||||
text += ` Last error: ${status.last_error}.`;
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
function refreshUploadStatus() {
|
||||
fetch('/api/upload/status')
|
||||
.then(response => response.json())
|
||||
.then(status => {
|
||||
uploadStatusEl.textContent = describeUploadStatus(status);
|
||||
dashcamToggle.checked = status.dashcam_upload_enabled;
|
||||
dashcamToggle.disabled = !status.configured;
|
||||
})
|
||||
.catch(err => {
|
||||
uploadStatusEl.textContent = 'Error while checking upload status: ' + err;
|
||||
});
|
||||
}
|
||||
|
||||
dashcamToggle.addEventListener('change', () => {
|
||||
fetch('/api/upload/dashcam_toggle', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ enabled: dashcamToggle.checked }),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(status => {
|
||||
uploadStatusEl.textContent = describeUploadStatus(status);
|
||||
dashcamToggle.checked = status.dashcam_upload_enabled;
|
||||
})
|
||||
.catch(err => {
|
||||
uploadStatusEl.textContent = 'Error while updating toggle: ' + err;
|
||||
});
|
||||
});
|
||||
|
||||
refreshUploadStatus();
|
||||
setInterval(refreshUploadStatus, 15000);
|
||||
|
||||
Reference in New Issue
Block a user