diff --git a/admin_server.py b/admin_server.py
index 48d9755..c7eaaf1 100644
--- a/admin_server.py
+++ b/admin_server.py
@@ -1586,17 +1586,6 @@ def export_checkins_csv(asset_id: Optional[int] = Query(None)):
# ─── Asset GPS Management ──────────────────────────────────────────────────
-@app.get("/api/assets/{asset_id}")
-def get_asset_admin(asset_id: int):
- """Get a single asset by ID (admin)."""
- conn = get_db()
- row = conn.execute("SELECT * FROM assets WHERE id = ?", (asset_id,)).fetchone()
- conn.close()
- if row is None:
- raise HTTPException(status_code=404, detail="Asset not found")
- return row_to_dict(row)
-
-
@app.get("/api/assets/search")
def search_assets_admin(machine_id: str = Query(...)):
"""Search for an asset by machine_id (admin)."""
@@ -1610,6 +1599,16 @@ def search_assets_admin(machine_id: str = Query(...)):
return row_to_dict(row)
+@app.get("/api/assets/{asset_id}")
+def get_asset_admin(asset_id: int):
+ """Get a single asset by ID (admin)."""
+ conn = get_db()
+ row = conn.execute("SELECT * FROM assets WHERE id = ?", (asset_id,)).fetchone()
+ conn.close()
+ if row is None:
+ raise HTTPException(status_code=404, detail="Asset not found")
+ return row_to_dict(row)
+
@app.delete("/api/assets/{asset_id}/gps", status_code=204)
def clear_asset_gps(asset_id: int):
"""Clear GPS coordinates from an asset (sets latitude/longitude to NULL)."""
diff --git a/static/index.html b/static/index.html
index 4730602..98c5897 100644
--- a/static/index.html
+++ b/static/index.html
@@ -2169,7 +2169,11 @@ async function clearAssetGps() {
showToast('GPS data cleared');
} catch (e) {
resultEl.style.display = '';
- resultEl.innerHTML = '' + esc(e.message) + '';
+ const errMsg = (e && typeof e.message === 'string') ? e.message
+ : (typeof e === 'string') ? e
+ : (e && e.detail && typeof e.detail === 'string') ? e.detail
+ : 'Unknown error';
+ resultEl.innerHTML = '' + esc(errMsg) + '';
}
}