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"> <div class="column is-10">
<h2>Historique des messages de l'utilisateur #{{ .UserID }}</h2> <h2>Historique des messages de l'utilisateur #{{ .UserID }}</h2>
<div class="mb-3"> <div class="filters mb-3">
<label>Filtrer par type :</label> <input type="text" class="input is-small" placeholder="📅 Filtrer par date" onkeyup="filterTable(0, this.value)">
<select id="filterType" name="type" hx-get="/api/user/{{ .UserID }}/conversations" hx-target="#conversationRows" <input type="text" class="input is-small" placeholder="➡️ Direction" onkeyup="filterTable(1, this.value)">
hx-trigger="change" hx-include="#filterType"> <input type="text" class="input is-small" placeholder="📨 Expéditeur" onkeyup="filterTable(2, this.value)">
<option value="">Tous</option> <input type="text" class="input is-small" placeholder="📦 Type" onkeyup="filterTable(3, this.value)">
<option value="text">Texte</option> <input type="text" class="input is-small" placeholder="💬 Contenu" onkeyup="filterTable(4, this.value)">
<option value="image">Image</option> <input type="text" class="input is-small" placeholder="✅ Statut" onkeyup="filterTable(5, this.value)">
<option value="video">Vidéo</option>
<option value="interactive">Interactif</option>
</select>
</div> </div>
<table class="table"> <table class="table is-fullwidth is-striped is-hoverable" id="conversationTable">
<thead> <thead>
<tr> <tr>
<th>Date</th> <th>Date</th>
@ -28,13 +25,33 @@
<th>Statut</th> <th>Statut</th>
</tr> </tr>
</thead> </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"> hx-swap="innerHTML">
</tbody> </tbody>
</table> </table>
<hr> <hr>
<h3>Conversation complète</h3> <h3>Conversation complète</h3>
<div id="threadViewer" class="mt-3"></div> <div id="threadViewer" class="mt-3"></div>
</div> </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 }}