improved launch process using cloudflare

This commit is contained in:
2025-06-20 19:34:37 +02:00
parent bb139a2b95
commit e85d91d1f4
9 changed files with 878 additions and 69 deletions

View File

@@ -435,6 +435,100 @@ async function saveGitConnection(event, provider) {
saveModal.show();
}
// Test Cloudflare Connection
async function testCloudflareConnection() {
const saveModal = new bootstrap.Modal(document.getElementById('saveConnectionModal'));
const messageElement = document.getElementById('saveConnectionMessage');
messageElement.textContent = 'Testing connection...';
messageElement.className = '';
saveModal.show();
try {
const email = document.getElementById('cloudflareEmail').value;
const apiKey = document.getElementById('cloudflareApiKey').value;
const zoneId = document.getElementById('cloudflareZone').value;
const serverIp = document.getElementById('cloudflareServerIp').value;
if (!email || !apiKey || !zoneId || !serverIp) {
throw new Error('Please fill in all required fields');
}
const data = {
email: email,
api_key: apiKey,
zone_id: zoneId,
server_ip: serverIp
};
const response = await fetch('/settings/test-cloudflare-connection', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
},
body: JSON.stringify(data)
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Connection test failed');
}
messageElement.textContent = 'Connection test successful!';
messageElement.className = 'text-success';
} catch (error) {
messageElement.textContent = error.message || 'Connection test failed';
messageElement.className = 'text-danger';
}
}
// Save Cloudflare Connection
async function saveCloudflareConnection(event) {
event.preventDefault();
const saveModal = new bootstrap.Modal(document.getElementById('saveConnectionModal'));
const messageElement = document.getElementById('saveConnectionMessage');
messageElement.textContent = '';
messageElement.className = '';
try {
const email = document.getElementById('cloudflareEmail').value;
const apiKey = document.getElementById('cloudflareApiKey').value;
const zoneId = document.getElementById('cloudflareZone').value;
const serverIp = document.getElementById('cloudflareServerIp').value;
if (!email || !apiKey || !zoneId || !serverIp) {
throw new Error('Please fill in all required fields');
}
const response = await fetch('/settings/save-cloudflare-connection', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': getCsrfToken()
},
body: JSON.stringify({
email: email,
api_key: apiKey,
zone_id: zoneId,
server_ip: serverIp
})
});
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Failed to save settings');
}
messageElement.textContent = 'Settings saved successfully!';
messageElement.className = 'text-success';
} catch (error) {
messageElement.textContent = error.message || 'Failed to save settings';
messageElement.className = 'text-danger';
}
saveModal.show();
}
// Initialize on page load
document.addEventListener('DOMContentLoaded', function() {
const gitSettings = JSON.parse(document.querySelector('meta[name="git-settings"]').getAttribute('content'));