All checks were successful
continuous-integration/drone/push Build is passing
✨ New Features: - Dynamic permission-based context menus for files and folders - Support for collaborative folder access control - Upload to specific folders including shared folders - Changelog modal for version updates - Improved dark mode synchronization 🐛 Bug Fixes: - Fixed context menu displaying incorrect options - Fixed CSS !important override preventing dynamic menu behavior - Fixed folder collaboration permission checks - Fixed breadcrumb navigation with empty segments - Fixed "Premature close" error loop in attachments - Fixed missing user variable in admin routes - Fixed avatar loading COEP policy issues 🔒 Security: - Added security middleware (CSRF, rate limiting, input validation) - Fixed collaboration folder access validation - Improved shared folder permission handling 🎨 UI/UX Improvements: - Removed Actions column from folder view - Context menu now properly hides/shows based on permissions - Better visual feedback for collaborative folders - Improved upload flow with inline modals 🧹 Code Quality: - Added collaboration data to folder routes - Refactored context menu logic for better maintainability - Added debug logging for troubleshooting - Improved file upload handling with chunking support
722 lines
35 KiB
Plaintext
722 lines
35 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="fr">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Dashboard CDN</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>
|
|
<link rel="stylesheet" href="../public/css/dashboard.styles.css">
|
|
<link rel="stylesheet" href="../public/css/dropdown-fixes.css">
|
|
<style>
|
|
/* Changelog Modal Styles */
|
|
#changelogModal .modal-content {
|
|
border: none;
|
|
box-shadow: 0 10px 40px rgba(0,0,0,0.2);
|
|
border-radius: 15px;
|
|
}
|
|
|
|
#changelogModal .modal-header {
|
|
border-top-left-radius: 15px;
|
|
border-top-right-radius: 15px;
|
|
border-bottom: none;
|
|
}
|
|
|
|
#changelogModal .modal-body ul li {
|
|
padding: 8px 0;
|
|
transition: all 0.2s ease;
|
|
}
|
|
|
|
#changelogModal .modal-body ul li:hover {
|
|
padding-left: 10px;
|
|
background-color: rgba(102, 126, 234, 0.05);
|
|
border-radius: 5px;
|
|
}
|
|
|
|
#changelogModal .modal-footer {
|
|
border-top: 1px solid #e9ecef;
|
|
}
|
|
|
|
@keyframes pulse {
|
|
0%, 100% {
|
|
opacity: 1;
|
|
}
|
|
50% {
|
|
opacity: 0.6;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
background-image: url('<%= user.wallpaper %>');
|
|
background-size: cover;
|
|
background-position: center;
|
|
background-repeat: no-repeat;
|
|
background-attachment: fixed;
|
|
margin: 0;
|
|
min-height: 100vh;
|
|
display: flex;
|
|
flex-direction: column;
|
|
}
|
|
</style>
|
|
</head>
|
|
<body class="animate">
|
|
|
|
<nav class="navbar navbar-expand-md navbar-light bg-light header">
|
|
<div class="container-fluid">
|
|
<a class="navbar-brand" href="/dpanel/dashboard">
|
|
Dashboard CDN
|
|
<span class="bg-purple-100 text-purple-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-full dark:bg-purple-900 dark:text-purple-300">Beta</span>
|
|
</a>
|
|
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav"
|
|
aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
|
|
<span class="navbar-toggler-icon"></span>
|
|
</button>
|
|
<div class="collapse navbar-collapse" id="navbarNav">
|
|
<ul class="navbar-nav ml-auto">
|
|
<li class="nav-item">
|
|
<button type="button" class="btn btn-primary" id="uploadToDashboardBtn">
|
|
<i class="fas fa-cloud-upload-alt"></i> Téléverser
|
|
</button>
|
|
</li>
|
|
<li class="nav-item">
|
|
<button type="button" class="btn btn-success" id="newFolderBtn">
|
|
<i class="fas fa-folder-open"></i> Nouveau
|
|
</button>
|
|
</li>
|
|
<li class="nav-item dropdown">
|
|
<button class="btn dropdown-toggle nav-btn" id="accountDropdownBtn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
|
<img
|
|
src="<%= user.profilePicture ? user.profilePicture : `https://api.dicebear.com/7.x/initials/svg?seed=${encodeURIComponent(user.name)}&background=%234e54c8&radius=50` %>"
|
|
alt="<%= user.name %>"
|
|
class="rounded-full user-avatar"
|
|
style="width: 40px; height: 40px;"
|
|
onerror="this.src=`https://api.dicebear.com/7.x/initials/svg?seed=${encodeURIComponent('<%= user.name %>')}&background=%234e54c8&radius=50`"
|
|
/>
|
|
</button>
|
|
<div class="dropdown-menu dropdown-menu-right" id="accountDropdownMenu">
|
|
<a class="dropdown-item" href="/dpanel/dashboard/profil">
|
|
<span style="display: inline-block; width: 20px; text-align: center;">
|
|
<i class="fas fa-user"></i>
|
|
</span>
|
|
Mon profil
|
|
</a>
|
|
<% if (user.role === 'admin') { %>
|
|
<a class="dropdown-item" href="/dpanel/dashboard/admin">
|
|
<span style="display: inline-block; width: 20px; text-align: center;">
|
|
<i class="fas fa-user-shield"></i>
|
|
</span>
|
|
Administration du site
|
|
</a>
|
|
<% } %>
|
|
<div class="dropdown-divider"></div>
|
|
<a class="dropdown-item" href="#" id="showChangelogBtn">
|
|
<span style="display: inline-block; width: 20px; text-align: center;">
|
|
<i class="fas fa-rocket"></i>
|
|
</span>
|
|
Nouveautés v1.2.0-beta
|
|
<span class="badge badge-danger ml-2" style="animation: pulse 2s infinite;">Nouveau</span>
|
|
</a>
|
|
<div class="dropdown-divider"></div>
|
|
<a class="dropdown-item" href="/auth/logout">
|
|
<span style="display: inline-block; width: 20px; text-align: center;">
|
|
<i class="fas fa-sign-out-alt"></i>
|
|
</span>
|
|
Déconnexion
|
|
</a>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</nav>
|
|
|
|
|
|
<div class="container mt-4 animate">
|
|
<!-- Menu contextuel -->
|
|
<div id="contextMenu" class="context-menu" style="display: none; position: fixed; z-index: 1000;">
|
|
<a href="#" class="context-item-open menu-item">
|
|
<i class="fas fa-folder-open"></i> <span>Ouvrir</span>
|
|
</a>
|
|
<button class="context-item-rename menu-item">
|
|
<i class="fas fa-edit"></i> <span>Renommer</span>
|
|
</button>
|
|
<button class="context-item-collaborate menu-item">
|
|
<i class="fas fa-users"></i> <span>Collaborer</span>
|
|
</button>
|
|
<button class="context-item-share menu-item">
|
|
<i class="fas fa-share-alt"></i> <span>Copier le lien</span>
|
|
</button>
|
|
<button class="context-item-move menu-item">
|
|
<i class="fas fa-file-export"></i> <span>Déplacer</span>
|
|
</button>
|
|
<button class="context-item-leave menu-item" style="color: #f59e0b;">
|
|
<i class="fas fa-sign-out-alt"></i> <span>Quitter ce dossier</span>
|
|
</button>
|
|
<div class="menu-separator"></div>
|
|
<button class="context-item-delete menu-item destructive" style="color: #ef4444;">
|
|
<i class="fas fa-trash-alt"></i> <span>Supprimer</span>
|
|
</button>
|
|
</div>
|
|
|
|
<div class="form-container">
|
|
<div class="flex justify-between items-center mb-4">
|
|
<input type="text" id="searchInput" class="form-control w-1/2" placeholder="Rechercher par nom de fichier">
|
|
<button id="searchButton" class="btn btn-primary">Rechercher</button>
|
|
</div>
|
|
|
|
<div class="table-responsive">
|
|
<table class="table" id="fileTable">
|
|
<thead>
|
|
<tr>
|
|
<th>Nom</th>
|
|
<th class="text-center">Type</th>
|
|
<th class="text-center">Propriétaire</th>
|
|
<th class="text-center">Taille</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<!-- Dossiers personnels -->
|
|
<% files.filter(item => item.type === 'folder').forEach(folder => { %>
|
|
<tr data-type="folder" data-name="<%= folder.name %>" data-url="/dpanel/dashboard/folder/<%= encodeURIComponent(folder.name) %>" class="hover:bg-gray-50">
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<i class="fas fa-folder text-warning mr-2"></i>
|
|
<%= folder.name %>
|
|
<% if (folder.isCollaborative) { %>
|
|
<span class="ml-2 badge badge-info collaboration-badge">
|
|
<i class="fas fa-users"></i>
|
|
<span class="active-users-count"><%= folder.activeUsers.length %></span>
|
|
</span>
|
|
<% } %>
|
|
</div>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="badge badge-warning">Dossier</span>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="text-muted">
|
|
<i class="fas fa-user"></i>
|
|
moi
|
|
</span>
|
|
</td>
|
|
<td class="text-center">-</td>
|
|
</tr>
|
|
<% }); %>
|
|
|
|
<!-- Dossiers partagés -->
|
|
<% if (sharedFolders && sharedFolders.length > 0) { %>
|
|
<% sharedFolders.forEach(folder => { %>
|
|
<tr data-type="shared-folder" data-name="<%= folder.folderName %>" data-url="/dpanel/dashboard/folder/shared/<%= folder.owner %>/<%= encodeURIComponent(folder.folderName) %>" class="hover:bg-gray-50">
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<i class="fas fa-folder-open text-info mr-2"></i>
|
|
<%= folder.folderName %>
|
|
<span class="ml-2 badge badge-info collaboration-badge">
|
|
<i class="fas fa-users"></i>
|
|
<span class="active-users-count"><%= folder.activeUsers.length %></span>
|
|
</span>
|
|
</div>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="badge badge-info">Dossier partagé</span>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="text-muted">
|
|
<i class="fas fa-user"></i>
|
|
<%= folder.owner === userData.name ? 'moi' : folder.owner %>
|
|
</span>
|
|
</td>
|
|
<td class="text-center">-</td>
|
|
</tr>
|
|
<% }); %>
|
|
<% } %>
|
|
|
|
<!-- Fichiers -->
|
|
<% files.filter(item => item.type === 'file').forEach(file => { %>
|
|
<tr data-type="file" data-name="<%= file.name %>" data-url="<%= file.url %>" class="hover:bg-gray-50">
|
|
<td>
|
|
<div class="d-flex align-items-center">
|
|
<i class="fas fa-file text-secondary mr-2"></i>
|
|
<%= file.name %>
|
|
</div>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="badge badge-secondary">Fichier</span>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="text-muted">
|
|
<i class="fas fa-user"></i>
|
|
moi
|
|
</span>
|
|
</td>
|
|
<td class="text-center">
|
|
<span class="file-size" data-size="<%= file.size %>">
|
|
<%= file.size %> octets
|
|
</span>
|
|
</td>
|
|
</tr>
|
|
<% }); %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<footer class="footer mt-auto py-3 bg-light">
|
|
<div class="container">
|
|
<span class="text-muted">Version: <span id="version-number">...</span> | © <span id="current-year"></span> Myaxrin Labs</span>
|
|
<a href="#" class="float-right" onclick="displayMetadata()">Metadata</a>
|
|
</div>
|
|
</footer>
|
|
|
|
<script>
|
|
document.getElementById('current-year').textContent = new Date().getFullYear();
|
|
</script>
|
|
|
|
<div class="modal fade" id="metadataModal" tabindex="-1" role="dialog" aria-labelledby="metadataModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="metadataModalLabel">Metadata</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<p><i class="fas fa-code-branch"></i> Version de Build: <span id="buildVersion"></span></p>
|
|
<p><i class="fab fa-node"></i> Version de Node.js: <span id="nodeVersion"></span></p>
|
|
<p><i class="fas fa-server"></i> Version de Express.js: <span id="expressVersion"></span></p>
|
|
<p><i class="fas fa-hashtag"></i> SHA de Build: <span id="buildSha"></span></p>
|
|
<p><i class="fas fa-windows"></i> Type d'OS: <span id="osType"></span></p>
|
|
<p><i class="fas fa-laptop-code"></i> Version d'OS: <span id="osRelease"></span></p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="moveFileModal" tabindex="-1" role="dialog" aria-labelledby="moveFileModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Déplacer le fichier</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="moveFileForm">
|
|
<input type="hidden" id="moveFileName" name="fileName">
|
|
<select class="form-control" id="moveFolderSelect" name="folderName">
|
|
<option value="" disabled selected>Choisir un dossier...</option>
|
|
<% allFolders.forEach(folder => { %>
|
|
<option value="<%= folder.name %>"><%= folder.name %></option>
|
|
<% }); %>
|
|
</select>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
|
|
<button type="button" class="btn btn-primary" id="confirmMoveFile">Déplacer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Modal Collaboration -->
|
|
<div class="modal fade" id="collaborationModal" tabindex="-1" aria-labelledby="collaborationModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title" id="collaborationModalLabel">Gestion de la collaboration</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<div class="collaboration-users mb-4">
|
|
<!-- Liste des utilisateurs -->
|
|
</div>
|
|
<div class="add-collaborator">
|
|
<h6 class="mb-3">Ajouter un collaborateur</h6>
|
|
<div class="input-group mb-3">
|
|
<input type="text" id="searchCollabUser" class="form-control" placeholder="Rechercher un utilisateur">
|
|
<div class="input-group-append">
|
|
<button class="btn btn-outline-secondary" type="button" id="searchCollabBtn">
|
|
<i class="fas fa-search"></i>
|
|
</button>
|
|
</div>
|
|
</div>
|
|
<div id="searchCollabResults" class="mb-3">
|
|
<!-- Résultats de recherche -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer justify-content-between">
|
|
<button type="button" class="btn btn-danger" id="disableCollabBtn">
|
|
<i class="fas fa-users-slash"></i> Désactiver la collaboration
|
|
</button>
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Fermer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- Changelog Modal -->
|
|
<div class="modal fade" id="changelogModal" tabindex="-1" role="dialog" aria-labelledby="changelogModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header" style="background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white;">
|
|
<h5 class="modal-title" id="changelogModalLabel">
|
|
<i class="fas fa-rocket"></i> Nouveautés - Version 1.2.0-beta
|
|
</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer" style="color: white; opacity: 1;">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body" style="max-height: 70vh; overflow-y: auto;">
|
|
<!-- Nouvelles fonctionnalités -->
|
|
<div class="mb-4">
|
|
<h6 class="text-primary font-weight-bold mb-3">
|
|
<i class="fas fa-star text-warning"></i> Nouvelles Fonctionnalités
|
|
</h6>
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fas fa-check-circle text-success mr-2"></i>
|
|
<strong>Upload direct dans les dossiers</strong> - Téléversez vos fichiers directement dans n'importe quel dossier avec le bouton "Téléverser ici"
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-check-circle text-success mr-2"></i>
|
|
<strong>Upload dans dossiers partagés</strong> - Collaborez en uploadant des fichiers dans les dossiers partagés avec vous
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-check-circle text-success mr-2"></i>
|
|
<strong>Menu contextuel amélioré</strong> - Clic droit sur fichiers/dossiers pour actions rapides (Renommer, Copier, Déplacer, Supprimer)
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-check-circle text-success mr-2"></i>
|
|
<strong>Double-clic pour ouvrir</strong> - Double-cliquez sur un fichier pour l'ouvrir ou un dossier pour naviguer
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-check-circle text-success mr-2"></i>
|
|
<strong>Upload modal dans dashboard</strong> - Plus besoin de redirection, uploadez directement depuis le dashboard
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-check-circle text-success mr-2"></i>
|
|
<strong>Dark mode synchronisé</strong> - Le thème sombre est maintenant synchronisé sur toutes les pages
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Améliorations -->
|
|
<div class="mb-4">
|
|
<h6 class="text-info font-weight-bold mb-3">
|
|
<i class="fas fa-magic"></i> Améliorations
|
|
</h6>
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fas fa-arrow-up text-info mr-2"></i>
|
|
Interface simplifiée - Colonne "Actions" supprimée pour plus de clarté
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-arrow-up text-info mr-2"></i>
|
|
SweetAlert2 intégré - Toutes les confirmations utilisent maintenant des modales élégantes
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-arrow-up text-info mr-2"></i>
|
|
Breadcrumb corrigé - Navigation par fil d'Ariane améliorée
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-arrow-up text-info mr-2"></i>
|
|
Upload par chunks optimisé - Meilleure gestion des gros fichiers (jusqu'à 1GB)
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Corrections de bugs -->
|
|
<div class="mb-4">
|
|
<h6 class="text-danger font-weight-bold mb-3">
|
|
<i class="fas fa-bug"></i> Corrections de Bugs
|
|
</h6>
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fas fa-wrench text-danger mr-2"></i>
|
|
Résolution des erreurs de statistiques manquantes dans l'admin
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-wrench text-danger mr-2"></i>
|
|
Correction CORS/COEP pour les avatars DiceBear
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-wrench text-danger mr-2"></i>
|
|
Fichier dropdown-fixes.css créé (erreur 404 corrigée)
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-wrench text-danger mr-2"></i>
|
|
Erreurs JavaScript dans folder.js corrigées
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-wrench text-danger mr-2"></i>
|
|
Violation CSP pour CDN Tailwind corrigée
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-wrench text-danger mr-2"></i>
|
|
Variable user manquante dans les routes admin ajoutée
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-wrench text-danger mr-2"></i>
|
|
Fonction initForm manquante créée
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<!-- Sécurité -->
|
|
<div class="mb-3">
|
|
<h6 class="text-warning font-weight-bold mb-3">
|
|
<i class="fas fa-shield-alt"></i> Sécurité
|
|
</h6>
|
|
<ul class="list-unstyled">
|
|
<li class="mb-2">
|
|
<i class="fas fa-lock text-warning mr-2"></i>
|
|
Vérification des permissions pour dossiers partagés
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-lock text-warning mr-2"></i>
|
|
Génération automatique de noms de fichiers sécurisés
|
|
</li>
|
|
<li class="mb-2">
|
|
<i class="fas fa-lock text-warning mr-2"></i>
|
|
Headers de sécurité optimisés
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<div class="text-center text-muted small">
|
|
<p class="mb-1">Merci d'utiliser CDN-APP-INSIDER !</p>
|
|
<p class="mb-0">
|
|
<i class="fas fa-heart text-danger"></i>
|
|
Développé par <strong>Dinawo - Group Myaxrin Labs</strong>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-primary" data-dismiss="modal">Fermer</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="modal fade" id="uploadModal" tabindex="-1" role="dialog" aria-labelledby="uploadModalLabel" aria-hidden="true">
|
|
<div class="modal-dialog modal-dialog-centered" role="document">
|
|
<div class="modal-content">
|
|
<div class="modal-header">
|
|
<h5 class="modal-title">Téléverser dans le dossier racine</h5>
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
|
|
<span aria-hidden="true">×</span>
|
|
</button>
|
|
</div>
|
|
<div class="modal-body">
|
|
<form id="dashboardUploadForm">
|
|
<div class="form-group">
|
|
<label for="uploadFileInput">Sélectionnez un fichier :</label>
|
|
<input type="file" class="form-control" id="uploadFileInput" name="file" required>
|
|
<small class="form-text text-muted">Taille maximale : 1 GB</small>
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="uploadExpiryDate">Date d'expiration (optionnel) :</label>
|
|
<input type="date" class="form-control" id="uploadExpiryDate" name="expiryDate">
|
|
</div>
|
|
<div class="form-group">
|
|
<label for="uploadPassword">Mot de passe (optionnel) :</label>
|
|
<input type="password" class="form-control" id="uploadPassword" name="password" placeholder="Au moins 6 caractères">
|
|
</div>
|
|
<div class="progress" id="uploadProgress" style="display: none;">
|
|
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%">
|
|
<span class="sr-only">0% Complete</span>
|
|
</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-dismiss="modal">Annuler</button>
|
|
<button type="button" class="btn btn-primary" id="confirmUpload">
|
|
<i class="fas fa-upload"></i> Téléverser
|
|
</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<script src="https://code.jquery.com/jquery-3.6.0.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>
|
|
<script src="/public/js/dashboard.js"></script>
|
|
<script>
|
|
// Upload functionality
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Afficher le changelog uniquement si l'utilisateur ne l'a pas encore vu pour cette version
|
|
const changelogVersion = '1.2.0-beta';
|
|
const seenChangelog = localStorage.getItem('changelog_seen_' + changelogVersion);
|
|
|
|
if (!seenChangelog) {
|
|
// Délai de 1 seconde pour laisser la page se charger
|
|
setTimeout(function() {
|
|
$('#changelogModal').modal('show');
|
|
}, 1000);
|
|
|
|
// Marquer comme vu quand la modal est fermée
|
|
$('#changelogModal').on('hidden.bs.modal', function() {
|
|
localStorage.setItem('changelog_seen_' + changelogVersion, 'true');
|
|
});
|
|
}
|
|
|
|
// Bouton pour voir le changelog manuellement
|
|
const showChangelogBtn = document.getElementById('showChangelogBtn');
|
|
if (showChangelogBtn) {
|
|
showChangelogBtn.addEventListener('click', function(e) {
|
|
e.preventDefault();
|
|
$('#changelogModal').modal('show');
|
|
});
|
|
}
|
|
|
|
document.getElementById('uploadToDashboardBtn').addEventListener('click', function() {
|
|
$('#uploadModal').modal('show');
|
|
});
|
|
|
|
const CHUNK_SIZE = 5 * 1024 * 1024; // 5MB chunks
|
|
|
|
async function generateSecurityCode() {
|
|
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
|
|
let code = '';
|
|
for (let i = 0; i < 6; i++) {
|
|
code += characters.charAt(Math.floor(Math.random() * characters.length));
|
|
}
|
|
return code;
|
|
}
|
|
|
|
async function formatSecureFileName(originalFileName) {
|
|
const now = new Date();
|
|
const date = now.toISOString().slice(0,10).replace(/-/g, '');
|
|
const securityCode = await generateSecurityCode();
|
|
|
|
const lastDot = originalFileName.lastIndexOf('.');
|
|
const fileName = lastDot !== -1 ? originalFileName.substring(0, lastDot) : originalFileName;
|
|
const fileExt = lastDot !== -1 ? originalFileName.substring(lastDot) : '';
|
|
|
|
return `${date}_${securityCode}_${fileName}${fileExt}`;
|
|
}
|
|
|
|
document.getElementById('confirmUpload').addEventListener('click', async function() {
|
|
const fileInput = document.getElementById('uploadFileInput');
|
|
const file = fileInput.files[0];
|
|
|
|
if (!file) {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Erreur',
|
|
text: 'Veuillez sélectionner un fichier'
|
|
});
|
|
return;
|
|
}
|
|
|
|
const MAX_FILE_SIZE = 1024 * 1024 * 1024; // 1GB
|
|
if (file.size > MAX_FILE_SIZE) {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Fichier trop volumineux',
|
|
text: 'La taille maximale est de 1 GB'
|
|
});
|
|
return;
|
|
}
|
|
|
|
const password = document.getElementById('uploadPassword').value;
|
|
if (password && password.length < 6) {
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Erreur',
|
|
text: 'Le mot de passe doit contenir au moins 6 caractères'
|
|
});
|
|
return;
|
|
}
|
|
|
|
const expiryDate = document.getElementById('uploadExpiryDate').value;
|
|
const secureFileName = await formatSecureFileName(file.name);
|
|
|
|
const totalChunks = Math.ceil(file.size / CHUNK_SIZE);
|
|
let uploadedChunks = 0;
|
|
|
|
const progressBar = document.querySelector('#uploadProgress .progress-bar');
|
|
document.getElementById('uploadProgress').style.display = 'block';
|
|
document.getElementById('confirmUpload').disabled = true;
|
|
|
|
try {
|
|
for (let chunkIndex = 0; chunkIndex < totalChunks; chunkIndex++) {
|
|
const start = chunkIndex * CHUNK_SIZE;
|
|
const end = Math.min(start + CHUNK_SIZE, file.size);
|
|
const chunk = file.slice(start, end);
|
|
|
|
const formData = new FormData();
|
|
formData.append('file', chunk);
|
|
formData.append('chunkIndex', chunkIndex);
|
|
formData.append('totalChunks', totalChunks);
|
|
formData.append('filename', secureFileName);
|
|
formData.append('originalFilename', file.name);
|
|
formData.append('targetFolder', ''); // Dossier racine
|
|
|
|
if (expiryDate) formData.append('expiryDate', expiryDate);
|
|
if (password) formData.append('password', password);
|
|
|
|
const response = await fetch('/api/dpanel/upload', {
|
|
method: 'POST',
|
|
body: formData
|
|
});
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Upload failed: ${response.statusText}`);
|
|
}
|
|
|
|
uploadedChunks++;
|
|
const progress = (uploadedChunks / totalChunks) * 100;
|
|
progressBar.style.width = progress + '%';
|
|
progressBar.textContent = Math.round(progress) + '%';
|
|
}
|
|
|
|
Swal.fire({
|
|
icon: 'success',
|
|
title: 'Fichier téléversé !',
|
|
text: 'Le fichier a été téléversé avec succès'
|
|
}).then(() => {
|
|
location.reload();
|
|
});
|
|
|
|
$('#uploadModal').modal('hide');
|
|
|
|
} catch (error) {
|
|
console.error('Upload error:', error);
|
|
Swal.fire({
|
|
icon: 'error',
|
|
title: 'Erreur',
|
|
text: 'Une erreur est survenue lors du téléversement'
|
|
});
|
|
} finally {
|
|
document.getElementById('confirmUpload').disabled = false;
|
|
document.getElementById('uploadProgress').style.display = 'none';
|
|
progressBar.style.width = '0%';
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |