further updates

This commit is contained in:
Raven Scott
2025-11-24 16:28:21 -05:00
parent 6469f620e6
commit 4bf3381270
6 changed files with 428 additions and 321 deletions
+33 -40
View File
@@ -1,6 +1,6 @@
// Import dependencies first (ES6 imports must be at top)
import { showOperationStatus } from './loadingStates.js';
import { closeAllModals, showStatusIndicator, hideStatusIndicator, showAlert } from './uiUtils.js';
import notificationManager from './notifications.js';
// DOM Elements
const templateList = document.getElementById('template-list');
@@ -750,19 +750,20 @@ deployForm.addEventListener('submit', async (e) => {
return;
}
// Safely get container name with fallback
const containerName = (formData && formData.containerName) ? String(formData.containerName) : 'container';
// Close modal immediately before async operation
if (typeof closeAllModals === 'function') {
closeAllModals();
}
closeDeployModal();
// Add notification for container creation
notificationManager.add('info', `Creating container "${containerName}"...`, { autoDismiss: false });
showStatusIndicator('Deploying container...');
try {
// Safely get container name with fallback
const containerName = (formData && formData.containerName) ? String(formData.containerName) : 'container';
showStatusIndicator('Deploying container...');
try {
if (typeof showOperationStatus === 'function') {
showOperationStatus(`Deploying ${containerName}`, 'processing');
}
} catch (e) {
console.warn('[WARN] Failed to show operation status:', e);
}
// Deploy container with proper error handling
const successResponse = await deployDockerContainer(formData);
@@ -773,24 +774,13 @@ deployForm.addEventListener('submit', async (e) => {
hideStatusIndicator();
try {
if (typeof showOperationStatus === 'function') {
showOperationStatus(`Deploying ${containerName}`, 'completed');
}
} catch (e) {
console.warn('[WARN] Failed to show operation status:', e);
}
// Close all modals including the deploy modal
if (typeof closeAllModals === 'function') {
closeAllModals();
}
closeDeployModal();
// Safely extract success message
const successMessage = (successResponse && successResponse.message)
? String(successResponse.message)
: 'Container deployed successfully!';
// Update notification to success
notificationManager.add('success', `Container "${containerName}" created successfully!`);
showAlert('success', successMessage);
} catch (error) {
// Safely extract error message
@@ -813,17 +803,8 @@ deployForm.addEventListener('submit', async (e) => {
console.warn('[WARN] Failed to hide status indicator:', e);
}
// Safely get container name for error status
try {
const containerName = (formData && formData.containerName)
? String(formData.containerName)
: 'container';
if (typeof showOperationStatus === 'function') {
showOperationStatus(`Deploying ${containerName}`, 'failed');
}
} catch (e) {
console.warn('[WARN] Failed to show operation status:', e);
}
// Update notification to error (containerName already defined above)
notificationManager.add('danger', `Failed to create container "${containerName}"`);
showAlert('danger', errorMessage);
}
@@ -831,8 +812,20 @@ deployForm.addEventListener('submit', async (e) => {
// Save template functionality removed to match working version
// Initialize templates on load
document.addEventListener('DOMContentLoaded', fetchTemplates);
// Initialize templates on load - defer to not block initialization
if (typeof requestIdleCallback !== 'undefined') {
document.addEventListener('DOMContentLoaded', () => {
requestIdleCallback(() => {
fetchTemplates();
}, { timeout: 2000 });
});
} else {
document.addEventListener('DOMContentLoaded', () => {
setTimeout(() => {
fetchTemplates();
}, 500);
});
}
// Duplicate modal array management functions
let duplicatePortCounter = 0;