Urgent correction of version v1.0.0-beta.14 due to crash issues when acting on the CDN.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2024-07-12 18:13:03 +02:00
parent aaff0ed4ea
commit 44631acfc6
27 changed files with 704 additions and 534 deletions

View File

@@ -1,4 +1,4 @@
document.addEventListener('DOMContentLoaded', function () {
const copyButtons = document.querySelectorAll('.copy-button');
@@ -60,28 +60,6 @@
styleSwitcherButton.addEventListener('click', toggleDarkMode);
filterForm.addEventListener('submit', function (event) {
event.preventDefault();
const selectedExtension = extensionFilter.value.toLowerCase();
const searchQuery = fileSearchInput.value.toLowerCase();
const fileList = document.querySelectorAll('tr[data-extension]');
fileList.forEach(file => {
const fileExtension = file.getAttribute('data-extension').toLowerCase();
const fileName = file.querySelector('td:first-child').textContent.toLowerCase();
const extensionMatch = selectedExtension === '' || selectedExtension === fileExtension;
const searchMatch = fileName.includes(searchQuery);
if (extensionMatch && searchMatch) {
file.style.display = '';
} else {
file.style.display = 'none';
}
});
});
});
document.addEventListener('DOMContentLoaded', function () {
@@ -204,111 +182,6 @@
}
};
function performUpdate() {
fetch('/applyupdate')
.then(response => response.json())
.then(result => {
if (result.success) {
Swal.fire({
title: 'Mise à jour réussie',
text: 'Votre application a été mise à jour avec succès.',
icon: 'success',
toast: true,
position: 'bottom-right',
showConfirmButton: false,
timer: 5000
});
} else {
Swal.fire({
title: 'Mise à jour échouée',
text: 'Une erreur s\'est produite lors de la mise à jour de votre application.',
icon: 'error',
toast: true,
position: 'bottom-right',
showConfirmButton: false,
timer: 5000
});
}
})
.catch(error => {
console.error('Erreur lors de la mise à jour :', error);
Swal.fire({
text: 'Erreur lors de la mise à jour.',
icon: 'error',
toast: true,
position: 'bottom-right',
showConfirmButton: false,
timer: 5000
});
});
}
function checkUpdates() {
fetch('/checkupdate')
.then(response => response.json())
.then(result => {
if (result.updateAvailable) {
Swal.fire({
title: 'Nouvelle mise à jour disponible',
text: 'Voulez-vous mettre à jour votre application?',
icon: 'info',
showCancelButton: true,
confirmButtonText: 'Oui',
cancelButtonText: 'Non',
position: 'bottom-right',
toast: true,
}).then((result) => {
if (result.isConfirmed) {
performUpdate();
}
});
} else {
Swal.fire({
title: 'Application à jour',
text: 'Votre application est à jour.',
icon: 'success',
toast: true,
position: 'bottom-right',
showConfirmButton: false,
timer: 5000
});
}
})
.catch(error => {
console.error('Erreur lors de la vérification des mises à jour :', error);
Swal.fire({
text: 'Erreur lors de la vérification des mises à jour.',
icon: 'error',
toast: true,
position: 'bottom-right',
showConfirmButton: false,
timer: 5000
});
});
}
document.getElementById('checkUpdateButton').addEventListener('click', async function() {
const userName = await getLoggedInUserName();
fs.readFile('user.json', (err, data) => {
if (err) throw err;
let users = JSON.parse(data);
const user = users.find(user => user.name === userName);
if (user && user.role === 'admin') {
checkUpdates();
} else {
Swal.fire({
position: 'top',
icon: 'warning',
title: 'Vous n\'avez pas les droits pour effectuer cette action.',
showConfirmButton: false,
timer: 2600,
toast: true
});
}
});
});
var modal = document.getElementById('patchNoteModal');
@@ -386,7 +259,7 @@
function renameFile(folderName, currentName) {
const fileExtensionIndex = currentName.lastIndexOf('.');
const fileExtension = currentName.substring(fileExtensionIndex);
Swal.fire({
title: 'Entrez le nouveau nom',
input: 'text',
@@ -399,13 +272,13 @@
setTimeout(() => {
const input = Swal.getInput();
const pos = input.value.lastIndexOf('.');
input.setSelectionRange(0, pos);
input.setSelectionRange(0, pos);
}, 0);
}
}).then((result) => {
if (result.isConfirmed) {
const newName = result.value;
fetch(`/api/dpanel/dashboard/rename/${folderName}`, {
method: 'POST',
headers: {
@@ -617,3 +490,57 @@ function closeModal() {
const modal = document.getElementById('metadataModal');
modal.style.display = 'none';
}
function moveFile(folderName, fileName) {
Swal.fire({
title: 'Confirmer le déplacement du fichier',
text: `Voulez-vous déplacer le fichier ${fileName} vers ${folderName} ?`,
icon: 'warning',
showCancelButton: true,
confirmButtonText: 'Déplacer',
cancelButtonText: 'Annuler',
}).then((result) => {
if (result.isConfirmed) {
fetch('/api/dpanel/dashboard/movefile', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ fileName: fileName, folderName: folderName }),
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
if (data.message === "File moved successfully") {
Swal.fire({
position: 'top',
icon: 'success',
title: 'Le fichier a été déplacé avec succès.',
showConfirmButton: false,
timer: 1800,
toast: true,
}).then(() => {
location.reload();
});
} else {
throw new Error(data.error || 'Une erreur est survenue');
}
})
.catch((error) => {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Erreur lors du déplacement du fichier.',
showConfirmButton: false,
timer: 1800,
toast: true,
});
});
}
});
}