« Info::IA:création de websites » : différence entre les versions

De wiki_pcwiki2
Aller à la navigationAller à la recherche
Aucun résumé des modifications
Aucun résumé des modifications
Ligne 5 : Ligne 5 :
  Exemple:
  Exemple:
  https://huggingface.co/spaces/enzostvs/deepsite
  https://huggingface.co/spaces/enzostvs/deepsite
PREMIERE VERSION:
  Crée moi un site pour gérer deux interrupteurs ethernet:
  Crée moi un site pour gérer deux interrupteurs ethernet:
{| align="center" border="0" cellpading="2" cellspacing="2"
{| align="center" border="0" cellpading="2" cellspacing="2"
Ligne 383 : Ligne 384 :
</html>
</html>
</pre></code>
</pre></code>
SECONDE VERSION:
Crée moi un site internet pour gerer 4 interrupteurs ethernet. Chaque interrupteur sera geré par un executable sur un debian 12
{| align="center" border="0" cellpading="2" cellspacing="2"
| [[image:ContrôleQuatreInterrupteursEthernet.png|2048px|thumb|border|Site generé par huggingface]]
|}
<pre><code>
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contrôle des Interrupteurs Ethernet</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .switch-container {
            transition: all 0.3s ease;
        }
        .switch-container:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        .log-entry {
            animation: fadeIn 0.5s ease-in;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .switch-btn {
            transition: all 0.2s ease;
        }
        .switch-btn:active {
            transform: scale(0.95);
        }
    </style>
</head>
<body class="bg-gray-100 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="mb-8 text-center">
            <h1 class="text-3xl md:text-4xl font-bold text-gray-800 mb-2">
                <i class="fas fa-network-wired mr-2 text-blue-500"></i>
                Contrôle des Interrupteurs Ethernet
            </h1>
            <p class="text-gray-600">Gestion des 4 interrupteurs connectés au serveur Debian 12</p>
            <div class="mt-4 flex justify-center space-x-4">
                <div class="bg-green-100 text-green-800 px-4 py-2 rounded-full flex items-center">
                    <span class="w-3 h-3 rounded-full bg-green-500 mr-2"></span>
                    Serveur connecté
                </div>
                <div class="bg-blue-100 text-blue-800 px-4 py-2 rounded-full flex items-center">
                    <i class="fas fa-shield-alt mr-2"></i>
                    Sécurisé
                </div>
            </div>
        </header>
        <!-- Main Dashboard -->
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
            <!-- Switch 1 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #1</h2>
                    <span id="switch1-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.101</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>8 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch1-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch1-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch1-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch1-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch1-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>
            <!-- Switch 2 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #2</h2>
                    <span id="switch2-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.102</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>8 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch2-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch2-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch2-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch2-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch2-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>
            <!-- Switch 3 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #3</h2>
                    <span id="switch3-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.103</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>16 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch3-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch3-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch3-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch3-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch3-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>
            <!-- Switch 4 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #4</h2>
                    <span id="switch4-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.104</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>24 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch4-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch4-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch4-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch4-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch4-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>
        </div>
        <!-- Control All Section -->
        <div class="bg-white rounded-xl shadow-md p-6 mb-8">
            <h2 class="text-xl font-semibold text-gray-800 mb-4">Contrôle Global</h2>
            <div class="flex flex-wrap gap-3">
                <button id="all-on" class="switch-btn bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-plug mr-2"></i>Tout activer
                </button>
                <button id="all-off" class="switch-btn bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-plug mr-2"></i>Tout désactiver
                </button>
                <button id="restart-all" class="switch-btn bg-yellow-500 hover:bg-yellow-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-sync-alt mr-2"></i>Redémarrer tout
                </button>
                <button id="refresh-all" class="switch-btn bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-sync mr-2"></i>Actualiser les statuts
                </button>
            </div>
        </div>
        <!-- Log Section -->
        <div class="bg-white rounded-xl shadow-md p-6">
            <div class="flex justify-between items-center mb-4">
                <h2 class="text-xl font-semibold text-gray-800">Journal d'activité</h2>
                <button id="clear-logs" class="text-sm text-red-500 hover:text-red-700 flex items-center">
                    <i class="fas fa-trash-alt mr-1"></i> Effacer le journal
                </button>
            </div>
            <div class="bg-gray-50 rounded-lg p-4 h-64 overflow-y-auto" id="log-container">
                <div class="text-center text-gray-500 py-8" id="empty-log-message">
                    <i class="fas fa-clipboard-list text-3xl mb-2"></i>
                    <p>Aucune activité enregistrée</p>
                </div>
                <!-- Log entries will be added here dynamically -->
            </div>
        </div>
        <!-- Footer -->
        <footer class="mt-8 text-center text-gray-600 text-sm">
            <p>Système de contrôle des interrupteurs Ethernet - Debian 12</p>
            <p class="mt-1">Dernière mise à jour: <span id="last-update">chargement...</span></p>
        </footer>
    </div>
    <script>
        // Simulate switch status (in a real app, this would come from API calls)
        const switchStatus = {
            switch1: { on: false, power: 0, lastActivity: null },
            switch2: { on: false, power: 0, lastActivity: null },
            switch3: { on: false, power: 0, lastActivity: null },
            switch4: { on: false, power: 0, lastActivity: null }
        };
        // Initialize the UI
        document.addEventListener('DOMContentLoaded', function() {
            // Set current date
            document.getElementById('last-update').textContent = new Date().toLocaleString();
           
            // Load initial status (simulated)
            setTimeout(() => {
                updateSwitchStatus(1, Math.random() > 0.5, Math.floor(Math.random() * 30));
                updateSwitchStatus(2, Math.random() > 0.5, Math.floor(Math.random() * 30));
                updateSwitchStatus(3, Math.random() > 0.5, Math.floor(Math.random() * 50));
                updateSwitchStatus(4, Math.random() > 0.5, Math.floor(Math.random() * 80));
            }, 1000);
            // Set up event listeners for all buttons
            setupButtonListeners();
           
            // Simulate periodic updates
            setInterval(simulateRandomUpdates, 5000);
        });
        // Update switch status in UI
        function updateSwitchStatus(switchNum, isOn, powerUsage) {
            const statusElement = document.getElementById(`switch${switchNum}-status`);
            const powerElement = document.getElementById(`switch${switchNum}-power`);
            const powerBarElement = document.getElementById(`switch${switchNum}-power-bar`);
            const activityElement = document.getElementById(`switch${switchNum}-activity`);
            const onBtn = document.getElementById(`switch${switchNum}-on`);
            const offBtn = document.getElementById(`switch${switchNum}-off`);
           
            // Update status
            switchStatus[`switch${switchNum}`].on = isOn;
            switchStatus[`switch${switchNum}`].power = powerUsage;
            switchStatus[`switch${switchNum}`].lastActivity = new Date();
           
            // Update UI
            if (isOn) {
                statusElement.textContent = 'Activé';
                statusElement.className = 'px-3 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800';
                onBtn.disabled = true;
                onBtn.classList.add('opacity-50', 'cursor-not-allowed');
                offBtn.disabled = false;
                offBtn.classList.remove('opacity-50', 'cursor-not-allowed');
            } else {
                statusElement.textContent = 'Désactivé';
                statusElement.className = 'px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800';
                onBtn.disabled = false;
                onBtn.classList.remove('opacity-50', 'cursor-not-allowed');
                offBtn.disabled = true;
                offBtn.classList.add('opacity-50', 'cursor-not-allowed');
            }
           
            // Update power usage
            if (powerUsage > 0) {
                powerElement.textContent = `${powerUsage} W`;
               
                // Calculate percentage for power bar (assuming max power is 100W for 8-port, 150W for 16-port, 200W for 24-port)
                let maxPower = 100;
                if (switchNum === 3) maxPower = 150;
                if (switchNum === 4) maxPower = 200;
               
                const percentage = Math.min(100, Math.round((powerUsage / maxPower) * 100));
                powerBarElement.style.width = `${percentage}%`;
               
                // Change color based on usage
                if (percentage > 80) {
                    powerBarElement.className = 'bg-red-500 h-2 rounded-full';
                } else if (percentage > 50) {
                    powerBarElement.className = 'bg-yellow-500 h-2 rounded-full';
                } else {
                    powerBarElement.className = 'bg-blue-500 h-2 rounded-full';
                }
            } else {
                powerElement.textContent = '-- W';
                powerBarElement.style.width = '0%';
            }
           
            // Update last activity time
            if (switchStatus[`switch${switchNum}`].lastActivity) {
                activityElement.textContent = switchStatus[`switch${switchNum}`].lastActivity.toLocaleTimeString();
            }
           
            // Add log entry
            addLogEntry(`Interrupteur #${switchNum} ${isOn ? 'activé' : 'désactivé'}. Consommation: ${powerUsage}W`);
        }
        // Add entry to log
        function addLogEntry(message) {
            const logContainer = document.getElementById('log-container');
            const emptyLogMessage = document.getElementById('empty-log-message');
           
            // Hide empty message if it's the first log
            if (emptyLogMessage.style.display !== 'none') {
                emptyLogMessage.style.display = 'none';
            }
           
            // Create new log entry
            const logEntry = document.createElement('div');
            logEntry.className = 'log-entry mb-2 pb-2 border-b border-gray-100';
            logEntry.innerHTML = `
                <div class="flex justify-between items-center">
                    <span class="text-sm font-medium">${message}</span>
                    <span class="text-xs text-gray-500">${new Date().toLocaleTimeString()}</span>
                </div>
            `;
           
            // Add to top of log
            logContainer.insertBefore(logEntry, logContainer.firstChild);
           
            // Limit to 50 log entries
            if (logContainer.children.length > 50) {
                logContainer.removeChild(logContainer.lastChild);
            }
        }
        // Setup button event listeners
        function setupButtonListeners() {
            // Individual switch controls
            for (let i = 1; i <= 4; i++) {
                document.getElementById(`switch${i}-on`).addEventListener('click', () => {
                    // In a real app, this would be an API call
                    const power = i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) :
                                i === 3 ? Math.floor(20 + Math.random() * 30) :
                                Math.floor(30 + Math.random() * 50);
                    updateSwitchStatus(i, true, power);
                });
               
                document.getElementById(`switch${i}-off`).addEventListener('click', () => {
                    // In a real app, this would be an API call
                    updateSwitchStatus(i, false, 0);
                });
            }
           
            // Global controls
            document.getElementById('all-on').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    const power = i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) :
                                i === 3 ? Math.floor(20 + Math.random() * 30) :
                                Math.floor(30 + Math.random() * 50);
                    updateSwitchStatus(i, true, power);
                }
                addLogEntry('Tous les interrupteurs ont été activés');
            });
           
            document.getElementById('all-off').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    updateSwitchStatus(i, false, 0);
                }
                addLogEntry('Tous les interrupteurs ont été désactivés');
            });
           
            document.getElementById('restart-all').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    // Simulate restart (off then on)
                    updateSwitchStatus(i, false, 0);
                    setTimeout(() => {
                        const power = i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) :
                                    i === 3 ? Math.floor(20 + Math.random() * 30) :
                                    Math.floor(30 + Math.random() * 50);
                        updateSwitchStatus(i, true, power);
                    }, 1000);
                }
                addLogEntry('Tous les interrupteurs ont été redémarrés');
            });
           
            document.getElementById('refresh-all').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    const currentStatus = switchStatus[`switch${i}`].on;
                    const power = currentStatus ?
                        (i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) :
                        i === 3 ? Math.floor(20 + Math.random() * 30) :
                        Math.floor(30 + Math.random() * 50)) : 0;
                    updateSwitchStatus(i, currentStatus, power);
                }
                addLogEntry('Statuts des interrupteurs actualisés');
                document.getElementById('last-update').textContent = new Date().toLocaleString();
            });
           
            // Clear logs
            document.getElementById('clear-logs').addEventListener('click', () => {
                const logContainer = document.getElementById('log-container');
                while (logContainer.firstChild) {
                    logContainer.removeChild(logContainer.firstChild);
                }
                document.getElementById('empty-log-message').style.display = 'block';
                addLogEntry('Journal effacé');
            });
        }
        // Simulate random updates to switches (for demo purposes)
        function simulateRandomUpdates() {
            for (let i = 1; i <= 4; i++) {
                if (Math.random() > 0.7 && switchStatus[`switch${i}`].on) {
                    // Random power fluctuation
                    const fluctuation = Math.floor(Math.random() * 10) - 5;
                    const newPower = Math.max(0, switchStatus[`switch${i}`].power + fluctuation);
                   
                    switchStatus[`switch${i}`].power = newPower;
                    document.getElementById(`switch${i}-power`).textContent = `${newPower} W`;
                   
                    // Update power bar
                    const powerBarElement = document.getElementById(`switch${i}-power-bar`);
                    let maxPower = 100;
                    if (i === 3) maxPower = 150;
                    if (i === 4) maxPower = 200;
                   
                    const percentage = Math.min(100, Math.round((newPower / maxPower) * 100));
                    powerBarElement.style.width = `${percentage}%`;
                   
                    // Change color based on usage
                    if (percentage > 80) {
                        powerBarElement.className = 'bg-red-500 h-2 rounded-full';
                    } else if (percentage > 50) {
                        powerBarElement.className = 'bg-yellow-500 h-2 rounded-full';
                    } else {
                        powerBarElement.className = 'bg-blue-500 h-2 rounded-full';
                    }
                   
                    // Random activity
                    if (Math.random() > 0.8) {
                        switchStatus[`switch${i}`].lastActivity = new Date();
                        document.getElementById(`switch${i}-activity`).textContent =
                            switchStatus[`switch${i}`].lastActivity.toLocaleTimeString();
                    }
                }
            }
           
            // Random log entry
            if (Math.random() > 0.9) {
                const messages = [
                    'Vérification automatique du système effectuée',
                    'Aucune anomalie détectée',
                    'Système fonctionnant normalement',
                    'Mise à jour des statistiques'
                ];
                addLogEntry(messages[Math.floor(Math.random() * messages.length)]);
            }
        }
    </script>
</body>
</html>
</code></pre>

Version du 14 juillet 2025 à 09:14

KEYWORDS: IA, CREATION, WEBSITE

Le 14/07/2025:
J'ai découvert que huggingface.co permet (entre autres) de créer des petits sites internet, rien qu'en décrivant le besoin.
Exemple:
https://huggingface.co/spaces/enzostvs/deepsite
PREMIERE VERSION:
Crée moi un site pour gérer deux interrupteurs ethernet:
Site generé par huggingface
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contrôle Interrupteurs Ethernet</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .switch-container {
            perspective: 1000px;
        }
        .switch-btn {
            transition: all 0.3s ease, transform 0.2s ease;
            transform-style: preserve-3d;
        }
        .switch-btn:active {
            transform: scale(0.95) rotateX(10deg);
        }
        .switch-btn.on {
            box-shadow: 0 0 20px rgba(72, 187, 120, 0.6);
        }
        .switch-btn.off {
            box-shadow: 0 0 20px rgba(239, 68, 68, 0.4);
        }
        .status-indicator {
            width: 12px;
            height: 12px;
            transition: all 0.3s ease;
        }
        .connection-status {
            animation: pulse 2s infinite;
        }
        @keyframes pulse {
            0% { opacity: 1; }
            50% { opacity: 0.5; }
            100% { opacity: 1; }
        }
    </style>
</head>
<body class="bg-gray-100 min-h-screen font-sans">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="mb-10 text-center">
            <h1 class="text-4xl font-bold text-gray-800 mb-2">Contrôle Interrupteurs Ethernet</h1>
            <p class="text-gray-600">Interface de contrôle à distance pour vos appareils connectés</p>
            <div class="mt-4 flex items-center justify-center space-x-2">
                <span id="connectionStatus" class="connection-status inline-block status-indicator rounded-full bg-green-500"></span>
                <span id="connectionText" class="text-sm text-gray-600">Connecté</span>
            </div>
        </header>

        <!-- Main Content -->
        <main>
            <div class="grid grid-cols-1 md:grid-cols-2 gap-8 max-w-4xl mx-auto">
                <!-- Switch 1 -->
                <div class="bg-white rounded-xl shadow-lg overflow-hidden transition-all hover:shadow-xl">
                    <div class="p-6">
                        <div class="flex items-center justify-between mb-4">
                            <h2 class="text-xl font-semibold text-gray-800">Interrupteur #1</h2>
                            <div class="flex items-center">
                                <span id="switch1Status" class="status-indicator rounded-full bg-red-500 mr-2"></span>
                                <span id="switch1StatusText" class="text-sm font-medium text-gray-500">Éteint</span>
                            </div>
                        </div>
                        
                        <div class="switch-container mt-6 mb-4">
                            <button id="switch1Btn" class="switch-btn off w-full py-4 px-6 rounded-lg bg-gradient-to-br from-gray-200 to-gray-300 text-gray-700 font-bold text-lg flex items-center justify-center">
                                <i class="fas fa-power-off mr-2"></i>
                                <span>Éteint</span>
                            </button>
                        </div>
                        
                        <div class="mt-6">
                            <h3 class="text-sm font-medium text-gray-500 mb-2">Statistiques</h3>
                            <div class="grid grid-cols-2 gap-4 text-sm">
                                <div class="bg-gray-50 p-3 rounded-lg">
                                    <p class="text-gray-500">Dernière activation</p>
                                    <p id="switch1LastOn" class="font-medium">--:--</p>
                                </div>
                                <div class="bg-gray-50 p-3 rounded-lg">
                                    <p class="text-gray-500">Dernière désactivation</p>
                                    <p id="switch1LastOff" class="font-medium">--:--</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Switch 2 -->
                <div class="bg-white rounded-xl shadow-lg overflow-hidden transition-all hover:shadow-xl">
                    <div class="p-6">
                        <div class="flex items-center justify-between mb-4">
                            <h2 class="text-xl font-semibold text-gray-800">Interrupteur #2</h2>
                            <div class="flex items-center">
                                <span id="switch2Status" class="status-indicator rounded-full bg-red-500 mr-2"></span>
                                <span id="switch2StatusText" class="text-sm font-medium text-gray-500">Éteint</span>
                            </div>
                        </div>
                        
                        <div class="switch-container mt-6 mb-4">
                            <button id="switch2Btn" class="switch-btn off w-full py-4 px-6 rounded-lg bg-gradient-to-br from-gray-200 to-gray-300 text-gray-700 font-bold text-lg flex items-center justify-center">
                                <i class="fas fa-power-off mr-2"></i>
                                <span>Éteint</span>
                            </button>
                        </div>
                        
                        <div class="mt-6">
                            <h3 class="text-sm font-medium text-gray-500 mb-2">Statistiques</h3>
                            <div class="grid grid-cols-2 gap-4 text-sm">
                                <div class="bg-gray-50 p-3 rounded-lg">
                                    <p class="text-gray-500">Dernière activation</p>
                                    <p id="switch2LastOn" class="font-medium">--:--</p>
                                </div>
                                <div class="bg-gray-50 p-3 rounded-lg">
                                    <p class="text-gray-500">Dernière désactivation</p>
                                    <p id="switch2LastOff" class="font-medium">--:--</p>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <!-- Control Both -->
            <div class="max-w-4xl mx-auto mt-8 bg-white rounded-xl shadow-lg overflow-hidden">
                <div class="p-6">
                    <h2 class="text-xl font-semibold text-gray-800 mb-4">Contrôle global</h2>
                    <div class="grid grid-cols-2 md:grid-cols-4 gap-4">
                        <button id="allOnBtn" class="py-3 px-4 bg-green-500 hover:bg-green-600 text-white rounded-lg font-medium flex items-center justify-center transition">
                            <i class="fas fa-power-off mr-2 transform rotate-90"></i>
                            Tout allumer
                        </button>
                        <button id="allOffBtn" class="py-3 px-4 bg-red-500 hover:bg-red-600 text-white rounded-lg font-medium flex items-center justify-center transition">
                            <i class="fas fa-power-off mr-2"></i>
                            Tout éteindre
                        </button>
                        <button id="toggleAllBtn" class="py-3 px-4 bg-blue-500 hover:bg-blue-600 text-white rounded-lg font-medium flex items-center justify-center transition">
                            <i class="fas fa-random mr-2"></i>
                            Basculer tout
                        </button>
                        <button id="refreshBtn" class="py-3 px-4 bg-gray-500 hover:bg-gray-600 text-white rounded-lg font-medium flex items-center justify-center transition">
                            <i class="fas fa-sync-alt mr-2"></i>
                            Actualiser
                        </button>
                    </div>
                </div>
            </div>
        </main>

        <!-- Footer -->
        <footer class="mt-16 text-center text-gray-500 text-sm">
            <p>© 2023 Contrôle Interrupteurs Ethernet. Tous droits réservés.</p>
            <p class="mt-1">Statut du serveur: <span id="serverStatus" class="font-medium text-green-500">En ligne</span></p>
        </footer>
    </div>

    <script>
        // État des interrupteurs
        let switch1State = false;
        let switch2State = false;
        let connectionActive = true;

        // Éléments DOM
        const switch1Btn = document.getElementById('switch1Btn');
        const switch2Btn = document.getElementById('switch2Btn');
        const switch1Status = document.getElementById('switch1Status');
        const switch2Status = document.getElementById('switch2Status');
        const switch1StatusText = document.getElementById('switch1StatusText');
        const switch2StatusText = document.getElementById('switch2StatusText');
        const switch1LastOn = document.getElementById('switch1LastOn');
        const switch1LastOff = document.getElementById('switch1LastOff');
        const switch2LastOn = document.getElementById('switch2LastOn');
        const switch2LastOff = document.getElementById('switch2LastOff');
        const allOnBtn = document.getElementById('allOnBtn');
        const allOffBtn = document.getElementById('allOffBtn');
        const toggleAllBtn = document.getElementById('toggleAllBtn');
        const refreshBtn = document.getElementById('refreshBtn');
        const connectionStatus = document.getElementById('connectionStatus');
        const connectionText = document.getElementById('connectionText');
        const serverStatus = document.getElementById('serverStatus');

        // Fonction pour mettre à jour l'état d'un interrupteur
        function updateSwitch(switchNum, state) {
            const btn = switchNum === 1 ? switch1Btn : switch2Btn;
            const status = switchNum === 1 ? switch1Status : switch2Status;
            const statusText = switchNum === 1 ? switch1StatusText : switch2StatusText;
            const lastOn = switchNum === 1 ? switch1LastOn : switch2LastOn;
            const lastOff = switchNum === 1 ? switch1LastOff : switch2LastOff;

            if (state) {
                // Allumé
                btn.classList.remove('off', 'bg-gradient-to-br', 'from-gray-200', 'to-gray-300');
                btn.classList.add('on', 'bg-gradient-to-br', 'from-green-200', 'to-green-400', 'text-green-800');
                btn.innerHTML = '<i class="fas fa-power-off mr-2"></i><span>Allumé</span>';
                status.classList.remove('bg-red-500');
                status.classList.add('bg-green-500');
                statusText.textContent = 'Allumé';
                statusText.classList.remove('text-gray-500');
                statusText.classList.add('text-green-600');
                
                // Mettre à jour le dernier allumage
                const now = new Date();
                lastOn.textContent = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
            } else {
                // Éteint
                btn.classList.remove('on', 'bg-gradient-to-br', 'from-green-200', 'to-green-400', 'text-green-800');
                btn.classList.add('off', 'bg-gradient-to-br', 'from-gray-200', 'to-gray-300', 'text-gray-700');
                btn.innerHTML = '<i class="fas fa-power-off mr-2"></i><span>Éteint</span>';
                status.classList.remove('bg-green-500');
                status.classList.add('bg-red-500');
                statusText.textContent = 'Éteint';
                statusText.classList.remove('text-green-600');
                statusText.classList.add('text-gray-500');
                
                // Mettre à jour la dernière extinction
                const now = new Date();
                lastOff.textContent = `${now.getHours()}:${now.getMinutes().toString().padStart(2, '0')}`;
            }
        }

        // Fonction pour simuler la communication avec le serveur
        function sendCommand(switchNum, command) {
            return new Promise((resolve) => {
                // Simuler un délai réseau
                setTimeout(() => {
                    // Simuler une chance de 10% d'échec de connexion
                    if (Math.random() < 0.1) {
                        connectionActive = false;
                        updateConnectionStatus();
                        resolve({ success: false, message: "Erreur de connexion" });
                    } else {
                        connectionActive = true;
                        updateConnectionStatus();
                        
                        // Mettre à jour l'état local
                        if (switchNum === 'all') {
                            if (command === 'on') {
                                switch1State = true;
                                switch2State = true;
                            } else if (command === 'off') {
                                switch1State = false;
                                switch2State = false;
                            } else if (command === 'toggle') {
                                switch1State = !switch1State;
                                switch2State = !switch2State;
                            }
                            updateSwitch(1, switch1State);
                            updateSwitch(2, switch2State);
                        } else {
                            if (command === 'toggle') {
                                if (switchNum === 1) switch1State = !switch1State;
                                else switch2State = !switch2State;
                            } else {
                                if (switchNum === 1) switch1State = command === 'on';
                                else switch2State = command === 'on';
                            }
                            updateSwitch(switchNum, switchNum === 1 ? switch1State : switch2State);
                        }
                        
                        resolve({ success: true, message: "Commande exécutée" });
                    }
                }, 300 + Math.random() * 700); // Délai aléatoire entre 300 et 1000ms
            });
        }

        // Fonction pour mettre à jour l'état de la connexion
        function updateConnectionStatus() {
            if (connectionActive) {
                connectionStatus.classList.remove('bg-red-500', 'bg-yellow-500');
                connectionStatus.classList.add('bg-green-500');
                connectionText.textContent = 'Connecté';
                serverStatus.textContent = 'En ligne';
                serverStatus.classList.remove('text-red-500', 'text-yellow-500');
                serverStatus.classList.add('text-green-500');
            } else {
                connectionStatus.classList.remove('bg-green-500', 'bg-yellow-500');
                connectionStatus.classList.add('bg-red-500');
                connectionText.textContent = 'Déconnecté';
                serverStatus.textContent = 'Hors ligne';
                serverStatus.classList.remove('text-green-500', 'text-yellow-500');
                serverStatus.classList.add('text-red-500');
            }
        }

        // Écouteurs d'événements
        switch1Btn.addEventListener('click', async () => {
            switch1Btn.disabled = true;
            const result = await sendCommand(1, 'toggle');
            if (result.success) {
                // Animation de feedback
                switch1Btn.style.transform = 'scale(0.95) rotateX(10deg)';
                setTimeout(() => {
                    switch1Btn.style.transform = '';
                }, 200);
            } else {
                alert(result.message);
            }
            switch1Btn.disabled = false;
        });

        switch2Btn.addEventListener('click', async () => {
            switch2Btn.disabled = true;
            const result = await sendCommand(2, 'toggle');
            if (result.success) {
                // Animation de feedback
                switch2Btn.style.transform = 'scale(0.95) rotateX(10deg)';
                setTimeout(() => {
                    switch2Btn.style.transform = '';
                }, 200);
            } else {
                alert(result.message);
            }
            switch2Btn.disabled = false;
        });

        allOnBtn.addEventListener('click', async () => {
            allOnBtn.disabled = true;
            const result = await sendCommand('all', 'on');
            if (!result.success) {
                alert(result.message);
            }
            allOnBtn.disabled = false;
        });

        allOffBtn.addEventListener('click', async () => {
            allOffBtn.disabled = true;
            const result = await sendCommand('all', 'off');
            if (!result.success) {
                alert(result.message);
            }
            allOffBtn.disabled = false;
        });

        toggleAllBtn.addEventListener('click', async () => {
            toggleAllBtn.disabled = true;
            const result = await sendCommand('all', 'toggle');
            if (!result.success) {
                alert(result.message);
            }
            toggleAllBtn.disabled = false;
        });

        refreshBtn.addEventListener('click', () => {
            // Simuler un rafraîchissement
            refreshBtn.innerHTML = '<i class="fas fa-spinner fa-spin mr-2"></i> Actualisation';
            setTimeout(() => {
                refreshBtn.innerHTML = '<i class="fas fa-sync-alt mr-2"></i> Actualiser';
                
                // Simuler une mise à jour de l'état
                if (Math.random() < 0.2) {
                    connectionActive = !connectionActive;
                    updateConnectionStatus();
                }
            }, 1000);
        });

        // Initialisation
        updateSwitch(1, switch1State);
        updateSwitch(2, switch2State);
        updateConnectionStatus();

        // Simuler des changements aléatoires d'état (pour la démo)
        setInterval(() => {
            if (Math.random() < 0.01 && connectionActive) { // 1% de chance de changement
                const switchNum = Math.random() < 0.5 ? 1 : 2;
                sendCommand(switchNum, 'toggle');
            }
        }, 5000);
    </script>
</body>
</html>
SECONDE VERSION:
Crée moi un site internet pour gerer 4 interrupteurs ethernet. Chaque interrupteur sera geré par un executable sur un debian 12
Site generé par huggingface
<code>
<!DOCTYPE html>
<html lang="fr">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Contrôle des Interrupteurs Ethernet</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
    <style>
        .switch-container {
            transition: all 0.3s ease;
        }
        .switch-container:hover {
            transform: translateY(-2px);
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
        }
        .log-entry {
            animation: fadeIn 0.5s ease-in;
        }
        @keyframes fadeIn {
            from { opacity: 0; transform: translateY(10px); }
            to { opacity: 1; transform: translateY(0); }
        }
        .switch-btn {
            transition: all 0.2s ease;
        }
        .switch-btn:active {
            transform: scale(0.95);
        }
    </style>
</head>
<body class="bg-gray-100 min-h-screen">
    <div class="container mx-auto px-4 py-8">
        <!-- Header -->
        <header class="mb-8 text-center">
            <h1 class="text-3xl md:text-4xl font-bold text-gray-800 mb-2">
                <i class="fas fa-network-wired mr-2 text-blue-500"></i>
                Contrôle des Interrupteurs Ethernet
            </h1>
            <p class="text-gray-600">Gestion des 4 interrupteurs connectés au serveur Debian 12</p>
            <div class="mt-4 flex justify-center space-x-4">
                <div class="bg-green-100 text-green-800 px-4 py-2 rounded-full flex items-center">
                    <span class="w-3 h-3 rounded-full bg-green-500 mr-2"></span>
                    Serveur connecté
                </div>
                <div class="bg-blue-100 text-blue-800 px-4 py-2 rounded-full flex items-center">
                    <i class="fas fa-shield-alt mr-2"></i>
                    Sécurisé
                </div>
            </div>
        </header>

        <!-- Main Dashboard -->
        <div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6 mb-8">
            <!-- Switch 1 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #1</h2>
                    <span id="switch1-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.101</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>8 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch1-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch1-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch1-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch1-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch1-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>

            <!-- Switch 2 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #2</h2>
                    <span id="switch2-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.102</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>8 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch2-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch2-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch2-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch2-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch2-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>

            <!-- Switch 3 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #3</h2>
                    <span id="switch3-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.103</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>16 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch3-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch3-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch3-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch3-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch3-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>

            <!-- Switch 4 -->
            <div class="switch-container bg-white rounded-xl shadow-md p-6">
                <div class="flex justify-between items-center mb-4">
                    <h2 class="text-xl font-semibold text-gray-800">Interrupteur #4</h2>
                    <span id="switch4-status" class="px-3 py-1 rounded-full text-xs font-medium bg-gray-200 text-gray-800">
                        Chargement...
                    </span>
                </div>
                <div class="mb-4">
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Adresse IP:</span>
                        <span>192.168.1.104</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600 mb-1">
                        <span>Ports:</span>
                        <span>24 ports</span>
                    </div>
                    <div class="flex justify-between text-sm text-gray-600">
                        <span>Dernière activité:</span>
                        <span id="switch4-activity">--:--</span>
                    </div>
                </div>
                <div class="flex space-x-3">
                    <button id="switch4-on" class="switch-btn flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Activer
                    </button>
                    <button id="switch4-off" class="switch-btn flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                        <i class="fas fa-power-off mr-2"></i>Désactiver
                    </button>
                </div>
                <div class="mt-4 pt-4 border-t border-gray-100">
                    <div class="flex justify-between items-center">
                        <span class="text-sm text-gray-600">Consommation:</span>
                        <span id="switch4-power" class="text-sm font-medium">-- W</span>
                    </div>
                    <div class="w-full bg-gray-200 rounded-full h-2 mt-1">
                        <div id="switch4-power-bar" class="bg-blue-500 h-2 rounded-full" style="width: 0%"></div>
                    </div>
                </div>
            </div>
        </div>

        <!-- Control All Section -->
        <div class="bg-white rounded-xl shadow-md p-6 mb-8">
            <h2 class="text-xl font-semibold text-gray-800 mb-4">Contrôle Global</h2>
            <div class="flex flex-wrap gap-3">
                <button id="all-on" class="switch-btn bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-plug mr-2"></i>Tout activer
                </button>
                <button id="all-off" class="switch-btn bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-plug mr-2"></i>Tout désactiver
                </button>
                <button id="restart-all" class="switch-btn bg-yellow-500 hover:bg-yellow-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-sync-alt mr-2"></i>Redémarrer tout
                </button>
                <button id="refresh-all" class="switch-btn bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded-lg transition">
                    <i class="fas fa-sync mr-2"></i>Actualiser les statuts
                </button>
            </div>
        </div>

        <!-- Log Section -->
        <div class="bg-white rounded-xl shadow-md p-6">
            <div class="flex justify-between items-center mb-4">
                <h2 class="text-xl font-semibold text-gray-800">Journal d'activité</h2>
                <button id="clear-logs" class="text-sm text-red-500 hover:text-red-700 flex items-center">
                    <i class="fas fa-trash-alt mr-1"></i> Effacer le journal
                </button>
            </div>
            <div class="bg-gray-50 rounded-lg p-4 h-64 overflow-y-auto" id="log-container">
                <div class="text-center text-gray-500 py-8" id="empty-log-message">
                    <i class="fas fa-clipboard-list text-3xl mb-2"></i>
                    <p>Aucune activité enregistrée</p>
                </div>
                <!-- Log entries will be added here dynamically -->
            </div>
        </div>

        <!-- Footer -->
        <footer class="mt-8 text-center text-gray-600 text-sm">
            <p>Système de contrôle des interrupteurs Ethernet - Debian 12</p>
            <p class="mt-1">Dernière mise à jour: <span id="last-update">chargement...</span></p>
        </footer>
    </div>

    <script>
        // Simulate switch status (in a real app, this would come from API calls)
        const switchStatus = {
            switch1: { on: false, power: 0, lastActivity: null },
            switch2: { on: false, power: 0, lastActivity: null },
            switch3: { on: false, power: 0, lastActivity: null },
            switch4: { on: false, power: 0, lastActivity: null }
        };

        // Initialize the UI
        document.addEventListener('DOMContentLoaded', function() {
            // Set current date
            document.getElementById('last-update').textContent = new Date().toLocaleString();
            
            // Load initial status (simulated)
            setTimeout(() => {
                updateSwitchStatus(1, Math.random() > 0.5, Math.floor(Math.random() * 30));
                updateSwitchStatus(2, Math.random() > 0.5, Math.floor(Math.random() * 30));
                updateSwitchStatus(3, Math.random() > 0.5, Math.floor(Math.random() * 50));
                updateSwitchStatus(4, Math.random() > 0.5, Math.floor(Math.random() * 80));
            }, 1000);

            // Set up event listeners for all buttons
            setupButtonListeners();
            
            // Simulate periodic updates
            setInterval(simulateRandomUpdates, 5000);
        });

        // Update switch status in UI
        function updateSwitchStatus(switchNum, isOn, powerUsage) {
            const statusElement = document.getElementById(`switch${switchNum}-status`);
            const powerElement = document.getElementById(`switch${switchNum}-power`);
            const powerBarElement = document.getElementById(`switch${switchNum}-power-bar`);
            const activityElement = document.getElementById(`switch${switchNum}-activity`);
            const onBtn = document.getElementById(`switch${switchNum}-on`);
            const offBtn = document.getElementById(`switch${switchNum}-off`);
            
            // Update status
            switchStatus[`switch${switchNum}`].on = isOn;
            switchStatus[`switch${switchNum}`].power = powerUsage;
            switchStatus[`switch${switchNum}`].lastActivity = new Date();
            
            // Update UI
            if (isOn) {
                statusElement.textContent = 'Activé';
                statusElement.className = 'px-3 py-1 rounded-full text-xs font-medium bg-green-100 text-green-800';
                onBtn.disabled = true;
                onBtn.classList.add('opacity-50', 'cursor-not-allowed');
                offBtn.disabled = false;
                offBtn.classList.remove('opacity-50', 'cursor-not-allowed');
            } else {
                statusElement.textContent = 'Désactivé';
                statusElement.className = 'px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800';
                onBtn.disabled = false;
                onBtn.classList.remove('opacity-50', 'cursor-not-allowed');
                offBtn.disabled = true;
                offBtn.classList.add('opacity-50', 'cursor-not-allowed');
            }
            
            // Update power usage
            if (powerUsage > 0) {
                powerElement.textContent = `${powerUsage} W`;
                
                // Calculate percentage for power bar (assuming max power is 100W for 8-port, 150W for 16-port, 200W for 24-port)
                let maxPower = 100;
                if (switchNum === 3) maxPower = 150;
                if (switchNum === 4) maxPower = 200;
                
                const percentage = Math.min(100, Math.round((powerUsage / maxPower) * 100));
                powerBarElement.style.width = `${percentage}%`;
                
                // Change color based on usage
                if (percentage > 80) {
                    powerBarElement.className = 'bg-red-500 h-2 rounded-full';
                } else if (percentage > 50) {
                    powerBarElement.className = 'bg-yellow-500 h-2 rounded-full';
                } else {
                    powerBarElement.className = 'bg-blue-500 h-2 rounded-full';
                }
            } else {
                powerElement.textContent = '-- W';
                powerBarElement.style.width = '0%';
            }
            
            // Update last activity time
            if (switchStatus[`switch${switchNum}`].lastActivity) {
                activityElement.textContent = switchStatus[`switch${switchNum}`].lastActivity.toLocaleTimeString();
            }
            
            // Add log entry
            addLogEntry(`Interrupteur #${switchNum} ${isOn ? 'activé' : 'désactivé'}. Consommation: ${powerUsage}W`);
        }

        // Add entry to log
        function addLogEntry(message) {
            const logContainer = document.getElementById('log-container');
            const emptyLogMessage = document.getElementById('empty-log-message');
            
            // Hide empty message if it's the first log
            if (emptyLogMessage.style.display !== 'none') {
                emptyLogMessage.style.display = 'none';
            }
            
            // Create new log entry
            const logEntry = document.createElement('div');
            logEntry.className = 'log-entry mb-2 pb-2 border-b border-gray-100';
            logEntry.innerHTML = `
                <div class="flex justify-between items-center">
                    <span class="text-sm font-medium">${message}</span>
                    <span class="text-xs text-gray-500">${new Date().toLocaleTimeString()}</span>
                </div>
            `;
            
            // Add to top of log
            logContainer.insertBefore(logEntry, logContainer.firstChild);
            
            // Limit to 50 log entries
            if (logContainer.children.length > 50) {
                logContainer.removeChild(logContainer.lastChild);
            }
        }

        // Setup button event listeners
        function setupButtonListeners() {
            // Individual switch controls
            for (let i = 1; i <= 4; i++) {
                document.getElementById(`switch${i}-on`).addEventListener('click', () => {
                    // In a real app, this would be an API call
                    const power = i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) : 
                                 i === 3 ? Math.floor(20 + Math.random() * 30) : 
                                 Math.floor(30 + Math.random() * 50);
                    updateSwitchStatus(i, true, power);
                });
                
                document.getElementById(`switch${i}-off`).addEventListener('click', () => {
                    // In a real app, this would be an API call
                    updateSwitchStatus(i, false, 0);
                });
            }
            
            // Global controls
            document.getElementById('all-on').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    const power = i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) : 
                                 i === 3 ? Math.floor(20 + Math.random() * 30) : 
                                 Math.floor(30 + Math.random() * 50);
                    updateSwitchStatus(i, true, power);
                }
                addLogEntry('Tous les interrupteurs ont été activés');
            });
            
            document.getElementById('all-off').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    updateSwitchStatus(i, false, 0);
                }
                addLogEntry('Tous les interrupteurs ont été désactivés');
            });
            
            document.getElementById('restart-all').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    // Simulate restart (off then on)
                    updateSwitchStatus(i, false, 0);
                    setTimeout(() => {
                        const power = i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) : 
                                     i === 3 ? Math.floor(20 + Math.random() * 30) : 
                                     Math.floor(30 + Math.random() * 50);
                        updateSwitchStatus(i, true, power);
                    }, 1000);
                }
                addLogEntry('Tous les interrupteurs ont été redémarrés');
            });
            
            document.getElementById('refresh-all').addEventListener('click', () => {
                for (let i = 1; i <= 4; i++) {
                    const currentStatus = switchStatus[`switch${i}`].on;
                    const power = currentStatus ? 
                        (i === 1 || i === 2 ? Math.floor(10 + Math.random() * 20) : 
                         i === 3 ? Math.floor(20 + Math.random() * 30) : 
                         Math.floor(30 + Math.random() * 50)) : 0;
                    updateSwitchStatus(i, currentStatus, power);
                }
                addLogEntry('Statuts des interrupteurs actualisés');
                document.getElementById('last-update').textContent = new Date().toLocaleString();
            });
            
            // Clear logs
            document.getElementById('clear-logs').addEventListener('click', () => {
                const logContainer = document.getElementById('log-container');
                while (logContainer.firstChild) {
                    logContainer.removeChild(logContainer.firstChild);
                }
                document.getElementById('empty-log-message').style.display = 'block';
                addLogEntry('Journal effacé');
            });
        }

        // Simulate random updates to switches (for demo purposes)
        function simulateRandomUpdates() {
            for (let i = 1; i <= 4; i++) {
                if (Math.random() > 0.7 && switchStatus[`switch${i}`].on) {
                    // Random power fluctuation
                    const fluctuation = Math.floor(Math.random() * 10) - 5;
                    const newPower = Math.max(0, switchStatus[`switch${i}`].power + fluctuation);
                    
                    switchStatus[`switch${i}`].power = newPower;
                    document.getElementById(`switch${i}-power`).textContent = `${newPower} W`;
                    
                    // Update power bar
                    const powerBarElement = document.getElementById(`switch${i}-power-bar`);
                    let maxPower = 100;
                    if (i === 3) maxPower = 150;
                    if (i === 4) maxPower = 200;
                    
                    const percentage = Math.min(100, Math.round((newPower / maxPower) * 100));
                    powerBarElement.style.width = `${percentage}%`;
                    
                    // Change color based on usage
                    if (percentage > 80) {
                        powerBarElement.className = 'bg-red-500 h-2 rounded-full';
                    } else if (percentage > 50) {
                        powerBarElement.className = 'bg-yellow-500 h-2 rounded-full';
                    } else {
                        powerBarElement.className = 'bg-blue-500 h-2 rounded-full';
                    }
                    
                    // Random activity
                    if (Math.random() > 0.8) {
                        switchStatus[`switch${i}`].lastActivity = new Date();
                        document.getElementById(`switch${i}-activity`).textContent = 
                            switchStatus[`switch${i}`].lastActivity.toLocaleTimeString();
                    }
                }
            }
            
            // Random log entry
            if (Math.random() > 0.9) {
                const messages = [
                    'Vérification automatique du système effectuée',
                    'Aucune anomalie détectée',
                    'Système fonctionnant normalement',
                    'Mise à jour des statistiques'
                ];
                addLogEntry(messages[Math.floor(Math.random() * messages.length)]);
            }
        }
    </script>
</body>
</html>
 </code>