🛠 Mises à jour du 24/4/25
This commit is contained in:
29
domo91.py
29
domo91.py
@@ -32,7 +32,6 @@ db_config = {
|
|||||||
"database": os.getenv("DB_NAME")
|
"database": os.getenv("DB_NAME")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# --- Fonction de génération PDF ---
|
# --- Fonction de génération PDF ---
|
||||||
def generer_pdf(site, date_str):
|
def generer_pdf(site, date_str):
|
||||||
st.info(f"Génération du rapport PDF pour {site} à la date {date_str}")
|
st.info(f"Génération du rapport PDF pour {site} à la date {date_str}")
|
||||||
@@ -124,7 +123,7 @@ if "lieu_autorise" not in st.session_state:
|
|||||||
st.session_state["lieu_autorise"] = None
|
st.session_state["lieu_autorise"] = None
|
||||||
|
|
||||||
# --- Connexion utilisateur dans la sidebar ---
|
# --- Connexion utilisateur dans la sidebar ---
|
||||||
st.sidebar.header("🔐 Connexion")
|
st.sidebar.header("🔐 Connexion")
|
||||||
if not st.session_state.get("authenticated"):
|
if not st.session_state.get("authenticated"):
|
||||||
login = st.sidebar.text_input("Nom d'utilisateur")
|
login = st.sidebar.text_input("Nom d'utilisateur")
|
||||||
password = st.sidebar.text_input("Mot de passe", type="password")
|
password = st.sidebar.text_input("Mot de passe", type="password")
|
||||||
@@ -271,10 +270,10 @@ if st.session_state["authenticated"]:
|
|||||||
|
|
||||||
# --- NAVIGATION ---
|
# --- NAVIGATION ---
|
||||||
if st.session_state["role"] == "superviseur":
|
if st.session_state["role"] == "superviseur":
|
||||||
onglet = st.sidebar.radio("📁 Navigation", ["Accueil", "Statistiques"])
|
onglet = st.sidebar.radio("📁 Navigation", ["Accueil", "Statistiques", "Traffic"])
|
||||||
|
# --- ONGLET ACCUEIL ---
|
||||||
else:
|
else:
|
||||||
onglet = "Accueil"
|
onglet = "Accueil"
|
||||||
|
|
||||||
if onglet == "Accueil":
|
if onglet == "Accueil":
|
||||||
st.markdown("## Sélection du site et de la date")
|
st.markdown("## Sélection du site et de la date")
|
||||||
try:
|
try:
|
||||||
@@ -354,7 +353,7 @@ if st.session_state["authenticated"]:
|
|||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
st.error(f"Erreur MySQL : {e}")
|
st.error(f"Erreur MySQL : {e}")
|
||||||
|
# ---- ONGLET STATISTIQUES ---
|
||||||
elif onglet == "Statistiques":
|
elif onglet == "Statistiques":
|
||||||
st.markdown("## 📈 Statistiques de température")
|
st.markdown("## 📈 Statistiques de température")
|
||||||
try:
|
try:
|
||||||
@@ -486,5 +485,25 @@ if st.session_state["authenticated"]:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
st.error(f"Erreur SQL (admin) : {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:
|
except exception as err:
|
||||||
st.error(f"Erreur MySQL : {err}")
|
st.error(f"Erreur MySQL : {err}")
|
||||||
|
|||||||
Reference in New Issue
Block a user