fix: odometer sync is Pi→Server only — portal displays read-only value from DB

This commit is contained in:
Mathieu Moran
2026-08-11 22:14:46 -04:00
parent 7de8948e08
commit d35cea367f
4 changed files with 29 additions and 16 deletions
+5 -3
View File
@@ -28,9 +28,12 @@ const fields = {
car_model: document.getElementById('car_model'),
device_name: document.getElementById('device_name'),
avatar_path: document.getElementById('avatar_path'),
odometer_baseline: document.getElementById('odometer_baseline'),
};
// Read-only display field — populated from server config, never sent on save.
// Odometer is Pi→Server only: the Pi pushes its baseline, the portal just shows it.
const odometerField = document.getElementById('odometer_baseline');
let devices = [];
let selectedDeviceId = null;
let initialState = null;
@@ -57,7 +60,6 @@ function currentState() {
car_model: fields.car_model.value.trim(),
device_name: fields.device_name.value.trim(),
avatar_path: fields.avatar_path.value.trim(),
odometer_baseline: Number(fields.odometer_baseline.value) || 0,
};
}
@@ -117,7 +119,7 @@ function populateDevice(device, config) {
fields.car_model.value = config.car_model || '';
fields.device_name.value = config.device_name || '';
fields.avatar_path.value = config.avatar_path || '';
fields.odometer_baseline.value = (config.odometer_baseline || 0).toFixed(1);
odometerField.value = (config.odometer_baseline || 0).toFixed(1);
initialState = currentState();
credentialFields.deviceName.value = device.name;
renderDeviceList();