Files
crowdsec-admin/app/templates/_decisions.html
domverse a324d5a68d
All checks were successful
Deploy / deploy (push) Successful in 23s
feat: bulk unban via checkboxes
Adds per-row checkboxes, a select-all toggle, a live "N selected" counter,
and an /unban-bulk endpoint that DELETEs each chosen decision id. Single-row
Unban buttons still work via hx-vals so they don't accidentally submit the
bulk form.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-17 00:02:59 +02:00

53 lines
2.0 KiB
HTML

{% if error %}
<p class="err">{{ error }}</p>
{% endif %}
{% if decisions %}
<form hx-post="/unban-bulk" hx-target="#decisions" hx-swap="innerHTML"
hx-confirm="Unban all selected decisions?" id="bulk-form">
<div class="row" style="margin: .5rem 0;">
<button class="danger" type="submit">Unban selected</button>
<span class="pill"><span id="sel-count">0</span> selected of {{ decisions|length }}</span>
</div>
<table>
<thead>
<tr>
<th><input type="checkbox" id="sel-all" onclick="document.querySelectorAll('#bulk-form .sel').forEach(c=>{c.checked=this.checked});updateCount()"></th>
<th>ID</th><th>IP / value</th><th>Scope</th><th>Type</th><th>Reason</th><th>Until</th><th>Origin</th><th></th>
</tr>
</thead>
<tbody>
{% for d in decisions %}
<tr>
<td><input type="checkbox" class="sel" name="id" value="{{ d.id }}" onclick="updateCount()"></td>
<td><code>{{ d.id }}</code></td>
<td><code>{{ d.value }}</code></td>
<td>{{ d.scope }}</td>
<td>{{ d.type }}</td>
<td>{{ d.scenario }}</td>
<td>{{ d.until }}</td>
<td>{{ d.origin }}</td>
<td>
<button class="danger" type="button"
hx-post="/unban" hx-target="#decisions" hx-swap="innerHTML"
hx-vals='{"id": "{{ d.id }}"}'
hx-confirm="Delete decision {{ d.id }} for {{ d.value }}?">Unban</button>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</form>
<script>
function updateCount(){
const n = document.querySelectorAll('#bulk-form .sel:checked').length;
const total = document.querySelectorAll('#bulk-form .sel').length;
document.getElementById('sel-count').textContent = n;
const all = document.getElementById('sel-all');
if (all) all.checked = (n === total && total > 0);
}
updateCount();
</script>
{% else %}
{% if not error %}<p>No active decisions.</p>{% endif %}
{% endif %}