Info::IA:création de websites
De wiki_pcwiki2
Aller à la navigationAller à la recherche
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:
![]() |
<!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
![]() |
<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>
TROISIEME ESSAI Fabrique moi un serveur web pour gérer 8 interrupteurs ethernet. Chaque interupteur sera geré par un programme spécifique tournant sous debian12. Chaque cartouche devra afficher son nom, son IP, sa derniere date et heure d'arrêt, sa derniere date et heure de démarrage, le temps depuis lequel il est allumé, sa consommation et le nom du programme associé
![]() |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Gestion 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-card {
transition: all 0.3s ease;
}
.switch-card:hover {
transform: translateY(-5px);
box-shadow: 0 10px 20px rgba(0,0,0,0.1);
}
.status-indicator {
width: 12px;
height: 12px;
border-radius: 50%;
display: inline-block;
margin-right: 5px;
}
.online {
background-color: #10B981;
box-shadow: 0 0 10px #10B981;
}
.offline {
background-color: #EF4444;
}
.rebooting {
background-color: #F59E0B;
animation: pulse 2s infinite;
}
@keyframes pulse {
0% { opacity: 1; }
50% { opacity: 0.5; }
100% { opacity: 1; }
}
.consumption-bar {
height: 6px;
border-radius: 3px;
background-color: #E5E7EB;
overflow: hidden;
}
.consumption-fill {
height: 100%;
transition: width 0.5s ease;
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<div class="container mx-auto px-4 py-8">
<header class="mb-8">
<h1 class="text-3xl font-bold text-gray-800 flex items-center">
<i class="fas fa-network-wired mr-3 text-blue-500"></i>
Gestion des Interrupteurs Ethernet
</h1>
<p class="text-gray-600 mt-2">Surveillance et contrôle de 8 interrupteurs réseau</p>
<div class="mt-6 bg-white rounded-lg shadow p-4 flex flex-wrap justify-between items-center">
<div class="flex items-center mb-2 sm:mb-0">
<span class="status-indicator online"></span>
<span class="text-gray-700 mr-4">5 En ligne</span>
<span class="status-indicator offline"></span>
<span class="text-gray-700 mr-4">2 Hors ligne</span>
<span class="status-indicator rebooting"></span>
<span class="text-gray-700">1 Redémarrage</span>
</div>
<div class="flex items-center">
<span class="text-gray-700 mr-2">Dernière mise à jour:</span>
<span id="last-update" class="font-medium">Chargement...</span>
<button id="refresh-btn" class="ml-3 bg-blue-500 hover:bg-blue-600 text-white p-2 rounded-full">
<i class="fas fa-sync-alt"></i>
</button>
</div>
</div>
</header>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
<!-- Switch Card 1 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #1</h3>
<span class="status-indicator online"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.101</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">network-monitor-v1</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">15/06/2023 08:32:45</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">14/06/2023 23:15:12</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">9h 17m 33s</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-green-500" style="width: 35%"></div>
</div>
<span class="text-sm font-medium text-gray-700">35%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
<!-- Switch Card 2 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #2</h3>
<span class="status-indicator offline"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.102</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">traffic-analyzer</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">14/06/2023 14:22:18</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">15/06/2023 01:45:30</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">-</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-gray-400" style="width: 0%"></div>
</div>
<span class="text-sm font-medium text-gray-700">0%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
<!-- Switch Card 3 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #3</h3>
<span class="status-indicator rebooting"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.103</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">security-gateway</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">15/06/2023 09:15:22</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">15/06/2023 09:15:20</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">Redémarrage...</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-yellow-500" style="width: 65%"></div>
</div>
<span class="text-sm font-medium text-gray-700">65%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
<!-- Switch Card 4 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #4</h3>
<span class="status-indicator online"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.104</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">load-balancer</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">13/06/2023 12:10:05</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">10/06/2023 03:45:18</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">2j 21h 32m</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-green-500" style="width: 42%"></div>
</div>
<span class="text-sm font-medium text-gray-700">42%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
<!-- Switch Card 5 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #5</h3>
<span class="status-indicator online"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.105</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">data-processor</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">15/06/2023 07:15:33</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">14/06/2023 22:30:47</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">8h 44m 46s</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-green-500" style="width: 28%"></div>
</div>
<span class="text-sm font-medium text-gray-700">28%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
<!-- Switch Card 6 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #6</h3>
<span class="status-indicator online"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.106</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">storage-manager</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">12/06/2023 16:20:15</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">11/06/2023 01:10:33</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">3j 15h 09m</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-green-500" style="width: 55%"></div>
</div>
<span class="text-sm font-medium text-gray-700">55%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
<!-- Switch Card 7 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #7</h3>
<span class="status-indicator offline"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.107</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">backup-service</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">14/06/2023 10:05:22</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">15/06/2023 00:30:15</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">-</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-gray-400" style="width: 0%"></div>
</div>
<span class="text-sm font-medium text-gray-700">0%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
<!-- Switch Card 8 -->
<div class="switch-card bg-white rounded-xl shadow-md overflow-hidden">
<div class="p-5 border-b border-gray-200 flex justify-between items-center">
<h3 class="text-lg font-semibold text-gray-800">Switch #8</h3>
<span class="status-indicator online"></span>
</div>
<div class="p-5">
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Adresse IP</label>
<p class="text-gray-800 font-mono">192.168.1.108</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Programme associé</label>
<p class="text-gray-800">monitoring-agent</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier démarrage</label>
<p class="text-gray-800">10/06/2023 09:45:12</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Dernier arrêt</label>
<p class="text-gray-800">08/06/2023 18:20:05</p>
</div>
<div class="mb-4">
<label class="block text-sm text-gray-500 mb-1">Temps actif</label>
<p class="text-gray-800">5j 2h 24m</p>
</div>
<div class="mb-6">
<label class="block text-sm text-gray-500 mb-1">Consommation</label>
<div class="flex items-center">
<div class="consumption-bar flex-1 mr-2">
<div class="consumption-fill bg-green-500" style="width: 18%"></div>
</div>
<span class="text-sm font-medium text-gray-700">18%</span>
</div>
</div>
<div class="flex space-x-2">
<button class="flex-1 bg-green-500 hover:bg-green-600 text-white py-2 px-4 rounded flex items-center justify-center" disabled>
<i class="fas fa-power-off mr-2"></i> Démarrer
</button>
<button class="flex-1 bg-red-500 hover:bg-red-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-stop mr-2"></i> Arrêter
</button>
<button class="flex-1 bg-blue-500 hover:bg-blue-600 text-white py-2 px-4 rounded flex items-center justify-center">
<i class="fas fa-redo mr-2"></i> Redémarrer
</button>
</div>
</div>
</div>
</div>
<footer class="mt-12 text-center text-gray-500 text-sm">
<p>Système de gestion des interrupteurs réseau - Debian 12 - Version 1.0.0</p>
<p class="mt-1">Dernière mise à jour: <span id="footer-update"></span></p>
</footer>
</div>
<script>
// Update timestamp
function updateTimestamp() {
const now = new Date();
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
second: '2-digit'
};
const formattedDate = now.toLocaleDateString('fr-FR', options);
document.getElementById('last-update').textContent = formattedDate;
document.getElementById('footer-update').textContent = formattedDate;
}
// Initial update
updateTimestamp();
// Update every second
setInterval(updateTimestamp, 1000);
// Refresh button
document.getElementById('refresh-btn').addEventListener('click', function() {
// Simulate refresh
const btn = this;
btn.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
btn.disabled = true;
setTimeout(function() {
updateTimestamp();
btn.innerHTML = '<i class="fas fa-sync-alt"></i>';
btn.disabled = false;
// Show notification
const notification = document.createElement('div');
notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded shadow-lg flex items-center';
notification.innerHTML = '<i class="fas fa-check-circle mr-2"></i> Données actualisées avec succès';
document.body.appendChild(notification);
setTimeout(() => {
notification.style.opacity = '0';
setTimeout(() => notification.remove(), 300);
}, 3000);
}, 1500);
});
// Switch control buttons
document.querySelectorAll('.switch-card button').forEach(button => {
button.addEventListener('click', function() {
const card = this.closest('.switch-card');
const statusIndicator = card.querySelector('.status-indicator');
const action = this.textContent.trim();
// Disable all buttons temporarily
card.querySelectorAll('button').forEach(btn => btn.disabled = true);
// Show loading state
const originalText = this.innerHTML;
this.innerHTML = '<i class="fas fa-spinner fa-spin"></i>';
// Simulate action
setTimeout(() => {
if (action.includes('Démarrer')) {
statusIndicator.classList.remove('offline');
statusIndicator.classList.add('online');
// Enable stop and restart buttons
card.querySelectorAll('button').forEach(btn => {
if (!btn.textContent.includes('Démarrer')) btn.disabled = false;
});
}
else if (action.includes('Arrêter')) {
statusIndicator.classList.remove('online', 'rebooting');
statusIndicator.classList.add('offline');
// Enable start button
card.querySelectorAll('button').forEach(btn => {
if (btn.textContent.includes('Démarrer')) btn.disabled = false;
});
}
else if (action.includes('Redémarrer')) {
statusIndicator.classList.remove('online', 'offline');
statusIndicator.classList.add('rebooting');
// After reboot completes
setTimeout(() => {
statusIndicator.classList.remove('rebooting');
statusIndicator.classList.add('online');
// Enable all buttons except start
card.querySelectorAll('button').forEach(btn => {
if (!btn.textContent.includes('Démarrer')) btn.disabled = false;
});
}, 3000);
}
// Restore button text
this.innerHTML = originalText;
// Update timestamp
updateTimestamp();
// Show notification
const notification = document.createElement('div');
notification.className = 'fixed bottom-4 right-4 bg-green-500 text-white px-4 py-2 rounded shadow-lg flex items-center';
notification.innerHTML = `<i class="fas fa-check-circle mr-2"></i> Action "${action}" exécutée`;
document.body.appendChild(notification);
setTimeout(() => {
notification.style.opacity = '0';
setTimeout(() => notification.remove(), 300);
}, 3000);
}, 1500);
});
});
</script>
</body>
</html>
</code>


