Modify dashboard management
This commit is contained in:
Binary file not shown.
@@ -1,16 +1,15 @@
|
||||
import streamlit as st
|
||||
from auth_runtime import require_login
|
||||
# from ui.sidebar import build_sidebar
|
||||
from auth import create_user
|
||||
from pathlib import Path
|
||||
from tools.load_css import load_css
|
||||
from app_db.app_db import get_list, send_cmd
|
||||
from ui.selectboxes import get_groups, get_id
|
||||
from tools.numgen import get_num, update_num
|
||||
import bcrypt
|
||||
|
||||
|
||||
DASH_NAME = Path(__file__).stem # Hier muss die dash_id aus der DB stehen -> 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"])
|
||||
|
||||
|
||||
3
app/pages/default.py
Normal file
3
app/pages/default.py
Normal file
@@ -0,0 +1,3 @@
|
||||
import streamlit as st
|
||||
|
||||
st.header("Baustelle!")
|
||||
Reference in New Issue
Block a user