This commit is contained in:
cangui 2025-05-09 17:56:57 +02:00
parent 08f64bf87f
commit 5410413ffb

View File

@ -5,19 +5,16 @@
<div class="column is-10">
<h2>Historique des messages de l'utilisateur #{{ .UserID }}</h2>
<div class="mb-3">
<label>Filtrer par type :</label>
<select id="filterType" name="type" hx-get="/api/user/{{ .UserID }}/conversations" hx-target="#conversationRows"
hx-trigger="change" hx-include="#filterType">
<option value="">Tous</option>
<option value="text">Texte</option>
<option value="image">Image</option>
<option value="video">Vidéo</option>
<option value="interactive">Interactif</option>
</select>
<div class="filters mb-3">
<input type="text" class="input is-small" placeholder="📅 Filtrer par date" onkeyup="filterTable(0, this.value)">
<input type="text" class="input is-small" placeholder="➡️ Direction" onkeyup="filterTable(1, this.value)">
<input type="text" class="input is-small" placeholder="📨 Expéditeur" onkeyup="filterTable(2, this.value)">
<input type="text" class="input is-small" placeholder="📦 Type" onkeyup="filterTable(3, this.value)">
<input type="text" class="input is-small" placeholder="💬 Contenu" onkeyup="filterTable(4, this.value)">
<input type="text" class="input is-small" placeholder="✅ Statut" onkeyup="filterTable(5, this.value)">
</div>
<table class="table">
<table class="table is-fullwidth is-striped is-hoverable" id="conversationTable">
<thead>
<tr>
<th>Date</th>
@ -28,13 +25,33 @@
<th>Statut</th>
</tr>
</thead>
<tbody id="conversationRows" hx-get="/api/user/{{ .UserID }}/conversations" hx-trigger="load" hx-target="this"
<tbody id="conversationRows"
hx-get="/api/user/{{ .UserID }}/conversations"
hx-trigger="load"
hx-target="this"
hx-swap="innerHTML">
</tbody>
</table>
<hr>
<h3>Conversation complète</h3>
<div id="threadViewer" class="mt-3"></div>
</div>
</div>
{{ end }}
<script>
function filterTable(colIndex, filterValue) {
const table = document.getElementById("conversationTable");
const rows = table.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
filterValue = filterValue.toLowerCase();
for (let i = 0; i < rows.length; i++) {
const td = rows[i].getElementsByTagName("td")[colIndex];
if (td) {
const text = td.textContent || td.innerText;
rows[i].style.display = text.toLowerCase().includes(filterValue) ? "" : "none";
}
}
}
</script>
{{ end }}