|
|
|
|
@ -1,18 +1,29 @@
|
|
|
|
|
// ============================================
|
|
|
|
|
// GIT PUSHER - MAIN JAVASCRIPT
|
|
|
|
|
// Version 2.0 avec système de licence par fichier
|
|
|
|
|
// Version 2.1 avec déploiement vers SH Cluster
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
|
|
// Configuration
|
|
|
|
|
const GIT_PUSHER_CONFIG = {
|
|
|
|
|
// Détecter automatiquement l'URL du serveur
|
|
|
|
|
serverUrl: window.location.protocol + '//' + window.location.hostname + ':9999',
|
|
|
|
|
credentialsKey: 'git_pusher_credentials',
|
|
|
|
|
version: '2.0.0'
|
|
|
|
|
deployerConfigKey: 'git_pusher_deployer_config',
|
|
|
|
|
version: '2.1.0'
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Configuration SH Deployer (peut être modifiée via l'interface)
|
|
|
|
|
let SH_DEPLOYER_CONFIG = {
|
|
|
|
|
enabled: false,
|
|
|
|
|
host: '10.10.40.14',
|
|
|
|
|
port: 9998,
|
|
|
|
|
token: ''
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// État global
|
|
|
|
|
let selectedApps = [];
|
|
|
|
|
let isProcessing = false;
|
|
|
|
|
let deployerAvailable = false;
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
// INITIALISATION
|
|
|
|
|
@ -25,7 +36,7 @@ require([
|
|
|
|
|
'splunkjs/mvc/simplexml/ready!'
|
|
|
|
|
], function($, mvc, SearchManager) {
|
|
|
|
|
|
|
|
|
|
console.log("Git Pusher v2.0 initializing...");
|
|
|
|
|
console.log("Git Pusher v2.1 initializing...");
|
|
|
|
|
|
|
|
|
|
// Initialiser le système de licence
|
|
|
|
|
if (typeof initializeLicense === 'function') {
|
|
|
|
|
@ -37,6 +48,12 @@ require([
|
|
|
|
|
// Charger les credentials sauvegardés
|
|
|
|
|
loadSavedCredentials();
|
|
|
|
|
|
|
|
|
|
// Charger la config du deployer
|
|
|
|
|
loadDeployerConfig();
|
|
|
|
|
|
|
|
|
|
// Vérifier la disponibilité du SH Deployer
|
|
|
|
|
checkDeployerHealth();
|
|
|
|
|
|
|
|
|
|
// Récupérer les résultats de recherche pour les apps
|
|
|
|
|
const searchManager = mvc.Components.get('dsearch');
|
|
|
|
|
|
|
|
|
|
@ -59,23 +76,6 @@ require([
|
|
|
|
|
window.toggleSelectAll = toggleSelectAll;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Attacher l'événement au bouton après chargement du DOM
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
setTimeout(function() {
|
|
|
|
|
var pushBtn = document.getElementById('push-btn');
|
|
|
|
|
if (pushBtn) {
|
|
|
|
|
pushBtn.onclick = function() {
|
|
|
|
|
if (typeof pushDashboards === 'function') {
|
|
|
|
|
pushDashboards();
|
|
|
|
|
} else if (typeof window.pushDashboards === 'function') {
|
|
|
|
|
window.pushDashboards();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
console.log("Push button event attached");
|
|
|
|
|
}
|
|
|
|
|
}, 2000); // Attendre 2 secondes que tout soit chargé
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
// RENDU DE LA LISTE DES APPLICATIONS
|
|
|
|
|
// ============================================
|
|
|
|
|
@ -84,16 +84,11 @@ function renderAppsList(rows, fields) {
|
|
|
|
|
const container = document.getElementById('dashboard-list');
|
|
|
|
|
if (!container) return;
|
|
|
|
|
|
|
|
|
|
console.log("Fields:", fields);
|
|
|
|
|
console.log("First row:", rows[0]);
|
|
|
|
|
|
|
|
|
|
// Trouver les index des colonnes
|
|
|
|
|
const nameIdx = fields.indexOf('name');
|
|
|
|
|
const labelIdx = fields.indexOf('label');
|
|
|
|
|
const descIdx = fields.indexOf('description');
|
|
|
|
|
|
|
|
|
|
console.log("Index - name:", nameIdx, "label:", labelIdx);
|
|
|
|
|
|
|
|
|
|
// Générer le HTML
|
|
|
|
|
let html = `
|
|
|
|
|
<div class="app-header">
|
|
|
|
|
@ -105,34 +100,16 @@ function renderAppsList(rows, fields) {
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
let validApps = 0;
|
|
|
|
|
|
|
|
|
|
rows.forEach((row, index) => {
|
|
|
|
|
// Récupérer le nom - essayer plusieurs méthodes
|
|
|
|
|
let name = '';
|
|
|
|
|
if (nameIdx >= 0 && row[nameIdx]) {
|
|
|
|
|
name = row[nameIdx];
|
|
|
|
|
} else if (labelIdx >= 0 && row[labelIdx]) {
|
|
|
|
|
// Si name est null, utiliser label comme fallback temporaire
|
|
|
|
|
// On va chercher le vrai nom via l'API
|
|
|
|
|
name = row[labelIdx];
|
|
|
|
|
} else if (row[0]) {
|
|
|
|
|
name = row[0];
|
|
|
|
|
} else if (row[1]) {
|
|
|
|
|
name = row[1]; // Deuxième élément si premier est null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const label = (labelIdx >= 0 && row[labelIdx]) ? row[labelIdx] : name;
|
|
|
|
|
|
|
|
|
|
console.log(`Row ${index}: name="${name}", label="${label}"`);
|
|
|
|
|
const name = row[nameIdx] || '';
|
|
|
|
|
const label = row[labelIdx] || name;
|
|
|
|
|
const desc = row[descIdx] || '';
|
|
|
|
|
|
|
|
|
|
// Ignorer si pas de nom ou apps système
|
|
|
|
|
if (!name || name.startsWith('splunk_') || name === 'learned' || name === 'launcher') {
|
|
|
|
|
// Ignorer certaines apps système
|
|
|
|
|
if (name.startsWith('splunk_') || name === 'learned' || name === 'launcher') {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
validApps++;
|
|
|
|
|
|
|
|
|
|
html += `
|
|
|
|
|
<div class="app-item">
|
|
|
|
|
<input type="checkbox"
|
|
|
|
|
@ -142,7 +119,7 @@ function renderAppsList(rows, fields) {
|
|
|
|
|
onchange="updateSelectedApps()" />
|
|
|
|
|
<label for="app-${index}">
|
|
|
|
|
<span class="app-badge">${name}</span>
|
|
|
|
|
${label !== name ? ' - ' + label : ''}
|
|
|
|
|
${label !== name ? label : ''}
|
|
|
|
|
</label>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
@ -150,7 +127,7 @@ function renderAppsList(rows, fields) {
|
|
|
|
|
|
|
|
|
|
container.innerHTML = html;
|
|
|
|
|
|
|
|
|
|
console.log(`Rendered ${validApps} valid applications out of ${rows.length}`);
|
|
|
|
|
console.log(`Rendered ${rows.length} applications`);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
@ -203,27 +180,6 @@ async function pushDashboards() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Récupérer les apps sélectionnées directement depuis le DOM
|
|
|
|
|
var apps = [];
|
|
|
|
|
var checkboxes = document.querySelectorAll('#dashboard-list input[type="checkbox"][data-app-id]:checked');
|
|
|
|
|
checkboxes.forEach(function(cb) {
|
|
|
|
|
apps.push({
|
|
|
|
|
id: cb.getAttribute('data-app-id'),
|
|
|
|
|
label: cb.getAttribute('data-app-label') || cb.getAttribute('data-app-id')
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log("Apps selected from DOM:", apps);
|
|
|
|
|
|
|
|
|
|
// Mettre à jour selectedApps
|
|
|
|
|
selectedApps = apps;
|
|
|
|
|
|
|
|
|
|
// Vérifier si déjà en cours
|
|
|
|
|
if (isProcessing) {
|
|
|
|
|
console.log("Push already in progress");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Vérifier la licence AVANT tout
|
|
|
|
|
if (typeof checkLicenseBeforePush === 'function') {
|
|
|
|
|
const licenseOk = await checkLicenseBeforePush();
|
|
|
|
|
@ -269,9 +225,14 @@ async function pushDashboards() {
|
|
|
|
|
saveCredentialsToStorage(gitUrl, gitBranch, gitToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Vérifier si le déploiement vers SH Cluster est activé
|
|
|
|
|
const deployToSHCluster = document.getElementById('deploy-to-shcluster')?.checked || false;
|
|
|
|
|
const shAuthUser = document.getElementById('sh-auth-user')?.value?.trim() || '';
|
|
|
|
|
const shAuthPass = document.getElementById('sh-auth-pass')?.value?.trim() || '';
|
|
|
|
|
|
|
|
|
|
// Démarrer le push
|
|
|
|
|
isProcessing = true;
|
|
|
|
|
showLoading(true);
|
|
|
|
|
showLoading(true, deployToSHCluster);
|
|
|
|
|
hideMessages();
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
@ -285,10 +246,17 @@ async function pushDashboards() {
|
|
|
|
|
git_token: gitToken,
|
|
|
|
|
commit_message: commitMessage,
|
|
|
|
|
apps: JSON.stringify(selectedApps),
|
|
|
|
|
user: currentUser
|
|
|
|
|
user: currentUser,
|
|
|
|
|
deploy_to_shcluster: deployToSHCluster.toString(),
|
|
|
|
|
deployer_host: SH_DEPLOYER_CONFIG.host,
|
|
|
|
|
deployer_token: SH_DEPLOYER_CONFIG.token
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log(`Pushing ${selectedApps.length} apps to ${gitUrl}`);
|
|
|
|
|
// Ajouter les credentials SH si fournis
|
|
|
|
|
if (shAuthUser) params.append('sh_auth_user', shAuthUser);
|
|
|
|
|
if (shAuthPass) params.append('sh_auth_pass', shAuthPass);
|
|
|
|
|
|
|
|
|
|
console.log(`Pushing ${selectedApps.length} apps to ${gitUrl}${deployToSHCluster ? ' + SH Cluster deployment' : ''}`);
|
|
|
|
|
|
|
|
|
|
// Appeler le serveur
|
|
|
|
|
const response = await fetch(`${GIT_PUSHER_CONFIG.serverUrl}/push?${params.toString()}`, {
|
|
|
|
|
@ -302,7 +270,18 @@ async function pushDashboards() {
|
|
|
|
|
console.log("Push result:", result);
|
|
|
|
|
|
|
|
|
|
if (result.status === 'success') {
|
|
|
|
|
showMessage('success', `✅ Successfully deployed ${result.apps_pushed || selectedApps.length} application(s) to Git!`);
|
|
|
|
|
let message = `✅ Successfully deployed ${result.apps_pushed || selectedApps.length} application(s) to Git!`;
|
|
|
|
|
|
|
|
|
|
// Ajouter le statut du déploiement SH Cluster
|
|
|
|
|
if (deployToSHCluster && result.shcluster_deployment) {
|
|
|
|
|
if (result.shcluster_deployment.success) {
|
|
|
|
|
message += '\n🚀 SH Cluster deployment triggered successfully!';
|
|
|
|
|
} else {
|
|
|
|
|
message += `\n⚠️ SH Cluster deployment failed: ${result.shcluster_deployment.message}`;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
showMessage('success', message);
|
|
|
|
|
|
|
|
|
|
// Reset la sélection après succès
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
@ -334,17 +313,30 @@ async function pushDashboards() {
|
|
|
|
|
// UTILITAIRES UI
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
|
|
function showLoading(show) {
|
|
|
|
|
function showLoading(show, deployToSHCluster = false) {
|
|
|
|
|
const loading = document.getElementById('loading');
|
|
|
|
|
const pushBtn = document.getElementById('push-btn');
|
|
|
|
|
const loadingText = document.querySelector('.loading-text');
|
|
|
|
|
|
|
|
|
|
if (loading) {
|
|
|
|
|
loading.classList.toggle('active', show);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (loadingText && show) {
|
|
|
|
|
if (deployToSHCluster) {
|
|
|
|
|
loadingText.textContent = 'Deploying to Git and SH Cluster... Please wait';
|
|
|
|
|
} else {
|
|
|
|
|
loadingText.textContent = 'Deploying applications to Git... Please wait';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (pushBtn) {
|
|
|
|
|
pushBtn.disabled = show;
|
|
|
|
|
pushBtn.textContent = show ? '⏳ Deploying...' : '✈️ Deploy to Git';
|
|
|
|
|
if (show) {
|
|
|
|
|
pushBtn.textContent = deployToSHCluster ? '⏳ Deploying to Git + SH...' : '⏳ Deploying...';
|
|
|
|
|
} else {
|
|
|
|
|
pushBtn.textContent = '✈️ Deploy to Git';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -493,6 +485,190 @@ async function checkServerHealth() {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
// SH DEPLOYER FUNCTIONS
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
|
|
async function checkDeployerHealth() {
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(`${GIT_PUSHER_CONFIG.serverUrl}/deployer/health`, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
timeout: 5000
|
|
|
|
|
});
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
|
|
|
|
|
deployerAvailable = data.status === 'ok';
|
|
|
|
|
|
|
|
|
|
// Mettre à jour l'UI
|
|
|
|
|
updateDeployerUI();
|
|
|
|
|
|
|
|
|
|
console.log("SH Deployer status:", deployerAvailable ? "Available" : "Unavailable");
|
|
|
|
|
return deployerAvailable;
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Deployer health check failed:", error);
|
|
|
|
|
deployerAvailable = false;
|
|
|
|
|
updateDeployerUI();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateDeployerUI() {
|
|
|
|
|
const deployerCheckbox = document.getElementById('deploy-to-shcluster');
|
|
|
|
|
const deployerStatus = document.getElementById('deployer-status');
|
|
|
|
|
const deployerSection = document.getElementById('deployer-section');
|
|
|
|
|
|
|
|
|
|
if (deployerCheckbox) {
|
|
|
|
|
deployerCheckbox.disabled = !deployerAvailable;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (deployerStatus) {
|
|
|
|
|
if (deployerAvailable) {
|
|
|
|
|
deployerStatus.innerHTML = '<span style="color: #4CAF50;">● Connected</span>';
|
|
|
|
|
} else {
|
|
|
|
|
deployerStatus.innerHTML = '<span style="color: #f44336;">● Disconnected</span>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (deployerSection && !deployerAvailable) {
|
|
|
|
|
deployerSection.style.opacity = '0.6';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadDeployerConfig() {
|
|
|
|
|
try {
|
|
|
|
|
const saved = localStorage.getItem(GIT_PUSHER_CONFIG.deployerConfigKey);
|
|
|
|
|
if (saved) {
|
|
|
|
|
const config = JSON.parse(saved);
|
|
|
|
|
SH_DEPLOYER_CONFIG = { ...SH_DEPLOYER_CONFIG, ...config };
|
|
|
|
|
console.log("Deployer config loaded");
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error loading deployer config:", error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveDeployerConfig() {
|
|
|
|
|
try {
|
|
|
|
|
localStorage.setItem(GIT_PUSHER_CONFIG.deployerConfigKey, JSON.stringify(SH_DEPLOYER_CONFIG));
|
|
|
|
|
console.log("Deployer config saved");
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error saving deployer config:", error);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function showDeployerConfigModal() {
|
|
|
|
|
const modal = document.createElement('div');
|
|
|
|
|
modal.id = 'deployer-config-modal';
|
|
|
|
|
modal.style.cssText = `
|
|
|
|
|
position: fixed;
|
|
|
|
|
top: 0;
|
|
|
|
|
left: 0;
|
|
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
|
|
|
|
background: rgba(0, 0, 0, 0.7);
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: center;
|
|
|
|
|
z-index: 10000;
|
|
|
|
|
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
modal.innerHTML = `
|
|
|
|
|
<div style="background: white; border-radius: 16px; padding: 30px; max-width: 500px; width: 90%; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);">
|
|
|
|
|
<h2 style="margin: 0 0 20px 0; color: #333;">⚙️ SH Deployer Configuration</h2>
|
|
|
|
|
|
|
|
|
|
<div style="margin-bottom: 15px;">
|
|
|
|
|
<label style="display: block; font-weight: 600; margin-bottom: 5px;">Deployer Host</label>
|
|
|
|
|
<input type="text" id="deployer-config-host" value="${SH_DEPLOYER_CONFIG.host}"
|
|
|
|
|
style="width: 100%; padding: 10px; border: 2px solid #e0e0e0; border-radius: 6px; box-sizing: border-box;">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style="margin-bottom: 15px;">
|
|
|
|
|
<label style="display: block; font-weight: 600; margin-bottom: 5px;">Port</label>
|
|
|
|
|
<input type="number" id="deployer-config-port" value="${SH_DEPLOYER_CONFIG.port}"
|
|
|
|
|
style="width: 100%; padding: 10px; border: 2px solid #e0e0e0; border-radius: 6px; box-sizing: border-box;">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style="margin-bottom: 20px;">
|
|
|
|
|
<label style="display: block; font-weight: 600; margin-bottom: 5px;">Auth Token</label>
|
|
|
|
|
<input type="password" id="deployer-config-token" value="${SH_DEPLOYER_CONFIG.token}"
|
|
|
|
|
placeholder="Deployer agent token"
|
|
|
|
|
style="width: 100%; padding: 10px; border: 2px solid #e0e0e0; border-radius: 6px; box-sizing: border-box;">
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div style="display: flex; gap: 10px;">
|
|
|
|
|
<button onclick="saveDeployerConfigFromModal()" style="
|
|
|
|
|
flex: 1; padding: 12px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
|
|
|
color: white; border: none; border-radius: 8px; font-weight: 600; cursor: pointer;
|
|
|
|
|
">Save & Test</button>
|
|
|
|
|
<button onclick="closeDeployerConfigModal()" style="
|
|
|
|
|
flex: 1; padding: 12px; background: #f5f5f5; color: #333;
|
|
|
|
|
border: none; border-radius: 8px; font-weight: 600; cursor: pointer;
|
|
|
|
|
">Cancel</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div id="deployer-config-message" style="margin-top: 15px; display: none; padding: 10px; border-radius: 6px;"></div>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
document.body.appendChild(modal);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeDeployerConfigModal() {
|
|
|
|
|
const modal = document.getElementById('deployer-config-modal');
|
|
|
|
|
if (modal) modal.remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function saveDeployerConfigFromModal() {
|
|
|
|
|
const host = document.getElementById('deployer-config-host')?.value?.trim();
|
|
|
|
|
const port = parseInt(document.getElementById('deployer-config-port')?.value) || 9998;
|
|
|
|
|
const token = document.getElementById('deployer-config-token')?.value?.trim();
|
|
|
|
|
const msgEl = document.getElementById('deployer-config-message');
|
|
|
|
|
|
|
|
|
|
if (!host) {
|
|
|
|
|
if (msgEl) {
|
|
|
|
|
msgEl.style.display = 'block';
|
|
|
|
|
msgEl.style.background = '#ffebee';
|
|
|
|
|
msgEl.style.color = '#c62828';
|
|
|
|
|
msgEl.textContent = 'Please enter a host';
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Mettre à jour la config
|
|
|
|
|
SH_DEPLOYER_CONFIG.host = host;
|
|
|
|
|
SH_DEPLOYER_CONFIG.port = port;
|
|
|
|
|
SH_DEPLOYER_CONFIG.token = token;
|
|
|
|
|
|
|
|
|
|
// Sauvegarder
|
|
|
|
|
saveDeployerConfig();
|
|
|
|
|
|
|
|
|
|
// Tester la connexion
|
|
|
|
|
if (msgEl) {
|
|
|
|
|
msgEl.style.display = 'block';
|
|
|
|
|
msgEl.style.background = '#e3f2fd';
|
|
|
|
|
msgEl.style.color = '#1565c0';
|
|
|
|
|
msgEl.textContent = 'Testing connection...';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const isHealthy = await checkDeployerHealth();
|
|
|
|
|
|
|
|
|
|
if (isHealthy) {
|
|
|
|
|
if (msgEl) {
|
|
|
|
|
msgEl.style.background = '#e8f5e9';
|
|
|
|
|
msgEl.style.color = '#2e7d32';
|
|
|
|
|
msgEl.textContent = '✓ Connected successfully!';
|
|
|
|
|
}
|
|
|
|
|
setTimeout(closeDeployerConfigModal, 1500);
|
|
|
|
|
} else {
|
|
|
|
|
if (msgEl) {
|
|
|
|
|
msgEl.style.background = '#ffebee';
|
|
|
|
|
msgEl.style.color = '#c62828';
|
|
|
|
|
msgEl.textContent = '✗ Connection failed. Check host and port.';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Vérifier la santé du serveur au démarrage
|
|
|
|
|
setTimeout(async () => {
|
|
|
|
|
const healthy = await checkServerHealth();
|
|
|
|
|
@ -503,12 +679,31 @@ setTimeout(async () => {
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
// EXPORT FONCTIONS GLOBALES
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
|
|
// Exposer les fonctions du deployer globalement pour les onclick du HTML
|
|
|
|
|
window.showDeployerConfigModal = showDeployerConfigModal;
|
|
|
|
|
window.closeDeployerConfigModal = closeDeployerConfigModal;
|
|
|
|
|
window.saveDeployerConfigFromModal = saveDeployerConfigFromModal;
|
|
|
|
|
|
|
|
|
|
// Fonction toggle pour le HTML
|
|
|
|
|
window.toggleDeployerAuth = function() {
|
|
|
|
|
var checkbox = document.getElementById('deploy-to-shcluster');
|
|
|
|
|
var authSection = document.getElementById('deployer-auth');
|
|
|
|
|
if (checkbox && authSection) {
|
|
|
|
|
authSection.classList.toggle('visible', checkbox.checked);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// ============================================
|
|
|
|
|
// EXPORT POUR DEBUG
|
|
|
|
|
// ============================================
|
|
|
|
|
|
|
|
|
|
window.GitPusher = {
|
|
|
|
|
config: GIT_PUSHER_CONFIG,
|
|
|
|
|
deployerConfig: SH_DEPLOYER_CONFIG,
|
|
|
|
|
getSelectedApps: () => selectedApps,
|
|
|
|
|
checkServer: checkServerHealth,
|
|
|
|
|
version: GIT_PUSHER_CONFIG.version
|
|
|
|
|
@ -530,29 +725,44 @@ window.GitPusher = {
|
|
|
|
|
console.log("✓ Push button event attached");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Bouton Reset - chercher par le texte ou la classe
|
|
|
|
|
var resetBtn = document.querySelector('button.btn-secondary');
|
|
|
|
|
if (!resetBtn) {
|
|
|
|
|
// Chercher par le contenu
|
|
|
|
|
var allButtons = document.querySelectorAll('button.btn');
|
|
|
|
|
allButtons.forEach(function(btn) {
|
|
|
|
|
if (btn.textContent.includes('Reset') || btn.textContent.includes('🔄')) {
|
|
|
|
|
resetBtn = btn;
|
|
|
|
|
}
|
|
|
|
|
// Bouton Reset
|
|
|
|
|
var buttons = document.querySelectorAll('button.btn');
|
|
|
|
|
buttons.forEach(function(btn) {
|
|
|
|
|
if (btn.textContent.includes('Reset') || btn.textContent.includes('🔄')) {
|
|
|
|
|
btn.addEventListener('click', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
console.log("Reset button clicked");
|
|
|
|
|
resetForm(true);
|
|
|
|
|
});
|
|
|
|
|
console.log("✓ Reset button event attached");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Bouton Configure Deployer
|
|
|
|
|
var configBtn = document.querySelector('.deployer-config-btn');
|
|
|
|
|
if (configBtn) {
|
|
|
|
|
configBtn.addEventListener('click', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
console.log("Configure button clicked");
|
|
|
|
|
showDeployerConfigModal();
|
|
|
|
|
});
|
|
|
|
|
console.log("✓ Configure button event attached");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (resetBtn) {
|
|
|
|
|
resetBtn.addEventListener('click', function(e) {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
console.log("Reset button clicked");
|
|
|
|
|
resetForm(true);
|
|
|
|
|
// Checkbox deploy to shcluster
|
|
|
|
|
var deployCheckbox = document.getElementById('deploy-to-shcluster');
|
|
|
|
|
if (deployCheckbox) {
|
|
|
|
|
deployCheckbox.addEventListener('change', function() {
|
|
|
|
|
var authSection = document.getElementById('deployer-auth');
|
|
|
|
|
if (authSection) {
|
|
|
|
|
authSection.classList.toggle('visible', this.checked);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
console.log("✓ Reset button event attached");
|
|
|
|
|
console.log("✓ Deploy checkbox event attached");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Si les boutons ne sont pas encore là, réessayer
|
|
|
|
|
if (!pushBtn || !resetBtn) {
|
|
|
|
|
if (!pushBtn) {
|
|
|
|
|
setTimeout(tryAttach, 500);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|