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

55 lines
1.7 KiB
HTML

{{define "validators_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 "validators_content" .}}
</main>
</body>
</html>
{{end}}
{{define "validators_content"}}
<h1>Валидаторы</h1>
<form hx-post="/validators" hx-target="#validators-table-wrap" hx-swap="innerHTML" hx-on::after-request="this.reset()">
<div class="grid">
<input type="text" name="validator_id" placeholder="validator_id" required>
<input type="text" name="os_port_id" placeholder="os_port_id (Neutron port ID)" required>
<button type="submit">Добавить</button>
</div>
</form>
<div id="validators-table-wrap">
{{template "validators_table" .}}
</div>
{{end}}
{{define "validators_table"}}
<table role="grid">
<thead><tr><th>ID</th><th>OS Port ID</th><th>Состояние</th><th>Действия</th></tr></thead>
<tbody>
{{range .Items}}
{{$b := validatorBadge .State}}
<tr>
<td>{{.ValidatorID}}</td>
<td>
<form hx-put="/validators/{{.ValidatorID}}" hx-target="#validators-table-wrap" hx-swap="innerHTML" style="display:flex;gap:.5rem;margin:0">
<input type="text" name="os_port_id" value="{{.OSPortID}}" style="margin:0">
<button type="submit" class="secondary" style="margin:0">Сохранить</button>
</form>
</td>
<td><span class="{{$b.Class}}">{{$b.Label}}</span></td>
<td class="actions-cell">
<button class="contrast" hx-delete="/validators/{{.ValidatorID}}" hx-target="#validators-table-wrap" hx-swap="innerHTML" hx-confirm="Удалить валидатор {{.ValidatorID}}?">Удалить</button>
</td>
</tr>
{{end}}
</tbody>
</table>
{{if not .Items}}<p class="muted">Валидаторов нет.</p>{{end}}
{{end}}