diff --git a/python/PiFinder/server.py b/python/PiFinder/server.py index 6f1bea592..012e6686c 100644 --- a/python/PiFinder/server.py +++ b/python/PiFinder/server.py @@ -640,6 +640,40 @@ def equipment_delete_eyepiece(eyepiece_id: int): success_message="Eyepiece Deleted, restart your PiFinder to remove from menu", ) + @app.route("/equipment/reorder_eyepieces", method="post") + @auth_required + def equipment_reorder_eyepieces(): + cfg = config.Config() + try: + # Get the new order from the request body + data = request.json + new_order = data.get("order", []) + + # Validate the order + if len(new_order) != len(cfg.equipment.eyepieces): + return {"success": False, "error": "Invalid order length"} + + # Reorder the eyepieces based on the new indices + reordered_eyepieces = [ + cfg.equipment.eyepieces[idx] for idx in new_order + ] + cfg.equipment.eyepieces = reordered_eyepieces + + # Update active eyepiece index if needed + if cfg.equipment.active_eyepiece_index >= 0: + # Find where the active eyepiece moved to + old_active_idx = cfg.equipment.active_eyepiece_index + new_active_idx = new_order.index(old_active_idx) + cfg.equipment.active_eyepiece_index = new_active_idx + + # Save the new order + cfg.save_equipment() + self.ui_queue.put("reload_config") + + return {"success": True} + except Exception as e: + return {"success": False, "error": str(e)} + @app.route("/equipment/edit_instrument/") @auth_required def edit_instrument(instrument_id: int): diff --git a/python/PiFinder/solver.py b/python/PiFinder/solver.py index 07a901528..31b697816 100644 --- a/python/PiFinder/solver.py +++ b/python/PiFinder/solver.py @@ -17,7 +17,6 @@ from time import perf_counter as precision_timestamp import os import threading -from PIL import Image from PiFinder import state_utils from PiFinder import utils diff --git a/python/views/equipment.tpl b/python/views/equipment.tpl index 7e3fd71ed..ace540a6e 100644 --- a/python/views/equipment.tpl +++ b/python/views/equipment.tpl @@ -110,20 +110,24 @@ % end -
Eyepieces
+
Eyepieces (drag to reorder)
- - - - - - - - - - + + + + + + + + + + + + + % for eyepiece in equipment.eyepieces: - + + @@ -147,10 +151,12 @@ % end +
MakeNameFocal Length (mm)Apparent FOVField StopActiveActions
MakeNameFocal Length (mm)Apparent FOVField StopActiveActions
drag_indicator {{eyepiece.make}} {{eyepiece.name}} {{eyepiece.focal_length_mm}}

+ % include("footer.tpl")