2025-06-06 07:42:55 +00:00
|
|
|
console.log("la");
|
|
|
|
|
console.log("la");
|
|
|
|
|
async function validatePath() {
|
|
|
|
|
const pathInput = document.getElementById('path-input');
|
|
|
|
|
const statusIcon = document.getElementById('path-status-icon');
|
|
|
|
|
const validateBtn = document.getElementById('validate-btn');
|
2025-06-19 14:37:39 +00:00
|
|
|
const inputPathNameHidden = document.getElementById('pathName');
|
|
|
|
|
const inputNamePathSection = document.getElementById('namePath');
|
|
|
|
|
|
|
|
|
|
const pathName = pathInput.value.trim();
|
2025-06-06 07:42:55 +00:00
|
|
|
|
2025-06-19 14:37:39 +00:00
|
|
|
if (!pathName) {
|
2025-06-06 07:42:55 +00:00
|
|
|
statusIcon.innerHTML = '<i class="fas fa-times has-text-danger"></i>';
|
|
|
|
|
validateBtn.disabled = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
statusIcon.innerHTML = '<i class="fas fa-circle-notch fa-spin"></i>'; // Loading icon
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch('/validate-path', {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
headers: { 'Content-Type': 'application/json' },
|
2025-06-19 14:37:39 +00:00
|
|
|
body: JSON.stringify({ pathName: pathName }), // ⚠️ on envoie pathName !
|
2025-06-06 07:42:55 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (response.ok) {
|
|
|
|
|
statusIcon.innerHTML = '<i class="fas fa-check-square"></i>';
|
|
|
|
|
validateBtn.disabled = false;
|
2025-06-19 14:37:39 +00:00
|
|
|
inputPathNameHidden.value = pathName; // on stocke le PathName dans le hidden pour le form
|
|
|
|
|
inputNamePathSection.style.display = "block";
|
2025-06-06 07:42:55 +00:00
|
|
|
} else {
|
|
|
|
|
const result = await response.json();
|
|
|
|
|
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle"></i>';
|
|
|
|
|
validateBtn.disabled = true;
|
|
|
|
|
console.error('Error:', result.error);
|
|
|
|
|
}
|
|
|
|
|
} catch (error) {
|
|
|
|
|
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle"></i>';
|
|
|
|
|
validateBtn.disabled = true;
|
|
|
|
|
console.error('Request failed:', error);
|
|
|
|
|
}
|
|
|
|
|
}
|
2025-06-19 14:37:39 +00:00
|
|
|
|
2025-06-06 07:42:55 +00:00
|
|
|
function disableAllInputPath(id){
|
|
|
|
|
console.log(this)
|
|
|
|
|
var inputs = document.querySelectorAll('#path-'+id+' .fff');
|
|
|
|
|
var btn =document.getElementById('btn-path-annuler-'+id)
|
|
|
|
|
btn.style.display = "none";
|
|
|
|
|
var btn2 =document.getElementById('btn-path-edit-'+id)
|
|
|
|
|
btn2.style.display = "block";
|
|
|
|
|
var btn3 =document.getElementById('btn-path-valider-'+id)
|
|
|
|
|
btn3.style.display = "none";
|
|
|
|
|
|
|
|
|
|
inputs.forEach(function(input) {
|
|
|
|
|
input.disabled = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function enableAllInputPath(id){
|
|
|
|
|
console.log(this)
|
|
|
|
|
var inputs = document.querySelectorAll('#path-'+id+' .fff');
|
|
|
|
|
var btn =document.getElementById('btn-path-annuler-'+id)
|
|
|
|
|
btn.style.display = "block";
|
|
|
|
|
var btn2 =document.getElementById('btn-path-edit-'+id)
|
|
|
|
|
btn2.style.display = "none";
|
|
|
|
|
var btn3 =document.getElementById('btn-path-valider-'+id)
|
|
|
|
|
btn3.style.display = "block";
|
|
|
|
|
inputs.forEach(function(input) {
|
|
|
|
|
input.disabled = false;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function setInputHidden(target,value){
|
|
|
|
|
document.getElementById(target).value = value;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
function hide(target){
|
|
|
|
|
var btn =document.getElementById(target)
|
|
|
|
|
btn.style.display = "none";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.addEventListener("htmx:afterOnLoad", function (event) {
|
2025-06-15 15:21:11 +00:00
|
|
|
// console.log("Réponse du serveur :", event.detail.xhr.responseText);
|
2025-06-06 07:42:55 +00:00
|
|
|
});
|
|
|
|
|
|