🎉 Improved documentation and code organization in Backend 🌐

This commit is contained in:
2025-06-12 10:06:34 +02:00
parent c356111149
commit 2bf4e0e6c0
30 changed files with 1596 additions and 94 deletions

View File

@@ -7,6 +7,7 @@ from sqlalchemy import and_, or_, func
from models import Job, Printer, User, UserPermission, get_cached_session
from utils.logging_config import get_logger
from utils.job_queue_system import conflict_manager, ConflictType, ConflictSeverity
from utils.tapo_status_manager import tapo_status_manager
calendar_blueprint = Blueprint('calendar', __name__)
logger = get_logger("calendar")
@@ -241,6 +242,49 @@ def api_get_calendar_events():
}
}
# Für Admins: Erweiterte Steckdosen-Status-Informationen hinzufügen
if current_user.is_admin:
# Aktuellen Steckdosen-Status abrufen
printer_status = tapo_status_manager.get_printer_status(job.printer_id)
event["extendedProps"].update({
"plugStatus": printer_status.get("plug_status", "unknown"),
"plugReachable": printer_status.get("plug_reachable", False),
"hasPlug": printer_status.get("has_plug", False),
"canControl": printer_status.get("can_control", False),
"currentJob": printer_status.get("current_job"),
"nextJob": printer_status.get("next_job")
})
# Status-Display-Informationen hinzufügen
plug_status = printer_status.get("plug_status", "unknown")
if plug_status in tapo_status_manager.STATUS_DISPLAY:
status_info = tapo_status_manager.STATUS_DISPLAY[plug_status]
event["extendedProps"]["statusDisplay"] = {
"text": status_info["text"],
"color": status_info["color"],
"icon": status_info["icon"]
}
# Tooltip-Informationen hinzufügen
tooltip_parts = [
f"Job: {job.name}",
f"Drucker: {printer_name}",
f"Status: {job.status}",
f"Benutzer: {user_name}"
]
if printer_status.get("has_plug"):
plug_status_text = event["extendedProps"].get("statusDisplay", {}).get("text", "Unbekannt")
tooltip_parts.append(f"Steckdose: {plug_status_text}")
if printer_status.get("plug_reachable"):
tooltip_parts.append("✓ Steckdose erreichbar")
else:
tooltip_parts.append("✗ Steckdose nicht erreichbar")
event["tooltip"] = "\n".join(tooltip_parts)
events.append(event)
# Steckdosen-Status-Events hinzufügen (falls gewünscht)