Add navigation in sidebar
This commit is contained in:
24
app/dashboards/__init__.py
Normal file
24
app/dashboards/__init__.py
Normal file
@@ -0,0 +1,24 @@
|
||||
import importlib
|
||||
|
||||
def get_dashboard_renderer(code: str):
|
||||
"""
|
||||
Liefert die passende Render-Funktion zum Dashboard-Code.
|
||||
- "home" -> interne Funktion home_dashboard
|
||||
- alles andere -> Modul app.dashboards.<code> mit Funktion render(username, role)
|
||||
"""
|
||||
if code == "home":
|
||||
return home_dashboard
|
||||
|
||||
module_name = f"app.dashboards.{code}"
|
||||
try:
|
||||
module = importlib.import_module(module_name)
|
||||
except ModuleNotFoundError:
|
||||
# Zum Debuggen:
|
||||
st.error(f"Modul '{module_name}' wurde nicht gefunden.")
|
||||
return None
|
||||
|
||||
if not hasattr(module, "render"):
|
||||
st.error(f"Modul '{module_name}' hat keine Funktion render().")
|
||||
return None
|
||||
|
||||
return module.render
|
||||
Reference in New Issue
Block a user