2026-07-22 16:37:53 +02:00
|
|
|
{% extends "base.html" %} {% block title %}Gestion des utilisateurs - Bolsa{%
|
|
|
|
|
endblock %} {% block header_title %}Gestion utilisateurs{% endblock %} {% block
|
|
|
|
|
content %}
|
2026-07-23 09:56:47 +02:00
|
|
|
<div class="flex flex-col items-center justify-center py-6 relative">
|
|
|
|
|
<!-- Système de Toasts (Notifications flottantes centrées) -->
|
|
|
|
|
<div
|
|
|
|
|
id="toast-container"
|
|
|
|
|
class="fixed top-6 left-1/2 transform -translate-x-1/2 z-50 space-y-3 w-full max-w-md px-4 pointer-events-none"
|
|
|
|
|
>
|
|
|
|
|
{% set messages = get_flashed_messages(with_categories=true) %} {% if
|
|
|
|
|
messages %} {% for category, message in messages %}
|
|
|
|
|
<div
|
|
|
|
|
class="toast-message pointer-events-auto flex items-center justify-center px-4 py-3 rounded-xl shadow-2xl text-white text-sm font-medium transition-all duration-300 transform translate-y-0 opacity-100 text-center {% if category == 'success' %} bg-emerald-600 border border-emerald-500 {% elif category == 'warning' %} bg-amber-600 border border-amber-500 {% else %} bg-rose-600 border border-rose-500 {% endif %}"
|
|
|
|
|
>
|
|
|
|
|
<span>{{ message }}</span>
|
|
|
|
|
</div>
|
|
|
|
|
{% endfor %} {% endif %}
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-07-22 16:37:53 +02:00
|
|
|
<!-- Box centrée principale -->
|
|
|
|
|
<div
|
2026-07-22 17:54:47 +02:00
|
|
|
class="bg-gray-900 border border-gray-800 p-8 rounded-2xl shadow-2xl w-full max-w-6xl"
|
2026-07-22 16:37:53 +02:00
|
|
|
>
|
|
|
|
|
<!-- En-tête de section -->
|
|
|
|
|
<div
|
|
|
|
|
class="flex justify-between items-center mb-6 border-b border-gray-800 pb-4"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
|
<h2 class="text-2xl font-extrabold text-white">
|
|
|
|
|
Administration des utilisateurs
|
|
|
|
|
</h2>
|
|
|
|
|
<p class="text-gray-400 text-sm">
|
2026-07-23 09:56:47 +02:00
|
|
|
Gérez les comptes d'accès à l'application.
|
2026-07-22 16:37:53 +02:00
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<a
|
|
|
|
|
href="{{ url_for('main.menu') }}"
|
|
|
|
|
class="px-4 py-2 bg-gray-800 hover:bg-gray-700 text-gray-200 text-sm font-medium rounded-lg transition duration-200"
|
|
|
|
|
>
|
|
|
|
|
Retour au menu
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-07-23 09:56:47 +02:00
|
|
|
<!-- Grille principale -->
|
2026-07-22 17:54:47 +02:00
|
|
|
<div class="grid grid-cols-1 md:grid-cols-12 gap-8 py-4">
|
2026-07-23 09:56:47 +02:00
|
|
|
<!-- COLONNE GAUCHE : Liste des utilisateurs -->
|
2026-07-22 17:54:47 +02:00
|
|
|
<div
|
|
|
|
|
class="md:col-span-4 bg-gray-950 border border-gray-800 rounded-xl p-4 flex flex-col h-[520px]"
|
|
|
|
|
>
|
|
|
|
|
<h3
|
|
|
|
|
class="text-sm font-semibold text-gray-300 uppercase tracking-wider mb-3 px-2"
|
|
|
|
|
>
|
|
|
|
|
Utilisateurs enregistrés
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
|
|
<!-- Liste scrollable -->
|
|
|
|
|
<div class="overflow-y-auto flex-1 space-y-1 pr-1">
|
|
|
|
|
{% for u in users %}
|
|
|
|
|
<div
|
2026-07-23 09:56:47 +02:00
|
|
|
onclick="selectionnerUtilisateur('{{ u.id }}', '{{ u.actif }}', '{{ u.prenom | e }}', '{{ u.nom | e }}', '{{ u.login | e }}', '{{ u.mail | e }}')"
|
2026-07-22 17:54:47 +02:00
|
|
|
class="user-item cursor-pointer px-3 py-2.5 rounded-lg {% if loop.first %}bg-blue-600 text-white{% else %}hover:bg-gray-800 text-gray-300{% endif %} font-medium text-sm transition flex justify-between items-center"
|
|
|
|
|
data-id="{{ u.id }}"
|
|
|
|
|
>
|
2026-07-23 09:56:47 +02:00
|
|
|
<span class="truncate pr-2">{{ u.prenom }} {{ u.nom }}</span>
|
2026-07-22 17:54:47 +02:00
|
|
|
<span
|
2026-07-23 09:56:47 +02:00
|
|
|
class="text-xs {% if loop.first %}bg-blue-800{% else %}bg-gray-800 text-gray-400{% endif %} px-2 py-0.5 rounded whitespace-nowrap"
|
2026-07-22 17:54:47 +02:00
|
|
|
>
|
2026-07-23 09:56:47 +02:00
|
|
|
{% if u.actif == 1 or u.actif == True %}Actif{% else %}Inactif{%
|
|
|
|
|
endif %}
|
|
|
|
|
</span>
|
2026-07-22 17:54:47 +02:00
|
|
|
</div>
|
|
|
|
|
{% endfor %}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-07-23 09:56:47 +02:00
|
|
|
<!-- COLONNE DROITE : Formulaire -->
|
2026-07-22 17:54:47 +02:00
|
|
|
<div
|
|
|
|
|
class="md:col-span-8 bg-gray-950 border border-gray-800 rounded-xl p-6 flex flex-col justify-between"
|
|
|
|
|
>
|
|
|
|
|
<form
|
|
|
|
|
id="user-form"
|
|
|
|
|
method="POST"
|
|
|
|
|
action=""
|
|
|
|
|
class="space-y-4 flex-1 flex flex-col justify-between"
|
|
|
|
|
>
|
2026-07-23 09:56:47 +02:00
|
|
|
<!-- ID technique caché -->
|
|
|
|
|
<input type="hidden" id="field-id" name="id" />
|
|
|
|
|
|
2026-07-22 17:54:47 +02:00
|
|
|
<div class="space-y-4">
|
|
|
|
|
<h3
|
|
|
|
|
class="text-sm font-semibold text-gray-300 uppercase tracking-wider mb-2"
|
|
|
|
|
>
|
2026-07-23 09:56:47 +02:00
|
|
|
Détails de l'utilisateur
|
2026-07-22 17:54:47 +02:00
|
|
|
</h3>
|
|
|
|
|
|
|
|
|
|
<div class="grid grid-cols-2 gap-4">
|
|
|
|
|
<!-- Prénom -->
|
|
|
|
|
<div>
|
|
|
|
|
<label class="block text-xs font-medium text-gray-400 mb-1"
|
|
|
|
|
>Prénom</label
|
|
|
|
|
>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
id="field-prenom"
|
|
|
|
|
name="prenom"
|
2026-07-23 09:56:47 +02:00
|
|
|
required
|
2026-07-22 17:54:47 +02:00
|
|
|
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Nom -->
|
|
|
|
|
<div>
|
|
|
|
|
<label class="block text-xs font-medium text-gray-400 mb-1"
|
|
|
|
|
>Nom</label
|
|
|
|
|
>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
id="field-nom"
|
|
|
|
|
name="nom"
|
2026-07-23 09:56:47 +02:00
|
|
|
required
|
2026-07-22 17:54:47 +02:00
|
|
|
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div class="grid grid-cols-2 gap-4">
|
|
|
|
|
<!-- Login -->
|
|
|
|
|
<div>
|
|
|
|
|
<label class="block text-xs font-medium text-gray-400 mb-1"
|
|
|
|
|
>Login</label
|
|
|
|
|
>
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
id="field-login"
|
|
|
|
|
name="login"
|
2026-07-23 09:56:47 +02:00
|
|
|
required
|
2026-07-22 17:54:47 +02:00
|
|
|
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<!-- Mail -->
|
|
|
|
|
<div>
|
|
|
|
|
<label class="block text-xs font-medium text-gray-400 mb-1"
|
2026-07-23 09:56:47 +02:00
|
|
|
>Email</label
|
2026-07-22 17:54:47 +02:00
|
|
|
>
|
|
|
|
|
<input
|
|
|
|
|
type="email"
|
|
|
|
|
id="field-mail"
|
|
|
|
|
name="mail"
|
2026-07-23 09:56:47 +02:00
|
|
|
required
|
2026-07-22 17:54:47 +02:00
|
|
|
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-07-23 09:56:47 +02:00
|
|
|
<div class="grid grid-cols-2 gap-4">
|
2026-07-22 17:54:47 +02:00
|
|
|
<!-- Mot de passe -->
|
|
|
|
|
<div>
|
|
|
|
|
<label class="block text-xs font-medium text-gray-400 mb-1"
|
2026-07-23 09:56:47 +02:00
|
|
|
>Mot de passe (Laisser vide pour ne pas modifier)</label
|
2026-07-22 17:54:47 +02:00
|
|
|
>
|
|
|
|
|
<input
|
|
|
|
|
type="password"
|
|
|
|
|
id="field-pass"
|
|
|
|
|
name="pass"
|
|
|
|
|
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2026-07-23 09:56:47 +02:00
|
|
|
|
|
|
|
|
<!-- Actif -->
|
|
|
|
|
<div>
|
|
|
|
|
<label class="block text-xs font-medium text-gray-400 mb-1"
|
|
|
|
|
>Statut</label
|
|
|
|
|
>
|
|
|
|
|
<select
|
|
|
|
|
id="field-actif"
|
|
|
|
|
name="actif"
|
|
|
|
|
class="w-full bg-gray-900 border border-gray-800 rounded-lg px-3 py-2 text-white text-sm focus:outline-none focus:border-blue-500"
|
|
|
|
|
>
|
|
|
|
|
<option value="1">Actif</option>
|
|
|
|
|
<option value="0">Inactif</option>
|
|
|
|
|
</select>
|
|
|
|
|
</div>
|
2026-07-22 17:54:47 +02:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-07-23 09:56:47 +02:00
|
|
|
<!-- Bas : Boutons -->
|
2026-07-22 17:54:47 +02:00
|
|
|
<div
|
|
|
|
|
class="flex items-center justify-end space-x-3 pt-6 border-t border-gray-800 mt-6"
|
|
|
|
|
>
|
2026-07-23 09:56:47 +02:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onclick="preparerCreation()"
|
|
|
|
|
class="px-4 py-2 bg-gray-800 hover:bg-gray-700 text-gray-300 text-sm font-medium rounded-lg transition duration-200"
|
|
|
|
|
>
|
|
|
|
|
Nouveau / Vider
|
|
|
|
|
</button>
|
2026-07-22 17:54:47 +02:00
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onclick="annulerAction()"
|
|
|
|
|
class="px-4 py-2 bg-gray-800 hover:bg-gray-700 text-gray-300 text-sm font-medium rounded-lg transition duration-200"
|
|
|
|
|
>
|
|
|
|
|
Annuler
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="submit"
|
|
|
|
|
name="action"
|
|
|
|
|
value="creer"
|
|
|
|
|
class="px-4 py-2 bg-emerald-600 hover:bg-emerald-500 text-white text-sm font-medium rounded-lg transition duration-200"
|
|
|
|
|
>
|
|
|
|
|
Créer
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
type="submit"
|
|
|
|
|
name="action"
|
|
|
|
|
value="modifier"
|
|
|
|
|
class="px-4 py-2 bg-blue-600 hover:bg-blue-500 text-white text-sm font-medium rounded-lg transition duration-200"
|
|
|
|
|
>
|
|
|
|
|
Modifier
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</form>
|
|
|
|
|
</div>
|
2026-07-22 16:37:53 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
class="border-t border-gray-800 pt-4 text-xs text-gray-400 italic text-center"
|
|
|
|
|
>
|
|
|
|
|
Positions en bourse : Accès sécurisé. Veillez à fermer votre session après
|
|
|
|
|
chaque utilisation.
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
2026-07-22 17:54:47 +02:00
|
|
|
|
|
|
|
|
<script>
|
2026-07-23 09:56:47 +02:00
|
|
|
// Disparition automatique des Toasts au bout de 4 secondes
|
|
|
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
|
|
|
const toasts = document.querySelectorAll(".toast-message");
|
|
|
|
|
toasts.forEach((toast) => {
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
toast.style.opacity = "0";
|
|
|
|
|
toast.style.transform = "translateY(-10px)";
|
|
|
|
|
setTimeout(() => toast.remove(), 300);
|
|
|
|
|
}, 4000);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const premierUser = document.querySelector(".user-item");
|
|
|
|
|
if (premierUser) {
|
|
|
|
|
premierUser.click();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2026-07-22 17:54:47 +02:00
|
|
|
function selectionnerUtilisateur(id, actif, prenom, nom, login, mail) {
|
|
|
|
|
document.getElementById("field-id").value = id;
|
2026-07-23 09:56:47 +02:00
|
|
|
document.getElementById("field-actif").value =
|
|
|
|
|
actif == "True" || actif == "1" ? "1" : "0";
|
2026-07-22 17:54:47 +02:00
|
|
|
document.getElementById("field-prenom").value = prenom;
|
|
|
|
|
document.getElementById("field-nom").value = nom;
|
|
|
|
|
document.getElementById("field-login").value = login;
|
|
|
|
|
document.getElementById("field-mail").value = mail;
|
|
|
|
|
document.getElementById("field-pass").value = "";
|
|
|
|
|
|
|
|
|
|
document.querySelectorAll(".user-item").forEach((el) => {
|
|
|
|
|
el.classList.remove("bg-blue-600", "text-white");
|
|
|
|
|
el.classList.add("hover:bg-gray-800", "text-gray-300");
|
|
|
|
|
const badge = el.querySelector("span:last-child");
|
|
|
|
|
if (badge) {
|
|
|
|
|
badge.classList.remove("bg-blue-800");
|
|
|
|
|
badge.classList.add("bg-gray-800", "text-gray-400");
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const selectedEl = document.querySelector(`[data-id="${id}"]`);
|
|
|
|
|
if (selectedEl) {
|
|
|
|
|
selectedEl.classList.remove("hover:bg-gray-800", "text-gray-300");
|
|
|
|
|
selectedEl.classList.add("bg-blue-600", "text-white");
|
|
|
|
|
const badge = selectedEl.querySelector("span:last-child");
|
|
|
|
|
if (badge) {
|
|
|
|
|
badge.classList.remove("bg-gray-800", "text-gray-400");
|
|
|
|
|
badge.classList.add("bg-blue-800");
|
|
|
|
|
}
|
2026-07-23 09:56:47 +02:00
|
|
|
selectedEl.scrollIntoView({ block: "nearest" });
|
2026-07-22 17:54:47 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-23 09:56:47 +02:00
|
|
|
// Fonction pour vider le formulaire pour une création propre
|
|
|
|
|
function preparerCreation() {
|
|
|
|
|
document.getElementById("field-id").value = "";
|
|
|
|
|
document.getElementById("field-actif").value = "1";
|
|
|
|
|
document.getElementById("field-prenom").value = "";
|
|
|
|
|
document.getElementById("field-nom").value = "";
|
|
|
|
|
document.getElementById("field-login").value = "";
|
|
|
|
|
document.getElementById("field-mail").value = "";
|
|
|
|
|
document.getElementById("field-pass").value = "";
|
|
|
|
|
|
|
|
|
|
// Retirer la surbrillance de la liste
|
|
|
|
|
document.querySelectorAll(".user-item").forEach((el) => {
|
|
|
|
|
el.classList.remove("bg-blue-600", "text-white");
|
|
|
|
|
el.classList.add("hover:bg-gray-800", "text-gray-300");
|
|
|
|
|
const badge = el.querySelector("span:last-child");
|
|
|
|
|
if (badge) {
|
|
|
|
|
badge.classList.remove("bg-blue-800");
|
|
|
|
|
badge.classList.add("bg-gray-800", "text-gray-400");
|
|
|
|
|
}
|
|
|
|
|
});
|
2026-07-22 17:54:47 +02:00
|
|
|
}
|
|
|
|
|
|
2026-07-23 09:56:47 +02:00
|
|
|
function annulerAction() {
|
2026-07-22 17:54:47 +02:00
|
|
|
const premierUser = document.querySelector(".user-item");
|
|
|
|
|
if (premierUser) {
|
|
|
|
|
premierUser.click();
|
|
|
|
|
}
|
2026-07-23 09:56:47 +02:00
|
|
|
}
|
2026-07-22 17:54:47 +02:00
|
|
|
</script>
|
2026-07-22 16:37:53 +02:00
|
|
|
{% endblock %}
|