diff --git a/libs/templateDeploy.js b/libs/templateDeploy.js index 36f9ed5..8a1666c 100644 --- a/libs/templateDeploy.js +++ b/libs/templateDeploy.js @@ -226,16 +226,8 @@ deployForm.addEventListener('submit', async (e) => { closeAllModals(); // Send the deployment request await deployDockerContainer(deployPayload); - - // Wait for a specific response - // Wait for the specific response - const successResponse = await waitForSpecificResponse("deployed successfully", 90000); - - console.log('[INFO] Waiting for the deployment response...' + successResponse); - - console.log('[INFO] Deployment success:', successResponse); - hideStatusIndicator(); - showAlert('success', successResponse.message); + // hideStatusIndicator(); + // showAlert('success', successResponse.message); startStatsInterval(); } catch (error) { console.error('[ERROR] Failed to deploy container:', error.message); @@ -243,46 +235,6 @@ deployForm.addEventListener('submit', async (e) => { showAlert('danger', error.message); } }); - -// Utility function to wait for a specific response -function waitForSpecificResponse(expectedMessageFragment, timeout = 90000) { - return new Promise((resolve, reject) => { - const startTime = Date.now(); - - function handleResponse(event) { - const response = event.detail; // Extract the response data - console.log('[DEBUG] Received response:', response); - - if (response?.success && response.message.includes(expectedMessageFragment)) { - console.log('[DEBUG] Expected response received:', response.message); - window.removeEventListener('responseReceived', handleResponse); // Remove listener - resolve(response); // Resolve with the response - } - } - - // Timeout handler - const timeoutId = setTimeout(() => { - console.warn('[WARN] Timeout while waiting for the expected response.'); - window.removeEventListener('responseReceived', handleResponse); // Cleanup - reject(new Error('Timeout waiting for the expected response')); - }, timeout); - - // Attach listener - window.addEventListener('responseReceived', handleResponse); - - // Ensure cleanup on successful resolution - const wrappedResolve = (response) => { - clearTimeout(timeoutId); - resolve(response); - }; - - // Replace `resolve` in `handleResponse` for proper cleanup - handleResponse.wrappedResolve = wrappedResolve; - }); -} - - - // Initialize templates on load document.addEventListener('DOMContentLoaded', fetchTemplates);