top
Browse files- templates/index.html +77 -48
templates/index.html
CHANGED
|
@@ -170,8 +170,12 @@
|
|
| 170 |
.btn-secondary:not(:disabled):hover, .btn-secondary:not(:disabled):focus { background-color: var(--secondary); color: white; transform: translateY(-1px); box-shadow: var(--shadow-md); }
|
| 171 |
.btn-secondary:not(:disabled):active { transform: translateY(0); }
|
| 172 |
|
| 173 |
-
|
| 174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 175 |
.spinner { width: 3rem; height: 3rem; border: 4px solid var(--gray-200); border-radius: 50%; border-top-color: var(--primary); animation: spin 1s linear infinite; margin: 0 auto 1rem; }
|
| 176 |
@keyframes spin { to { transform: rotate(360deg); } }
|
| 177 |
|
|
@@ -319,15 +323,21 @@
|
|
| 319 |
/* .markdown-table td { font-size: 0.8rem; } */
|
| 320 |
|
| 321 |
.loading-card {
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 331 |
}
|
| 332 |
|
| 333 |
</style>
|
|
@@ -365,12 +375,13 @@
|
|
| 365 |
</form>
|
| 366 |
</div>
|
| 367 |
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
|
|
|
| 374 |
<div id="dissertationContentWrapper" class="tab-content">
|
| 375 |
<div id="dissertationContent" class="custom-prose"></div>
|
| 376 |
</div>
|
|
@@ -387,9 +398,14 @@
|
|
| 387 |
</div>
|
| 388 |
</main>
|
| 389 |
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 393 |
|
| 394 |
<script>
|
| 395 |
// Vérification bibliothèques
|
|
@@ -518,39 +534,52 @@
|
|
| 518 |
}
|
| 519 |
}
|
| 520 |
function processStreamChunk(jsonData, isDeepThink) { // Pass deepthink flag
|
| 521 |
-
|
| 522 |
-
|
| 523 |
-
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
|
| 527 |
-
|
| 528 |
-
|
| 529 |
-
|
| 530 |
-
|
| 531 |
-
|
| 532 |
-
|
| 533 |
-
|
| 534 |
-
|
| 535 |
-
|
| 536 |
|
| 537 |
-
|
| 538 |
-
|
| 539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 540 |
|
| 541 |
-
|
| 542 |
-
|
| 543 |
|
| 544 |
-
|
| 545 |
-
|
| 546 |
-
|
| 547 |
|
| 548 |
// --- Analysis Request Logic (Reusable) ---
|
| 549 |
-
|
| 550 |
-
|
| 551 |
-
|
| 552 |
-
|
| 553 |
-
|
|
|
|
| 554 |
|
| 555 |
const isDeepThinkRequest = formData.get('use_deepthink') === 'true';
|
| 556 |
console.log(`Lancement de l'analyse ${isDeepThinkRequest ? 'DeepThink' : 'standard'}...`);
|
|
|
|
| 170 |
.btn-secondary:not(:disabled):hover, .btn-secondary:not(:disabled):focus { background-color: var(--secondary); color: white; transform: translateY(-1px); box-shadow: var(--shadow-md); }
|
| 171 |
.btn-secondary:not(:disabled):active { transform: translateY(0); }
|
| 172 |
|
| 173 |
+
.loading-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, 0.5); display: flex; justify-content: center; align-items: center; z-index: 100; padding: 1rem; /* Ajout padding pour mobile */ }
|
| 174 |
+
.loading-card { background-color: white; padding: 2rem; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); text-align: center; max-width: 90%; /* Légère augmentation pour petits écrans */ }
|
| 175 |
+
.progress-bar { width: 100%; height: 4px; background-color: var(--gray-200); border-radius: 2px; overflow: hidden; margin: 1rem 0; }
|
| 176 |
+
.progress-fill { height: 100%; background-color: var(--primary); animation: progress 2s ease-in-out infinite; }
|
| 177 |
+
@keyframes progress { 0% { width: 0%; } 50% { width: 100%; } 100% { width: 0%; } }
|
| 178 |
+
.status-message { font-size: 0.9rem; color: var(--gray-700); text-align: center; margin: 0.5rem 0; font-style: italic; }
|
| 179 |
.spinner { width: 3rem; height: 3rem; border: 4px solid var(--gray-200); border-radius: 50%; border-top-color: var(--primary); animation: spin 1s linear infinite; margin: 0 auto 1rem; }
|
| 180 |
@keyframes spin { to { transform: rotate(360deg); } }
|
| 181 |
|
|
|
|
| 323 |
/* .markdown-table td { font-size: 0.8rem; } */
|
| 324 |
|
| 325 |
.loading-card {
|
| 326 |
+
padding: 1.5rem; /* Padding chargement réduit */
|
| 327 |
+
}
|
| 328 |
+
.spinner {
|
| 329 |
+
width: 2.5rem; height: 2.5rem; /* Spinner légèrement plus petit */
|
| 330 |
+
margin-bottom: 0.8rem;
|
| 331 |
+
}
|
| 332 |
+
.loading-card p {
|
| 333 |
+
font-size: 0.9rem; /* Texte chargement plus petit */
|
| 334 |
+
}
|
| 335 |
+
.progress-bar {
|
| 336 |
+
height: 3px; /* Plus fin sur mobile */
|
| 337 |
+
}
|
| 338 |
+
.status-message {
|
| 339 |
+
font-size: 0.8rem; /* Plus petit sur mobile */
|
| 340 |
+
}
|
| 341 |
}
|
| 342 |
|
| 343 |
</style>
|
|
|
|
| 375 |
</form>
|
| 376 |
</div>
|
| 377 |
|
| 378 |
+
<div id="result" class="card result-card" style="display: none;">
|
| 379 |
+
<div class="tabs">
|
| 380 |
+
<button id="dissertationTab" class="tab active">Dissertation</button>
|
| 381 |
+
<button id="tableauTab" class="tab">Tableau</button>
|
| 382 |
+
</div>
|
| 383 |
+
<div id="streamingStatus" class="status-message" style="display: none;">Phase en cours : Génération du tableau...</div>
|
| 384 |
+
<div id="displayContentWrapper">
|
| 385 |
<div id="dissertationContentWrapper" class="tab-content">
|
| 386 |
<div id="dissertationContent" class="custom-prose"></div>
|
| 387 |
</div>
|
|
|
|
| 398 |
</div>
|
| 399 |
</main>
|
| 400 |
|
| 401 |
+
<div id="loading" class="loading-overlay" style="display: none;">
|
| 402 |
+
<div class="loading-card">
|
| 403 |
+
<div class="spinner"></div>
|
| 404 |
+
<p id="loadingStatus">Préparation de l'analyse...</p>
|
| 405 |
+
<div class="progress-bar"><div class="progress-fill"></div></div>
|
| 406 |
+
<p id="timeEstimate">Temps estimé : 30-60 secondes</p>
|
| 407 |
+
</div>
|
| 408 |
+
</div>
|
| 409 |
|
| 410 |
<script>
|
| 411 |
// Vérification bibliothèques
|
|
|
|
| 534 |
}
|
| 535 |
}
|
| 536 |
function processStreamChunk(jsonData, isDeepThink) { // Pass deepthink flag
|
| 537 |
+
try {
|
| 538 |
+
const parsedData = JSON.parse(jsonData);
|
| 539 |
+
if (parsedData.error) { console.error("Erreur serveur:", parsedData.error); alert("Une erreur s'est produite lors de l'analyse. Veuillez vérifier votre connexion et réessayer."); loadingIndicator.style.display = 'none'; downloadPdfBtn.disabled = true; if (currentlyStreaming) removeCursor(currentlyStreaming); streamComplete = true; return; }
|
| 540 |
+
|
| 541 |
+
// First chunk received successfully
|
| 542 |
+
if (resultDiv.style.display === 'none') {
|
| 543 |
+
resultDiv.style.display = 'block';
|
| 544 |
+
resultDiv.classList.add('slide-up');
|
| 545 |
+
loadingIndicator.style.display = 'none';
|
| 546 |
+
switchTab('dissertation'); // Default to dissertation tab
|
| 547 |
+
// Record usage ONLY if it was a DeepThink request and this is the first chunk
|
| 548 |
+
if (isDeepThink) {
|
| 549 |
+
recordDeepThinkUsage();
|
| 550 |
+
}
|
| 551 |
+
}
|
| 552 |
|
| 553 |
+
if (parsedData.type === 'tableau') {
|
| 554 |
+
tableauMarkdownRaw += parsedData.chunk;
|
| 555 |
+
document.getElementById('loadingStatus').textContent = "Génération du tableau d'analyse en cours...";
|
| 556 |
+
document.getElementById('streamingStatus').textContent = "Phase en cours : Génération du tableau...";
|
| 557 |
+
document.getElementById('timeEstimate').textContent = "Temps estimé : 10-20 secondes";
|
| 558 |
+
document.getElementById('streamingStatus').style.display = 'block';
|
| 559 |
+
}
|
| 560 |
+
else if (parsedData.type === 'dissertation') {
|
| 561 |
+
dissertationMarkdownRaw += parsedData.chunk;
|
| 562 |
+
document.getElementById('loadingStatus').textContent = "Rédaction de la dissertation en cours...";
|
| 563 |
+
document.getElementById('streamingStatus').textContent = "Phase en cours : Rédaction de la dissertation...";
|
| 564 |
+
document.getElementById('timeEstimate').textContent = "Temps estimé : 30-60 secondes";
|
| 565 |
+
document.getElementById('streamingStatus').style.display = 'block';
|
| 566 |
+
}
|
| 567 |
+
else { console.warn("Type de chunk inconnu reçu:", parsedData.type); return; }
|
| 568 |
|
| 569 |
+
if (currentlyStreaming !== parsedData.type) { if (currentlyStreaming) { removeCursor(currentlyStreaming); } currentlyStreaming = parsedData.type; }
|
| 570 |
+
updateDisplayContent(parsedData.type);
|
| 571 |
|
| 572 |
+
} catch (e) { if (e instanceof SyntaxError) { console.warn("Chunk JSON invalide:", jsonData, e); } else { console.error("Erreur traitement chunk:", e, jsonData); } }
|
| 573 |
+
}
|
| 574 |
+
function handleStreamEnd() { console.log("Fin du stream."); streamComplete = true; if (currentlyStreaming) { removeCursor(currentlyStreaming); } loadingIndicator.style.display = 'none'; downloadPdfBtn.disabled = false; currentlyStreaming = null; document.getElementById('streamingStatus').style.display = 'none'; }
|
| 575 |
|
| 576 |
// --- Analysis Request Logic (Reusable) ---
|
| 577 |
+
function startAnalysis(formData) {
|
| 578 |
+
// Reset state before starting
|
| 579 |
+
tableauMarkdownRaw = ''; dissertationMarkdownRaw = ''; currentlyStreaming = null; streamComplete = false;
|
| 580 |
+
dissertationContent.innerHTML = ''; tableauContent.innerHTML = ''; // Clear previous content
|
| 581 |
+
resultDiv.style.display = 'none'; loadingIndicator.style.display = 'flex'; downloadPdfBtn.disabled = true; switchTab('dissertation');
|
| 582 |
+
document.getElementById('streamingStatus').style.display = 'none';
|
| 583 |
|
| 584 |
const isDeepThinkRequest = formData.get('use_deepthink') === 'true';
|
| 585 |
console.log(`Lancement de l'analyse ${isDeepThinkRequest ? 'DeepThink' : 'standard'}...`);
|