182 lines
9.6 KiB
Plaintext
182 lines
9.6 KiB
Plaintext
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
|
|
integrity="sha384-GLhlTQ8iRABdZLl6O5oVMWSktQOp6b7In1Zl3/JiR3eZB1+nHN/8u8UqXj2l1tji" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
|
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
|
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/toastify-js"></script>
|
|
<link rel="stylesheet" href="/public/css/styles.css" />
|
|
<script src="/public/js/folder.js"></script>
|
|
<title>Dashboard</title>
|
|
<link rel="icon" href="/public/assets/homelab_logo.png" />
|
|
</head>
|
|
|
|
<body class="light-mode">
|
|
<nav class="navbar navbar-expand-lg navbar-light bg-light header">
|
|
<a class="navbar-brand">
|
|
Dashboard CDN
|
|
<span class="badge badge-info ml-1">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 ml-auto" id="navbarNav">
|
|
<ul class="navbar-nav ml-auto">
|
|
<li class="nav-item">
|
|
<button class="btn btn-warning btn-round mr-2" onclick="window.location.href='/dpanel/dashboard';">
|
|
<i class="fas fa-home"></i>Page principal</button>
|
|
</li>
|
|
<li class="nav-item">
|
|
<form action="/dpanel/upload" class="form-inline">
|
|
<button class="btn btn-primary btn-round mr-2">
|
|
<i class="fas fa-cloud-upload-alt"></i> Téléverser un fichier
|
|
</button>
|
|
</form>
|
|
</li>
|
|
<li class="nav-item">
|
|
<button id="styleSwitcher" class="btn btn-link btn-round">
|
|
<span id="themeIcon" class="fas theme-icon"></span>
|
|
</button>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</nav>
|
|
<nav aria-label="breadcrumb">
|
|
<ol class="breadcrumb custom-breadcrumb">
|
|
<li class="breadcrumb-item"><a href="/dpanel/dashboard">Accueil</a></li>
|
|
<% let pathSegments = currentFolder.split('/'); %>
|
|
<% pathSegments.forEach((segment, index) => { %>
|
|
<% let pathSoFar = pathSegments.slice(0, index + 1).join('/'); %>
|
|
<li class="breadcrumb-item <%= (index === pathSegments.length - 1) ? 'active' : '' %>">
|
|
<% if (index === pathSegments.length - 1) { %>
|
|
<%= segment %>
|
|
<% } else { %>
|
|
<a href="/dpanel/dashboard/folder/<%= pathSoFar %>"><%= segment %></a>
|
|
<% } %>
|
|
</li>
|
|
<% }); %>
|
|
</ol>
|
|
</nav>
|
|
</body>
|
|
|
|
<% function formatSize(sizeInBytes) {
|
|
if (sizeInBytes < 1024) {
|
|
return `${sizeInBytes} octets`;
|
|
} else if (sizeInBytes < 1024 * 1024) {
|
|
return `${(sizeInBytes / 1024).toFixed(2)} Ko`;
|
|
} else if (sizeInBytes < 1024 * 1024 * 1024) {
|
|
return `${(sizeInBytes / (1024 * 1024)).toFixed(2)} Mo`;
|
|
} else {
|
|
return `${(sizeInBytes / (1024 * 1024 * 1024)).toFixed(2)} Go`;
|
|
}
|
|
}
|
|
%>
|
|
|
|
<div class="container mt-4 table-container">
|
|
<div class="table-responsive">
|
|
<table class="table w-100">
|
|
<thead>
|
|
<tr>
|
|
<th>Nom du fichier</th>
|
|
<th>Taille</th>
|
|
<th class="text-right">Action</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% files.forEach(file => { %>
|
|
<tr data-extension="<%= file.extension %>" data-type="<%= file.type %>">
|
|
<% if (fileInfoNames.includes(file.name)) { %>
|
|
<td><a href="#" onclick="showFileInfo('<%= file.name %>')"><%= file.name %></a></td>
|
|
<% } else { %>
|
|
<td><%= file.name %></td>
|
|
<% } %>
|
|
<td>
|
|
<% if (file.type === 'folder') { %>
|
|
<% const folderSize = calculateFolderSize(file.contents); %>
|
|
<%= (folderSize !== undefined && !isNaN(folderSize)) ? formatSize(folderSize) : 'Taille inconnue' %>
|
|
<% } else { %>
|
|
<%
|
|
const fileSizeInBytes = file.size;
|
|
let fileSize;
|
|
if (fileSizeInBytes !== undefined && !isNaN(fileSizeInBytes) && fileSizeInBytes >= 0) {
|
|
fileSize = formatSize(fileSizeInBytes);
|
|
} else {
|
|
console.error('Invalid file size:', fileSizeInBytes);
|
|
fileSize = 'Taille inconnue';
|
|
}
|
|
%>
|
|
<%= fileSize %>
|
|
<% } %>
|
|
</td>
|
|
<td class="d-flex justify-content-end align-items-center">
|
|
<% if (file.type === 'folder') { %>
|
|
<a href="/dpanel/dashboard/folder/<%= file.name %>" class="btn btn-primary btn-round mb-2">
|
|
<i class="fas fa-folder-open fa-xs btn-icon"></i> Accéder
|
|
</a>
|
|
<% } else { %>
|
|
<button class="btn btn-primary btn-round" onclick="renameFile('<%= folderName %>', '<%= file.name %>')">
|
|
<i class="fas fa-edit fa-xs btn-icon"></i> Renommer
|
|
</button>
|
|
<form class="file-actions mb-2" id="deleteForm" action="/api/dpanel/dashboard/delete" method="post">
|
|
<input type="hidden" name="_method" value="DELETE">
|
|
<input type="hidden" name="filename" value="<%= file.name %>">
|
|
<button class="delete-button btn btn-danger btn-round" type="button" onclick="confirmDeleteFile('<%= currentFolder %>', '<%= file.name %>')">
|
|
<i class="fas fa-trash-alt fa-xs btn-icon"></i>
|
|
</button>
|
|
</form>
|
|
<form class="file-actions mb-2">
|
|
<div class="copy-link-container d-flex align-items-center">
|
|
<input type="text" class="file-link form-control rounded mr-2" value="<%= file.url %>" readonly style="display: none;">
|
|
<button class="button copy-button btn btn-success btn-round" data-file="<%= file.name %>">
|
|
<i class="fas fa-copy fa-xs btn-icon"></i>
|
|
</button>
|
|
</div>
|
|
</form>
|
|
<form class="file-actions d-flex align-items-center mb-2" action="/api/dpanel/dashboard/movefile/<%= folderName %>" method="post">
|
|
<input type="hidden" name="fileName" value="<%= file.name %>">
|
|
<select class="form-control rounded mr-2" name="folderName">
|
|
<option value="" disabled selected>Déplacer vers...</option>
|
|
<% allFolders.forEach(folder => { %>
|
|
<option value="<%= folder %>"><%= folder %></option>
|
|
<% }); %>
|
|
</select>
|
|
<button type="submit" class="btn btn-success btn-round">Déplacer</button>
|
|
</form>
|
|
<% } %>
|
|
</td>
|
|
</tr>
|
|
<% }); %>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
<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>
|
|
|
|
<script>
|
|
|
|
</script>
|
|
|
|
<div class="container">
|
|
<footer class="py-3 my-4">
|
|
<ul class="nav justify-content-center border-bottom pb-3 mb-3">
|
|
<li class="nav-item"><a class="nav-link px-2 text-muted">Version: 1.0.0-beta.10</a></li>
|
|
</ul>
|
|
<p class="text-center text-muted">© 2024 SwiftLogic Labs</p>
|
|
</footer>
|
|
</div>
|
|
</body>
|
|
|
|
</html>
|