Files
mailgosend/web/admin/templates/bans.html
T
2026-05-22 06:06:44 +00:00

72 lines
2.3 KiB
HTML

{{define "title"}}IP Bans{{end}}
{{define "content"}}
<h1 class="text-xl font-bold text-white mb-6">IP Bans</h1>
<div class="card mb-6">
<div class="text-sm font-semibold text-gray-300 mb-3">Add ban</div>
<form method="POST" action="/admin/bans">
<input type="hidden" name="_csrf" value="{{.CSRF}}">
<div style="display:grid;grid-template-columns:1fr 2fr 1fr auto;gap:.75rem;align-items:end">
<div class="field" style="margin:0">
<label>IP address</label>
<input type="text" name="ip" required placeholder="192.168.1.1" maxlength="45">
</div>
<div class="field" style="margin:0">
<label>Reason</label>
<input type="text" name="reason" maxlength="255" placeholder="Manual ban">
</div>
<div class="field" style="margin:0">
<label>Duration (hours, 0 = permanent)</label>
<input type="number" name="hours" value="24" min="0" max="87600">
</div>
<button type="submit" class="btn btn-danger" style="white-space:nowrap">Add ban</button>
</div>
</form>
</div>
<div class="card" style="padding:0;overflow:hidden">
{{if .Bans}}
<table>
<thead>
<tr>
<th>IP address</th>
<th>Reason</th>
<th>Banned at</th>
<th>Expires</th>
<th>Active</th>
<th></th>
</tr>
</thead>
<tbody>
{{range .Bans}}
<tr>
<td class="font-mono text-sm">{{.IP}}</td>
<td class="text-gray-300 text-xs">{{.Reason}}</td>
<td class="text-gray-400 text-xs">{{shortTime .BannedAt}}</td>
<td class="text-gray-400 text-xs">
{{if .ExpiresAt.Valid}}{{shortTime .ExpiresAt.Time}}{{else}}permanent{{end}}
</td>
<td>
{{if .ExpiresAt.Valid}}
<span class="badge badge-gray">timed</span>
{{else}}
<span class="badge badge-red">permanent</span>
{{end}}
</td>
<td>
<form method="POST" action="/admin/bans/{{.IP}}/remove"
onsubmit="return confirm('Remove ban on {{.IP}}?')">
<input type="hidden" name="_csrf" value="{{$.CSRF}}">
<button type="submit" class="btn btn-primary btn-sm">Remove</button>
</form>
</td>
</tr>
{{end}}
</tbody>
</table>
{{else}}
<div class="p-8 text-center text-gray-500 text-sm">No IP bans.</div>
{{end}}
</div>
{{end}}