Hi comunity,
How are you? Hope you are doing fine.
Where I work we develop a Login Active Directory component to work with our apps.
Its currently on develop, but the first verision is on pypi. The idea is to make this a page of login and with a button of logout to refresh everything, but this does not happend.
I need help to find why, here is the code:
import streamlit as st
from streamlit import caching
from streamlit_azure_login import login_component
from PIL import Image
def main():
# Imagenes a utilizar
favicon = Image.open('src/app/components/assets/ic.png')
st.set_page_config(page_icon=favicon)
logo = Image.open('src/app/components/assets/log_ic.png')
st.session_state.token = False
print(f'Not Loged 1: {st.session_state.token}')
print(st.session_state)
print(type(st.session_state))
if st.session_state.token is False:
container = st.empty()
print(f'Not Loged 2: {st.session_state.token}')
with container.container():
token = login_component(
header_text='Intercement',
authentication_endpoint_url=environ.get('AD_ENDPOINT'),
logo_uri=environ.get('AD_LOGO_URI'),
prefix=environ.get('AD_PREFIX'),
)
print(f'Token: {token}')
if token:
st.session_state.token = True
token = login_component('', '', '', '',)
print(f'Token 2: {token}')
container.empty()
if st.session_state.token is True:
print(f'Loged: {st.session_state.token}')
# Estructura básica de la app
st.title('Dashboard 0800')
st.sidebar.image(logo, width = 300)
st.sidebar.title('Informacion de llamadas 0800')
informations = [
SidebarOptions.current_information.value,
SidebarOptions.attention_leves.value,
SidebarOptions.attention_on_levels_of_deviations.value,
SidebarOptions.top_15_sales_representatives.value,
SidebarOptions.top_customers_and_no_customers.value,
]
choice = st.sidebar.selectbox('Información de llamadas', informations)
if st.sidebar.button('Logout'):
del st.session_state['token']
print(f'Logout: {st.session_state}\n\n\n')
caching.clear_cache()
st.experimental_rerun()
if choice == SidebarOptions.current_information.value:
current_information_tab()
if choice == SidebarOptions.attention_leves.value:
attention_levels_tab()
if choice == SidebarOptions.attention_on_levels_of_deviations.value:
attention_levels_of_deviations_tab()
if choice == SidebarOptions.top_15_sales_representatives.value:
top_15_sales_representatives_tab()
if choice == SidebarOptions.top_customers_and_no_customers.value:
top_customers_and_no_customers()
I try deleting the cache, seting the token to none but its apear to pass away the logic and dont start again the app.
Its there any way to make a browser refresh from streamlit?
Thanks!