launch process completed!
This commit is contained in:
@@ -147,6 +147,30 @@ function initializeSteps() {
|
||||
</div>
|
||||
`;
|
||||
stepsContainer.appendChild(companyStep);
|
||||
|
||||
// Add Apply Colors step
|
||||
const colorsStep = document.createElement('div');
|
||||
colorsStep.className = 'step-item';
|
||||
colorsStep.innerHTML = `
|
||||
<div class="step-icon"><i class="fas fa-palette"></i></div>
|
||||
<div class="step-content">
|
||||
<h5>Apply Colors</h5>
|
||||
<p class="step-status">Configuring color scheme...</p>
|
||||
</div>
|
||||
`;
|
||||
stepsContainer.appendChild(colorsStep);
|
||||
|
||||
// Add Update Admin Credentials step
|
||||
const credentialsStep = document.createElement('div');
|
||||
credentialsStep.className = 'step-item';
|
||||
credentialsStep.innerHTML = `
|
||||
<div class="step-icon"><i class="fas fa-user-shield"></i></div>
|
||||
<div class="step-content">
|
||||
<h5>Update Admin Credentials</h5>
|
||||
<p class="step-status">Setting up admin account...</p>
|
||||
</div>
|
||||
`;
|
||||
stepsContainer.appendChild(credentialsStep);
|
||||
}
|
||||
|
||||
async function startLaunch(data) {
|
||||
@@ -548,9 +572,120 @@ async function startLaunch(data) {
|
||||
`;
|
||||
companyStep.querySelector('.step-content').appendChild(companyDetails);
|
||||
|
||||
// Step 12: Apply Colors
|
||||
await updateStep(12, 'Apply Colors', 'Configuring color scheme...');
|
||||
const colorsResult = await applyColors(`https://${data.webAddresses[0]}`, data.colors);
|
||||
|
||||
if (!colorsResult.success) {
|
||||
throw new Error(`Colors application failed: ${colorsResult.error}`);
|
||||
}
|
||||
|
||||
// Update the colors step to show success
|
||||
const colorsStep = document.querySelectorAll('.step-item')[11];
|
||||
colorsStep.classList.remove('active');
|
||||
colorsStep.classList.add('completed');
|
||||
colorsStep.querySelector('.step-status').textContent = 'Successfully applied color scheme';
|
||||
|
||||
// Add colors details
|
||||
const colorsDetails = document.createElement('div');
|
||||
colorsDetails.className = 'mt-3';
|
||||
colorsDetails.innerHTML = `
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title mb-3">Color Scheme Applied</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Property</th>
|
||||
<th>Value</th>
|
||||
<th>Preview</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Primary Color</td>
|
||||
<td>${data.colors.primary || 'Not set'}</td>
|
||||
<td><div style="width: 30px; height: 20px; background-color: ${data.colors.primary || '#ccc'}; border: 1px solid #ddd;"></div></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Secondary Color</td>
|
||||
<td>${data.colors.secondary || 'Not set'}</td>
|
||||
<td><div style="width: 30px; height: 20px; background-color: ${data.colors.secondary || '#ccc'}; border: 1px solid #ddd;"></div></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
colorsStep.querySelector('.step-content').appendChild(colorsDetails);
|
||||
|
||||
// Step 13: Update Admin Credentials
|
||||
await updateStep(13, 'Update Admin Credentials', 'Setting up admin account...');
|
||||
const credentialsResult = await updateAdminCredentials(`https://${data.webAddresses[0]}`, data.company.email);
|
||||
|
||||
if (!credentialsResult.success) {
|
||||
throw new Error(`Admin credentials update failed: ${credentialsResult.error}`);
|
||||
}
|
||||
|
||||
// Update the credentials step to show success
|
||||
const credentialsStep = document.querySelectorAll('.step-item')[12];
|
||||
credentialsStep.classList.remove('active');
|
||||
credentialsStep.classList.add('completed');
|
||||
credentialsStep.querySelector('.step-status').textContent = 'Successfully updated admin credentials';
|
||||
|
||||
// Add credentials details
|
||||
const credentialsDetails = document.createElement('div');
|
||||
credentialsDetails.className = 'mt-3';
|
||||
credentialsDetails.innerHTML = `
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h6 class="card-title mb-3">Admin Credentials Updated</h6>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Property</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Email Address</td>
|
||||
<td>${credentialsResult.data.email || 'Not set'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Password</td>
|
||||
<td><code class="text-primary">${credentialsResult.data.password || 'Not set'}</code></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Username</td>
|
||||
<td>${credentialsResult.data.username || 'administrator'}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Role</td>
|
||||
<td><span class="badge bg-primary">Administrator</span></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="alert alert-warning mt-3">
|
||||
<i class="fas fa-exclamation-triangle me-2"></i>
|
||||
<strong>Important:</strong> Please save these credentials securely. The password will not be shown again.
|
||||
</div>
|
||||
<div class="alert alert-info mt-2">
|
||||
<i class="fas fa-info-circle me-2"></i>
|
||||
<strong>Login URL:</strong> <a href="https://${data.webAddresses[0]}" target="_blank">https://${data.webAddresses[0]}</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
credentialsStep.querySelector('.step-content').appendChild(credentialsDetails);
|
||||
|
||||
} catch (error) {
|
||||
console.error('Launch failed:', error);
|
||||
await updateStep(11, 'Apply Company Information', `Error: ${error.message}`);
|
||||
await updateStep(13, 'Update Admin Credentials', `Error: ${error.message}`);
|
||||
showError(error.message);
|
||||
}
|
||||
}
|
||||
@@ -1156,8 +1291,8 @@ function updateStep(stepNumber, title, description) {
|
||||
document.getElementById('currentStep').textContent = title;
|
||||
document.getElementById('stepDescription').textContent = description;
|
||||
|
||||
// Calculate progress based on total number of steps (11 steps total)
|
||||
const totalSteps = 11;
|
||||
// Calculate progress based on total number of steps (13 steps total)
|
||||
const totalSteps = 13;
|
||||
const progress = ((stepNumber - 1) / (totalSteps - 1)) * 100;
|
||||
const progressBar = document.getElementById('launchProgress');
|
||||
progressBar.style.width = `${progress}%`;
|
||||
@@ -1599,4 +1734,80 @@ async function applyCompanyInformation(instanceUrl, company) {
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function applyColors(instanceUrl, colors) {
|
||||
try {
|
||||
console.log('Applying colors to:', instanceUrl);
|
||||
|
||||
const response = await fetch('/api/admin/apply-colors', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
|
||||
},
|
||||
body: JSON.stringify({
|
||||
instance_url: instanceUrl,
|
||||
colors_data: colors
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Failed to apply colors: ${errorText}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('Colors applied successfully:', result);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: result.message,
|
||||
data: result.data
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error applying colors:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
async function updateAdminCredentials(instanceUrl, email) {
|
||||
try {
|
||||
console.log('Updating admin credentials for:', instanceUrl);
|
||||
|
||||
const response = await fetch('/api/admin/update-admin-credentials', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-Token': document.querySelector('meta[name="csrf-token"]').content
|
||||
},
|
||||
body: JSON.stringify({
|
||||
instance_url: instanceUrl,
|
||||
email: email
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text();
|
||||
throw new Error(`Failed to update admin credentials: ${errorText}`);
|
||||
}
|
||||
|
||||
const result = await response.json();
|
||||
console.log('Admin credentials updated successfully:', result);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: result.message,
|
||||
data: result.data
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('Error updating admin credentials:', error);
|
||||
return {
|
||||
success: false,
|
||||
error: error.message
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user