Files
cloud-ip-validator/internal/dashboard/templates/ips.html
T

57 lines
2.1 KiB
HTML

{{define "ips_page"}}
<!doctype html>
<html lang="ru">
<head>{{template "html_head" .}}</head>
<body>
{{template "page_header" .}}
<main>
<div id="error-banner">{{template "banner_inner" .Banner}}</div>
{{template "ips_content" .}}
</main>
</body>
</html>
{{end}}
{{define "ips_content"}}
<h1>Очередь IP</h1>
<form hx-post="/ips" hx-target="#ips-table-wrap" hx-swap="innerHTML" hx-on::after-request="this.reset()">
<label for="addresses">Адреса (по одному на строку или через запятую)</label>
<textarea id="addresses" name="addresses" rows="3" placeholder="203.0.113.10&#10;203.0.113.11"></textarea>
<button type="submit">Добавить / принудительно перепроверить</button>
<p class="muted">Новый адрес встаёт в очередь; уже завершённый (done/failed) запускается заново
(тот же вызов); тот, что сейчас проверяется, не трогается.</p>
</form>
<div id="ips-table-wrap">
{{template "ips_table" .}}
</div>
{{end}}
{{define "ips_table"}}
<table role="grid">
<thead><tr><th>Адрес</th><th>Состояние</th><th>Валидатор</th><th>Попытка</th><th>Обновлено</th><th>Действия</th></tr></thead>
<tbody>
{{range .Items}}
{{$b := ipBadge .State .OverallResult}}
{{$terminal := or (eq .State "done") (eq .State "failed")}}
<tr>
<td><a href="/ips/{{.IPAddress}}">{{.IPAddress}}</a></td>
<td><span class="{{$b.Class}}">{{$b.Label}}</span></td>
<td>{{deref .OwnerValidatorID}}</td>
<td>{{.AttemptNumber}}</td>
<td>{{fmtTime .UpdatedAt}}</td>
<td class="actions-cell">
{{if $terminal}}
<button class="secondary" hx-post="/ips/{{.IPAddress}}/recheck" hx-target="#ips-table-wrap" hx-swap="innerHTML">Перепроверить</button>
{{else}}
<button class="contrast" hx-post="/ips/{{.IPAddress}}/cancel" hx-target="#ips-table-wrap" hx-swap="innerHTML" hx-confirm="Остановить проверку {{.IPAddress}}?">Отменить</button>
{{end}}
</td>
</tr>
{{end}}
</tbody>
</table>
{{if not .Items}}<p class="muted">Очередь пуста.</p>{{end}}
{{end}}