This commit is contained in:
@@ -1,21 +1,37 @@
|
||||
import streamlit as st
|
||||
import logging
|
||||
from streamlit import dialog
|
||||
import queries.user as user_queries
|
||||
|
||||
from logger import init_logger
|
||||
from styles import init_styles
|
||||
|
||||
init_logger()
|
||||
init_styles()
|
||||
|
||||
if hasattr(st, 'user') and hasattr(st.user, 'is_logged_in'):
|
||||
if not st.user.is_logged_in:
|
||||
with st.container(width="stretch", height="stretch", horizontal_alignment="center"):
|
||||
st.title("Daily Counter", width="stretch", text_alignment="center")
|
||||
st.text("Please log in to use this app", width="stretch", text_alignment="center")
|
||||
st.space()
|
||||
if st.button("Log in"):
|
||||
st.login()
|
||||
is_login_enabled = hasattr(st, 'user')
|
||||
is_logged_in = is_login_enabled and hasattr(st.user, 'is_logged_in') and st.user.is_logged_in
|
||||
|
||||
if is_logged_in:
|
||||
user_queries.set_user_in_session(st.user)
|
||||
else:
|
||||
st.session_state.user_id = 1 # default user
|
||||
|
||||
if is_login_enabled and not is_logged_in:
|
||||
with st.container(width="stretch", height="stretch", horizontal_alignment="center"):
|
||||
st.title("Daily Counter", width="stretch", text_alignment="center")
|
||||
st.text("Please log in to use this app", width="stretch", text_alignment="center")
|
||||
st.space()
|
||||
if st.button("Log in"):
|
||||
st.login()
|
||||
|
||||
else:
|
||||
counters = st.Page("pages/counters.py", title="Counters", icon=":material/update:")
|
||||
stats = st.Page("pages/stats.py", title="Statistics", icon=":material/chart_data:")
|
||||
pg = st.navigation(position="top", pages=[counters, stats])
|
||||
pg.run()
|
||||
logoutPage = st.Page(st.logout, title="Logout", icon=":material/logout:")
|
||||
|
||||
pages = [counters, stats]
|
||||
if is_login_enabled:
|
||||
pages = pages + [logoutPage]
|
||||
|
||||
pg = st.navigation(position="top", pages=pages)
|
||||
pg.run()
|
||||
|
||||
Reference in New Issue
Block a user