V1.0.0-beta.16 Update
All checks were successful
continuous-integration/drone/push Build is passing

Note: We appreciate your feedback and bug reports to continue improving our platform. Thank you for your continued support!
This commit is contained in:
2024-10-27 16:48:30 +01:00
parent f83358c67d
commit 9ff4642a10
33 changed files with 3550 additions and 2058 deletions

View File

@@ -1,98 +1,236 @@
<!DOCTYPE html>
<html lang="en">
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
<link rel="stylesheet" href="/public/css/upload.css">
<link rel="stylesheet" href="/public/css/styles.css">
<title>Upload</title>
<title>Upload de Fichiers</title>
<link rel="icon" href="/public/assets/homelab_logo.png" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
<style>
body {
background-image: url('<%= user.wallpaper %>');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
margin: 0;
height: 100vh;
overflow: hidden;
}
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap');
:root {
--background: 0 0% 100%;
--foreground: 222.2 84% 4.9%;
--card: 0 0% 100%;
--card-foreground: 222.2 84% 4.9%;
--popover: 0 0% 100%;
--popover-foreground: 222.2 84% 4.9%;
--primary: 222.2 47.4% 11.2%;
--primary-foreground: 210 40% 98%;
--secondary: 210 40% 96.1%;
--secondary-foreground: 222.2 47.4% 11.2%;
--muted: 210 40% 96.1%;
--muted-foreground: 215.4 16.3% 46.9%;
--accent: 210 40% 96.1%;
--accent-foreground: 222.2 47.4% 11.2%;
--destructive: 0 84.2% 60.2%;
--destructive-foreground: 210 40% 98%;
--border: 214.3 31.8% 91.4%;
--input: 214.3 31.8% 91.4%;
--ring: 222.2 84% 4.9%;
--radius: 0.5rem;
}
.dark {
--background: 222.2 84% 4.9%;
--foreground: 210 40% 98%;
--card: 222.2 84% 4.9%;
--card-foreground: 210 40% 98%;
--popover: 222.2 84% 4.9%;
--popover-foreground: 210 40% 98%;
--primary: 210 40% 98%;
--primary-foreground: 222.2 47.4% 11.2%;
--secondary: 217.2 32.6% 17.5%;
--secondary-foreground: 210 40% 98%;
--muted: 217.2 32.6% 17.5%;
--muted-foreground: 215 20.2% 65.1%;
--accent: 217.2 32.6% 17.5%;
--accent-foreground: 210 40% 98%;
--destructive: 0 62.8% 30.6%;
--destructive-foreground: 210 40% 98%;
--border: 217.2 32.6% 17.5%;
--input: 217.2 32.6% 17.5%;
--ring: 212.7 26.8% 83.9%;
}
body {
font-family: 'Inter', sans-serif;
background-color: hsl(var(--background));
color: hsl(var(--foreground));
transition: background-color 0.3s ease, color 0.3s ease;
}
.container {
max-width: 960px;
margin: 0 auto;
padding: 2rem;
}
.form-container {
background-color: hsl(var(--card));
border: 1px solid hsl(var(--border));
border-radius: var(--radius);
padding: 2rem;
}
.form-group {
margin-bottom: 1rem;
}
.form-control {
width: 100%;
padding: 0.5rem;
border: 1px solid hsl(var(--border));
border-radius: var(--radius);
background-color: hsl(var(--background));
color: hsl(var(--foreground));
}
.btn {
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: var(--radius);
font-weight: 500;
transition: all 0.3s ease;
cursor: pointer;
}
.btn-primary {
background-color: hsl(var(--primary));
color: hsl(var(--primary-foreground));
}
.btn-primary:hover {
opacity: 0.9;
}
.btn-secondary {
background-color: hsl(var(--secondary));
color: hsl(var(--secondary-foreground));
}
.btn-secondary:hover {
opacity: 0.9;
}
#themeSwitcher {
position: fixed;
top: 1rem;
right: 1rem;
}
.animate {
animation: fadeIn 0.5s ease-out;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.icon-spacing {
margin-right: 8px;
}
.progress-bar {
height: 2px;
background-color: hsl(var(--border));
border-radius: var(--radius);
overflow: hidden;
position: relative;
}
.progress-bar div {
height: 100%;
background-color: hsl(var(--primary));
width: 0%;
}
</style>
</head>
<body class="animate dark">
<button id="themeSwitcher" class="btn btn-secondary p-2">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="w-6 h-6">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" />
</svg>
</button>
<style>
body {
background-image: url('<%= user.wallpaper %>');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
background-attachment: fixed;
margin: 0;
height: 100vh;
overflow: hidden;
}
</style>
<div id="app" class="min-h-screen flex items-center justify-center">
<div class="container mt-8">
<h1 class="text-3xl font-semibold mb-6 text-center animate">Upload de Fichiers</h1>
<div class="form-container">
<form id="uploadForm">
<div class="form-group">
<label for="file" class="block mb-2">Sélectionnez un fichier :</label>
<input type="file" name="file" id="fileInput" accept=".zip, .pdf, .txt, .jpg, .jpeg, .png, .gif, .iso, .mp4" class="form-control">
</div>
<body class="light-mode">
<div class="alert alert-primary text-center" role="alert">
Un nouveau look sera bientôt disponible pour la page de téléversement. Myaxrin Labs va améliorer son application pour la rendre plus rapide et plus facile à utiliser.
</div>
<div class="container mt-4 flex-column">
<h1 class="mb-4">Upload de Fichiers</h1>
<form id="uploadForm" enctype="multipart/form-data">
<div class="form-group">
<label for="file">Sélectionnez un fichier :</label>
<input class="form-control" type="file" name="file" id="fileInput"
accept=".zip, .pdf, .txt, .jpg, .jpeg, .png, .gif, .iso, .mp4">
</div>
<div class="form-group">
<label for="expiryDate" class="block mb-2">Date d'expiration :</label>
<input type="date" name="expiryDate" id="expiryDate" class="form-control">
</div>
<div class="form-group">
<label for="expiryDate">Date d'expiration :</label>
<input class="form-control" type="date" name="expiryDate" id="expiryDate">
</div>
<div class="form-group">
<label for="password">Mot de passe :</label>
<input class="form-control" type="password" name="password" id="password">
</div>
</form>
<div class="form-group">
<label for="password" class="block mb-2">Mot de passe :</label>
<input type="password" name="password" id="password" class="form-control">
</div>
<div class="progress mt-4 bg-white shadow-sm form-control">
<div class="progress-bar" id="progressBar" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
</div>
<div class="mt-2 progress-info">
<small class="text-muted" id="progressText">0%</small>
<small class="text-muted ml-3" id="estimatedTime">Temps estimé : Calcul en cours...</small>
</div>
<div class="form-group mb-4">
<label class="block mb-2">Progression :</label>
<div class="progress-bar relative">
<div id="progressBar"></div>
<div id="progressText" class="absolute inset-0 flex items-center justify-center text-white font-semibold">0%</div>
</div>
</div>
<div class="d-flex justify-content-between mt-4">
<button onclick="window.location.href='/dpanel/dashboard';" class="btn btn-primary mt-3 custom-btn">Retourner au Dashboard</button>
<div class="form-group mb-4">
<p id="estimatedTime" class="text-sm text-gray-400">Temps estimé : 0 min 0 sec</p>
</div>
<div class="mx-auto">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="darkModeSwitch">
<button id="themeSwitcher" class="btn btn-warning mt-3 ml-2">Changer de Thème</button>
<button type="submit" id="uploadButton" class="btn btn-primary w-full py-2 mt-4">
<i class="fas fa-upload icon-spacing"></i>
Téléverser
</button>
</form>
<div class="text-center">
<button onclick="window.location.href='/dpanel/dashboard';" class="btn btn-secondary w-full py-2 mt-4">
<i class="fas fa-arrow-left icon-spacing"></i>
Retour au Dashboard
</button>
</div>
</div>
<button type="submit" form="uploadForm" class="btn btn-primary mt-3 custom-btn">Envoyer</button>
</div>
</div>
<script>
const uploadForm = document.getElementById('uploadForm');
const fileInput = document.getElementById('fileInput');
const progressBar = document.getElementById('progressBar');
const progressText = document.getElementById('progressText');
const estimatedTime = document.getElementById('estimatedTime');
const uploadForm = document.getElementById('uploadForm');
const body = document.body;
document.getElementById('themeSwitcher').addEventListener('click', function () {
body.classList.toggle('dark-mode');
});
uploadForm.addEventListener('submit', (event) => {
event.preventDefault();
const fileInput = document.getElementById('fileInput');
uploadForm.addEventListener('submit', async function(e) {
e.preventDefault();
const file = fileInput.files[0];
if (!file) {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Veuillez sélectionner \nun fichier avant de soumettre.',
title: 'Aucun fichier sélectionné',
showConfirmButton: false,
timer: 1800,
toast: true,
@@ -100,94 +238,79 @@
return;
}
const originalFileName = file.name;
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);
formData.append('expiryDate', document.getElementById('expiryDate').value);
formData.append('password', document.getElementById('password').value);
const xhr = new XMLHttpRequest();
xhr.open('POST', '/api/dpanel/upload', true);
xhr.upload.onprogress = (event) => {
if (event.lengthComputable) {
const percentage = Math.round((event.loaded / event.total) * 100);
const remainingTime = calculateRemainingTime(event.loaded, event.total, event.timeStamp);
updateProgress(percentage, remainingTime);
xhr.upload.addEventListener('progress', function(e) {
if (e.lengthComputable) {
const percentComplete = Math.round((e.loaded / e.total) * 100);
const remainingBytes = e.total - e.loaded;
const bytesPerSecond = e.loaded / (Date.now() - startTime);
const remainingSeconds = Math.ceil(remainingBytes / bytesPerSecond);
const minutes = Math.floor(remainingSeconds / 60);
const seconds = remainingSeconds % 60;
progressBar.style.width = `${percentComplete}%`;
progressText.textContent = `${percentComplete}%`;
estimatedTime.textContent = `Temps estimé : ${minutes} min ${seconds} sec`;
}
};
xhr.onload = () => {
});
xhr.onload = function() {
if (xhr.status === 200) {
Swal.fire({
position: 'top',
icon: 'success',
title: `Votre fichier ${originalFileName} a été téléchargé avec succès.`,
title: 'Fichier téléchargé avec succès !',
showConfirmButton: false,
timer: 1800,
toast: true,
});
} else {
Swal.fire({
position: 'top',
icon: 'error',
title: 'Erreur lors du téléchargement du fichier.',
title: 'Échec du téléchargement',
showConfirmButton: false,
timer: 1800,
toast: true,
});
console.error('Erreur lors du téléchargement du fichier.', xhr.status, xhr.responseText);
}
};
xhr.send(formData);
const startTime = Date.now();
});
function calculateRemainingTime(loaded, total, timeStamp) {
const bytesPerSecond = loaded / (timeStamp / 1000);
const remainingBytes = total - loaded;
const remainingSeconds = Math.round(remainingBytes / bytesPerSecond);
const body = document.body;
const themeSwitcher = document.getElementById('themeSwitcher');
if (remainingSeconds < 60) {
return remainingSeconds + ' seconde' + (remainingSeconds !== 1 ? 's' : '');
} else if (remainingSeconds < 3600) {
const remainingMinutes = Math.floor(remainingSeconds / 60);
const remainingSecondsPart = remainingSeconds % 60;
return remainingMinutes + ' minute' + (remainingMinutes !== 1 ? 's' : '') + ' et ' + remainingSecondsPart + ' seconde' + (remainingSecondsPart !== 1 ? 's' : '');
function setTheme(theme) {
if (theme === 'dark') {
body.classList.add('dark');
} else {
const remainingHours = Math.floor(remainingSeconds / 3600);
const remainingMinutes = Math.floor((remainingSeconds % 3600) / 60);
const remainingSecondsPart = remainingSeconds % 60;
return remainingHours + ' heure' + (remainingHours !== 1 ? 's' : '') + ' ' + remainingMinutes + ' minute' + (remainingMinutes !== 1 ? 's' : '') + ' et ' + remainingSecondsPart + ' seconde' + (remainingSecondsPart !== 1 ? 's' : '');
body.classList.remove('dark');
}
localStorage.setItem('theme', theme);
}
function updateProgress(percentage, timeRemaining) {
progressBar.style.width = percentage + '%';
progressBar.setAttribute('aria-valuenow', percentage);
progressText.textContent = percentage + '%';
estimatedTime.textContent = 'Temps estimé : ' + timeRemaining;
const savedTheme = localStorage.getItem('theme');
if (savedTheme) {
setTheme(savedTheme);
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
setTheme('dark');
}
document.addEventListener('DOMContentLoaded', function () {
const darkModeSwitch = document.getElementById('darkModeSwitch');
const body = document.body;
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
darkModeMediaQuery.addListener(function (e) {
body.classList.toggle('dark-mode', e.matches);
});
themeSwitcher.addEventListener('click', function() {
if (body.classList.contains('dark')) {
setTheme('light');
} else {
setTheme('dark');
}
});
</script>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
</body>
</html>
</html>