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:
@@ -699,6 +699,19 @@ def portal_device_request_sync(device_id):
|
||||
return jsonify(result)
|
||||
|
||||
|
||||
@app.delete("/api/v1/portal/devices/<int:device_id>")
|
||||
@require_login
|
||||
def portal_device_delete(device_id):
|
||||
success, errors = device_registry.delete_device(
|
||||
device_id,
|
||||
protected_device_name=os.environ.get("DEVICE_NAME", "yaris-2013"),
|
||||
)
|
||||
if not success:
|
||||
status = 404 if errors.get("error") == "Device not found." else 409
|
||||
return jsonify(error=errors.get("error", "Could not delete device.")), status
|
||||
return jsonify(status="deleted")
|
||||
|
||||
|
||||
@app.get("/api/v1/portal/device-config")
|
||||
@require_login
|
||||
def portal_device_config_get():
|
||||
|
||||
Reference in New Issue
Block a user