|
106 | 106 | } |
107 | 107 | } |
108 | 108 |
|
109 | | - /* Masquer la barre d'entrée si configPanel ou sandboxModal sont visibles */ |
| 109 | + /* Masquer la barre d'entrée si configPanel ou sandboxModal ou deleteConfirmModal sont visibles */ |
110 | 110 | #configPanel[style*="display: flex"]~#sandboxModal[style*="display: flex"]~#floatingInputBar { |
111 | 111 | display: none !important; |
112 | 112 | } |
|
115 | 115 | display: none !important; |
116 | 116 | } |
117 | 117 |
|
| 118 | + #deleteConfirmModal[style*="display: flex"]~#floatingInputBar { |
| 119 | + display: none !important; |
| 120 | + } |
| 121 | + |
118 | 122 | /* Styles pour la vue chat */ |
119 | 123 | .chat-view { |
120 | 124 | display: none; |
@@ -313,6 +317,28 @@ <h3 id="sandboxModalTitle" class="text-lg font-semibold mb-4">Sandbox Title</h3> |
313 | 317 | </div> |
314 | 318 | </div> |
315 | 319 | </div> |
| 320 | + <!-- Modal pour confirmation de suppression de sandbox --> |
| 321 | + <div id="deleteConfirmModal" class="fixed inset-0 bg-black bg-opacity-30 z-40 items-center justify-center" |
| 322 | + style="display:none;"> |
| 323 | + <div class="bg-white rounded-lg shadow-lg p-6 w-full max-w-md mx-auto flex flex-col"> |
| 324 | + <h3 class="text-lg font-semibold mb-4 text-red-600"> |
| 325 | + <i class="fas fa-exclamation-triangle mr-2"></i>Delete Sandbox |
| 326 | + </h3> |
| 327 | + <p class="text-gray-700 mb-6">Are you sure you want to delete this sandbox?</p> |
| 328 | + <div class="flex flex-col space-y-3"> |
| 329 | + <button id="deleteKeepFolderBtn" |
| 330 | + class="bg-orange-500 hover:bg-orange-600 text-white py-3 px-4 rounded flex items-center justify-center"> |
| 331 | + <i class="fas fa-folder mr-2"></i>Delete sandbox but keep folder |
| 332 | + </button> |
| 333 | + <button id="deleteWithFolderBtn" |
| 334 | + class="bg-red-600 hover:bg-red-700 text-white py-3 px-4 rounded flex items-center justify-center"> |
| 335 | + <i class="fas fa-trash mr-2"></i>Delete sandbox and folder |
| 336 | + </button> |
| 337 | + <button id="deleteCancelBtn" |
| 338 | + class="bg-gray-300 hover:bg-gray-400 text-gray-800 py-2 px-4 rounded">Cancel</button> |
| 339 | + </div> |
| 340 | + </div> |
| 341 | + </div> |
316 | 342 | <!-- Champ de saisie flottant discret à droite --> |
317 | 343 | <div id="floatingInputBar" |
318 | 344 | class="floating-input-bar z-30 flex items-center justify-center pointer-events-none"> |
@@ -476,24 +502,73 @@ <h3 id="sandboxModalTitle" class="text-lg font-semibold mb-4">Sandbox Title</h3> |
476 | 502 |
|
477 | 503 | deleteBtn.onclick = async function () { |
478 | 504 | if (!currentConvId) return; |
479 | | - if (confirm('Delete Sandbox (folder will also be deleted)?')) { |
480 | | - const ok = await deleteSandbox(currentConvId); |
481 | | - if (ok) { |
482 | | - await loadHistoryPanel(); |
483 | | - // Charge la première conversation restante, sinon vide le chat |
484 | | - const convs = await fetchSandboxes(); |
485 | | - if (convs.length > 0) { |
486 | | - await loadSandbox(convs[0].id); |
487 | | - } else { |
488 | | - currentConvId = null; |
489 | | - currentConvMessages = []; |
490 | | - document.getElementById('timelineContainer').innerHTML = ''; |
491 | | - document.getElementById('chatContainer').innerHTML = ''; |
492 | | - document.getElementById('currentConvTitle').textContent = ''; |
493 | | - } |
| 505 | + |
| 506 | + // Show the delete confirmation modal |
| 507 | + const deleteModal = document.getElementById('deleteConfirmModal'); |
| 508 | + deleteModal.style.display = 'flex'; |
| 509 | + }; |
| 510 | + |
| 511 | + // Handle delete confirmation modal buttons |
| 512 | + const deleteModal = document.getElementById('deleteConfirmModal'); |
| 513 | + const deleteKeepFolderBtn = document.getElementById('deleteKeepFolderBtn'); |
| 514 | + const deleteWithFolderBtn = document.getElementById('deleteWithFolderBtn'); |
| 515 | + const deleteCancelBtn = document.getElementById('deleteCancelBtn'); |
| 516 | + |
| 517 | + deleteKeepFolderBtn.onclick = async function () { |
| 518 | + deleteModal.style.display = 'none'; |
| 519 | + const ok = await deleteSandbox(currentConvId, false); // false = keep folder |
| 520 | + if (ok) { |
| 521 | + await loadHistoryPanel(); |
| 522 | + // Charge la première conversation restante, sinon vide le chat |
| 523 | + const convs = await fetchSandboxes(); |
| 524 | + if (convs.length > 0) { |
| 525 | + await loadSandbox(convs[0].id); |
| 526 | + } else { |
| 527 | + currentConvId = null; |
| 528 | + currentConvMessages = []; |
| 529 | + document.getElementById('timelineContainer').innerHTML = ''; |
| 530 | + document.getElementById('chatContainer').innerHTML = ''; |
| 531 | + document.getElementById('currentConvTitle').textContent = ''; |
494 | 532 | } |
495 | 533 | } |
496 | 534 | }; |
| 535 | + |
| 536 | + deleteWithFolderBtn.onclick = async function () { |
| 537 | + deleteModal.style.display = 'none'; |
| 538 | + const ok = await deleteSandbox(currentConvId, true); // true = delete folder |
| 539 | + if (ok) { |
| 540 | + await loadHistoryPanel(); |
| 541 | + // Charge la première conversation restante, sinon vide le chat |
| 542 | + const convs = await fetchSandboxes(); |
| 543 | + if (convs.length > 0) { |
| 544 | + await loadSandbox(convs[0].id); |
| 545 | + } else { |
| 546 | + currentConvId = null; |
| 547 | + currentConvMessages = []; |
| 548 | + document.getElementById('timelineContainer').innerHTML = ''; |
| 549 | + document.getElementById('chatContainer').innerHTML = ''; |
| 550 | + document.getElementById('currentConvTitle').textContent = ''; |
| 551 | + } |
| 552 | + } |
| 553 | + }; |
| 554 | + |
| 555 | + deleteCancelBtn.onclick = function () { |
| 556 | + deleteModal.style.display = 'none'; |
| 557 | + }; |
| 558 | + |
| 559 | + // Handle escape key for delete modal |
| 560 | + document.addEventListener('keydown', function(e) { |
| 561 | + if (e.key === 'Escape' && deleteModal.style.display === 'flex') { |
| 562 | + deleteModal.style.display = 'none'; |
| 563 | + } |
| 564 | + }); |
| 565 | + |
| 566 | + // Handle click outside modal to close |
| 567 | + deleteModal.addEventListener('click', function(e) { |
| 568 | + if (e.target === deleteModal) { |
| 569 | + deleteModal.style.display = 'none'; |
| 570 | + } |
| 571 | + }); |
497 | 572 | }; |
498 | 573 |
|
499 | 574 | // Gestionnaires pour les boutons de basculement de vue |
@@ -796,8 +871,10 @@ <h3 id="sandboxModalTitle" class="text-lg font-semibold mb-4">Sandbox Title</h3> |
796 | 871 | } |
797 | 872 | }); |
798 | 873 | // Fonctions pour supprimer et renommer une conversation |
799 | | - async function deleteSandbox(convId) { |
800 | | - const res = await fetch(`/sandboxes/${convId}`, { method: 'DELETE' }); |
| 874 | + async function deleteSandbox(convId, deleteFolder = true) { |
| 875 | + const params = new URLSearchParams(); |
| 876 | + params.append('delete_folder', deleteFolder.toString()); |
| 877 | + const res = await fetch(`/sandboxes/${convId}?${params}`, { method: 'DELETE' }); |
801 | 878 | return res.ok; |
802 | 879 | } |
803 | 880 | async function renameSandbox(convId, newTitle) { |
@@ -884,7 +961,7 @@ <h3 id="sandboxModalTitle" class="text-lg font-semibold mb-4">Sandbox Title</h3> |
884 | 961 | timeline.innerHTML = '<div class="text-center text-gray-500 py-8">Welcome ! What can I do for you today? Don\'t forget to configure your API key in the configuration panel.</div>'; |
885 | 962 | return; |
886 | 963 | } |
887 | | - |
| 964 | + |
888 | 965 | // Regroupement correct des étapes : chaque user suivi de 1 ou plusieurs assistant |
889 | 966 | const steps = []; |
890 | 967 | let currentStep = null; |
|
0 commit comments