edit: add modal asking user if they really want to delete a container

This commit is contained in:
Raven Scott 2024-11-29 20:17:53 -05:00
parent b2302f8067
commit 956b7ee056
2 changed files with 29 additions and 2 deletions

12
app.js
View File

@ -341,7 +341,6 @@ function renderContainers(containers) {
});
}
// Add event listeners to action buttons
function addActionListeners(row, container) {
const startBtn = row.querySelector('.action-start');
const stopBtn = row.querySelector('.action-stop');
@ -357,7 +356,16 @@ function addActionListeners(row, container) {
});
removeBtn.addEventListener('click', () => {
sendCommand('removeContainer', { id: container.Id });
// Show the delete confirmation modal
const deleteModal = new bootstrap.Modal(document.getElementById('deleteModal'));
deleteModal.show();
// Handle confirmation button
const confirmDeleteBtn = document.getElementById('confirm-delete-btn');
confirmDeleteBtn.onclick = () => {
sendCommand('removeContainer', { id: container.Id }); // Remove the container
deleteModal.hide(); // Close the modal
};
});
terminalBtn.addEventListener('click', () => {

View File

@ -267,6 +267,25 @@
<div id="terminal-resize-handle"></div> <!-- Resize handle -->
</div>
<!-- Delete Confirmation Modal -->
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content bg-dark text-white">
<div class="modal-header">
<h5 class="modal-title" id="deleteModalLabel">Confirm Deletion</h5>
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
Are you sure you want to delete this container?
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
<button type="button" id="confirm-delete-btn" class="btn btn-danger">Delete</button>
</div>
</div>
</div>
</div>
<div id="tray"></div>
<!-- xterm.js -->