🎉 Feat: Enhanced Printer Management System
This commit introduces a comprehensive overhaul of the printer management system, enhancing its functionality and user experience. The following changes have been implemented: - backend/blueprints/__pycache__/admin_unified.cpython-311.pyc: Updated for improved admin interface integration. - backend/blueprints/__pycache__/drucker_steuerung.cpython-311.pyc
This commit is contained in:
Binary file not shown.
BIN
backend/blueprints/__pycache__/drucker_steuerung.cpython-311.pyc
Normal file
BIN
backend/blueprints/__pycache__/drucker_steuerung.cpython-311.pyc
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -2620,7 +2620,8 @@ def tapo_monitoring():
|
||||
|
||||
# Aktueller Status aller Tapo-Steckdosen abrufen
|
||||
try:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
tapo_available = True
|
||||
|
||||
# Status für jeden Drucker mit Tapo-Steckdose abrufen
|
||||
@ -2749,7 +2750,8 @@ def api_admin_bulk_tapo_control():
|
||||
|
||||
# Tapo-Controller laden
|
||||
try:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
'success': False,
|
||||
@ -2870,7 +2872,8 @@ def api_admin_tapo_health_check():
|
||||
try:
|
||||
# Tapo-Controller laden
|
||||
try:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
tapo_available = True
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
@ -3060,7 +3063,8 @@ def api_admin_configure_printer_tapo():
|
||||
test_result = None
|
||||
if test_connection and printer.plug_ip:
|
||||
try:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
test_result = tapo_controller.test_connection(
|
||||
printer.plug_ip,
|
||||
username=printer.plug_username,
|
||||
|
@ -131,7 +131,7 @@ def drucker_details(drucker_id):
|
||||
|
||||
@drucker_blueprint.route("/einschalten/<int:drucker_id>", methods=["POST"])
|
||||
@login_required
|
||||
@require_permission(Permission.CAN_CONTROL_PRINTERS)
|
||||
@require_permission(Permission.CONTROL_PRINTER)
|
||||
def drucker_einschalten(drucker_id):
|
||||
"""
|
||||
Schaltet einen Drucker über seine Tapo-Steckdose EIN.
|
||||
@ -163,7 +163,7 @@ def drucker_einschalten(drucker_id):
|
||||
|
||||
@drucker_blueprint.route("/ausschalten/<int:drucker_id>", methods=["POST"])
|
||||
@login_required
|
||||
@require_permission(Permission.CAN_CONTROL_PRINTERS)
|
||||
@require_permission(Permission.CONTROL_PRINTER)
|
||||
def drucker_ausschalten(drucker_id):
|
||||
"""
|
||||
Schaltet einen Drucker über seine Tapo-Steckdose AUS.
|
||||
@ -195,7 +195,7 @@ def drucker_ausschalten(drucker_id):
|
||||
|
||||
@drucker_blueprint.route("/toggle/<int:drucker_id>", methods=["POST"])
|
||||
@login_required
|
||||
@require_permission(Permission.CAN_CONTROL_PRINTERS)
|
||||
@require_permission(Permission.CONTROL_PRINTER)
|
||||
def drucker_toggle(drucker_id):
|
||||
"""
|
||||
Wechselt den Status eines Druckers (Ein <-> Aus).
|
||||
|
@ -182,10 +182,12 @@ def get_live_printer_status():
|
||||
|
||||
try:
|
||||
# Live-Status über den PrinterMonitor abrufen
|
||||
status_data = printer_monitor.get_live_printer_status(use_session_cache=use_cache)
|
||||
monitor = get_printer_monitor()
|
||||
status_data = monitor.get_live_printer_status(use_session_cache=use_cache)
|
||||
|
||||
# Zusammenfassung der Druckerstatus erstellen
|
||||
summary = printer_monitor.get_printer_summary()
|
||||
monitor = get_printer_monitor()
|
||||
summary = monitor.get_printer_summary()
|
||||
|
||||
# Antwort mit Status und Zusammenfassung
|
||||
response = {
|
||||
@ -448,7 +450,8 @@ def control_printer_power(printer_id):
|
||||
db_session.commit()
|
||||
|
||||
# Cache leeren, damit neue Status-Abfragen aktuell sind
|
||||
printer_monitor.clear_all_caches()
|
||||
monitor = get_printer_monitor()
|
||||
monitor.clear_all_caches()
|
||||
|
||||
printers_logger.info(f"✅ {action.upper()}: Drucker {printer.name} erfolgreich {message}")
|
||||
|
||||
@ -494,10 +497,10 @@ def force_refresh_all_printer_status():
|
||||
|
||||
try:
|
||||
# Hardware Integration Monitor für Force-Refresh verwenden
|
||||
from utils.hardware_integration import printer_monitor
|
||||
|
||||
# Force-Network-Refresh durchführen
|
||||
refresh_results = printer_monitor.force_network_refresh()
|
||||
monitor = get_printer_monitor()
|
||||
refresh_results = monitor.force_network_refresh()
|
||||
|
||||
if refresh_results.get("success", False):
|
||||
printers_logger.info(f"✅ Force-Refresh erfolgreich: {refresh_results.get('printers_refreshed', 0)} Drucker aktualisiert")
|
||||
@ -792,7 +795,8 @@ def test_socket_control(printer_id):
|
||||
db_session.commit()
|
||||
|
||||
# Cache leeren, damit neue Status-Abfragen aktuell sind
|
||||
printer_monitor.clear_all_caches()
|
||||
monitor = get_printer_monitor()
|
||||
monitor.clear_all_caches()
|
||||
|
||||
# Test-Eintrag für Audit-Log
|
||||
printers_logger.info(f"🧪 TEST DURCHGEFÜHRT: {action.upper()} für {printer.name} | "
|
||||
@ -1335,7 +1339,8 @@ def mass_tapo_status_check():
|
||||
|
||||
# Tapo-Controller laden
|
||||
try:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
tapo_available = True
|
||||
except Exception as e:
|
||||
db_session.close()
|
||||
@ -1512,7 +1517,8 @@ def tapo_configuration_wizard():
|
||||
|
||||
# Tapo-Controller laden
|
||||
try:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
except Exception as e:
|
||||
return jsonify({
|
||||
"success": False,
|
||||
@ -1700,7 +1706,8 @@ def validate_tapo_configuration(printer_id):
|
||||
|
||||
# Tapo-Controller laden
|
||||
try:
|
||||
from utils.hardware_integration import tapo_controller
|
||||
from utils.hardware_integration import get_tapo_controller
|
||||
tapo_controller = get_tapo_controller()
|
||||
except Exception as e:
|
||||
db_session.close()
|
||||
return jsonify({
|
||||
|
@ -74,7 +74,8 @@ def tapo_dashboard():
|
||||
|
||||
# Status der Steckdose prüfen
|
||||
try:
|
||||
reachable, status = tapo_controller.check_outlet_status(
|
||||
controller = get_tapo_controller()
|
||||
reachable, status = controller.check_outlet_status(
|
||||
tapo_ip,
|
||||
printer_id=printer_id
|
||||
)
|
||||
@ -195,7 +196,8 @@ def control_outlet():
|
||||
|
||||
# Steckdose schalten
|
||||
state = action == 'on'
|
||||
success = tapo_controller.toggle_plug(ip, state)
|
||||
controller = get_tapo_controller()
|
||||
success = controller.toggle_plug(ip, state)
|
||||
|
||||
if success:
|
||||
action_text = "eingeschaltet" if state else "ausgeschaltet"
|
||||
@ -241,7 +243,8 @@ def get_outlet_status(ip):
|
||||
}), 400
|
||||
|
||||
# Status prüfen
|
||||
reachable, status = tapo_controller.check_outlet_status(ip)
|
||||
controller = get_tapo_controller()
|
||||
reachable, status = controller.check_outlet_status(ip)
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
@ -267,7 +270,8 @@ def discover_outlets():
|
||||
tapo_logger.info(f"🔍 Starte Tapo-Steckdosen-Erkennung auf Anfrage von {current_user.name}")
|
||||
|
||||
# Discovery starten
|
||||
results = tapo_controller.auto_discover_outlets()
|
||||
controller = get_tapo_controller()
|
||||
results = controller.auto_discover_outlets()
|
||||
|
||||
success_count = sum(1 for success in results.values() if success)
|
||||
total_count = len(results)
|
||||
@ -304,7 +308,8 @@ def test_connection(ip):
|
||||
}), 400
|
||||
|
||||
# Verbindung testen
|
||||
test_result = tapo_controller.test_connection(ip)
|
||||
controller = get_tapo_controller()
|
||||
test_result = controller.test_connection(ip)
|
||||
|
||||
return jsonify({
|
||||
'success': True,
|
||||
@ -342,7 +347,8 @@ def get_all_status():
|
||||
for printer in printers_with_tapo:
|
||||
try:
|
||||
tapo_logger.debug(f"Prüfe Status für {printer.plug_ip} ({printer.name})")
|
||||
reachable, status = tapo_controller.check_outlet_status(
|
||||
controller = get_tapo_controller()
|
||||
reachable, status = controller.check_outlet_status(
|
||||
printer.plug_ip,
|
||||
printer_id=printer.id
|
||||
)
|
||||
@ -431,7 +437,8 @@ def manual_control():
|
||||
|
||||
if action == 'status':
|
||||
# Status abfragen
|
||||
reachable, status = tapo_controller.check_outlet_status(ip)
|
||||
controller = get_tapo_controller()
|
||||
reachable, status = controller.check_outlet_status(ip)
|
||||
if reachable:
|
||||
flash(f'Steckdose {ip} ist {status.upper()}', 'success')
|
||||
else:
|
||||
@ -439,7 +446,8 @@ def manual_control():
|
||||
else:
|
||||
# Ein/Ausschalten
|
||||
state = action == 'on'
|
||||
success = tapo_controller.toggle_plug(ip, state)
|
||||
controller = get_tapo_controller()
|
||||
success = controller.toggle_plug(ip, state)
|
||||
|
||||
if success:
|
||||
action_text = "eingeschaltet" if state else "ausgeschaltet"
|
||||
@ -482,7 +490,8 @@ def control_outlet_form():
|
||||
|
||||
# Steckdose schalten
|
||||
state = action == 'on'
|
||||
success = tapo_controller.toggle_plug(ip, state)
|
||||
controller = get_tapo_controller()
|
||||
success = controller.toggle_plug(ip, state)
|
||||
|
||||
if success:
|
||||
action_text = "eingeschaltet" if state else "ausgeschaltet"
|
||||
@ -520,7 +529,8 @@ def test_connection_form():
|
||||
return redirect(url_for('tapo.tapo_dashboard'))
|
||||
|
||||
# Verbindung testen
|
||||
test_result = tapo_controller.test_connection(ip)
|
||||
controller = get_tapo_controller()
|
||||
test_result = controller.test_connection(ip)
|
||||
|
||||
if test_result.get('success', False):
|
||||
flash(f'✅ Verbindung zu {ip} erfolgreich!', 'success')
|
||||
|
Reference in New Issue
Block a user