First commit of the new Insider version on docker
BIN
public/assets/background/background_1.jpg
Normal file
|
After Width: | Height: | Size: 246 KiB |
BIN
public/assets/background/background_2.jpg
Normal file
|
After Width: | Height: | Size: 146 KiB |
BIN
public/assets/background/background_3.jpg
Normal file
|
After Width: | Height: | Size: 12 KiB |
BIN
public/assets/background/background_4.jpg
Normal file
|
After Width: | Height: | Size: 41 KiB |
BIN
public/assets/dashboardimgforpresentation.png
Normal file
|
After Width: | Height: | Size: 108 KiB |
BIN
public/assets/homelab_logo.png
Normal file
|
After Width: | Height: | Size: 9.2 KiB |
BIN
public/assets/homelab_logo@2x.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
public/assets/homelab_logo@3x.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
public/assets/indeximgforpresentation.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
public/assets/loginimgforpresentation.png
Normal file
|
After Width: | Height: | Size: 17 KiB |
BIN
public/assets/uploadimgforpresentation.png
Normal file
|
After Width: | Height: | Size: 31 KiB |
15
public/css/acces-denied.css
Normal file
@@ -0,0 +1,15 @@
|
||||
body{
|
||||
background-color: black;
|
||||
color: white;
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: red;
|
||||
}
|
||||
|
||||
h6{
|
||||
color: red;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
|
||||
54
public/css/auth.css
Normal file
@@ -0,0 +1,54 @@
|
||||
body {
|
||||
background-color: #36393f;
|
||||
color: #ffffff;
|
||||
font-family: Arial, sans-serif;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.title-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.container {
|
||||
width: 300px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.tittle {
|
||||
font-size: 24px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
input[type="text"],
|
||||
input[type="password"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-bottom: 15px;
|
||||
background-color: #40444b;
|
||||
border: none;
|
||||
color: #ffffff;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
button {
|
||||
background-color: #7289da;
|
||||
color: #ffffff;
|
||||
border: none;
|
||||
padding: 10px 20px;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
font-size: 16px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #677bc4;
|
||||
}
|
||||
49
public/css/login.css
Normal file
@@ -0,0 +1,49 @@
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
padding: 20px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.form-group label,
|
||||
.form-group small {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form-control,
|
||||
.btn {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
/* Dark Mode */
|
||||
body.dark-mode {
|
||||
background-color: #151a1e;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.dark-mode .container {
|
||||
background-color: #262636;
|
||||
box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.dark-mode .form-control {
|
||||
background-color: #343a40; /* Nouvelle couleur pour les boutons en mode sombre */
|
||||
border-color: #343a40; /* Nouvelle couleur de bordure pour les boutons en mode sombre */
|
||||
color: #fff; /* Couleur du texte pour les boutons en mode sombre */
|
||||
}
|
||||
|
||||
.dark-mode .form-group label,
|
||||
.dark-mode .form-group small {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
|
||||
169
public/css/styles.css
Normal file
@@ -0,0 +1,169 @@
|
||||
.btn-round {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.btn-link {
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
.dark-mode {
|
||||
background-color: #151a1e;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.dark-mode table {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.dark-mode .navbar-light .navbar-toggler-icon {
|
||||
background-color: #0b0d0f;
|
||||
}
|
||||
|
||||
.dark-mode .navbar-light .navbar-toggler {
|
||||
border-color: #0b0d0f;
|
||||
}
|
||||
|
||||
.dark-mode .header {
|
||||
background-color: #0b0d0f !important;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.dark-mode .navbar-brand {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.header-form {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.header-form button {
|
||||
background-color: #007bff;
|
||||
border-radius: 20px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.table {
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
border: none;
|
||||
background-color: #f8f9fa;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.table th {
|
||||
background-color: #9798a1;
|
||||
}
|
||||
|
||||
.table-bordered th,
|
||||
.table-bordered td {
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.dark-mode .table {
|
||||
border-radius: 10px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.dark-mode .table th,
|
||||
.dark-mode .table td {
|
||||
border: none;
|
||||
background-color: #262636;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.dark-mode .table th {
|
||||
background-color: #0b0d0f;
|
||||
}
|
||||
|
||||
.dark-mode .table-bordered th,
|
||||
.dark-mode .table-bordered td {
|
||||
border: 1px solid #dee2e6;
|
||||
}
|
||||
|
||||
.table-container {
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.dark-mode .modal-content {
|
||||
background-color: #262636;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.light-mode .modal-content {
|
||||
background-color: #ffffff;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
border-radius: 15px;
|
||||
}
|
||||
|
||||
.custom-breadcrumb {
|
||||
font-size: 14px;
|
||||
max-width: 800px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
margin: 10px auto 0;
|
||||
}
|
||||
|
||||
.table-hover tbody tr:hover {
|
||||
background-color: #5b5b82;
|
||||
}
|
||||
|
||||
body.dark-theme .navbar-toggler-icon {
|
||||
filter: invert(1);
|
||||
}
|
||||
|
||||
#logoutLink {
|
||||
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
|
||||
color: #007BFF;
|
||||
background-color: transparent;
|
||||
padding: 8px 16px;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
margin: 4px 2px;
|
||||
border-radius: 50px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
|
||||
border: 2px solid #007BFF;
|
||||
}
|
||||
|
||||
#logoutLink:hover {
|
||||
transform: scale(1.15);
|
||||
background-color: #007BFF;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.custom-btn {
|
||||
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
|
||||
color: #007BFF;
|
||||
background-color: transparent;
|
||||
padding: 8px 16px;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
margin: 4px 2px;
|
||||
border-radius: 50px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
|
||||
border: 2px solid #007BFF;
|
||||
}
|
||||
|
||||
.custom-btn:hover {
|
||||
transform: scale(1.15);
|
||||
background-color: #007BFF;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn-icon {
|
||||
border-radius: 50%;
|
||||
padding: 0.5em;
|
||||
}
|
||||
104
public/css/upload.css
Normal file
@@ -0,0 +1,104 @@
|
||||
body {
|
||||
background-color: #f8f9fa;
|
||||
}
|
||||
|
||||
.container {
|
||||
background-color: #f8f9fa;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
padding: 20px;
|
||||
margin-top: 50px;
|
||||
}
|
||||
|
||||
.progress {
|
||||
height: 25px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
||||
#progressBar {
|
||||
background-color: #007bff;
|
||||
}
|
||||
|
||||
.progress-info {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#progressText {
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
.form-group label,
|
||||
.form-group small {
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.form-control,
|
||||
.btn {
|
||||
border-radius: 20px;
|
||||
}
|
||||
|
||||
.form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
body.dark-mode {
|
||||
background-color: #151a1e;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.dark-mode .container{
|
||||
background-color: #262636;
|
||||
box-shadow: 0 0 10px rgba(255, 255, 255, 0.1);
|
||||
}
|
||||
|
||||
.progress-bar.dark-mode {
|
||||
background-color: #007bff;
|
||||
}
|
||||
|
||||
#progressText.dark-mode,
|
||||
#estimatedTime.dark-mode {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.form-group label.dark-mode,
|
||||
.form-group small.dark-mode {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.dark-mode .form-control.dark-mode,
|
||||
.btn.dark-mode {
|
||||
background-color: #0b0d0f;
|
||||
border-color: #0b0d0f;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.dark-mode .form-group label{
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.dark-mode text-muted{
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.custom-btn {
|
||||
transition: transform 0.3s ease, background-color 0.3s ease, border-color 0.3s ease;
|
||||
color: #007BFF;
|
||||
background-color: transparent;
|
||||
padding: 8px 16px;
|
||||
text-decoration: none;
|
||||
display: inline-block;
|
||||
font-size: 14px;
|
||||
margin: 4px 2px;
|
||||
border-radius: 50px;
|
||||
cursor: pointer;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.25);
|
||||
border: 2px solid #007BFF;
|
||||
}
|
||||
|
||||
.custom-btn:hover {
|
||||
transform: scale(1.15);
|
||||
background-color: #007BFF;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
536
public/js/dashboard.js
Normal file
@@ -0,0 +1,536 @@
|
||||
|
||||
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);
|
||||
|
||||
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 () {
|
||||
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(`/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');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
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('/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 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');
|
||||
|
||||
if (isDarkMode()) {
|
||||
modal.classList.add('dark-mode');
|
||||
} else {
|
||||
modal.classList.add('light-mode');
|
||||
}
|
||||
|
||||
$(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 confirmDelete(filename) {
|
||||
Swal.fire({
|
||||
title: 'Êtes-vous sûr de vouloir supprimer ce fichier?',
|
||||
text: 'Cette action est irréversible!',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Supprimer'
|
||||
}).then(async (result) => {
|
||||
if (result.isConfirmed) {
|
||||
try {
|
||||
const response = await fetch('/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');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function renameFile(folderName, currentName) {
|
||||
const fileExtensionIndex = currentName.lastIndexOf('.');
|
||||
const fileExtension = currentName.substring(fileExtensionIndex);
|
||||
|
||||
Swal.fire({
|
||||
title: 'Entrez le nouveau nom',
|
||||
input: 'text',
|
||||
inputValue: currentName,
|
||||
inputPlaceholder: 'Nouveau nom',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Renommer',
|
||||
cancelButtonText: 'Annuler',
|
||||
onOpen: (el) => {
|
||||
setTimeout(() => {
|
||||
const input = Swal.getInput();
|
||||
const pos = input.value.lastIndexOf('.');
|
||||
input.setSelectionRange(0, pos);
|
||||
}, 0);
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const newName = result.value;
|
||||
|
||||
fetch(`/dpanel/dashboard/rename/${folderName}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
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 => {
|
||||
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.',
|
||||
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;
|
||||
}
|
||||
|
||||
async function showFileInfo(fileLink) {
|
||||
let data;
|
||||
try {
|
||||
let response = await fetch(`/file_info.json`);
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
data = await response.json();
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Les informations sur les fichiers ne sont pas disponibles pour le moment. Veuillez réessayer plus tard.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let fileName = fileLink.split('/').pop();
|
||||
let pathParts = fileLink.split('/');
|
||||
if (pathParts.length < 2) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: `Le lien du fichier ${fileLink} n'est pas valide.`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
let username = pathParts[1].replace('.', '');
|
||||
console.log('Extracted username:', username);
|
||||
|
||||
let userId = await getUserIdFromFolder(username);
|
||||
console.log('Obtained userId:', userId);
|
||||
|
||||
let fileInfo = data.find(file => file.fileName === fileName && file.Id === userId);
|
||||
if (!fileInfo) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: `Aucune information trouvée pour le fichier ${fileName} pour l'utilisateur ${username}.`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Found fileInfo:', fileInfo);
|
||||
|
||||
let html = `<p>Nom du fichier : ${fileInfo.fileName}</p>`;
|
||||
if (fileInfo.expiryDate) {
|
||||
html += `<p>Date de fin de disponibilité : ${fileInfo.expiryDate}</p>`;
|
||||
}
|
||||
if (fileInfo.password) {
|
||||
html += `<p>Mot de passe : Oui</p>`;
|
||||
}
|
||||
Swal.fire({
|
||||
title: 'Informations sur le fichier',
|
||||
html: html,
|
||||
confirmButtonText: 'Fermer'
|
||||
});
|
||||
}
|
||||
340
public/js/folder.js
Normal file
@@ -0,0 +1,340 @@
|
||||
function calculateFolderSize(contents) {
|
||||
let totalSize = 0;
|
||||
|
||||
contents.forEach(file => {
|
||||
|
||||
if (file.type === 'file' && file.size !== undefined && !isNaN(file.size) && file.size >= 0) {
|
||||
totalSize += file.size;
|
||||
} else if (file.type === 'folder' && file.contents !== undefined) {
|
||||
totalSize += calculateFolderSize(file.contents);
|
||||
}
|
||||
});
|
||||
|
||||
return totalSize;
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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';
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
async function confirmDeleteFile(folderName, filename) {
|
||||
const requestBody = JSON.stringify({
|
||||
filename: filename,
|
||||
});
|
||||
|
||||
const confirmationResult = await Swal.fire({
|
||||
title: 'Êtes-vous sûr de vouloir supprimer ce fichier?',
|
||||
text: 'Cette action est irréversible!',
|
||||
icon: 'warning',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#d33',
|
||||
cancelButtonColor: '#3085d6',
|
||||
confirmButtonText: 'Supprimer'
|
||||
});
|
||||
|
||||
if (confirmationResult.isConfirmed) {
|
||||
try {
|
||||
const response = await fetch(`/dpanel/dashboard/deletefile/${folderName}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: requestBody,
|
||||
});
|
||||
|
||||
const responseData = await response.json();
|
||||
|
||||
if (response.ok) {
|
||||
handleDeleteSuccess();
|
||||
} else {
|
||||
handleDeleteFailure(response, responseData);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Erreur lors de la suppression du fichier:', error);
|
||||
handleDeleteFailure();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function handleDeleteSuccess() {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Le fichier a été supprimé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
})
|
||||
.then(() => {
|
||||
location.reload();
|
||||
});
|
||||
}
|
||||
|
||||
function handleDeleteFailure(response, responseData) {
|
||||
if (response.status === 404 && responseData && responseData.status === 'error') {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: responseData.message,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
})
|
||||
} else {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'La suppression du fichier a échoué.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function getCurrentFolderName() {
|
||||
const currentPath = window.location.pathname;
|
||||
const pathSegments = currentPath.split('/');
|
||||
|
||||
const currentFolderName = pathSegments[pathSegments.length - 1];
|
||||
|
||||
return currentFolderName;
|
||||
}
|
||||
|
||||
function renameFolder(currentName, newName) {
|
||||
try {
|
||||
const currentFolderName = getCurrentFolderName();
|
||||
const renameURL = `/dpanel/dashboard/renamefile/${currentFolderName}`;
|
||||
|
||||
fetch(renameURL, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify({ newName: newName, currentName: currentName }),
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.renamed) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'errsuccessor',
|
||||
title: 'Succès',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
}).then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
throw new Error(data.error);
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Erreur lors du renommage du fichier:', error);
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: error.message || 'Une erreur est survenue lors du renommage du fichier.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true
|
||||
})
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Erreur lors du renommage du fichier:', error);
|
||||
}
|
||||
}
|
||||
|
||||
function renameFile(folderName, currentName) {
|
||||
const fileExtensionIndex = currentName.lastIndexOf('.');
|
||||
const fileExtension = currentName.substring(fileExtensionIndex);
|
||||
|
||||
Swal.fire({
|
||||
title: 'Entrez le nouveau nom',
|
||||
input: 'text',
|
||||
inputValue: currentName,
|
||||
inputPlaceholder: 'Nouveau nom',
|
||||
showCancelButton: true,
|
||||
confirmButtonText: 'Renommer',
|
||||
cancelButtonText: 'Annuler',
|
||||
onOpen: (el) => {
|
||||
setTimeout(() => {
|
||||
const input = Swal.getInput();
|
||||
const pos = input.value.lastIndexOf('.');
|
||||
input.setSelectionRange(0, pos);
|
||||
}, 0);
|
||||
}
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
const newName = result.value;
|
||||
|
||||
fetch(`/dpanel/dashboard/rename/${folderName}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
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 => {
|
||||
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.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async function showFileInfo(fileName) {
|
||||
|
||||
let data;
|
||||
try {
|
||||
let response = await fetch('/file_info.json');
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
data = await response.json();
|
||||
} catch (error) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Les informations sur les fichiers ne sont pas disponibles pour le moment. Veuillez réessayer plus tard.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let fileInfo = data.find(file => file.fileName === fileName);
|
||||
|
||||
if (!fileInfo) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: `Aucune information trouvée pour le fichier ${fileName}.`,
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
let html = `<p>Nom du fichier : ${fileInfo.fileName}</p>`;
|
||||
if (fileInfo.expiryDate) {
|
||||
html += `<p>Date de fin de disponibilité : ${fileInfo.expiryDate}</p>`;
|
||||
}
|
||||
if (fileInfo.password) {
|
||||
html += `<p>Mot de passe : Oui</p>`;
|
||||
}
|
||||
Swal.fire({
|
||||
title: 'Informations sur le fichier',
|
||||
html: html,
|
||||
confirmButtonText: 'Fermer'
|
||||
});
|
||||
}
|
||||