-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmenu.py
38 lines (32 loc) · 1.43 KB
/
menu.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import streamlit as st
def authenticated_menu():
# Show a navigation menu for authenticated users
st.sidebar.page_link("Resilient_Home.py", label="Switch accounts")
st.sidebar.page_link("pages/user.py", label="Your profile")
if st.session_state.role in ["admin", "super-admin"]:
st.sidebar.page_link("pages/admin.py", label="Manage users")
st.sidebar.page_link(
"pages/super-admin.py",
label="Manage admin access",
disabled=st.session_state.role != "super-admin",
)
st.title("Dashboards", anchor=None, help=None)
st.sidebar.page_link("pages/dashboards_v0.py", label="Dashboards")
def unauthenticated_menu():
# Show a navigation menu for unauthenticated users
st.sidebar.page_link("Resilient_Home.py", label="Log in")
st.title("Dashboards", anchor=None, help=None)
st.sidebar.page_link("pages/dashboards_v0.py", label="Unautehticated Dashboards")
def menu():
# Determine if a user is logged in or not, then show the correct
# navigation menu
if "role" not in st.session_state or st.session_state.role is None:
unauthenticated_menu()
return
authenticated_menu()
def menu_with_redirect():
# Redirect users to the main page if not logged in, otherwise continue to
# render the navigation menu
if "role" not in st.session_state or st.session_state.role is None:
st.switch_page("Resilient_Home.py")
menu()