/** * ========================================================================= * PLATEFORME ECO-PANNEAU.FR - VERSION 1.0.0 * Interface Administrateur - Modales : Système (Code, Logs, Diagnostics) * ========================================================================= */ window.pano_AdminModalsSystem = ({ activeModal, closeCurrentLayer, showToast }) => { const { useState, useEffect } = React; const [isSaving, setIsSaving] = useState(false); // 1. ÉTATS const [codeStats, setCodeStats] = useState(null); const [sortConfig, setSortConfig] = useState({ key: 'lines', direction: 'desc' }); const [logs, setLogs] = useState(''); const [diagnostics, setDiagnostics] = useState([]); // 2. COMPOSANTS ET ICÔNES const Modal = window.pano_Modal || (() => null); const Button = window.pano_Button || (() => null); const { ActivityIcon, TerminalIcon, FileDigitIcon, Trash2Icon, CopyIcon, CheckCircleIcon } = window.pano_getIcons(); // 3. CHARGEMENT DYNAMIQUE useEffect(() => { if (activeModal === 'code_stats') loadCodeStats(); if (activeModal === 'logs') loadLogs(); if (activeModal === 'diagnostics') loadDiagnostics(); }, [activeModal]); const loadCodeStats = async () => { // CORRECTION : Ajout de { method: 'GET' } const d = await window.pano_apiFetch('system/code_stats', { method: 'GET' }); if (d && d.status === 'success') setCodeStats(d.data); }; const loadLogs = async () => { // CORRECTION : Ajout de { method: 'GET' } const d = await window.pano_apiFetch('system/logs', { method: 'GET' }); if (d && d.status === 'success') setLogs(d.data?.logs || ''); }; const loadDiagnostics = async () => { // CORRECTION : Ajout de { method: 'GET' } const d = await window.pano_apiFetch('system/diagnostics', { method: 'GET' }); if (d && d.status === 'success') setDiagnostics(d.data || []); }; // 4. HANDLERS JOURNAUX (LOGS) const handleClearLogs = async () => { const d = await window.pano_apiFetch('system/clear_logs', { method: 'POST', // Nettoyer les logs devrait être un POST setLoading: setIsSaving, successMessage: "Journaux purgés." }); if (d) setLogs(''); }; const handleCopyLogs = () => { navigator.clipboard.writeText(logs); if (showToast) showToast("Journaux copiés dans le presse-papiers.", "success"); }; // 5. TRI DES FICHIERS (CODE STATS) const sortedFiles = React.useMemo(() => { if (!codeStats || !codeStats.files) return []; let sortableItems = [...codeStats.files]; if (sortConfig !== null) { sortableItems.sort((a, b) => { if (a[sortConfig.key] < b[sortConfig.key]) return sortConfig.direction === 'asc' ? -1 : 1; if (a[sortConfig.key] > b[sortConfig.key]) return sortConfig.direction === 'asc' ? 1 : -1; return 0; }); } return sortableItems; }, [codeStats, sortConfig]); const requestSort = (key) => { let direction = 'asc'; if (sortConfig && sortConfig.key === key && sortConfig.direction === 'asc') direction = 'desc'; setSortConfig({ key, direction }); }; // 6. RENDU return ( <> {/* STATS DU CODE SOURCE */} {activeModal === 'code_stats' && ( {!codeStats ? (
Analyse des fichiers en cours...
) : (

{codeStats.totalLines.toLocaleString('fr-FR')}

Lignes totales

{codeStats.totalChars.toLocaleString('fr-FR')}

Caractères

{codeStats.totalFiles.toLocaleString('fr-FR')}

Fichiers analysés

{codeStats.totalSizeMB.toFixed(2)} Mo

Poids (Code seul)

{sortedFiles.map((f, i) => ( ))}
requestSort('name')}> Fichier {sortConfig?.key === 'name' ? (sortConfig.direction === 'asc' ? '↑' : '↓') : ''} requestSort('type')}> Type {sortConfig?.key === 'type' ? (sortConfig.direction === 'asc' ? '↑' : '↓') : ''} requestSort('lines')}> Lignes {sortConfig?.key === 'lines' ? (sortConfig.direction === 'asc' ? '↑' : '↓') : ''} requestSort('chars')}> Caractères {sortConfig?.key === 'chars' ? (sortConfig.direction === 'asc' ? '↑' : '↓') : ''}
{f.name} {f.type} {f.lines.toLocaleString('fr-FR')} {f.chars.toLocaleString('fr-FR')}
)}
)} {/* JOURNAUX D'ERREURS */} {activeModal === 'logs' && (

Trace technique des erreurs et alertes serveur.

{logs || "Aucune erreur enregistrée dans le journal (Fichier error_log vide)."}
)} {/* DIAGNOSTICS */} {activeModal === 'diagnostics' && (

État de santé des services et de l'environnement d'hébergement.

{diagnostics.length > 0 ? diagnostics.map((d, i) => { let statusColor = 'text-emerald-500'; if (d.status === 'warning') statusColor = 'text-amber-500'; if (d.status === 'error') statusColor = 'text-red-500'; return (

{d.name} {d.status === 'success' && } {d.status !== 'success' && }

{d.detail}

); }) : (
Récupération des diagnostics...
)}
)} ); }; /* EOF ========== [_react/_admin_modals_system.jsx] */