From 57db888e892a636a07f4ae61378cb18bedcba468 Mon Sep 17 00:00:00 2001 From: Xavier Date: Sat, 29 Aug 2026 11:18:17 +0200 Subject: [PATCH] =?UTF-8?q?Am=C3=A9liorations=20BO3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/system_utils.py | 41 ++++++++++++++++++---------------------- modules/ui_components.py | 14 +++++++++----- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/modules/system_utils.py b/modules/system_utils.py index 3a1fc40..8524152 100644 --- a/modules/system_utils.py +++ b/modules/system_utils.py @@ -7,34 +7,29 @@ def obtenir_infos_serveur(): # Espace disque racine / total, used, free = shutil.disk_usage("/") - # Recherche intelligente de la partition RAID ou /DATA via psutil + # Recherche spécifique de la partition RAID /DATA ou du périphérique md data_stats = {} try: - partitions = psutil.disk_partitions(all=False) - for p in partitions: - # Priorité à la détection d'un périphérique md (RAID) ou du point de montage /DATA - if "md" in p.device or p.mountpoint == "/DATA": - try: - dt, du, df = shutil.disk_usage(p.mountpoint) - data_stats = { - "device": p.device, - "mountpoint": p.mountpoint, - "total_gb": round(dt / (2**30), 2), - "utilise_gb": round(du / (2**30), 2), - "libre_gb": round(df / (2**30), 2), - "pourcentage": round((du / dt) * 100, 1) - } - if "md" in p.device: - break # On privilégie en premier le RAID détecté - except Exception: - pass + partitions = psutil.disk_partitions(all=True) + point_montage_cible = None - # Fallback sur /DATA si aucune détection spécifique md n'a eu lieu - if not data_stats and os.path.exists("/DATA"): + # On cherche en priorité un montage sur /DATA ou un device contenant 'md' + for p in partitions: + if p.mountpoint == "/DATA" or "md" in p.device: + point_montage_cible = p.mountpoint + break + + if point_montage_cible: + dt, du, df = shutil.disk_usage(point_montage_cible) + data_stats = { + "total_gb": round(dt / (2**30), 2), + "utilise_gb": round(du / (2**30), 2), + "libre_gb": round(df / (2**30), 2), + "pourcentage": round((du / dt) * 100, 1) + } + elif os.path.exists("/DATA"): dt, du, df = shutil.disk_usage("/DATA") data_stats = { - "device": "bind-mount /DATA", - "mountpoint": "/DATA", "total_gb": round(dt / (2**30), 2), "utilise_gb": round(du / (2**30), 2), "libre_gb": round(df / (2**30), 2), diff --git a/modules/ui_components.py b/modules/ui_components.py index bb8c435..8ac61ef 100644 --- a/modules/ui_components.py +++ b/modules/ui_components.py @@ -325,7 +325,7 @@ def render_backoffice_page(utilisateur, role, tous_les_utilisateurs, stats_serve sections.append(Div( H3("🖥️ Supervision Système, RAID & Agent Vectoriel", style="color: #ff9800;"), P(f"💾 Espace disque racine : {stats_serveur['disque_utilise_gb']} Go / {stats_serveur['disque_total_gb']} Go ({stats_serveur['pourcentage_utilise']}%)"), - (P(f"🗄️ Périphérique RAID ({data_st.get('device', '/DATA')} sur {data_st.get('mountpoint', '/DATA')}) : {data_st.get('utilise_gb', 0)} Go / {data_st.get('total_gb', 0)} Go ({data_st.get('pourcentage', 0)}% utilisés, {data_st.get('libre_gb', 0)} Go libres)") if data_st else P("🗄️ Partition RAID (/DATA) : Non montée ou non détectée")), + (P(f"🗄️ Partition RAID (/DATA) : {data_st.get('utilise_gb', 0)} Go / {data_st.get('total_gb', 0)} Go ({data_st.get('pourcentage', 0)}% utilisés, {data_st.get('libre_gb', 0)} Go libres)") if data_st else P("🗄️ Partition RAID (/DATA) : Non détectée")), Div( P("📡 État du RAID (mdstat) :", style="margin-bottom: 5px; font-weight: bold;"), Pre(stats_serveur.get('raid_status', 'N/A'), style="font-size: 0.8em; background: #111; color: #00ffcc; padding: 10px; border-radius: 4px; overflow-x: auto; max-height: 180px; overflow-y: auto; white-space: pre-wrap; font-family: monospace; margin: 0;"), @@ -338,12 +338,16 @@ def render_backoffice_page(utilisateur, role, tous_les_utilisateurs, stats_serve Button("Forcer la vectorisation globale de tout le RAG", type="submit", cls="btn-submit", style="background-color: #e91e63; color: white; width: 100%; font-weight: bold; cursor: pointer;"), method="post", action="/backoffice/forcer_vectorisation" ), - style="background: #1a1a1a; padding: 20px; border-radius: 8px; border: 1px solid #333;" + style="background: #1a1a1a; padding: 20px; border-radius: 8px; border: 1px solid #333; margin-bottom: 20px;" )) - sections.append(A("← Retour au Chat", href="/", style="display: block; margin-top: 20px; color: #00e5ff; text-decoration: none;")) + # Vrai bouton ergonomique de retour au Front Office + sections.append( + A("← Retour au Chat (Front Office)", href="/", cls="btn-submit", style="display: block; text-align: center; background-color: #00e5ff; color: black; text-decoration: none; font-weight: bold; padding: 12px; border-radius: 6px;") + ) return Title("Back Office - Aethas38"), Body( - Div(*sections, style="max-width: 600px; margin: 50px auto; font-family: monospace; color: #fff;"), - style="background-color: #0d0d0d; padding: 20px;" + Div(*sections, style="max-width: 600px; margin: 40px auto; font-family: monospace; color: #fff; padding-bottom: 40px;"), + # Style global appliqué au Body pour forcer le défilement vertical et éliminer les blocages d'affichage + style="background-color: #0d0d0d; padding: 20px; overflow-y: auto !important; height: 100vh; box-sizing: border-box;" ) \ No newline at end of file