From 07854cc0ad71f685335f0892c4923a81f4afa597 Mon Sep 17 00:00:00 2001 From: knedlik Date: Mon, 29 Dec 2025 11:04:16 +0100 Subject: [PATCH] Modify dashboard management --- app/app_db/app.db | Bin 69632 -> 69632 bytes app/pages/dashboards.py | 40 +++++++++++++++++++++++++++++++++------- app/pages/default.py | 3 +++ 3 files changed, 36 insertions(+), 7 deletions(-) create mode 100644 app/pages/default.py diff --git a/app/app_db/app.db b/app/app_db/app.db index 0ef9bfaf017ade1297b70a0ebc891484edab5fbc..1f6c7efd18dc238e399749747f21a2d4eb492619 100644 GIT binary patch delta 55 zcmV-70LcG%i NjbI@GF|$>#t6=eN6E*+< delta 106 zcmZozz|ydQWr8##>qHr6M%Il99r29Zn_tFDD=>5LuH4Mtu!z^plberGRGpF2m;nel z4TU*NQj1GKI3=+-BPl wird gegen die session_state geprüft (User-Berechtigung) +DASH_PATH = Path(__file__).resolve().parent + load_css() @@ -19,8 +18,14 @@ st.set_page_config(page_title="Co-App Benutzer", page_icon=":material/person:", authenticator = require_login() st.session_state["authenticator"] = authenticator - - +def get_dashboards_from_pages(): + dashboards = sorted( + d.stem + for d in DASH_PATH.glob("*.py") + if d.name != "__init__.py" + ) + #dash_list = [""] + dashboards + return dashboards def sidebar(): @@ -53,6 +58,10 @@ def dialog_create_dashboard(dash_id): df_groups = get_groups() groups = df_groups["group"].tolist() + dash_list = get_dashboards_from_pages() + dash_default_index = dash_list.index("default") + + txt_dash_id = st.text_input("Dash-Id", value=dash_id, disabled=True) col1, col2 = st.columns([2,1],vertical_alignment="center") with col1: @@ -61,7 +70,12 @@ def dialog_create_dashboard(dash_id): is_active = st.checkbox(label="Aktiv", value=1) txt_dash_description = st.text_area(label="Beschreibung") cmb_dash_type = st.selectbox(label="Typ", options=dash_types) - txt_page_file = st.text_input(label="Page") + + if cmb_dash_type == "url": + txt_page_file = st.text_input(label="URL", placeholder="URL, z.B. https://www.gmn.de") + else: + txt_page_file = st.selectbox(label="Dashboard", options=dash_list, index=dash_default_index) + cmb_group = st.selectbox(label="Gruppe", options=groups, placeholder="Gruppe auswählen") txt_order_no = st.text_input(label="Order-Nr") @@ -161,6 +175,10 @@ def dialog_edit_dashboard(dash_id): dash_types = ["page", "url"] dash_type_index = dash_types.index(df.iloc[0]["dash_type"]) + dash_list = get_dashboards_from_pages() + dash_default_index = dash_list.index(df.iloc[0]["page_file"]) if df.iloc[0]["page_file"] in dash_list else dash_list.index("default") + + col1, col2 = st.columns([2,1],vertical_alignment="center") with col1: txt_dash_text = st.text_input(label="Dashboard", value=df.iloc[0]["dash_text"]) @@ -168,7 +186,15 @@ def dialog_edit_dashboard(dash_id): is_active = st.checkbox(label="Aktiv", value=df.iloc[0]["active"]) txt_dash_description = st.text_area(label="Beschreibung", value=df.iloc[0]["dash_description"]) cmb_dash_type = st.selectbox(label="Typ", options=dash_types, index=dash_type_index) - txt_page_file = st.text_input(label="Page", value=df.iloc[0]["page_file"]) + if cmb_dash_type == "url": + if df.iloc[0]["dash_type"] == "page": + txt_page_file = st.text_input(label="URL", value="", placeholder="URL, z.B. https://www.gmn.de") + else: + txt_page_file = st.text_input(label="URL", value=df.iloc[0]["page_file"]) + dash_default_index = dash_list.index("default") + else: + txt_page_file = st.selectbox(label="Dashboard", options=dash_list, index=dash_default_index) + cmb_group = st.selectbox(label="Gruppe", options=groups, placeholder="Gruppe auswählen", index=idx) txt_order_no = st.text_input(label="Order-Nr",value=df.iloc[0]["order_no"]) diff --git a/app/pages/default.py b/app/pages/default.py new file mode 100644 index 0000000..98fcf08 --- /dev/null +++ b/app/pages/default.py @@ -0,0 +1,3 @@ +import streamlit as st + +st.header("Baustelle!") \ No newline at end of file