feat: add server-side device deletion
- add portal API and UI action to delete non-default devices - protect the configured portal default device from deletion - document that trip/history pages still scope to the single DEVICE_NAME Co-authored-by: Copilot <[email protected]>
This commit is contained in:
@@ -63,6 +63,21 @@ def request_sync(device_id):
|
||||
}
|
||||
|
||||
|
||||
def delete_device(device_id, protected_device_name=None):
|
||||
device = db.get_device_by_id(device_id)
|
||||
if device is None:
|
||||
return False, {"error": "Device not found."}
|
||||
if protected_device_name and device["name"] == protected_device_name:
|
||||
return False, {
|
||||
"error": "Cannot delete the portal's default device while DEVICE_NAME still points to it.",
|
||||
}
|
||||
|
||||
deleted_id = db.delete_device(device_id)
|
||||
if deleted_id is None:
|
||||
return False, {"error": "Device not found."}
|
||||
return True, {}
|
||||
|
||||
|
||||
def acknowledge_sync(device_id, config_version):
|
||||
db.acknowledge_device_sync(device_id, config_version)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user