📝 "Refactor admin UI components for improved consistency and performance" 🌈
This commit is contained in:
@@ -1627,6 +1627,52 @@ def tapo_configuration_wizard():
|
||||
"error": f"Systemfehler: {str(e)}"
|
||||
}), 500
|
||||
|
||||
@printers_blueprint.route("/<int:printer_id>/connect", methods=["POST"])
|
||||
@login_required
|
||||
@require_permission(Permission.CONTROL_PRINTER)
|
||||
@measure_execution_time(logger=printers_logger, task_name="API-Drucker-Verbindung")
|
||||
def connect_printer(printer_id):
|
||||
"""
|
||||
Verbindet einen Drucker (schaltet die Steckdose ein).
|
||||
Wrapper für control_printer_power mit action='on'
|
||||
|
||||
Args:
|
||||
printer_id: ID des zu verbindenden Druckers
|
||||
|
||||
Returns:
|
||||
JSON mit Ergebnis der Verbindungsaktion
|
||||
"""
|
||||
printers_logger.info(f"🔗 Drucker-Verbindung für Drucker {printer_id} von Benutzer {current_user.name}")
|
||||
|
||||
try:
|
||||
# Fake JSON für control_printer_power
|
||||
original_json = request.get_json()
|
||||
request._cached_json = ({"action": "on"}, True)
|
||||
|
||||
# Delegiere an existing control_printer_power function
|
||||
result = control_printer_power(printer_id)
|
||||
|
||||
# Response für connect-API anpassen
|
||||
if hasattr(result, 'get_json') and result.get_json().get('success'):
|
||||
data = result.get_json()
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"message": f"Verbindung zu Drucker {printer_id} hergestellt",
|
||||
"printer_id": printer_id,
|
||||
"printer_name": data.get('printer_name'),
|
||||
"action": "connect",
|
||||
"timestamp": data.get('timestamp')
|
||||
})
|
||||
|
||||
return result
|
||||
|
||||
except Exception as e:
|
||||
printers_logger.error(f"❌ Fehler bei Drucker-Verbindung: {str(e)}")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": f"Verbindungsfehler: {str(e)}"
|
||||
}), 500
|
||||
|
||||
@printers_blueprint.route("/tapo/validate-configuration/<int:printer_id>", methods=["POST"])
|
||||
@login_required
|
||||
@require_permission(Permission.ADMIN)
|
||||
|
Reference in New Issue
Block a user