2025-05-09 08:14:22 +00:00
|
|
|
|
{{ define "admin_users.pages.tmpl" }}
|
2025-05-09 15:09:51 +00:00
|
|
|
|
{{ template "head" . }}
|
2025-05-11 06:36:19 +00:00
|
|
|
|
<div class="columns">
|
|
|
|
|
|
<!-- Sidebar -->
|
|
|
|
|
|
{{ template "sidebar" . }}
|
|
|
|
|
|
<div class="column is-10">
|
2025-05-09 15:28:15 +00:00
|
|
|
|
<h1 class="title">Gestion des utilisateurs</h1>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Flash message -->
|
|
|
|
|
|
<div id="userFlash"></div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Bouton création -->
|
|
|
|
|
|
<div class="mb-4">
|
2025-05-11 06:32:43 +00:00
|
|
|
|
<a class="button is-primary"
|
|
|
|
|
|
href="/admin/user/create-form"
|
|
|
|
|
|
>
|
2025-05-09 15:28:15 +00:00
|
|
|
|
➕ Ajouter un utilisateur
|
2025-05-11 06:32:43 +00:00
|
|
|
|
</a>
|
2025-05-09 15:28:15 +00:00
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Formulaire création -->
|
|
|
|
|
|
<div id="createForm" class="mb-4"></div>
|
|
|
|
|
|
|
|
|
|
|
|
<!-- Tableau -->
|
2025-05-09 08:14:22 +00:00
|
|
|
|
<table class="table is-fullwidth is-striped">
|
|
|
|
|
|
<thead>
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<th>ID</th>
|
|
|
|
|
|
<th>Email</th>
|
|
|
|
|
|
<th>Role</th>
|
|
|
|
|
|
<th>Actif</th>
|
|
|
|
|
|
<th>Actions</th>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
</thead>
|
|
|
|
|
|
<tbody id="userList">
|
|
|
|
|
|
{{ range .Users }}
|
|
|
|
|
|
<tr>
|
|
|
|
|
|
<td>{{ .ID }}</td>
|
|
|
|
|
|
<td>{{ .Email }}</td>
|
|
|
|
|
|
<td>{{ .Role }}</td>
|
|
|
|
|
|
<td>{{ if .IsActive }}✅{{ else }}❌{{ end }}</td>
|
|
|
|
|
|
<td>
|
2025-05-11 06:32:43 +00:00
|
|
|
|
<a class="button is-small is-info"
|
|
|
|
|
|
href="/admin/user/{{ .ID }}/edit"
|
|
|
|
|
|
>
|
2025-05-09 15:28:15 +00:00
|
|
|
|
✏️ Modifier
|
2025-05-11 06:32:43 +00:00
|
|
|
|
</a>
|
2025-05-09 15:28:15 +00:00
|
|
|
|
<button class="button is-small is-danger"
|
|
|
|
|
|
hx-delete="/api/user/delete/{{ .ID }}"
|
|
|
|
|
|
hx-confirm="Confirmer suppression ?"
|
|
|
|
|
|
hx-target="#userList"
|
|
|
|
|
|
hx-swap="outerHTML">
|
|
|
|
|
|
🗑️ Supprimer
|
|
|
|
|
|
</button>
|
2025-05-09 08:14:22 +00:00
|
|
|
|
</td>
|
|
|
|
|
|
</tr>
|
|
|
|
|
|
{{ end }}
|
|
|
|
|
|
</tbody>
|
|
|
|
|
|
</table>
|
|
|
|
|
|
|
2025-05-09 15:28:15 +00:00
|
|
|
|
<!-- Formulaire modification -->
|
2025-05-09 08:14:22 +00:00
|
|
|
|
<hr>
|
|
|
|
|
|
<div id="editForm"></div>
|
2025-05-11 06:36:19 +00:00
|
|
|
|
</div>
|
2025-05-09 15:28:15 +00:00
|
|
|
|
<!-- Script HTMX flash -->
|
|
|
|
|
|
<script>
|
|
|
|
|
|
document.body.addEventListener('htmx:afterOnLoad', (e) => {
|
|
|
|
|
|
if (e.detail && e.detail.xhr) {
|
|
|
|
|
|
const json = JSON.parse(e.detail.xhr.getResponseHeader("HX-Trigger") || "{}")
|
|
|
|
|
|
if (json.userCreated) {
|
|
|
|
|
|
const flash = document.getElementById("userFlash")
|
|
|
|
|
|
flash.innerHTML = `<div class="notification is-success">${json.userCreated}</div>`
|
|
|
|
|
|
setTimeout(() => flash.innerHTML = "", 3000)
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
</script>
|
2025-05-09 08:14:22 +00:00
|
|
|
|
{{ end }}
|