dynamic appointments loading
This commit is contained in:
@@ -14,7 +14,7 @@ RUN apt-get update \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# --- Python-Abhängigkeiten kopieren und installieren ---
|
||||
COPY dash_using_fullcalendar-0.0.1.tar.gz ./
|
||||
COPY dash_using_fullcalendar-0.1.0.tar.gz ./
|
||||
COPY requirements.txt ./
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ RUN groupadd -g ${GROUP_ID} infoscreen_taa \
|
||||
WORKDIR /app
|
||||
|
||||
# Kopiere nur Requirements für schnellen Rebuild
|
||||
COPY dash_using_fullcalendar-0.0.1.tar.gz ./
|
||||
COPY dash_using_fullcalendar-0.1.0.tar.gz ./
|
||||
COPY requirements.txt ./
|
||||
COPY requirements-dev.txt ./
|
||||
|
||||
|
||||
@@ -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 []
|
||||
|
||||
|
||||
Binary file not shown.
BIN
dashboard/dash_using_fullcalendar-0.1.0.tar.gz
Normal file
BIN
dashboard/dash_using_fullcalendar-0.1.0.tar.gz
Normal file
Binary file not shown.
@@ -2,36 +2,24 @@
|
||||
from dash import html, dcc
|
||||
import dash
|
||||
from dash_using_fullcalendar import DashUsingFullcalendar
|
||||
|
||||
# dash.register_page(__name__, path="/appointments", name="Termine")
|
||||
# def layout(): # Als Funktion definieren
|
||||
# return html.Div([
|
||||
# dcc.Store(id="calendar-click-store"),
|
||||
# dcc.Store(id="calendar-event-store"),
|
||||
# dcc.Input(id="test-input"),
|
||||
# html.Div("TEST")
|
||||
# ])
|
||||
import dash_bootstrap_components as dbc
|
||||
|
||||
dash.register_page(__name__, path="/appointments", name="Termine")
|
||||
|
||||
layout = dbc.Container([
|
||||
dbc.Row([
|
||||
dbc.Col(html.H2("Dash FullCalendar mit Bootstrap 5"))
|
||||
dbc.Col(html.H2("Dash FullCalendar"))
|
||||
]),
|
||||
dbc.Row([
|
||||
dbc.Col(
|
||||
DashUsingFullcalendar(
|
||||
id='calendar',
|
||||
events=[
|
||||
{"id": "1", "title": "Meeting", "date": "2025-06-13T09:00:00"},
|
||||
{"id": "2", "title": "Workshop", "date": "2025-06-15T14:30:00"}
|
||||
],
|
||||
events=[],
|
||||
initialView="timeGridWeek",
|
||||
headerToolbar={
|
||||
"left": "prev,next today",
|
||||
"center": "title",
|
||||
"right": "dayGridMonth,timeGridWeek,timeGridDay"
|
||||
# "right": "dayGridMonth,timeGridWeek,timeGridDay"
|
||||
},
|
||||
height=600,
|
||||
locale="de",
|
||||
@@ -43,7 +31,7 @@ layout = dbc.Container([
|
||||
allDaySlot=False,
|
||||
firstDay=1,
|
||||
# themeSystem kann auf "bootstrap5" gesetzt werden, wenn das Plugin eingebunden ist
|
||||
themeSystem="bootstrap5"
|
||||
# themeSystem="bootstrap5"
|
||||
)
|
||||
)
|
||||
]),
|
||||
|
||||
@@ -10,4 +10,4 @@ paho-mqtt>=2.1.0
|
||||
python-dotenv>=1.1.0
|
||||
PyMySQL>=1.1.1
|
||||
SQLAlchemy>=2.0.41
|
||||
./dash_using_fullcalendar-0.0.1.tar.gz
|
||||
./dash_using_fullcalendar-0.1.0.tar.gz
|
||||
|
||||
Reference in New Issue
Block a user