dynamic appointments loading

This commit is contained in:
2025-06-14 15:08:43 +00:00
parent 4738740292
commit 2e8c852ee6
10 changed files with 187 additions and 52 deletions

View File

@@ -1,12 +1,16 @@
# dashboard/callbacks/appointments_callbacks.py
import os
import sys
sys.path.append('/workspace')
from dash import Input, Output, State, callback, ctx, dash
from flask import session
import json
import requests
print("appointments_callbacks.py geladen")
API_BASE_URL = os.getenv("API_BASE_URL", "http://192.168.43.100")
@callback(
dash.Output('output', 'children'),
dash.Input('calendar', 'lastDateClick')
@@ -34,3 +38,25 @@ def display_select(select_info):
return f"Markiert: {select_info['start']} bis {select_info['end']} (ganztägig: {select_info['allDay']})"
return "Markiere einen Bereich im Kalender!"
@callback(
dash.Output('calendar', 'events'),
dash.Input('calendar', 'lastNavClick'),
)
def load_events(view_dates):
"""
Lädt Events aus der API für den angezeigten Zeitraum im Kalender.
"""
print("Lade Events für Zeitraum:", view_dates)
if not view_dates or "start" not in view_dates or "end" not in view_dates:
return []
start = view_dates["start"]
end = view_dates["end"]
try:
resp = requests.get(f"{API_BASE_URL}/api/events", params={"start": start, "end": end})
resp.raise_for_status()
events = resp.json()
return events
except Exception as e:
print("Fehler beim Laden der Events:", e)
return []