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:
@@ -1,5 +1,5 @@
|
||||
from flask import Flask, render_template, make_response, json, jsonify, request, send_file, Response
|
||||
from modules import app_gps, app_events, app_car, app_account, app_obd, app_sql, app_dash, app_upload, app_video, app_health, app_alerts, app_settings, app_network
|
||||
from modules import app_gps, app_events, app_car, app_account, app_obd, app_sql, app_dash, app_upload, app_video, app_health, app_alerts, app_settings, app_network, app_device_config
|
||||
import os, time
|
||||
from gevent.pywsgi import WSGIServer
|
||||
|
||||
@@ -44,6 +44,16 @@ def api_settings():
|
||||
return jsonify(error="Invalid settings.", fields=errors), 400
|
||||
return jsonify(app_settings.get_settings())
|
||||
|
||||
@app.route('/api/device-config', methods=['GET', 'POST'])
|
||||
def api_device_config():
|
||||
if request.method == 'GET':
|
||||
return jsonify(app_device_config.get_device_config())
|
||||
errors = {}
|
||||
app_device_config.update_device_config(request.get_json(silent=True), errors)
|
||||
if errors:
|
||||
return jsonify(error="Invalid device config.", fields=errors), 400
|
||||
return jsonify(app_device_config.get_device_config())
|
||||
|
||||
@app.route('/api/uplink/status')
|
||||
def uplink_status():
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user