Note: We appreciate your feedback and bug reports to continue improving our platform. Thank you for your continued support!
This commit is contained in:
@@ -1,142 +1,316 @@
|
||||
<!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://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@10"></script>
|
||||
<link rel="stylesheet" href="/public/css/login.css">
|
||||
<title>Parameter Admin</title>
|
||||
<title>Gestion des utilisateurs</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;
|
||||
min-height: 100vh;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
@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: 90%;
|
||||
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-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;
|
||||
padding: 0.5rem 1rem;
|
||||
}
|
||||
|
||||
.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; }
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
}
|
||||
|
||||
.table {
|
||||
width: 100%;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0;
|
||||
}
|
||||
|
||||
.table th,
|
||||
.table td {
|
||||
padding: 0.75rem;
|
||||
vertical-align: top;
|
||||
border-top: 1px solid hsl(var(--border));
|
||||
}
|
||||
|
||||
.table thead th {
|
||||
vertical-align: bottom;
|
||||
border-bottom: 2px solid hsl(var(--border));
|
||||
}
|
||||
|
||||
.pagination {
|
||||
display: flex;
|
||||
padding-left: 0;
|
||||
list-style: none;
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.page-item.active .page-link {
|
||||
z-index: 1;
|
||||
color: hsl(var(--primary-foreground));
|
||||
background-color: hsl(var(--primary));
|
||||
border-color: hsl(var(--primary));
|
||||
}
|
||||
|
||||
.page-link {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: 0.5rem 0.75rem;
|
||||
margin-left: -1px;
|
||||
line-height: 1.25;
|
||||
color: hsl(var(--primary));
|
||||
background-color: hsl(var(--background));
|
||||
border: 1px solid hsl(var(--border));
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="animate">
|
||||
<div class="container mt-4 animate">
|
||||
<h2 class="text-3xl font-semibold mb-6 text-center">Gestion des utilisateurs</h2>
|
||||
|
||||
<style>
|
||||
.pagination .active .page-link {
|
||||
background-color: #007bff !important;
|
||||
color: white !important;
|
||||
}
|
||||
<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 ou ID">
|
||||
<span id="shortcutHint" class="text-sm text-gray-500"></span>
|
||||
<button id="searchButton" class="btn btn-primary">Rechercher</button>
|
||||
<select id="usersPerPage" class="form-control w-auto">
|
||||
<option value="10">10</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
<option value="500">500</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
.table-container {
|
||||
max-width: 90%;
|
||||
}
|
||||
|
||||
#searchInput {
|
||||
flex-grow: 1;
|
||||
}
|
||||
#searchButton {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.custom-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
font-family: inherit;
|
||||
font-weight: 500;
|
||||
font-size: 14px; /* réduit la taille de la police */
|
||||
padding: 0.6em 1.2em; /* réduit le padding */
|
||||
color: white;
|
||||
background: linear-gradient(0deg, rgba(77,54,208,1) 0%, rgba(132,116,254,1) 100%);
|
||||
border: none;
|
||||
box-shadow: 0 0.7em 1.5em -0.5em #4d36d0be;
|
||||
letter-spacing: 0.05em;
|
||||
border-radius: 15em; /* réduit le rayon de la bordure */
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
<body class="light-mode animate">
|
||||
<div class="container mt-4 table-container animate">
|
||||
<h2 class="text-center">Gestion des utilisateurs</h2><br>
|
||||
<div class="d-flex justify-content-between align-items-center">
|
||||
<input type="text" id="searchInput" class="form-control rounded mr-2" placeholder="Rechercher par nom ou ID">
|
||||
<span id="shortcutHint" class="mr-2 align-self-center"></span>
|
||||
<button id="searchButton" class="btn btn-primary custom-btn">Rechercher</button>
|
||||
<select id="usersPerPage" class="form-control rounded ml-2" style="width: auto;">
|
||||
<option value="10">10</option>
|
||||
<option value="50">50</option>
|
||||
<option value="100">100</option>
|
||||
<option value="500">500</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="table-responsive mt-2">
|
||||
<table class="table w-100 table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Nom</th>
|
||||
<th>Rôle</th>
|
||||
<th class="text-right">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% users.forEach(user => { %>
|
||||
<div class="table-responsive">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<td><%= user.id %></td>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.role %></td>
|
||||
<td>
|
||||
<form id="update-role-form" action="/api/dpanel/dashboard/admin/update-role" method="POST" class="d-flex align-items-center">
|
||||
<input type="hidden" name="id" value="<%= user.id %>">
|
||||
<input type="hidden" name="name" value="<%= user.name %>">
|
||||
<select class="form-control rounded mr-2" name="role">
|
||||
<option value="user" <%= user.role === 'user' ? 'selected' : '' %>>User</option>
|
||||
<option value="admin" <%= user.role === 'admin' ? 'selected' : '' %>>Admin</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary btn-round custom-btn">Mettre à jour</button>
|
||||
</form>
|
||||
<form id="generate-token-form" action="/api/dpanel/generate-token" method="POST" class="d-flex align-items-center mt-2">
|
||||
<input type="hidden" name="id" value="<%= user.id %>">
|
||||
<input type="hidden" name="name" value="<%= user.name %>">
|
||||
<button type="submit" class="btn btn-secondary btn-round custom-btn">Générer Token</button>
|
||||
</form>
|
||||
</td>
|
||||
<th>ID</th>
|
||||
<th>Nom</th>
|
||||
<th>Rôle</th>
|
||||
<th>Photo</th>
|
||||
<th class="text-right">Action</th>
|
||||
</tr>
|
||||
<% }) %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-center">
|
||||
<% for(let i = 1; i <= pages; i++) { %>
|
||||
<li class="page-item <%= i === currentPage ? 'active' : '' %>">
|
||||
<a class="page-link" href="/dpanel/dashboard/admin/users?page=<%= i %>&limit=<%= limit %>"><%= i %></a>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</nav>
|
||||
<div class="d-flex justify-content-center align-items-center">
|
||||
<a class="dropdown-item text-center text-white no-hover custom-btn" href="/dpanel/dashboard/admin/" style="max-width: 250px; padding: 10px;">
|
||||
<i class="fas fa-sign-out-alt text-white "></i> Retourner au dashboard admin
|
||||
</a>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% users.forEach(user => { %>
|
||||
<tr>
|
||||
<td><%= user.id %></td>
|
||||
<td><%= user.name %></td>
|
||||
<td><%= user.role %></td>
|
||||
<td>
|
||||
<div class="profile-picture text-center mb-6">
|
||||
<a class="btn btn-secondary" id="accountDropdownBtn" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<img
|
||||
src="<%= user.profilePicture || 'https://api.dicebear.com/7.x/initials/svg?seed=' + user.name %>"
|
||||
alt="User Icon"
|
||||
class="rounded-full"
|
||||
style="max-width: 90px; max-height: 80px;"
|
||||
/>
|
||||
</a>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<form id="update-role-form" action="/api/dpanel/dashboard/admin/update-role" method="POST" class="flex items-center">
|
||||
<input type="hidden" name="id" value="<%= user.id %>">
|
||||
<input type="hidden" name="name" value="<%= user.name %>">
|
||||
<select class="form-control mr-2" name="role">
|
||||
<option value="user" <%= user.role === 'user' ? 'selected' : '' %>>User</option>
|
||||
<option value="admin" <%= user.role === 'admin' ? 'selected' : '' %>>Admin</option>
|
||||
</select>
|
||||
<button type="submit" class="btn btn-primary">Mettre à jour</button>
|
||||
</form>
|
||||
<form id="generate-token-form" action="/api/dpanel/generate-token" method="POST" class="flex items-center mt-2">
|
||||
<input type="hidden" name="id" value="<%= user.id %>">
|
||||
<input type="hidden" name="name" value="<%= user.name %>">
|
||||
<button type="submit" class="btn btn-secondary">Générer Token</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<% }) %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<nav aria-label="Page navigation" class="mt-4">
|
||||
<ul class="pagination justify-center">
|
||||
<% for(let i = 1; i <= pages; i++) { %>
|
||||
<li class="page-item <%= i === currentPage ? 'active' : '' %>">
|
||||
<a class="page-link" href="/dpanel/dashboard/admin/users?page=<%= i %>&limit=<%= limit %>"><%= i %></a>
|
||||
</li>
|
||||
<% } %>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
<div class="flex justify-center mt-4">
|
||||
<a href="/dpanel/dashboard/admin/" class="btn btn-secondary">
|
||||
<i class="fas fa-sign-out-alt mr-2"></i> Retourner au dashboard admin
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-center animate">
|
||||
<button id="themeSwitcher" class="btn btn-warning mt-3 animate ">Changer de Thème</button>
|
||||
</div>
|
||||
<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>
|
||||
|
||||
<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>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const darkModeSwitch = document.getElementById('darkModeSwitch');
|
||||
const darkModeMediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
||||
document.body.classList.toggle('dark-mode', darkModeMediaQuery.matches);
|
||||
darkModeMediaQuery.addListener(function (e) {
|
||||
document.body.classList.toggle('dark-mode', e.matches);
|
||||
});
|
||||
});
|
||||
const body = document.body;
|
||||
const themeSwitcher = document.getElementById('themeSwitcher');
|
||||
|
||||
document.getElementById('themeSwitcher').addEventListener('click', function () {
|
||||
document.body.classList.toggle('dark-mode');
|
||||
function setTheme(theme) {
|
||||
if (theme === 'dark') {
|
||||
body.classList.add('dark');
|
||||
} else {
|
||||
body.classList.remove('dark');
|
||||
}
|
||||
localStorage.setItem('theme', theme);
|
||||
}
|
||||
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
if (savedTheme) {
|
||||
setTheme(savedTheme);
|
||||
} else if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
setTheme('dark');
|
||||
}
|
||||
|
||||
themeSwitcher.addEventListener('click', function() {
|
||||
if (body.classList.contains('dark')) {
|
||||
setTheme('light');
|
||||
} else {
|
||||
setTheme('dark');
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('usersPerPage').addEventListener('change', function () {
|
||||
@@ -178,7 +352,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
// Ajout d'un événement pour les formulaires de génération de token
|
||||
document.querySelectorAll('form[id="generate-token-form"]').forEach(form => {
|
||||
form.addEventListener('submit', function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
Reference in New Issue
Block a user