Update launch_progress.js

This commit is contained in:
2025-06-20 19:44:02 +02:00
parent e85d91d1f4
commit 3f8517ec7d

View File

@@ -219,14 +219,34 @@ function initializeSteps() {
</div> </div>
`; `;
stepsContainer.appendChild(emailStep); stepsContainer.appendChild(emailStep);
// Add Download Launch Report step
const reportStep = document.createElement('div');
reportStep.className = 'step-item';
reportStep.innerHTML = `
<div class="step-icon"><i class="fas fa-file-download"></i></div>
<div class="step-content">
<h5>Download Launch Report</h5>
<p class="step-status">Preparing launch report...</p>
</div>
`;
stepsContainer.appendChild(reportStep);
} }
async function startLaunch(data) { async function startLaunch(data) {
const launchReport = {
startedAt: new Date().toISOString(),
steps: []
};
try { try {
// Step 1: Check Cloudflare connection // Step 1: Check Cloudflare connection
await updateStep(1, 'Checking Cloudflare Connection', 'Verifying Cloudflare API connection...'); await updateStep(1, 'Checking Cloudflare Connection', 'Verifying Cloudflare API connection...');
const cloudflareResult = await checkCloudflareConnection(); const cloudflareResult = await checkCloudflareConnection();
launchReport.steps.push({
step: 'Cloudflare Connection',
status: cloudflareResult.success ? 'success' : 'error',
details: cloudflareResult
});
if (!cloudflareResult.success) { if (!cloudflareResult.success) {
throw new Error(cloudflareResult.error || 'Failed to connect to Cloudflare'); throw new Error(cloudflareResult.error || 'Failed to connect to Cloudflare');
} }
@@ -240,7 +260,11 @@ async function startLaunch(data) {
// Step 2: Create DNS records // Step 2: Create DNS records
await updateStep(2, 'Creating DNS Records', 'Setting up domain DNS records in Cloudflare...'); await updateStep(2, 'Creating DNS Records', 'Setting up domain DNS records in Cloudflare...');
const dnsCreateResult = await createDNSRecords(data.webAddresses); const dnsCreateResult = await createDNSRecords(data.webAddresses);
launchReport.steps.push({
step: 'DNS Records',
status: dnsCreateResult.success ? 'success' : 'error',
details: dnsCreateResult
});
if (!dnsCreateResult.success) { if (!dnsCreateResult.success) {
throw new Error(dnsCreateResult.error || 'Failed to create DNS records'); throw new Error(dnsCreateResult.error || 'Failed to create DNS records');
} }
@@ -290,6 +314,14 @@ async function startLaunch(data) {
// Step 3: Check DNS records // Step 3: Check DNS records
await updateStep(3, 'Checking DNS Records', 'Verifying domain configurations...'); await updateStep(3, 'Checking DNS Records', 'Verifying domain configurations...');
const dnsResult = await checkDNSRecords(data.webAddresses); const dnsResult = await checkDNSRecords(data.webAddresses);
launchReport.steps.push({
step: 'DNS Check',
status: dnsResult.success ? 'success' : 'error',
details: dnsResult
});
if (!dnsResult.success) {
throw new Error(dnsResult.error || 'Failed to check DNS records');
}
// Check if any domains failed to resolve // Check if any domains failed to resolve
const failedDomains = Object.entries(dnsResult.results) const failedDomains = Object.entries(dnsResult.results)
@@ -350,7 +382,11 @@ async function startLaunch(data) {
// Step 4: Check NGINX connection // Step 4: Check NGINX connection
await updateStep(4, 'Checking NGINX Connection', 'Verifying connection to NGINX Proxy Manager...'); await updateStep(4, 'Checking NGINX Connection', 'Verifying connection to NGINX Proxy Manager...');
const nginxResult = await checkNginxConnection(); const nginxResult = await checkNginxConnection();
launchReport.steps.push({
step: 'NGINX Connection',
status: nginxResult.success ? 'success' : 'error',
details: nginxResult
});
if (!nginxResult.success) { if (!nginxResult.success) {
throw new Error(nginxResult.error || 'Failed to connect to NGINX Proxy Manager'); throw new Error(nginxResult.error || 'Failed to connect to NGINX Proxy Manager');
} }
@@ -364,7 +400,11 @@ async function startLaunch(data) {
// Step 5: Generate SSL Certificate // Step 5: Generate SSL Certificate
await updateStep(5, 'Generating SSL Certificate', 'Setting up secure HTTPS connection...'); await updateStep(5, 'Generating SSL Certificate', 'Setting up secure HTTPS connection...');
const sslResult = await generateSSLCertificate(data.webAddresses); const sslResult = await generateSSLCertificate(data.webAddresses);
launchReport.steps.push({
step: 'SSL Certificate',
status: sslResult.success ? 'success' : 'error',
details: sslResult
});
if (!sslResult.success) { if (!sslResult.success) {
throw new Error(sslResult.error || 'Failed to generate SSL certificate'); throw new Error(sslResult.error || 'Failed to generate SSL certificate');
} }
@@ -372,7 +412,11 @@ async function startLaunch(data) {
// Step 6: Create Proxy Host // Step 6: Create Proxy Host
await updateStep(6, 'Creating Proxy Host', 'Setting up NGINX proxy host configuration...'); await updateStep(6, 'Creating Proxy Host', 'Setting up NGINX proxy host configuration...');
const proxyResult = await createProxyHost(data.webAddresses, data.port, sslResult.data.certificate.id); const proxyResult = await createProxyHost(data.webAddresses, data.port, sslResult.data.certificate.id);
launchReport.steps.push({
step: 'Proxy Host',
status: proxyResult.success ? 'success' : 'error',
details: proxyResult
});
if (!proxyResult.success) { if (!proxyResult.success) {
throw new Error(proxyResult.error || 'Failed to create proxy host'); throw new Error(proxyResult.error || 'Failed to create proxy host');
} }
@@ -380,7 +424,11 @@ async function startLaunch(data) {
// Step 7: Check Portainer connection // Step 7: Check Portainer connection
await updateStep(7, 'Checking Portainer Connection', 'Verifying connection to Portainer...'); await updateStep(7, 'Checking Portainer Connection', 'Verifying connection to Portainer...');
const portainerResult = await checkPortainerConnection(); const portainerResult = await checkPortainerConnection();
launchReport.steps.push({
step: 'Portainer Connection',
status: portainerResult.success ? 'success' : 'error',
details: portainerResult
});
if (!portainerResult.success) { if (!portainerResult.success) {
throw new Error(portainerResult.message || 'Failed to connect to Portainer'); throw new Error(portainerResult.message || 'Failed to connect to Portainer');
} }
@@ -394,7 +442,11 @@ async function startLaunch(data) {
// Step 8: Download Docker Compose // Step 8: Download Docker Compose
await updateStep(8, 'Downloading Docker Compose', 'Fetching docker-compose.yml from repository...'); await updateStep(8, 'Downloading Docker Compose', 'Fetching docker-compose.yml from repository...');
const dockerComposeResult = await downloadDockerCompose(data.repository, data.branch); const dockerComposeResult = await downloadDockerCompose(data.repository, data.branch);
launchReport.steps.push({
step: 'Docker Compose',
status: dockerComposeResult.success ? 'success' : 'error',
details: dockerComposeResult
});
if (!dockerComposeResult.success) { if (!dockerComposeResult.success) {
throw new Error(dockerComposeResult.error || 'Failed to download docker-compose.yml'); throw new Error(dockerComposeResult.error || 'Failed to download docker-compose.yml');
} }
@@ -425,7 +477,11 @@ async function startLaunch(data) {
// Step 9: Deploy Stack // Step 9: Deploy Stack
await updateStep(9, 'Deploying Stack', 'Launching your application stack...'); await updateStep(9, 'Deploying Stack', 'Launching your application stack...');
const stackResult = await deployStack(dockerComposeResult.content, data.instanceName, data.port); const stackResult = await deployStack(dockerComposeResult.content, data.instanceName, data.port);
launchReport.steps.push({
step: 'Stack Deployment',
status: stackResult.success ? 'success' : 'error',
details: stackResult
});
if (!stackResult.success) { if (!stackResult.success) {
throw new Error(stackResult.error || 'Failed to deploy stack'); throw new Error(stackResult.error || 'Failed to deploy stack');
} }
@@ -629,7 +685,11 @@ async function startLaunch(data) {
// Step 13: Apply Company Information // Step 13: Apply Company Information
await updateStep(13, 'Apply Company Information', 'Configuring company details...'); await updateStep(13, 'Apply Company Information', 'Configuring company details...');
const companyResult = await applyCompanyInformation(`https://${data.webAddresses[0]}`, data.company); const companyResult = await applyCompanyInformation(`https://${data.webAddresses[0]}`, data.company);
launchReport.steps.push({
step: 'Company Information',
status: companyResult.success ? 'success' : 'error',
details: companyResult
});
if (!companyResult.success) { if (!companyResult.success) {
throw new Error(`Company information application failed: ${companyResult.error}`); throw new Error(`Company information application failed: ${companyResult.error}`);
} }
@@ -687,7 +747,11 @@ async function startLaunch(data) {
// Step 14: Apply Colors // Step 14: Apply Colors
await updateStep(14, 'Apply Colors', 'Configuring color scheme...'); await updateStep(14, 'Apply Colors', 'Configuring color scheme...');
const colorsResult = await applyColors(`https://${data.webAddresses[0]}`, data.colors); const colorsResult = await applyColors(`https://${data.webAddresses[0]}`, data.colors);
launchReport.steps.push({
step: 'Colors',
status: colorsResult.success ? 'success' : 'error',
details: colorsResult
});
if (!colorsResult.success) { if (!colorsResult.success) {
throw new Error(`Colors application failed: ${colorsResult.error}`); throw new Error(`Colors application failed: ${colorsResult.error}`);
} }
@@ -736,7 +800,11 @@ async function startLaunch(data) {
// Step 15: Update Admin Credentials // Step 15: Update Admin Credentials
await updateStep(15, 'Update Admin Credentials', 'Setting up admin account...'); await updateStep(15, 'Update Admin Credentials', 'Setting up admin account...');
const credentialsResult = await updateAdminCredentials(`https://${data.webAddresses[0]}`, data.company.email); const credentialsResult = await updateAdminCredentials(`https://${data.webAddresses[0]}`, data.company.email);
launchReport.steps.push({
step: 'Admin Credentials',
status: credentialsResult.success ? 'success' : 'error',
details: credentialsResult
});
if (!credentialsResult.success) { if (!credentialsResult.success) {
throw new Error(`Admin credentials update failed: ${credentialsResult.error}`); throw new Error(`Admin credentials update failed: ${credentialsResult.error}`);
} }
@@ -810,7 +878,11 @@ async function startLaunch(data) {
// Step 16: Copy SMTP Settings // Step 16: Copy SMTP Settings
await updateStep(16, 'Copy SMTP Settings', 'Configuring email settings...'); await updateStep(16, 'Copy SMTP Settings', 'Configuring email settings...');
const smtpResult = await copySmtpSettings(`https://${data.webAddresses[0]}`); const smtpResult = await copySmtpSettings(`https://${data.webAddresses[0]}`);
launchReport.steps.push({
step: 'SMTP Settings',
status: smtpResult.success ? 'success' : 'error',
details: smtpResult
});
if (!smtpResult.success) { if (!smtpResult.success) {
throw new Error(`SMTP settings copy failed: ${smtpResult.error}`); throw new Error(`SMTP settings copy failed: ${smtpResult.error}`);
} }
@@ -880,7 +952,11 @@ async function startLaunch(data) {
// Step 17: Send Completion Email // Step 17: Send Completion Email
await updateStep(17, 'Send Completion Email', 'Sending notification to client...'); await updateStep(17, 'Send Completion Email', 'Sending notification to client...');
const emailResult = await sendCompletionEmail(`https://${data.webAddresses[0]}`, data.company, credentialsResult.data); const emailResult = await sendCompletionEmail(`https://${data.webAddresses[0]}`, data.company, credentialsResult.data);
launchReport.steps.push({
step: 'Completion Email',
status: emailResult.success ? 'success' : 'error',
details: emailResult
});
if (!emailResult.success) { if (!emailResult.success) {
throw new Error(`Email sending failed: ${emailResult.error}`); throw new Error(`Email sending failed: ${emailResult.error}`);
} }
@@ -1069,6 +1145,50 @@ Thank you for choosing DocuPulse!
`; `;
emailStep.querySelector('.step-content').appendChild(emailDetails); emailStep.querySelector('.step-content').appendChild(emailDetails);
// Update the top section to show completion
document.getElementById('currentStep').textContent = 'Launch Complete!';
document.getElementById('stepDescription').textContent = 'Your DocuPulse instance has been successfully deployed and configured.';
const progressBar = document.getElementById('launchProgress');
progressBar.style.width = '100%';
progressBar.textContent = '100%';
// Scroll to the bottom of the steps container
const stepsContainer = document.getElementById('stepsContainer');
stepsContainer.scrollTo({
top: stepsContainer.scrollHeight,
behavior: 'smooth'
});
// Step 18: Download Launch Report
await updateStep(18, 'Download Launch Report', 'Download a full report of the launch process.');
const reportStep = document.querySelectorAll('.step-item')[17];
reportStep.classList.remove('active');
reportStep.classList.add('completed');
reportStep.querySelector('.step-status').textContent = 'Download your launch report below.';
// Prepare the report data
launchReport.completedAt = new Date().toISOString();
launchReport.instance = {
domains: data.webAddresses,
company: data.company,
port: data.port
};
// Create the download button
const downloadReportBtn = document.createElement('button');
downloadReportBtn.className = 'btn btn-success mt-3';
downloadReportBtn.innerHTML = '<i class="fas fa-file-download me-1"></i> Download Launch Report';
downloadReportBtn.onclick = () => {
const blob = new Blob([JSON.stringify(launchReport, null, 2)], { type: 'application/json' });
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = `docupulse_launch_report_${data.instanceName || 'instance'}.json`;
document.body.appendChild(a);
a.click();
window.URL.revokeObjectURL(url);
document.body.removeChild(a);
};
reportStep.querySelector('.step-content').appendChild(downloadReportBtn);
} catch (error) { } catch (error) {
console.error('Launch failed:', error); console.error('Launch failed:', error);
await updateStep(17, 'Send Completion Email', `Error: ${error.message}`); await updateStep(17, 'Send Completion Email', `Error: ${error.message}`);
@@ -1774,8 +1894,8 @@ function updateStep(stepNumber, title, description) {
document.getElementById('currentStep').textContent = title; document.getElementById('currentStep').textContent = title;
document.getElementById('stepDescription').textContent = description; document.getElementById('stepDescription').textContent = description;
// Calculate progress based on total number of steps (17 steps total) // Calculate progress based on total number of steps (18 steps total)
const totalSteps = 17; const totalSteps = 18;
const progress = ((stepNumber - 1) / (totalSteps - 1)) * 100; const progress = ((stepNumber - 1) / (totalSteps - 1)) * 100;
const progressBar = document.getElementById('launchProgress'); const progressBar = document.getElementById('launchProgress');
progressBar.style.width = `${progress}%`; progressBar.style.width = `${progress}%`;