Update DockerCompose.template, Dockerfile, Upload.js, and upload.ejs files
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
<link rel="stylesheet" href="/public/css/styles.css">
|
||||
<title>Upload</title>
|
||||
<link rel="icon" href="/public/assets/homelab_logo.png" />
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
</head>
|
||||
|
||||
<body class="light-mode">
|
||||
@@ -65,19 +66,32 @@
|
||||
});
|
||||
|
||||
uploadForm.addEventListener('submit', (event) => {
|
||||
event.preventDefault();
|
||||
event.preventDefault();
|
||||
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
const file = fileInput.files[0];
|
||||
const expiryDate = document.getElementById('expiryDate').value;
|
||||
const password = document.getElementById('password').value;
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('expiryDate', expiryDate);
|
||||
formData.append('password', password);
|
||||
const fileInput = document.getElementById('fileInput');
|
||||
const file = fileInput.files[0];
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/api/dpanel/upload', true);
|
||||
if (!file) {
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Veuillez sélectionner \nun fichier avant de soumettre.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const expiryDate = document.getElementById('expiryDate').value;
|
||||
const password = document.getElementById('password').value;
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('expiryDate', expiryDate);
|
||||
formData.append('password', password);
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', '/api/dpanel/upload', true);
|
||||
|
||||
xhr.upload.onprogress = (event) => {
|
||||
if (event.lengthComputable) {
|
||||
@@ -88,17 +102,30 @@
|
||||
};
|
||||
xhr.onload = () => {
|
||||
if (xhr.status === 200) {
|
||||
const response = JSON.parse(xhr.responseText);
|
||||
const fileLink = response.fileLink;
|
||||
window.location.href = '/dpanel/upload-success';
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'success',
|
||||
title: 'Votre fichier a été téléchargé avec succès.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
} else {
|
||||
console.error('Erreur lors du téléchargement du fichier.', xhr.status);
|
||||
Swal.fire({
|
||||
position: 'top',
|
||||
icon: 'error',
|
||||
title: 'Erreur lors du téléchargement du fichier.',
|
||||
showConfirmButton: false,
|
||||
timer: 1800,
|
||||
toast: true,
|
||||
});
|
||||
console.error('Erreur lors du téléchargement du fichier.', xhr.status, xhr.responseText);
|
||||
}
|
||||
};
|
||||
|
||||
xhr.send(formData);
|
||||
});
|
||||
|
||||
|
||||
function calculateRemainingTime(loaded, total, timeStamp) {
|
||||
const bytesPerSecond = loaded / (timeStamp / 1000);
|
||||
const remainingBytes = total - loaded;
|
||||
|
||||
Reference in New Issue
Block a user