import streamlit as st from components.connexion import connexion, bouton_deconnexion import streamlit.components.v1 as components from utils.translations import _ from utils.persistance import get_champ_statut, maj_champ_statut def afficher_menu(): with st.sidebar: st.markdown(f""" """, unsafe_allow_html=True) # === GESTION DU THÈME === # # Le changement de thème induit un st.rerun qui vide les formula # Pour éviter de perdre les informations dans les formulaires, # le changement de thème n'est proposé que si l'utilisateur est sur l'onglet "Instructions" # # theme_mode = get_champ_statut("theme_mode") if theme_mode == "": theme_mode = str(_("sidebar.theme_light")) maj_champ_statut("theme_mode", theme_mode) theme_title = str(_("sidebar.theme")) st.markdown(f"""

{theme_title}

""", unsafe_allow_html=True) theme_options = [ str(_("sidebar.theme_light")), str(_("sidebar.theme_dark")) ] theme = st.radio( str(_("sidebar.theme")), theme_options, index=theme_options.index(theme_mode), horizontal=True, label_visibility="hidden" ) maj_champ_statut("theme_mode", theme) st.markdown("""
""", unsafe_allow_html=True) connexion() if not get_champ_statut("login") == "": bouton_deconnexion() # === RERUN SI BESOIN === if (onglet_choisi and onglet_choisi != navigation_onglet) or (theme != theme_mode): if onglet_choisi: # Ne met à jour que si on a cliqué maj_champ_statut("navigation_onglet", onglet_choisi) maj_champ_statut("theme_mode", theme) st.rerun() # # Important : # Avec Selinux, il faut donner les bons droits # # sudo chcon -Rt httpd_sys_content_t /chemin/d/acces/assets/ # def afficher_impact(total_bytes): impact_label = str(_("sidebar.impact")) loading_text = str(_("sidebar.loading")) with st.sidebar: components.html(f""" Impact Environnemental

{impact_label}

{loading_text}

""") st.markdown("""
This website runs on green hosting - verified by thegreenwebfoundation.org
""", unsafe_allow_html=True)