Files
loustique-home/flask/templates/admin.html

409 lines
13 KiB
HTML
Raw Normal View History

2026-03-24 23:06:07 +01:00
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2026-03-26 14:47:53 +01:00
<title>Loustiques Home - Admin</title>
2026-03-24 23:06:07 +01:00
<style>
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
2026-03-26 14:47:53 +01:00
font-family: system-ui, sans-serif;
background: #1f1f1f;
color: #f0f0f0;
2026-03-24 23:06:07 +01:00
min-height: 100vh;
display: flex;
}
aside {
width: 220px;
min-height: 100vh;
2026-03-26 14:47:53 +01:00
background: #1a1a1a;
border-right: 1px solid #2e2e2e;
2026-03-24 23:06:07 +01:00
display: flex;
flex-direction: column;
padding: 2rem 1.25rem;
position: fixed;
top: 0; left: 0; bottom: 0;
}
.logo {
2026-03-26 14:47:53 +01:00
font-size: 20px;
font-weight: 700;
color: #f0f0f0;
2026-03-24 23:06:07 +01:00
margin-bottom: 2.5rem;
padding-bottom: 1.5rem;
2026-03-26 14:47:53 +01:00
border-bottom: 1px solid #2e2e2e;
2026-03-24 23:06:07 +01:00
}
.logo span {
display: block;
2026-03-26 14:47:53 +01:00
font-size: 15px;
color: #666;
2026-03-24 23:06:07 +01:00
margin-top: 4px;
2026-03-26 14:47:53 +01:00
font-weight: 400;
2026-03-24 23:06:07 +01:00
}
nav a {
display: flex;
align-items: center;
gap: 10px;
padding: 8px 10px;
border-radius: 6px;
2026-03-26 14:47:53 +01:00
font-size: 13px;
color: #888;
2026-03-24 23:06:07 +01:00
text-decoration: none;
margin-bottom: 2px;
transition: all 0.15s;
}
nav a.active, nav a:hover {
2026-03-26 14:47:53 +01:00
background: #2e2e3a;
color: #2563eb;
2026-03-24 23:06:07 +01:00
}
nav a svg { width: 15px; height: 15px; flex-shrink: 0; }
.sidebar-footer {
margin-top: auto;
2026-03-26 14:47:53 +01:00
font-size: 15px;
color: #555;
2026-03-24 23:06:07 +01:00
padding-top: 1rem;
2026-03-26 14:47:53 +01:00
border-top: 1px solid #2e2e2e;
2026-03-24 23:06:07 +01:00
}
main {
margin-left: 220px;
flex: 1;
padding: 2.5rem 3rem;
max-width: 900px;
}
2026-03-26 14:47:53 +01:00
.page-header {
margin-bottom: 2.5rem;
2026-03-24 23:06:07 +01:00
}
.page-header h1 {
font-size: 22px;
font-weight: 700;
2026-03-26 14:47:53 +01:00
margin-bottom: 4px;
2026-03-24 23:06:07 +01:00
}
.page-header p {
font-size: 14px;
2026-03-26 14:47:53 +01:00
color: #888;
2026-03-24 23:06:07 +01:00
}
.card {
2026-03-26 14:47:53 +01:00
background: #2a2a2a;
border: 1px solid #333;
border-radius: 8px;
2026-03-24 23:06:07 +01:00
padding: 1.75rem;
margin-bottom: 1.5rem;
}
.card-title {
2026-03-26 14:47:53 +01:00
font-size: 15px;
2026-03-24 23:06:07 +01:00
letter-spacing: 0.1em;
text-transform: uppercase;
2026-03-26 14:47:53 +01:00
color: #666;
2026-03-24 23:06:07 +01:00
margin-bottom: 1.25rem;
}
.form-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 1rem;
}
.form-group {
display: flex;
flex-direction: column;
2026-03-26 14:47:53 +01:00
gap: 6px;
}
.form-group.full {
grid-column: 1 / -1;
2026-03-24 23:06:07 +01:00
}
label {
font-size: 12px;
2026-03-26 14:47:53 +01:00
color: #888;
2026-03-24 23:06:07 +01:00
}
input[type="text"],
2026-03-26 14:47:53 +01:00
input[type="password"],
select {
background: #333;
border: 1px solid #3a3a3a;
border-radius: 6px;
2026-03-24 23:06:07 +01:00
padding: 10px 14px;
2026-03-26 14:47:53 +01:00
color: #f0f0f0;
font-family: inherit;
2026-03-24 23:06:07 +01:00
font-size: 13px;
outline: none;
width: 100%;
2026-03-26 14:47:53 +01:00
transition: border-color 0.15s;
appearance: none;
2026-03-24 23:06:07 +01:00
}
2026-03-26 14:47:53 +01:00
input:focus, select:focus { border-color: #2563eb; }
input::placeholder { color: #555; }
2026-03-24 23:06:07 +01:00
.btn {
display: inline-flex;
align-items: center;
gap: 8px;
2026-03-26 14:47:53 +01:00
padding: 9px 18px;
border-radius: 6px;
2026-03-24 23:06:07 +01:00
border: none;
2026-03-26 14:47:53 +01:00
font-family: inherit;
font-size: 13px;
2026-03-24 23:06:07 +01:00
cursor: pointer;
transition: all 0.15s;
}
2026-03-26 14:47:53 +01:00
.btn-primary { background: #2563eb; color: #fff; font-weight: 600; }
.btn-primary:hover { background: #1d4ed8; }
2026-03-24 23:06:07 +01:00
.btn-danger {
2026-03-26 14:47:53 +01:00
background: transparent;
color: #f87171;
border: 1px solid rgba(248,113,113,0.3);
font-size: 12px;
padding: 6px 14px;
2026-03-24 23:06:07 +01:00
}
2026-03-26 14:47:53 +01:00
.btn-danger:hover { background: rgba(248,113,113,0.1); }
2026-03-24 23:06:07 +01:00
2026-03-26 14:47:53 +01:00
.form-actions { display: flex; justify-content: flex-end; margin-top: 1.25rem; }
2026-03-24 23:06:07 +01:00
2026-03-26 14:47:53 +01:00
.user-list { display: flex; flex-direction: column; }
2026-03-24 23:06:07 +01:00
.user-row {
display: flex;
align-items: center;
padding: 12px 0;
2026-03-26 14:47:53 +01:00
border-bottom: 1px solid #333;
2026-03-24 23:06:07 +01:00
gap: 14px;
}
.user-row:last-child { border-bottom: none; }
.avatar {
2026-03-26 14:47:53 +01:00
width: 36px; height: 36px;
2026-03-24 23:06:07 +01:00
border-radius: 50%;
2026-03-26 14:47:53 +01:00
background: #2e2e3a;
border: 1px solid #3a3a4a;
display: flex; align-items: center; justify-content: center;
font-size: 11px; font-weight: 600;
color: #2563eb;
2026-03-24 23:06:07 +01:00
flex-shrink: 0;
}
.user-info { flex: 1; }
2026-03-26 14:47:53 +01:00
.user-name { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.user-meta { font-size: 11px; color: #666; }
2026-03-24 23:06:07 +01:00
.badge {
font-size: 10px;
padding: 3px 8px;
border-radius: 4px;
}
2026-03-26 14:47:53 +01:00
.badge-admin { background: rgba(37,99,235,0.15); color: #2563eb; border: 1px solid rgba(37,99,235,0.3); }
.badge-user { background: #333; color: #888; border: 1px solid #3a3a3a; }
2026-03-24 23:06:07 +01:00
.toast {
position: fixed;
2026-03-26 14:47:53 +01:00
bottom: 2rem; right: 2rem;
background: #2a2a2a;
border: 1px solid #333;
2026-03-24 23:06:07 +01:00
border-radius: 8px;
padding: 12px 18px;
font-size: 13px;
2026-03-26 14:47:53 +01:00
color: #f0f0f0;
2026-03-24 23:06:07 +01:00
transform: translateY(20px);
opacity: 0;
transition: all 0.25s;
pointer-events: none;
z-index: 999;
}
.toast.show { transform: translateY(0); opacity: 1; }
2026-03-26 14:47:53 +01:00
.toast.success { border-color: rgba(74,222,128,0.3); color: #4ade80; }
.toast.error { border-color: rgba(248,113,113,0.3); color: #f87171; }
2026-03-24 23:06:07 +01:00
2026-03-26 14:47:53 +01:00
.strength-bar { height: 3px; background: #333; border-radius: 2px; margin-top: 6px; overflow: hidden; }
.strength-fill { height: 100%; border-radius: 2px; transition: width 0.3s, background 0.3s; width: 0%; }
2026-03-24 23:06:07 +01:00
</style>
</head>
<body>
<aside>
<div class="logo">
2026-04-01 00:58:00 +02:00
SUPER Loustiques
2026-03-26 14:47:53 +01:00
<span>Panneau admin</span>
2026-03-24 23:06:07 +01:00
</div>
<nav>
<a href="#" class="active">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="8" cy="5" r="2.5"/><path d="M3 13c0-2.76 2.24-5 5-5s5 2.24 5 5"/></svg>
Utilisateurs
</a>
<a href="admin/logs">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><rect x="2" y="2" width="12" height="12" rx="2"/><path d="M5 8h6M5 5h6M5 11h4"/></svg>
Logs
</a>
<a href="#">
<svg viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.5"><circle cx="8" cy="8" r="3"/><path d="M8 1v2M8 13v2M1 8h2M13 8h2"/></svg>
Système
</a>
</nav>
2026-04-01 00:58:00 +02:00
<div class="sidebar-footer">Version 1.0</div>
2026-03-24 23:06:07 +01:00
</aside>
<main>
<div class="page-header">
2026-03-26 14:47:53 +01:00
<h1>Utilisateurs</h1>
2026-03-24 23:06:07 +01:00
<p>Créer et gérer les comptes d'accès.</p>
</div>
<div class="card">
<div class="card-title">Créer un utilisateur</div>
<div class="form-grid">
<div class="form-group">
2026-03-26 14:47:53 +01:00
<label>Nom d'utilisateur</label>
2026-03-24 23:06:07 +01:00
<input type="text" id="new-username" placeholder="ex: maxime" autocomplete="off">
</div>
<div class="form-group">
2026-03-26 14:47:53 +01:00
<label>Rôle</label>
<select id="new-role">
2026-03-24 23:06:07 +01:00
<option value="user">user</option>
<option value="admin">admin</option>
</select>
</div>
<div class="form-group">
2026-03-26 14:47:53 +01:00
<label>Mot de passe</label>
2026-03-24 23:06:07 +01:00
<input type="password" id="new-password" placeholder="••••••••" oninput="checkStrength(this.value)">
<div class="strength-bar"><div class="strength-fill" id="strength-fill"></div></div>
</div>
<div class="form-group">
2026-03-26 14:47:53 +01:00
<label>Confirmer</label>
2026-03-24 23:06:07 +01:00
<input type="password" id="confirm-password" placeholder="••••••••">
</div>
</div>
<div class="form-actions">
<button class="btn btn-primary" onclick="createUser()">
<svg width="13" height="13" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2"><path d="M8 3v10M3 8h10"/></svg>
Créer le compte
</button>
</div>
</div>
<div class="card">
<div class="card-title">Comptes existants</div>
2026-03-26 14:47:53 +01:00
<div class="user-list" id="user-list"></div>
2026-03-24 23:06:07 +01:00
</div>
</main>
<div class="toast" id="toast"></div>
<script>
function showToast(msg, type = 'success') {
const t = document.getElementById('toast');
t.textContent = msg;
t.className = `toast ${type} show`;
setTimeout(() => t.className = 'toast', 3000);
}
function checkStrength(val) {
const fill = document.getElementById('strength-fill');
let score = 0;
if (val.length >= 8) score++;
if (/[A-Z]/.test(val)) score++;
if (/[0-9]/.test(val)) score++;
if (/[^A-Za-z0-9]/.test(val)) score++;
2026-03-26 14:47:53 +01:00
const colors = ['#f87171', '#fb923c', '#facc15', '#4ade80'];
2026-03-24 23:06:07 +01:00
fill.style.width = (score * 25) + '%';
fill.style.background = colors[score - 1] || 'transparent';
}
function createUser() {
const username = document.getElementById('new-username').value.trim();
const password = document.getElementById('new-password').value;
const confirm = document.getElementById('confirm-password').value;
const role = document.getElementById('new-role').value;
if (!username || !password) return showToast('Champs manquants', 'error');
if (password !== confirm) return showToast('Mots de passe différents', 'error');
if (password.length < 6) return showToast('Mot de passe trop court', 'error');
fetch('/admin/add_user', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username, password, role })
})
.then(r => r.json())
.then(data => {
if (data.success) {
showToast(`Compte "${username}" créé`, 'success');
addUserRow(username, role);
document.getElementById('new-username').value = '';
document.getElementById('new-password').value = '';
document.getElementById('confirm-password').value = '';
document.getElementById('strength-fill').style.width = '0%';
} else {
showToast(data.message || 'Erreur', 'error');
}
})
.catch(() => showToast('Erreur réseau', 'error'));
}
2026-03-26 14:47:53 +01:00
2026-03-24 23:06:07 +01:00
function loadUsers() {
fetch('/admin/get_users')
.then(r => r.json())
.then(data => {
if (!data.success) return;
const list = document.getElementById('user-list');
list.innerHTML = '';
data.users.forEach(u => addUserRow(u.username, u.role, u.created_at));
});
}
2026-03-26 14:47:53 +01:00
loadUsers();
2026-03-24 23:06:07 +01:00
function addUserRow(username, role) {
const initials = username.slice(0, 2).toUpperCase();
const today = new Date().toLocaleDateString('fr-FR');
const list = document.getElementById('user-list');
const row = document.createElement('div');
row.className = 'user-row';
row.innerHTML = `
<div class="avatar">${initials}</div>
<div class="user-info">
<div class="user-name">${username}</div>
<div class="user-meta">créé le ${today}</div>
</div>
<span class="badge badge-${role}">${role}</span>
<button class="btn btn-danger" onclick="deleteUser(this, '${username}')">Supprimer</button>
`;
list.appendChild(row);
}
function deleteUser(btn, username) {
if (!confirm(`Supprimer "${username}" ?`)) return;
fetch('/admin/delete_user', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username })
})
.then(r => r.json())
.then(data => {
if (data.success) {
btn.closest('.user-row').remove();
showToast(`Compte "${username}" supprimé`);
} else {
showToast(data.message || 'Erreur', 'error');
}
})
.catch(() => showToast('Erreur réseau', 'error'));
}
</script>
</body>
2026-03-26 14:47:53 +01:00
</html>