modalbox for appoiments
This commit is contained in:
@@ -1,16 +1,17 @@
|
||||
# dashboard/callbacks/appointments_callbacks.py
|
||||
import requests
|
||||
import json
|
||||
from flask import session
|
||||
from dash import Input, Output, State, callback, ctx, dash
|
||||
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')
|
||||
@@ -20,6 +21,7 @@ def display_date(date_str):
|
||||
return f"Letzter Klick auf: {date_str}"
|
||||
return "Klicke auf ein Datum im Kalender!"
|
||||
|
||||
|
||||
@callback(
|
||||
dash.Output('event-output', 'children'),
|
||||
dash.Input('calendar', 'lastEventClick')
|
||||
@@ -29,6 +31,7 @@ def display_event(event_id):
|
||||
return f"Letztes Event geklickt: {event_id}"
|
||||
return "Klicke auf ein Event im Kalender!"
|
||||
|
||||
|
||||
@callback(
|
||||
dash.Output('select-output', 'children'),
|
||||
dash.Input('calendar', 'lastSelect')
|
||||
@@ -38,6 +41,7 @@ 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'),
|
||||
@@ -52,7 +56,8 @@ def load_events(view_dates):
|
||||
start = view_dates["start"]
|
||||
end = view_dates["end"]
|
||||
try:
|
||||
resp = requests.get(f"{API_BASE_URL}/api/events", params={"start": start, "end": end})
|
||||
resp = requests.get(f"{API_BASE_URL}/api/events",
|
||||
params={"start": start, "end": end})
|
||||
resp.raise_for_status()
|
||||
events = resp.json()
|
||||
return events
|
||||
@@ -60,3 +65,23 @@ def load_events(view_dates):
|
||||
print("Fehler beim Laden der Events:", e)
|
||||
return []
|
||||
|
||||
# --- Modalbox öffnen ---
|
||||
|
||||
|
||||
@callback(
|
||||
Output("appointment-modal", "opened"),
|
||||
[
|
||||
Input("open-appointment-modal-btn", "n_clicks"),
|
||||
Input("close-appointment-modal-btn", "n_clicks")
|
||||
],
|
||||
State("appointment-modal", "opened"),
|
||||
prevent_initial_call=True
|
||||
)
|
||||
def toggle_appointment_modal(open_click, close_click, is_open):
|
||||
from dash import ctx
|
||||
trigger = ctx.triggered_id
|
||||
if trigger == "open-appointment-modal-btn" and open_click:
|
||||
return True
|
||||
if trigger == "close-appointment-modal-btn" and close_click:
|
||||
return False
|
||||
return is_open
|
||||
|
||||
Reference in New Issue
Block a user