Note: We appreciate your feedback and bug reports to continue improving our platform. Thank you for your continued support!
This commit is contained in:
@@ -1,210 +1,227 @@
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const copyButtons = document.querySelectorAll('.copy-button');
|
||||
|
||||
copyButtons.forEach(copyButton => {
|
||||
copyButton.addEventListener("click", () => {
|
||||
const fileContainer = copyButton.closest('tr');
|
||||
const fileLink = fileContainer.querySelector('.file-link');
|
||||
fileLink.style.display = "block";
|
||||
fileLink.select();
|
||||
document.execCommand("copy");
|
||||
fileLink.style.display = "none";
|
||||
copyButton.textContent = "Lien copié !";
|
||||
setTimeout(() => {
|
||||
copyButton.textContent = "Copier le lien";
|
||||
}, 2000);
|
||||
});
|
||||
});
|
||||
|
||||
const filterForm = document.getElementById('filterForm');
|
||||
const extensionFilter = document.getElementById('extensionFilter');
|
||||
const fileSearchInput = document.getElementById('fileSearch');
|
||||
const styleSwitcherButton = document.getElementById('styleSwitcher');
|
||||
const icon = document.getElementById('themeIcon');
|
||||
|
||||
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
let isDarkMode = darkModeMediaQuery.matches;
|
||||
|
||||
function toggleDarkMode() {
|
||||
isDarkMode = !isDarkMode;
|
||||
document.body.classList.toggle('dark-mode', isDarkMode);
|
||||
|
||||
if (isDarkMode) {
|
||||
icon.classList.remove('bi-brightness-high-fill');
|
||||
icon.classList.add('bi-moon-fill');
|
||||
icon.innerHTML = '</svg><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-brightness-high-fill" viewBox="0 0 16 16"><path d="M12 8a4 4 0 1 1-8 0 4 4 0 0 1 8 0M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0m9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708"/></svg>';
|
||||
} else {
|
||||
icon.classList.remove('bi-moon-fill');
|
||||
icon.classList.add('bi-brightness-high-fill');
|
||||
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-moon-fill" viewBox="0 0 16 16"><path d="M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278"/>';
|
||||
}
|
||||
}
|
||||
|
||||
function applyStyleMode() {
|
||||
document.body.classList.toggle('dark-mode', isDarkMode);
|
||||
|
||||
if (isDarkMode) {
|
||||
icon.classList.remove('bi-brightness-high-fill');
|
||||
icon.classList.add('bi-moon-fill');
|
||||
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-brightness-high-fill" viewBox="0 0 16 16"><path d="M12 8a4 4 0 1 1-8 0 4 4 0 0 1 8 0M8 0a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 0m0 13a.5.5 0 0 1 .5.5v2a.5.5 0 0 1-1 0v-2A.5.5 0 0 1 8 13m8-5a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2a.5.5 0 0 1 .5.5M3 8a.5.5 0 0 1-.5.5h-2a.5.5 0 0 1 0-1h2A.5.5 0 0 1 3 8m10.657-5.657a.5.5 0 0 1 0 .707l-1.414 1.415a.5.5 0 1 1-.707-.708l1.414-1.414a.5.5 0 0 1 .707 0m-9.193 9.193a.5.5 0 0 1 0 .707L3.05 13.657a.5.5 0 0 1-.707-.707l1.414-1.414a.5.5 0 0 1 .707 0m9.193 2.121a.5.5 0 0 1-.707 0l-1.414-1.414a.5.5 0 0 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .707M4.464 4.465a.5.5 0 0 1-.707 0L2.343 3.05a.5.5 0 1 1 .707-.707l1.414 1.414a.5.5 0 0 1 0 .708"/></svg>';
|
||||
} else {
|
||||
icon.classList.remove('bi-moon-fill');
|
||||
icon.classList.add('bi-brightness-high-fill');
|
||||
icon.innerHTML = '<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-moon-fill" viewBox="0 0 16 16"><path d="M6 .278a.77.77 0 0 1 .08.858 7.2 7.2 0 0 0-.878 3.46c0 4.021 3.278 7.277 7.318 7.277q.792-.001 1.533-.16a.79.79 0 0 1 .81.316.73.73 0 0 1-.031.893A8.35 8.35 0 0 1 8.344 16C3.734 16 0 12.286 0 7.71 0 4.266 2.114 1.312 5.124.06A.75.75 0 0 1 6 .278"/></svg>';
|
||||
}
|
||||
}
|
||||
|
||||
darkModeMediaQuery.addListener(applyStyleMode);
|
||||
applyStyleMode();
|
||||
|
||||
styleSwitcherButton.addEventListener('click', toggleDarkMode);
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.querySelectorAll('.file-size').forEach(function(element) {
|
||||
const size = parseInt(element.getAttribute('data-size'));
|
||||
element.textContent = formatFileSize(size);
|
||||
});
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const deleteFolderButtons = document.querySelectorAll('.delete-folder-button');
|
||||
|
||||
deleteFolderButtons.forEach(deleteButton => {
|
||||
deleteButton.addEventListener('click', async () => {
|
||||
const fileContainer = deleteButton.closest('tr');
|
||||
const folderName = fileContainer.querySelector('td:first-child').textContent;
|
||||
|
||||
Swal.fire({
|
||||
title: 'Êtes-vous sûr?',
|
||||
text: `La suppression du dossier "${folderName}" est irréversible!`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Supprimer',
|
||||
cancelButtonText: 'Annuler',
|
||||
}).then(async (result) => {
|
||||
if (result.isConfirmed) {
|
||||
try {
|
||||
const response = await fetch(`/api/dpanel/dashboard/deletefolder/${folderName}`, {
|
||||
method: 'DELETE',
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
fileContainer.remove();
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le dossier a été supprimé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'La suppression du dossier a échoué',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la suppression du dossier:', error);
|
||||
Swal.fire('Erreur!', 'Une erreur s\'est produite lors de la suppression du dossier.', 'error');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
document.getElementById('searchButton').addEventListener('click', searchFiles);
|
||||
document.getElementById('newFolderBtn').addEventListener('click', showNewFolderModal);
|
||||
|
||||
document.querySelectorAll('.delete-folder-button').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const folderName = this.getAttribute('data-folder-name');
|
||||
confirmDeleteFolder(folderName);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
window.onload = function() {
|
||||
var newFolderModalBtn = document.getElementById('newFolderModalBtn');
|
||||
if(newFolderModalBtn) {
|
||||
newFolderModalBtn.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
Swal.fire({
|
||||
title: 'Nouveau dossier',
|
||||
input: 'text',
|
||||
inputPlaceholder: 'Entrer le nom du nouveau dossier',
|
||||
confirmButtonText: 'Créer',
|
||||
showCancelButton: true,
|
||||
cancelButtonText: 'Annuler',
|
||||
preConfirm: (folderName) => {
|
||||
if (!folderName) {
|
||||
Swal.showValidationMessage('Le nom du dossier ne peut pas être vide.');
|
||||
}
|
||||
return folderName;
|
||||
}
|
||||
}).then(result => {
|
||||
if (result.isConfirmed) {
|
||||
const folderName = result.value.trim();
|
||||
fetch('/api/dpanel/dashboard/newfolder', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ folderName }),
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.json().then(error => Promise.reject(error));
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le dossier a été créé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 2000,
|
||||
toast: true
|
||||
})
|
||||
.then(() => {
|
||||
location.reload();
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Erreur lors de la création du dossier.',
|
||||
text: error.message,
|
||||
showConfirmButton: false,
|
||||
timer: 2350,
|
||||
toast: true
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
document.querySelectorAll('.delete-file-button').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const fileName = this.getAttribute('data-file-name');
|
||||
confirmDelete(fileName);
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('.copy-button').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const fileUrl = this.getAttribute('data-file-url');
|
||||
copyFileLink(fileUrl);
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('.rename-file-btn').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const fileName = this.getAttribute('data-file-name');
|
||||
const folderName = this.getAttribute('data-folder-name');
|
||||
renameFile(folderName, fileName);
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('.move-file-btn').forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
const fileName = this.getAttribute('data-file-name');
|
||||
showMoveFileModal(fileName);
|
||||
});
|
||||
});
|
||||
|
||||
document.getElementById('confirmMoveFile').addEventListener('click', moveFile);
|
||||
document.getElementById('themeSwitcher').addEventListener('click', toggleDarkMode);
|
||||
|
||||
initTheme();
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const accountDropdownBtn = document.getElementById('accountDropdownBtn');
|
||||
const accountDropdownMenu = document.getElementById('accountDropdownMenu');
|
||||
|
||||
accountDropdownBtn.addEventListener('click', function (e) {
|
||||
e.stopPropagation();
|
||||
accountDropdownMenu.classList.toggle('show');
|
||||
});
|
||||
|
||||
document.addEventListener('click', function (e) {
|
||||
if (!accountDropdownBtn.contains(e.target) && !accountDropdownMenu.contains(e.target)) {
|
||||
accountDropdownMenu.classList.remove('show');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.modal').modal({
|
||||
show: false
|
||||
});
|
||||
|
||||
const metadataLink = document.querySelector('a[onclick="displayMetadata()"]');
|
||||
if (metadataLink) {
|
||||
metadataLink.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
displayMetadata();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
document.querySelectorAll('[onclick^="showFileInfo"]').forEach(link => {
|
||||
link.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
const fileName = this.getAttribute('onclick').match(/'([^']+)'/)[1];
|
||||
showFileInfo(fileName);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
var modal = document.getElementById('patchNoteModal');
|
||||
|
||||
if (isDarkMode()) {
|
||||
modal.classList.add('dark-mode');
|
||||
} else {
|
||||
modal.classList.add('light-mode');
|
||||
function formatFileSize(fileSizeInBytes) {
|
||||
if (fileSizeInBytes < 1024) return fileSizeInBytes + ' octets';
|
||||
else if (fileSizeInBytes < 1048576) return (fileSizeInBytes / 1024).toFixed(2) + ' Ko';
|
||||
else if (fileSizeInBytes < 1073741824) return (fileSizeInBytes / 1048576).toFixed(2) + ' Mo';
|
||||
else return (fileSizeInBytes / 1073741824).toFixed(2) + ' Go';
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#accountDropdownBtn').on('click', function () {
|
||||
$('#accountDropdownMenu').toggleClass('show');
|
||||
});
|
||||
|
||||
$(document).on('click', function (e) {
|
||||
if (!$('#accountDropdownBtnGroup').is(e.target) && $('#accountDropdownBtnGroup').has(e.target).length === 0) {
|
||||
$('#accountDropdownMenu').removeClass('show');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function searchFiles() {
|
||||
const input = document.getElementById('searchInput');
|
||||
const filter = input.value.toUpperCase();
|
||||
const table = document.getElementById('fileTable');
|
||||
const tr = table.getElementsByTagName('tr');
|
||||
|
||||
function confirmDelete(filename) {
|
||||
for (let i = 1; i < tr.length; i++) {
|
||||
const td = tr[i].getElementsByTagName('td')[0];
|
||||
if (td) {
|
||||
const txtValue = td.textContent || td.innerText;
|
||||
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
||||
tr[i].style.display = "";
|
||||
} else {
|
||||
tr[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function showNewFolderModal() {
|
||||
Swal.fire({
|
||||
title: 'Nouveau dossier',
|
||||
input: 'text',
|
||||
inputPlaceholder: 'Entrer le nom du nouveau dossier',
|
||||
confirmButtonText: 'Créer',
|
||||
showCancelButton: true,
|
||||
cancelButtonText: 'Annuler',
|
||||
preConfirm: (folderName) => {
|
||||
if (!folderName) {
|
||||
Swal.showValidationMessage('Le nom du dossier ne peut pas être vide.');
|
||||
}
|
||||
return folderName;
|
||||
}
|
||||
}).then(result => {
|
||||
if (result.isConfirmed) {
|
||||
createNewFolder(result.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function createNewFolder(folderName) {
|
||||
fetch('/api/dpanel/dashboard/newfolder', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ folderName }),
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
return response.json();
|
||||
} else {
|
||||
return response.json().then(error => Promise.reject(error));
|
||||
}
|
||||
})
|
||||
.then(result => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le dossier a été créé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 2000,
|
||||
toast: true
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Erreur lors de la création du dossier.',
|
||||
text: error.message,
|
||||
showConfirmButton: false,
|
||||
timer: 2350,
|
||||
toast: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function confirmDeleteFolder(folderName) {
|
||||
Swal.fire({
|
||||
title: 'Êtes-vous sûr?',
|
||||
text: `La suppression du dossier "${folderName}" est irréversible!`,
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Supprimer',
|
||||
cancelButtonText: 'Annuler',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
deleteFolder(folderName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function deleteFolder(folderName) {
|
||||
fetch(`/api/dpanel/dashboard/deletefolder/${folderName}`, {
|
||||
method: 'DELETE',
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le dossier a été supprimé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
throw new Error('La suppression du dossier a échoué');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: error.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function confirmDelete(filename) {
|
||||
Swal.fire({
|
||||
title: 'Êtes-vous sûr de vouloir supprimer ce fichier?',
|
||||
text: 'Cette action est irréversible!',
|
||||
@@ -213,53 +230,67 @@
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Supprimer'
|
||||
}).then(async (result) => {
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
try {
|
||||
const response = await fetch('/api/dpanel/dashboard/delete', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
filename: filename,
|
||||
}),
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le fichier a été supprimé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
})
|
||||
.then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'La suppression du fichier a échoué.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la suppression du fichier:', error);
|
||||
Swal.fire('Erreur!', 'Une erreur s\'est produite lors de la suppression du fichier.', 'error');
|
||||
}
|
||||
deleteFile(filename);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renameFile(folderName, currentName) {
|
||||
const fileExtensionIndex = currentName.lastIndexOf('.');
|
||||
const fileExtension = currentName.substring(fileExtensionIndex);
|
||||
function deleteFile(filename) {
|
||||
fetch('/api/dpanel/dashboard/delete', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
filename: filename,
|
||||
}),
|
||||
})
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le fichier a été supprimé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
throw new Error('La suppression du fichier a échoué');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: error.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function copyFileLink(fileUrl) {
|
||||
navigator.clipboard.writeText(fileUrl).then(() => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Lien copié !',
|
||||
showConfirmButton: false,
|
||||
timer: 1500,
|
||||
toast: true
|
||||
});
|
||||
}, (err) => {
|
||||
console.error('Erreur lors de la copie: ', err);
|
||||
});
|
||||
}
|
||||
|
||||
function renameFile(folderName, currentName) {
|
||||
Swal.fire({
|
||||
title: 'Entrez le nouveau nom',
|
||||
input: 'text',
|
||||
@@ -268,17 +299,14 @@
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Renommer',
|
||||
cancelButtonText: 'Annuler',
|
||||
onOpen: (el) => {
|
||||
setTimeout(() => {
|
||||
const input = Swal.getInput();
|
||||
const pos = input.value.lastIndexOf('.');
|
||||
input.setSelectionRange(0, pos);
|
||||
}, 0);
|
||||
inputValidator: (value) => {
|
||||
if (!value) {
|
||||
return 'Vous devez entrer un nom de fichier';
|
||||
}
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const newName = result.value;
|
||||
|
||||
fetch(`/api/dpanel/dashboard/rename/${folderName}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
@@ -286,261 +314,191 @@
|
||||
},
|
||||
body: JSON.stringify({ currentName: currentName, newName: newName }),
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.text();
|
||||
})
|
||||
.then(data => {
|
||||
.then(response => {
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
return response.json();
|
||||
})
|
||||
.then(data => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le fichier a été renommé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Erreur lors du renommage du fichier.',
|
||||
text: error.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function showMoveFileModal(fileName) {
|
||||
document.getElementById('moveFileName').value = fileName;
|
||||
$('#moveFileModal').modal('show');
|
||||
}
|
||||
|
||||
function moveFile() {
|
||||
const fileName = document.getElementById('moveFileName').value;
|
||||
const folderName = document.getElementById('moveFolderSelect').value;
|
||||
|
||||
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é renommé avec succès.',
|
||||
title: 'Le fichier a été déplacé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Erreur lors du renommage du fichier.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function getUserIdFromFolder(username) {
|
||||
if (!username) {
|
||||
console.error('Username is not defined');
|
||||
return null;
|
||||
}
|
||||
|
||||
let users;
|
||||
try {
|
||||
let response = await fetch(`/user.json`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
users = await response.json();
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
return null;
|
||||
}
|
||||
|
||||
let user = users.find(user => user.name.toLowerCase() === username.toLowerCase());
|
||||
|
||||
return user ? user.id : null;
|
||||
}
|
||||
|
||||
window.onload = async function() {
|
||||
console.log("Page loaded, fetching file info...");
|
||||
|
||||
let data;
|
||||
try {
|
||||
let response = await fetch('/api/dpanel/dashboard/getmetadatafile/file_info', {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
});
|
||||
console.log("Response from fetch:", response);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
data = await response.json();
|
||||
console.log("Data from response:", data);
|
||||
} catch (error) {
|
||||
console.log("Error in fetch:", error);
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Les informations sur le fichier ne sont pas disponibles pour le moment. Veuillez réessayer plus tard.',
|
||||
text: `Error: ${error.message}`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let table = document.getElementById("fileTable");
|
||||
for (let file of data) {
|
||||
let row = table.insertRow();
|
||||
let cell = row.insertCell();
|
||||
cell.innerHTML = `<a href="#" onclick="showFileInfo('${file.fileName}')">${file.fileName}</a>`;
|
||||
}
|
||||
}
|
||||
|
||||
async function showFileInfo(fileLink) {
|
||||
console.log("showFileInfo called with fileLink:", fileLink);
|
||||
let data;
|
||||
try {
|
||||
let response = await fetch('/api/dpanel/dashboard/getmetadatafile/file_info', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
fileLink: fileLink,
|
||||
})
|
||||
});
|
||||
console.log("Response from fetch:", response);
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
data = await response.json();
|
||||
console.log("Data from response:", data);
|
||||
} catch (error) {
|
||||
console.log("Error in fetch:", error);
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Les informations sur le fichier ne sont pas disponibles pour le moment. Veuillez réessayer plus tard.',
|
||||
text: `Error: ${error.message}`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let pathParts = fileLink.split('/');
|
||||
console.log("pathParts:", pathParts);
|
||||
if (pathParts.length < 4) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: `The file link ${fileLink} is not valid.`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
let fileName = pathParts.pop();
|
||||
let userId = pathParts.pop();
|
||||
|
||||
let fileInfo = data.find(file => file.fileName === fileName && file.Id === userId);
|
||||
console.log('Found fileInfo:', fileInfo);
|
||||
if (!fileInfo) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: `No information found for the file ${fileName} for the user with ID ${userId}.`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Found fileInfo:', fileInfo);
|
||||
|
||||
let html = `<p>File name: ${fileInfo.fileName}</p>`;
|
||||
if (fileInfo.expiryDate) {
|
||||
html += `<p>Expiry date: ${fileInfo.expiryDate}</p>`;
|
||||
}
|
||||
if (fileInfo.password) {
|
||||
html += `<p>Password: Yes</p>`;
|
||||
}
|
||||
if (fileInfo.userId) {
|
||||
html += `<p>User: <a href="/api/dpanel/dashboard/getuser/${fileInfo.userId}" target="_blank">${fileInfo.userId}</a></p>`;
|
||||
}
|
||||
Swal.fire({
|
||||
title: 'File Information',
|
||||
html: html,
|
||||
confirmButtonText: 'Close'
|
||||
});
|
||||
}
|
||||
|
||||
async function displayMetadata() {
|
||||
const response = await fetch('/build-metadata');
|
||||
if (!response.ok) {
|
||||
console.error('Failed to fetch metadata');
|
||||
return;
|
||||
}
|
||||
|
||||
const metadata = await response.json();
|
||||
if (!metadata) {
|
||||
console.error('No metadata provided');
|
||||
return;
|
||||
}
|
||||
|
||||
document.getElementById('buildVersion').textContent = metadata.build_version;
|
||||
document.getElementById('nodeVersion').textContent = metadata.node_version;
|
||||
document.getElementById('expressVersion').textContent = metadata.express_version;
|
||||
document.getElementById('buildSha').textContent = metadata.build_sha;
|
||||
document.getElementById('osType').textContent = metadata.os_type;
|
||||
document.getElementById('osRelease').textContent = metadata.os_release;
|
||||
|
||||
const modal = document.getElementById('metadataModal');
|
||||
modal.style.display = 'block';
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
});
|
||||
} 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.',
|
||||
text: error.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
});
|
||||
|
||||
$('#moveFileModal').modal('hide');
|
||||
}
|
||||
|
||||
const body = document.body;
|
||||
const themeSwitcher = document.getElementById('themeSwitcher');
|
||||
|
||||
function setTheme(theme) {
|
||||
if (theme === 'dark') {
|
||||
body.classList.add('dark');
|
||||
} else {
|
||||
body.classList.remove('dark');
|
||||
}
|
||||
localStorage.setItem('theme', theme);
|
||||
}
|
||||
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
if (savedTheme) {
|
||||
setTheme(savedTheme);
|
||||
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
setTheme('dark');
|
||||
}
|
||||
|
||||
themeSwitcher.addEventListener('click', function() {
|
||||
if (body.classList.contains('dark')) {
|
||||
setTheme('light');
|
||||
} else {
|
||||
setTheme('dark');
|
||||
}
|
||||
});
|
||||
|
||||
async function showFileInfo(fileName) {
|
||||
try {
|
||||
const response = await fetch('/api/dpanel/dashboard/getmetadatafile/file_info', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
fileLink: fileName,
|
||||
})
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
const fileInfo = data.find(file => file.fileName === fileName);
|
||||
|
||||
if (!fileInfo) {
|
||||
throw new Error(`No information found for the file ${fileName}.`);
|
||||
}
|
||||
|
||||
let html = `<p>Nom du fichier : ${fileInfo.fileName}</p>`;
|
||||
if (fileInfo.expiryDate) {
|
||||
html += `<p>Date d'expiration : ${fileInfo.expiryDate}</p>`;
|
||||
}
|
||||
if (fileInfo.password) {
|
||||
html += `<p>Mot de passe : Oui</p>`;
|
||||
}
|
||||
if (fileInfo.userId) {
|
||||
html += `<p>Utilisateur : <a href="/api/dpanel/dashboard/getuser/${fileInfo.userId}" target="_blank">${fileInfo.userId}</a></p>`;
|
||||
}
|
||||
|
||||
Swal.fire({
|
||||
title: 'Informations sur le fichier',
|
||||
html: html,
|
||||
confirmButtonText: 'Fermer'
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error in showFileInfo:', error);
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Les informations sur le fichier ne sont pas disponibles pour le moment.',
|
||||
text: `Erreur : ${error.message}`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function displayMetadata() {
|
||||
fetch('/build-metadata')
|
||||
.then(response => response.json())
|
||||
.then(metadata => {
|
||||
document.getElementById('buildVersion').textContent = metadata.build_version;
|
||||
document.getElementById('nodeVersion').textContent = metadata.node_version;
|
||||
document.getElementById('expressVersion').textContent = metadata.express_version;
|
||||
document.getElementById('buildSha').textContent = metadata.build_sha;
|
||||
document.getElementById('osType').textContent = metadata.os_type;
|
||||
document.getElementById('osRelease').textContent = metadata.os_release;
|
||||
|
||||
$('#metadataModal').modal('show');
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Failed to fetch metadata:', error);
|
||||
Swal.fire({
|
||||
icon: 'error',
|
||||
title: 'Erreur',
|
||||
text: 'Impossible de récupérer les métadonnées'
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -341,7 +341,7 @@ async function showFileInfo(fileName) {
|
||||
const moveFileForm = document.getElementById('moveFileForm');
|
||||
|
||||
moveFileForm.addEventListener('submit', function (event) {
|
||||
event.preventDefault(); // Empêche la soumission par défaut du formulaire
|
||||
event.preventDefault();
|
||||
|
||||
const fileName = this.querySelector('input[name="fileName"]').value;
|
||||
const userName = this.querySelector('input[name="userName"]').value;
|
||||
|
||||
Reference in New Issue
Block a user