File size: 16,350 Bytes
f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 0d104ce f9aefa0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 |
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Générateur de Données Synthétiques</title>
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
animation: {
'shimmer': 'shimmer 2s infinite',
'bounce-in': 'bounceIn 0.5s ease-out',
'slide-in': 'slideIn 0.3s ease-out'
},
keyframes: {
shimmer: {
'0%': { transform: 'translateX(-100%)' },
'100%': { transform: 'translateX(100%)' }
},
bounceIn: {
'0%': { transform: 'scale(0.3)', opacity: '0' },
'50%': { transform: 'scale(1.05)' },
'100%': { transform: 'scale(1)', opacity: '1' }
},
slideIn: {
'0%': { transform: 'translateX(100%)', opacity: '0' },
'100%': { transform: 'translateX(0)', opacity: '1' }
}
}
}
}
}
</script>
</head>
<body class="min-h-screen bg-gradient-to-br from-indigo-500 via-purple-500 to-pink-500 flex items-center justify-center p-5">
<div class="bg-white rounded-3xl shadow-2xl p-8 max-w-4xl w-full backdrop-blur-sm">
<!-- Header -->
<div class="text-center mb-10">
<h1 class="text-4xl font-bold bg-gradient-to-r from-indigo-600 to-purple-600 bg-clip-text text-transparent mb-3">
🤖 Générateur de Données Synthétiques
</h1>
<p class="text-gray-600 text-lg">Uploadez votre fichier pour générer 470 jeux de données synthétiques</p>
</div>
<!-- Upload Section -->
<div id="uploadSection" class="border-3 border-dashed border-gray-300 rounded-2xl p-10 text-center mb-8 transition-all duration-300 hover:border-indigo-500 hover:bg-indigo-50/30">
<div class="space-y-4">
<h3 class="text-xl font-semibold text-gray-700">📁 Sélectionnez votre fichier</h3>
<p class="text-gray-500">Glissez-déposez votre fichier ici ou cliquez pour sélectionner</p>
<input type="file" id="fileInput" accept=".txt" class="hidden">
<div class="space-x-4">
<button onclick="document.getElementById('fileInput').click()"
class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white px-8 py-3 rounded-full font-semibold transition-all duration-300 hover:scale-105 hover:shadow-lg">
Choisir le fichier
</button>
<button id="startBtn" onclick="startGeneration()"
class="hidden bg-gradient-to-r from-green-500 to-emerald-600 text-white px-8 py-3 rounded-full font-semibold transition-all duration-300 hover:scale-105 hover:shadow-lg">
🚀 Démarrer la génération
</button>
</div>
</div>
</div>
<!-- Progress Section -->
<div id="progressSection" class="hidden space-y-6">
<div class="text-center">
<h3 class="text-2xl font-bold text-gray-800 mb-4">⏳ Génération en cours...</h3>
<div class="w-full bg-gray-200 rounded-full h-6 overflow-hidden">
<div id="progressFill" class="h-full bg-gradient-to-r from-indigo-500 to-purple-600 transition-all duration-500 relative">
<div class="absolute inset-0 bg-gradient-to-r from-transparent via-white/30 to-transparent animate-shimmer"></div>
</div>
</div>
</div>
<!-- Status Cards -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div class="bg-gradient-to-br from-blue-50 to-indigo-100 p-6 rounded-xl border-l-4 border-indigo-500">
<h4 class="font-semibold text-gray-700 mb-2">Progrès</h4>
<p id="progressText" class="text-2xl font-bold text-indigo-600">0 / 470</p>
</div>
<div class="bg-gradient-to-br from-green-50 to-emerald-100 p-6 rounded-xl border-l-4 border-emerald-500">
<h4 class="font-semibold text-gray-700 mb-2">Pourcentage</h4>
<p id="percentageText" class="text-2xl font-bold text-emerald-600">0%</p>
</div>
<div class="bg-gradient-to-br from-purple-50 to-violet-100 p-6 rounded-xl border-l-4 border-violet-500">
<h4 class="font-semibold text-gray-700 mb-2">Statut</h4>
<p id="statusText" class="text-lg font-bold text-violet-600">En attente</p>
</div>
<div class="bg-gradient-to-br from-orange-50 to-amber-100 p-6 rounded-xl border-l-4 border-amber-500">
<h4 class="font-semibold text-gray-700 mb-2">Heure de début</h4>
<p id="startTimeText" class="text-lg font-bold text-amber-600">-</p>
</div>
</div>
<!-- Download Button -->
<div class="text-center">
<button id="downloadBtn" onclick="downloadResults()"
class="hidden bg-gradient-to-r from-green-500 to-emerald-600 text-white px-8 py-3 rounded-full font-semibold transition-all duration-300 hover:scale-105 hover:shadow-lg">
📥 Télécharger les résultats
</button>
<!-- Bouton de téléchargement en cours -->
<button id="downloadProgressBtn" onclick="downloadCurrentResults()"
class="hidden bg-gradient-to-r from-yellow-500 to-orange-500 text-white px-8 py-3 rounded-full font-semibold transition-all duration-300 hover:scale-105 hover:shadow-lg">
📥 Télécharger les données actuelles
</button>
</div>
</div>
<!-- Tasks Section -->
<div class="mt-10 pt-8 border-t-2 border-gray-200">
<h3 class="text-xl font-bold text-gray-800 mb-6">📋 Tâches précédentes</h3>
<div id="tasksList" class="space-y-4"></div>
</div>
</div>
<!-- Notification -->
<div id="notification" class="fixed top-5 right-5 px-6 py-4 rounded-xl text-white font-semibold transform translate-x-full transition-transform duration-300 z-50"></div>
<script>
let currentTaskId = null;
let statusInterval = null;
// Gestion du drag & drop
const uploadSection = document.getElementById('uploadSection');
const fileInput = document.getElementById('fileInput');
uploadSection.addEventListener('dragover', (e) => {
e.preventDefault();
uploadSection.classList.add('border-indigo-500', 'bg-indigo-50/50');
});
uploadSection.addEventListener('dragleave', () => {
uploadSection.classList.remove('border-indigo-500', 'bg-indigo-50/50');
});
uploadSection.addEventListener('drop', (e) => {
e.preventDefault();
uploadSection.classList.remove('border-indigo-500', 'bg-indigo-50/50');
const files = e.dataTransfer.files;
if (files.length > 0) {
fileInput.files = files;
handleFileSelect();
}
});
fileInput.addEventListener('change', handleFileSelect);
function handleFileSelect() {
const file = fileInput.files[0];
if (file) {
document.getElementById('startBtn').classList.remove('hidden');
document.getElementById('startBtn').classList.add('animate-bounce-in');
showNotification(`Fichier sélectionné: ${file.name}`, 'success');
}
}
function startGeneration() {
const file = fileInput.files[0];
if (!file) {
showNotification('Veuillez sélectionner un fichier', 'error');
return;
}
const formData = new FormData();
formData.append('file', file);
fetch('/upload', {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
if (data.error) {
showNotification(data.error, 'error');
} else {
currentTaskId = data.task_id;
document.getElementById('progressSection').classList.remove('hidden');
document.getElementById('downloadProgressBtn').classList.remove('hidden');
startStatusPolling();
showNotification('Génération démarrée!', 'success');
}
})
.catch(error => {
showNotification('Erreur lors du démarrage', 'error');
console.error('Error:', error);
});
}
function startStatusPolling() {
if (statusInterval) clearInterval(statusInterval);
statusInterval = setInterval(() => {
if (currentTaskId) {
fetch(`/status/${currentTaskId}`)
.then(response => response.json())
.then(data => {
updateProgress(data);
if (data.status === 'completed') {
clearInterval(statusInterval);
document.getElementById('downloadBtn').classList.remove('hidden');
document.getElementById('downloadProgressBtn').classList.add('hidden');
showNotification('Génération terminée!', 'success');
}
})
.catch(console.error);
}
}, 2000);
}
function updateProgress(data) {
const progressFill = document.getElementById('progressFill');
const progressText = document.getElementById('progressText');
const percentageText = document.getElementById('percentageText');
const statusText = document.getElementById('statusText');
const startTimeText = document.getElementById('startTimeText');
progressFill.style.width = `${data.percentage}%`;
progressText.textContent = `${data.progress} / ${data.total}`;
percentageText.textContent = `${data.percentage}%`;
statusText.textContent = data.status === 'running' ? 'En cours' :
data.status === 'completed' ? 'Terminé' : data.status;
startTimeText.textContent = data.start_time;
}
function downloadResults() {
if (currentTaskId) {
window.location.href = `/download/${currentTaskId}`;
}
}
function downloadCurrentResults() {
if (currentTaskId) {
window.location.href = `/download/${currentTaskId}?partial=true`;
showNotification('Téléchargement des données actuelles...', 'success');
}
}
function showNotification(message, type) {
const notification = document.getElementById('notification');
notification.textContent = message;
// Reset classes
notification.className = 'fixed top-5 right-5 px-6 py-4 rounded-xl text-white font-semibold transform translate-x-full transition-transform duration-300 z-50';
// Add type-specific classes
if (type === 'success') {
notification.classList.add('bg-gradient-to-r', 'from-green-500', 'to-emerald-600');
} else if (type === 'error') {
notification.classList.add('bg-gradient-to-r', 'from-red-500', 'to-rose-600');
}
// Show notification
setTimeout(() => {
notification.classList.remove('translate-x-full');
notification.classList.add('animate-slide-in');
}, 100);
// Hide notification after 3 seconds
setTimeout(() => {
notification.classList.add('translate-x-full');
}, 3000);
}
function loadTasks() {
fetch('/tasks')
.then(response => response.json())
.then(tasks => {
const tasksList = document.getElementById('tasksList');
tasksList.innerHTML = '';
tasks.forEach(task => {
const taskItem = document.createElement('div');
taskItem.className = `bg-gradient-to-r from-gray-50 to-gray-100 p-6 rounded-xl border-l-4 ${
task.status === 'completed' ? 'border-green-500' :
task.status === 'running' ? 'border-blue-500' : 'border-gray-400'
} transition-all duration-300 hover:shadow-md`;
taskItem.innerHTML = `
<div class="flex justify-between items-center">
<div class="space-y-2">
<div class="flex items-center space-x-3">
<span class="font-bold text-gray-800">Tâche ${task.id.substring(0, 8)}...</span>
<span class="px-3 py-1 rounded-full text-sm font-medium ${
task.status === 'completed' ? 'bg-green-100 text-green-800' :
task.status === 'running' ? 'bg-blue-100 text-blue-800' : 'bg-gray-100 text-gray-800'
}">
${task.status === 'completed' ? 'Terminé' :
task.status === 'running' ? 'En cours' : task.status}
</span>
</div>
<div class="text-sm text-gray-600">
<span>Démarré: ${task.start_time}</span> |
<span>Progrès: ${task.progress}/${task.total} (${task.percentage}%)</span>
</div>
</div>
<div class="space-x-2">
${task.status === 'completed' ?
`<button onclick="window.location.href='/download/${task.id}'"
class="bg-gradient-to-r from-green-500 to-emerald-600 text-white px-4 py-2 rounded-lg font-medium transition-all duration-300 hover:scale-105">
Télécharger
</button>` :
task.status === 'running' ?
`<button onclick="window.location.href='/download/${task.id}?partial=true'"
class="bg-gradient-to-r from-yellow-500 to-orange-500 text-white px-4 py-2 rounded-lg font-medium transition-all duration-300 hover:scale-105">
Télécharger actuel
</button>` :
`<span class="text-gray-500 font-medium">${task.status}</span>`
}
</div>
</div>
`;
tasksList.appendChild(taskItem);
});
})
.catch(console.error);
}
// Charger les tâches au démarrage
loadTasks();
// Recharger les tâches toutes les 30 secondes
setInterval(loadTasks, 30000);
</script>
</body>
</html> |