|
|
|
|
@ -132,22 +132,22 @@ 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');
|
|
|
|
|
const savedUrl = getCookie('git_pusher_url');
|
|
|
|
|
const savedToken = getCookie('git_pusher_token');
|
|
|
|
|
const savedBranch = getCookie('git_pusher_branch');
|
|
|
|
|
|
|
|
|
|
if (savedUrl) {
|
|
|
|
|
document.getElementById('git-url').value = savedUrl;
|
|
|
|
|
console.log("Loaded saved URL");
|
|
|
|
|
document.getElementById('git-url').value = decodeURIComponent(savedUrl);
|
|
|
|
|
console.log("Loaded saved URL from cookie");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (savedToken) {
|
|
|
|
|
document.getElementById('git-token').value = savedToken;
|
|
|
|
|
console.log("Loaded saved token");
|
|
|
|
|
document.getElementById('git-token').value = decodeURIComponent(savedToken);
|
|
|
|
|
console.log("Loaded saved token from cookie");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (savedBranch) {
|
|
|
|
|
document.getElementById('git-branch').value = savedBranch;
|
|
|
|
|
document.getElementById('git-branch').value = decodeURIComponent(savedBranch);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (savedUrl && savedToken) {
|
|
|
|
|
@ -167,10 +167,10 @@ function saveCredentials() {
|
|
|
|
|
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");
|
|
|
|
|
setCookie('git_pusher_url', gitUrl, 30);
|
|
|
|
|
setCookie('git_pusher_token', gitToken, 30);
|
|
|
|
|
setCookie('git_pusher_branch', gitBranch, 30);
|
|
|
|
|
console.log("Credentials saved to cookies");
|
|
|
|
|
showSuccess("Credentials saved locally");
|
|
|
|
|
} else {
|
|
|
|
|
showError("Please fill in URL and Token before saving");
|
|
|
|
|
@ -185,16 +185,42 @@ 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");
|
|
|
|
|
deleteCookie('git_pusher_url');
|
|
|
|
|
deleteCookie('git_pusher_token');
|
|
|
|
|
deleteCookie('git_pusher_branch');
|
|
|
|
|
console.log("Credentials cleared from cookies");
|
|
|
|
|
showSuccess("Credentials cleared");
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error("Error clearing credentials:", e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Fonctions utilitaires pour les cookies
|
|
|
|
|
function setCookie(name, value, days) {
|
|
|
|
|
const d = new Date();
|
|
|
|
|
d.setTime(d.getTime() + (days * 24 * 60 * 60 * 1000));
|
|
|
|
|
const expires = "expires=" + d.toUTCString();
|
|
|
|
|
document.cookie = name + "=" + encodeURIComponent(value) + ";" + expires + ";path=/";
|
|
|
|
|
console.log("Cookie set: " + name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getCookie(name) {
|
|
|
|
|
const nameEQ = name + "=";
|
|
|
|
|
const ca = document.cookie.split(';');
|
|
|
|
|
for (let i = 0; i < ca.length; i++) {
|
|
|
|
|
let c = ca[i].trim();
|
|
|
|
|
if (c.indexOf(nameEQ) === 0) {
|
|
|
|
|
return c.substring(nameEQ.length);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteCookie(name) {
|
|
|
|
|
setCookie(name, "", -1);
|
|
|
|
|
console.log("Cookie deleted: " + name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (document.readyState === 'loading') {
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
|
|
|
console.log("DOM Ready - Initializing script...");
|
|
|
|
|
@ -388,10 +414,10 @@ function pushDashboards() {
|
|
|
|
|
// 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");
|
|
|
|
|
setCookie('git_pusher_url', gitUrl, 30);
|
|
|
|
|
setCookie('git_pusher_token', gitToken, 30);
|
|
|
|
|
setCookie('git_pusher_branch', gitBranch, 30);
|
|
|
|
|
console.log("Credentials auto-saved to cookies");
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.warn("Could not auto-save credentials:", e);
|
|
|
|
|
}
|
|
|
|
|
|