|
|
|
@ -99,6 +99,9 @@ function initScript() {
|
|
|
|
// Charger les applications
|
|
|
|
// Charger les applications
|
|
|
|
loadAvailableApps();
|
|
|
|
loadAvailableApps();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Charger les credentials sauvegardés
|
|
|
|
|
|
|
|
loadSavedCredentials();
|
|
|
|
|
|
|
|
|
|
|
|
// Attacher les event listeners au bouton
|
|
|
|
// Attacher les event listeners au bouton
|
|
|
|
const pushBtn = document.getElementById('push-btn');
|
|
|
|
const pushBtn = document.getElementById('push-btn');
|
|
|
|
if (pushBtn) {
|
|
|
|
if (pushBtn) {
|
|
|
|
@ -111,6 +114,85 @@ function initScript() {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
console.warn("Push button not found");
|
|
|
|
console.warn("Push button not found");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Attacher l'event listener pour sauvegarder les credentials
|
|
|
|
|
|
|
|
const saveCheckbox = document.getElementById('save-credentials');
|
|
|
|
|
|
|
|
if (saveCheckbox) {
|
|
|
|
|
|
|
|
saveCheckbox.addEventListener('change', function() {
|
|
|
|
|
|
|
|
if (this.checked) {
|
|
|
|
|
|
|
|
saveCredentials();
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
clearSavedCredentials();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function loadSavedCredentials() {
|
|
|
|
|
|
|
|
console.log("Loading saved credentials...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const savedUrl = localStorage.getItem('git_pusher_url');
|
|
|
|
|
|
|
|
const savedToken = localStorage.getItem('git_pusher_token');
|
|
|
|
|
|
|
|
const savedBranch = localStorage.getItem('git_pusher_branch');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (savedUrl) {
|
|
|
|
|
|
|
|
document.getElementById('git-url').value = savedUrl;
|
|
|
|
|
|
|
|
console.log("Loaded saved URL");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (savedToken) {
|
|
|
|
|
|
|
|
document.getElementById('git-token').value = savedToken;
|
|
|
|
|
|
|
|
console.log("Loaded saved token");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (savedBranch) {
|
|
|
|
|
|
|
|
document.getElementById('git-branch').value = savedBranch;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (savedUrl && savedToken) {
|
|
|
|
|
|
|
|
document.getElementById('save-credentials').checked = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.warn("Could not load saved credentials:", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function saveCredentials() {
|
|
|
|
|
|
|
|
console.log("Saving credentials...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
const gitUrl = document.getElementById('git-url').value;
|
|
|
|
|
|
|
|
const gitToken = document.getElementById('git-token').value;
|
|
|
|
|
|
|
|
const gitBranch = document.getElementById('git-branch').value;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (gitUrl && gitToken) {
|
|
|
|
|
|
|
|
localStorage.setItem('git_pusher_url', gitUrl);
|
|
|
|
|
|
|
|
localStorage.setItem('git_pusher_token', gitToken);
|
|
|
|
|
|
|
|
localStorage.setItem('git_pusher_branch', gitBranch);
|
|
|
|
|
|
|
|
console.log("Credentials saved successfully");
|
|
|
|
|
|
|
|
showSuccess("Credentials saved locally");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
showError("Please fill in URL and Token before saving");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.error("Error saving credentials:", e);
|
|
|
|
|
|
|
|
showError("Could not save credentials");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function clearSavedCredentials() {
|
|
|
|
|
|
|
|
console.log("Clearing saved credentials...");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
localStorage.removeItem('git_pusher_url');
|
|
|
|
|
|
|
|
localStorage.removeItem('git_pusher_token');
|
|
|
|
|
|
|
|
localStorage.removeItem('git_pusher_branch');
|
|
|
|
|
|
|
|
console.log("Credentials cleared");
|
|
|
|
|
|
|
|
showSuccess("Credentials cleared");
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.error("Error clearing credentials:", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (document.readyState === 'loading') {
|
|
|
|
if (document.readyState === 'loading') {
|
|
|
|
@ -303,6 +385,18 @@ function pushDashboards() {
|
|
|
|
document.getElementById('error-msg').style.display = 'none';
|
|
|
|
document.getElementById('error-msg').style.display = 'none';
|
|
|
|
document.getElementById('push-btn').disabled = true;
|
|
|
|
document.getElementById('push-btn').disabled = true;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Sauvegarder les credentials si la case est cochée
|
|
|
|
|
|
|
|
if (document.getElementById('save-credentials').checked) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
localStorage.setItem('git_pusher_url', gitUrl);
|
|
|
|
|
|
|
|
localStorage.setItem('git_pusher_token', gitToken);
|
|
|
|
|
|
|
|
localStorage.setItem('git_pusher_branch', gitBranch);
|
|
|
|
|
|
|
|
console.log("Credentials auto-saved");
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
|
|
|
console.warn("Could not auto-save credentials:", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Préparer les données - passer les apps au lieu des dashboards
|
|
|
|
// Préparer les données - passer les apps au lieu des dashboards
|
|
|
|
const payload = {
|
|
|
|
const payload = {
|
|
|
|
git_url: gitUrl,
|
|
|
|
git_url: gitUrl,
|
|
|
|
@ -403,4 +497,13 @@ function resetForm() {
|
|
|
|
document.getElementById('git-token').value = '';
|
|
|
|
document.getElementById('git-token').value = '';
|
|
|
|
document.getElementById('commit-message').value = '';
|
|
|
|
document.getElementById('commit-message').value = '';
|
|
|
|
document.querySelectorAll('#dashboard-list input[type="checkbox"]').forEach(cb => cb.checked = false);
|
|
|
|
document.querySelectorAll('#dashboard-list input[type="checkbox"]').forEach(cb => cb.checked = false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Demander si l'utilisateur veut aussi effacer les credentials sauvegardés
|
|
|
|
|
|
|
|
if (document.getElementById('save-credentials').checked) {
|
|
|
|
|
|
|
|
const confirmClear = confirm('Do you want to clear saved credentials?');
|
|
|
|
|
|
|
|
if (confirmClear) {
|
|
|
|
|
|
|
|
clearSavedCredentials();
|
|
|
|
|
|
|
|
document.getElementById('save-credentials').checked = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|