Update launch_progress.js
This commit is contained in:
@@ -219,14 +219,34 @@ function initializeSteps() {
|
||||
</div>
|
||||
`;
|
||||
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) {
|
||||
const launchReport = {
|
||||
startedAt: new Date().toISOString(),
|
||||
steps: []
|
||||
};
|
||||
try {
|
||||
// Step 1: Check Cloudflare connection
|
||||
await updateStep(1, 'Checking Cloudflare Connection', 'Verifying Cloudflare API connection...');
|
||||
const cloudflareResult = await checkCloudflareConnection();
|
||||
|
||||
launchReport.steps.push({
|
||||
step: 'Cloudflare Connection',
|
||||
status: cloudflareResult.success ? 'success' : 'error',
|
||||
details: cloudflareResult
|
||||
});
|
||||
if (!cloudflareResult.success) {
|
||||
throw new Error(cloudflareResult.error || 'Failed to connect to Cloudflare');
|
||||
}
|
||||
@@ -240,7 +260,11 @@ async function startLaunch(data) {
|
||||
// Step 2: Create DNS records
|
||||
await updateStep(2, 'Creating DNS Records', 'Setting up domain DNS records in Cloudflare...');
|
||||
const dnsCreateResult = await createDNSRecords(data.webAddresses);
|
||||
|
||||
launchReport.steps.push({
|
||||
step: 'DNS Records',
|
||||
status: dnsCreateResult.success ? 'success' : 'error',
|
||||
details: dnsCreateResult
|
||||
});
|
||||
if (!dnsCreateResult.success) {
|
||||
throw new Error(dnsCreateResult.error || 'Failed to create DNS records');
|
||||
}
|
||||
@@ -290,6 +314,14 @@ async function startLaunch(data) {
|
||||
// Step 3: Check DNS records
|
||||
await updateStep(3, 'Checking DNS Records', 'Verifying domain configurations...');
|
||||
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
|
||||
const failedDomains = Object.entries(dnsResult.results)
|
||||
@@ -350,7 +382,11 @@ async function startLaunch(data) {
|
||||
// Step 4: Check NGINX connection
|
||||
await updateStep(4, 'Checking NGINX Connection', 'Verifying connection to NGINX Proxy Manager...');
|
||||
const nginxResult = await checkNginxConnection();
|
||||
|
||||
launchReport.steps.push({
|
||||
step: 'NGINX Connection',
|
||||
status: nginxResult.success ? 'success' : 'error',
|
||||
details: nginxResult
|
||||
});
|
||||
if (!nginxResult.success) {
|
||||
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
|
||||
await updateStep(5, 'Generating SSL Certificate', 'Setting up secure HTTPS connection...');
|
||||
const sslResult = await generateSSLCertificate(data.webAddresses);
|
||||
|
||||
launchReport.steps.push({
|
||||
step: 'SSL Certificate',
|
||||
status: sslResult.success ? 'success' : 'error',
|
||||
details: sslResult
|
||||
});
|
||||
if (!sslResult.success) {
|
||||
throw new Error(sslResult.error || 'Failed to generate SSL certificate');
|
||||
}
|
||||
@@ -372,7 +412,11 @@ async function startLaunch(data) {
|
||||
// Step 6: Create Proxy Host
|
||||
await updateStep(6, 'Creating Proxy Host', 'Setting up NGINX proxy host configuration...');
|
||||
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) {
|
||||
throw new Error(proxyResult.error || 'Failed to create proxy host');
|
||||
}
|
||||
@@ -380,7 +424,11 @@ async function startLaunch(data) {
|
||||
// Step 7: Check Portainer connection
|
||||
await updateStep(7, 'Checking Portainer Connection', 'Verifying connection to Portainer...');
|
||||
const portainerResult = await checkPortainerConnection();
|
||||
|
||||
launchReport.steps.push({
|
||||
step: 'Portainer Connection',
|
||||
status: portainerResult.success ? 'success' : 'error',
|
||||
details: portainerResult
|
||||
});
|
||||
if (!portainerResult.success) {
|
||||
throw new Error(portainerResult.message || 'Failed to connect to Portainer');
|
||||
}
|
||||
@@ -394,7 +442,11 @@ async function startLaunch(data) {
|
||||
// Step 8: Download Docker Compose
|
||||
await updateStep(8, 'Downloading Docker Compose', 'Fetching docker-compose.yml from repository...');
|
||||
const dockerComposeResult = await downloadDockerCompose(data.repository, data.branch);
|
||||
|
||||
launchReport.steps.push({
|
||||
step: 'Docker Compose',
|
||||
status: dockerComposeResult.success ? 'success' : 'error',
|
||||
details: dockerComposeResult
|
||||
});
|
||||
if (!dockerComposeResult.success) {
|
||||
throw new Error(dockerComposeResult.error || 'Failed to download docker-compose.yml');
|
||||
}
|
||||
@@ -425,7 +477,11 @@ async function startLaunch(data) {
|
||||
// Step 9: Deploy Stack
|
||||
await updateStep(9, 'Deploying Stack', 'Launching your application stack...');
|
||||
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) {
|
||||
throw new Error(stackResult.error || 'Failed to deploy stack');
|
||||
}
|
||||
@@ -629,7 +685,11 @@ async function startLaunch(data) {
|
||||
// Step 13: Apply Company Information
|
||||
await updateStep(13, 'Apply Company Information', 'Configuring company details...');
|
||||
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) {
|
||||
throw new Error(`Company information application failed: ${companyResult.error}`);
|
||||
}
|
||||
@@ -687,7 +747,11 @@ async function startLaunch(data) {
|
||||
// Step 14: Apply Colors
|
||||
await updateStep(14, 'Apply Colors', 'Configuring color scheme...');
|
||||
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) {
|
||||
throw new Error(`Colors application failed: ${colorsResult.error}`);
|
||||
}
|
||||
@@ -736,7 +800,11 @@ async function startLaunch(data) {
|
||||
// Step 15: Update Admin Credentials
|
||||
await updateStep(15, 'Update Admin Credentials', 'Setting up admin account...');
|
||||
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) {
|
||||
throw new Error(`Admin credentials update failed: ${credentialsResult.error}`);
|
||||
}
|
||||
@@ -810,7 +878,11 @@ async function startLaunch(data) {
|
||||
// Step 16: Copy SMTP Settings
|
||||
await updateStep(16, 'Copy SMTP Settings', 'Configuring email settings...');
|
||||
const smtpResult = await copySmtpSettings(`https://${data.webAddresses[0]}`);
|
||||
|
||||
launchReport.steps.push({
|
||||
step: 'SMTP Settings',
|
||||
status: smtpResult.success ? 'success' : 'error',
|
||||
details: smtpResult
|
||||
});
|
||||
if (!smtpResult.success) {
|
||||
throw new Error(`SMTP settings copy failed: ${smtpResult.error}`);
|
||||
}
|
||||
@@ -880,7 +952,11 @@ async function startLaunch(data) {
|
||||
// Step 17: Send Completion Email
|
||||
await updateStep(17, 'Send Completion Email', 'Sending notification to client...');
|
||||
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) {
|
||||
throw new Error(`Email sending failed: ${emailResult.error}`);
|
||||
}
|
||||
@@ -1069,6 +1145,50 @@ Thank you for choosing DocuPulse!
|
||||
`;
|
||||
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) {
|
||||
console.error('Launch failed:', error);
|
||||
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('stepDescription').textContent = description;
|
||||
|
||||
// Calculate progress based on total number of steps (17 steps total)
|
||||
const totalSteps = 17;
|
||||
// Calculate progress based on total number of steps (18 steps total)
|
||||
const totalSteps = 18;
|
||||
const progress = ((stepNumber - 1) / (totalSteps - 1)) * 100;
|
||||
const progressBar = document.getElementById('launchProgress');
|
||||
progressBar.style.width = `${progress}%`;
|
||||
|
||||
Reference in New Issue
Block a user