up js
This commit is contained in:
parent
8bccc63dc8
commit
3f0ea1c184
@ -4,44 +4,44 @@ async function validatePath() {
|
|||||||
const pathInput = document.getElementById('path-input');
|
const pathInput = document.getElementById('path-input');
|
||||||
const statusIcon = document.getElementById('path-status-icon');
|
const statusIcon = document.getElementById('path-status-icon');
|
||||||
const validateBtn = document.getElementById('validate-btn');
|
const validateBtn = document.getElementById('validate-btn');
|
||||||
const inputPathNameHidden = document.getElementById('pathName');
|
const pathNameHidden = document.getElementById('pathName');
|
||||||
const inputNamePathSection = document.getElementById('namePath');
|
const path = pathInput.value.trim();
|
||||||
|
|
||||||
const pathName = pathInput.value.trim();
|
|
||||||
|
|
||||||
if (!pathName) {
|
if (!path) {
|
||||||
statusIcon.innerHTML = '<i class="fas fa-times has-text-danger"></i>';
|
statusIcon.innerHTML = '<i class="fas fa-times has-text-danger"></i>';
|
||||||
validateBtn.disabled = true;
|
validateBtn.disabled = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
statusIcon.innerHTML = '<i class="fas fa-circle-notch fa-spin"></i>'; // Loading icon
|
// On assigne directement la valeur dans le champ hidden pour HTMX
|
||||||
|
pathNameHidden.value = path;
|
||||||
|
|
||||||
|
statusIcon.innerHTML = '<i class="fas fa-circle-notch fa-spin"></i>'; // Loading spinner
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/validate-path', {
|
const response = await fetch('/validate-path', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ pathName: pathName }), // ⚠️ on envoie pathName !
|
body: JSON.stringify({ path }),
|
||||||
});
|
});
|
||||||
|
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
statusIcon.innerHTML = '<i class="fas fa-check-square"></i>';
|
statusIcon.innerHTML = '<i class="fas fa-check-square has-text-success"></i>';
|
||||||
validateBtn.disabled = false;
|
validateBtn.disabled = false;
|
||||||
inputPathNameHidden.value = pathName; // on stocke le PathName dans le hidden pour le form
|
|
||||||
inputNamePathSection.style.display = "block";
|
|
||||||
} else {
|
} else {
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle"></i>';
|
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle has-text-danger"></i>';
|
||||||
validateBtn.disabled = true;
|
validateBtn.disabled = true;
|
||||||
console.error('Error:', result.error);
|
console.error('Error:', result.error);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle"></i>';
|
statusIcon.innerHTML = '<i class="fas fa-exclamation-triangle has-text-danger"></i>';
|
||||||
validateBtn.disabled = true;
|
validateBtn.disabled = true;
|
||||||
console.error('Request failed:', error);
|
console.error('Request failed:', error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function disableAllInputPath(id){
|
function disableAllInputPath(id){
|
||||||
console.log(this)
|
console.log(this)
|
||||||
var inputs = document.querySelectorAll('#path-'+id+' .fff');
|
var inputs = document.querySelectorAll('#path-'+id+' .fff');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user