Spaces:
Sleeping
Sleeping
File size: 4,537 Bytes
3dd5509 bd36982 3dd5509 f130825 3dd5509 49a419a d0539ef 3dd5509 |
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 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
import streamlit as st
from pages import login
from loguru import logger
APP_TITLE = ' '#'Revenue Cycle Management'
def _check_password():
"""Authenticate user and manage login state."""
if st.session_state.get("authenticated"):
return True
# Create a container for the entire page
container = st.container()
# Add a logo and title within the container
with container:
st.image("logo.png", width=200)
st.title("Welcome to Insights-Lab")
# Create a tabbed interface for login and signup
tabs = st.tabs(["Login", "Signup", "Resend Code"])
confirm_code_button = None
with tabs[0]:
# Login form
with st.form("login_form"):
login_user = st.text_input("Username",value = "maheshsr")
password = st.text_input("Password", type="password", value="Test@123")
login_button = st.form_submit_button("Login")
with tabs[1]:
# Signup form
with st.form("sign_up_form"):
name = st.text_input("Name")
email = st.text_input("Email")
new_username = st.text_input("New Username")
new_password = st.text_input("New Password", type="password")
confirm_password = st.text_input("Confirm Password", type="password")
signup_button = st.form_submit_button("Signup")
signup_code = st.text_input("OTP")
signup_code_button = st.form_submit_button("Confirm")
with tabs[2]:
# Resend Code
with st.form("resend_code"):
username = st.text_input("Username")
resend_code_button = st.form_submit_button("Resend Code")
confirm_code = st.text_input("OTP")
confirm_code_button = st.form_submit_button("Confirm")
# Add a placeholder for login/signup results
if login_button:
logger.info("Login button clicked.")
# login.login(login_user, password)
if login.login(login_user, password):
st.session_state.authenticated = True
# composer.run()
st.rerun()
elif signup_button:
logger.info("Signup button clicked.")
form_validation = login.signup_validation(new_password, confirm_password, name, email, new_username)
if form_validation:
login.signup(new_password, name, email, new_username)
elif resend_code_button:
logger.info("Resend code button clicked.")
login.resend_sign_up_code(username)
elif confirm_code_button:
logger.info("Confirm code button clicked.")
login.confirm_sign_up_code(username, confirm_code)
elif signup_code_button:
logger.info("Signup code button clicked.")
login.confirm_sign_up_code(new_username, signup_code)
return False
def _authenticated_menu():
if "page" not in st.session_state:
st.session_state.page = "composer"
st.switch_page("pages/composer.py")
with st.sidebar:
st.logo('logo.png')
st.image('insightlab_logo.png')
st.subheader(APP_TITLE, divider='blue')
st.header(" ")
st.sidebar.page_link("pages/composer.py", label="Dataset Composer")
st.session_state.page = "composer"
st.sidebar.page_link("pages/profiler.py",label="Data Profiler")
st.session_state.page = "profiler"
st.sidebar.page_link("pages/visualize.py", label="Data Visualizer")
st.session_state.page = "visualize"
st.sidebar.page_link("pages/designer.py", label="Insight Designer")
st.session_state.page = "designer"
st.sidebar.page_link("pages/automator.py", label="Insight Library")
st.session_state.page = "library"
if(st.session_state.userId=="c4686458-10a1-7096-10be-c5966f270129"):
st.sidebar.page_link("pages/logger.py", label="Logger")
st.session_state.page = "logger"
st.sidebar.divider()
if st.sidebar.button("Logout"):
_logout()
def _unauthenticated_menu():
logger.info("Rendering unauthenticated menu.")
pass
def _logout():
"""Log out the current user."""
logger.info("User logged out.")
st.session_state.clear()
st.success("You have been logged out successfully.")
st.rerun()
def menu():
if not _check_password():
logger.info("not logined")
_unauthenticated_menu()
st.stop()
else:
_authenticated_menu()
def menu_with_redirect():
if not _check_password():
st.switch_page("app.py")
menu() |