🛠 Mises à jour du 24/4/25

This commit is contained in:
2025-04-24 16:15:23 +02:00
parent 6aede05b7e
commit 74d734277d

View File

@@ -32,7 +32,6 @@ db_config = {
"database": os.getenv("DB_NAME")
}
# --- Fonction de génération PDF ---
def generer_pdf(site, date_str):
st.info(f"Génération du rapport PDF pour {site} à la date {date_str}")
@@ -271,10 +270,10 @@ if st.session_state["authenticated"]:
# --- NAVIGATION ---
if st.session_state["role"] == "superviseur":
onglet = st.sidebar.radio("📁 Navigation", ["Accueil", "Statistiques"])
onglet = st.sidebar.radio("📁 Navigation", ["Accueil", "Statistiques", "Traffic"])
# --- ONGLET ACCUEIL ---
else:
onglet = "Accueil"
if onglet == "Accueil":
st.markdown("## Sélection du site et de la date")
try:
@@ -354,7 +353,7 @@ if st.session_state["authenticated"]:
except Exception as e:
st.error(f"Erreur MySQL : {e}")
# ---- ONGLET STATISTIQUES ---
elif onglet == "Statistiques":
st.markdown("## 📈 Statistiques de température")
try:
@@ -486,5 +485,25 @@ if st.session_state["authenticated"]:
except Exception as e:
st.error(f"Erreur SQL (admin) : {e}")
# --- ONGLET TRAFFIC ------
elif onglet == "Traffic":
st.markdown("## 🚦 Connexions récentes")
try:
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor(dictionary=True)
cursor.execute(
"SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log ORDER BY Date_Connexion DESC LIMIT 200")
connexions = cursor.fetchall()
cursor.close()
conn.close()
if connexions:
df_connexions = pd.DataFrame(connexions)
st.dataframe(df_connexions, use_container_width=True)
else:
st.info("Aucune connexion enregistrée.")
except Exception as e:
st.error(f"Erreur chargement des connexions : {e}")
except exception as err:
st.error(f"Erreur MySQL : {err}")