forked from snxraven/peardock
If a container is deleted, auto close and delete its terminal session and modal
This commit is contained in:
parent
37aa448011
commit
ebe25cbe1c
35
app.js
35
app.js
@ -372,11 +372,42 @@ function addActionListeners(row, container) {
|
|||||||
// Handle confirmation button
|
// Handle confirmation button
|
||||||
const confirmDeleteBtn = document.getElementById('confirm-delete-btn');
|
const confirmDeleteBtn = document.getElementById('confirm-delete-btn');
|
||||||
confirmDeleteBtn.onclick = () => {
|
confirmDeleteBtn.onclick = () => {
|
||||||
sendCommand('removeContainer', { id: container.Id }); // Remove the container
|
console.log(`[INFO] Deleting container: ${container.Id}`);
|
||||||
deleteModal.hide(); // Close the modal
|
|
||||||
|
// Check if the container has active terminals
|
||||||
|
if (window.openTerminals[container.Id]) {
|
||||||
|
console.log(`[INFO] Closing active terminals for container: ${container.Id}`);
|
||||||
|
window.openTerminals[container.Id].forEach((terminalId) => {
|
||||||
|
try {
|
||||||
|
cleanUpTerminal(terminalId); // Use your terminal.js cleanup logic
|
||||||
|
} catch (err) {
|
||||||
|
console.error(`[ERROR] Failed to clean up terminal ${terminalId}: ${err.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
delete window.openTerminals[container.Id]; // Remove from open terminals
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check if the terminal modal is active and hide it
|
||||||
|
const terminalModal = document.getElementById('terminal-modal');
|
||||||
|
if (terminalModal.style.display === 'flex') {
|
||||||
|
console.log(`[INFO] Hiding terminal modal for container: ${container.Id}`);
|
||||||
|
terminalModal.style.display = 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the removeContainer command
|
||||||
|
sendCommand('removeContainer', { id: container.Id });
|
||||||
|
deleteModal.hide(); // Close the delete confirmation modal
|
||||||
|
|
||||||
|
// Remove the container row from the container list
|
||||||
|
const row = containerList.querySelector(`tr[data-container-id="${container.Id}"]`);
|
||||||
|
if (row) {
|
||||||
|
row.remove();
|
||||||
|
console.log(`[INFO] Removed container row for container ID: ${container.Id}`);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
terminalBtn.addEventListener('click', () => {
|
terminalBtn.addEventListener('click', () => {
|
||||||
startTerminal(container.Id, container.Names[0] || container.Id);
|
startTerminal(container.Id, container.Names[0] || container.Id);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user