Add SSL certificate provisioning button for superadmin
- New provision_ssl API endpoint runs certbot for new domains - SSL button appears next to domain textarea for superadmin - Shell script on server handles Apache config + Let's Encrypt - DNS check skips domains without resolution to avoid certbot errors Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
26
script.js
26
script.js
@@ -2908,6 +2908,8 @@ async function showCompanyDetail(id) {
|
||||
if (modulesSection) modulesSection.style.display = isSA ? '' : 'none';
|
||||
if (integrationsSection) integrationsSection.style.display = isSA ? '' : 'none';
|
||||
if (ipsSection) ipsSection.style.display = isSA ? '' : 'none';
|
||||
const sslBtn = document.getElementById('btn-provision-ssl');
|
||||
if (sslBtn) sslBtn.style.display = isSA ? '' : 'none';
|
||||
|
||||
// Moduuli-checkboxit (yhteensopivuus: vanha 'devices' → 'tekniikka')
|
||||
let enabledMods = comp?.enabled_modules || [];
|
||||
@@ -3203,6 +3205,30 @@ document.getElementById('btn-save-company-settings').addEventListener('click', a
|
||||
} catch (e) { alert(e.message); }
|
||||
});
|
||||
|
||||
// SSL-sertifikaatin provisiointi (superadmin)
|
||||
document.getElementById('btn-provision-ssl')?.addEventListener('click', async () => {
|
||||
const domains = document.getElementById('company-edit-domains').value.trim().split('\n').map(d => d.trim()).filter(Boolean);
|
||||
if (!domains.length) { alert('Lisää ensin domainit!'); return; }
|
||||
if (!confirm('Päivitetäänkö Apache-config ja Let\'s Encrypt -sertifikaatti seuraavilla domaineilla?\n\n' + domains.join('\n'))) return;
|
||||
const btn = document.getElementById('btn-provision-ssl');
|
||||
const status = document.getElementById('ssl-provision-status');
|
||||
btn.disabled = true;
|
||||
btn.textContent = '⏳ Provisioidaan...';
|
||||
status.style.display = 'block';
|
||||
status.textContent = 'Päivitetään Apache-config ja Let\'s Encrypt...';
|
||||
try {
|
||||
const result = await apiCall('provision_ssl', 'POST', { domains });
|
||||
status.style.color = '#27ae60';
|
||||
status.textContent = '✅ ' + (result.message || 'SSL-sertifikaatti päivitetty!');
|
||||
} catch (e) {
|
||||
status.style.color = '#e74c3c';
|
||||
status.textContent = '❌ ' + e.message;
|
||||
} finally {
|
||||
btn.disabled = false;
|
||||
btn.textContent = '🔒 Päivitä SSL-sertifikaatti';
|
||||
}
|
||||
});
|
||||
|
||||
// ==================== POSTILAATIKOT ====================
|
||||
|
||||
let mailboxesData = [];
|
||||
|
||||
Reference in New Issue
Block a user