feat: add device config settings UI with optional server sync
- Add app_device_config.py module for managing device configuration (owner_name, car_model, avatar_path, device_name) - Add sync_enabled flag to control whether Pi syncs config from server - When sync is enabled, device config fields are read-only (server is source of truth) - When sync is disabled, user can edit device config via Settings page - Add /api/device-config endpoint (GET to retrieve, POST to update) - Add Device identity section to settings.html with form fields for all config values - Update settings.js to load/save device config with sync toggle - Gracefully handles both config file (at startup) and database (live updates via settings UI) - All 63 tests passing Phase 25.5: Offline-first device config with eventual consistency. Config loads from JSON at startup (no network needed), can be edited via settings if not syncing, and will sync from server on next connectivity when Phase 25.5a server endpoints are implemented. Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -18,6 +18,49 @@
|
||||
|
||||
<form id="settings-form">
|
||||
|
||||
{# ── Device identity ────────────────────────────────────────────── #}
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-header py-2">
|
||||
<p class="text-primary m-0 fw-bold small">Device identity</p>
|
||||
</div>
|
||||
<div class="card-body py-3">
|
||||
<div class="form-check form-switch mb-3">
|
||||
<input class="form-check-input" type="checkbox" role="switch" id="device-sync-enabled">
|
||||
<label class="form-check-label" for="device-sync-enabled">
|
||||
Sync with server
|
||||
<span class="text-muted small d-block">If enabled, server is source of truth and these fields become read-only.</span>
|
||||
</label>
|
||||
</div>
|
||||
<div id="device-config-fields">
|
||||
<div class="row g-3 mb-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label form-label-sm" for="device-owner-name">Owner name</label>
|
||||
<input class="form-control form-control-sm" id="device-owner-name" maxlength="100" required>
|
||||
<div class="invalid-feedback" data-error-for="owner_name"></div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label form-label-sm" for="device-car-model">Car model</label>
|
||||
<input class="form-control form-control-sm" id="device-car-model" maxlength="100" required>
|
||||
<div class="invalid-feedback" data-error-for="car_model"></div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label form-label-sm" for="device-avatar-path">Avatar path</label>
|
||||
<input class="form-control form-control-sm" id="device-avatar-path" maxlength="255" placeholder="img/yaris.png" required>
|
||||
<div class="invalid-feedback" data-error-for="avatar_path"></div>
|
||||
<div class="form-text">Relative path from <code>static/</code> directory.</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label form-label-sm" for="device-name">Device name</label>
|
||||
<input class="form-control form-control-sm" id="device-name" maxlength="100">
|
||||
<div class="invalid-feedback" data-error-for="device_name"></div>
|
||||
<div class="form-text">Reserved for future server portal display.</div>
|
||||
</div>
|
||||
</div>
|
||||
<p class="text-muted small mb-0">Edit your device identity here. If server sync is enabled, these fields are read-only.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# ── Upload & retention ──────────────────────────────────────────── #}
|
||||
<div class="card shadow-sm mb-3">
|
||||
<div class="card-header py-2">
|
||||
|
||||
Reference in New Issue
Block a user