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

54 lines
1.9 KiB
HTML

{{define "targets_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 "targets_content" .}}
</main>
</body>
</html>
{{end}}
{{define "targets_content"}}
<h1>Цели проверки</h1>
<p class="muted">Группа целей — именованный список URL/адресов, на который затем ссылаются типы проверок.</p>
<form hx-post="/targets" hx-target="#targets-table-wrap" hx-swap="innerHTML" hx-on::after-request="this.reset()">
<label for="target-name">Имя новой группы</label>
<input id="target-name" type="text" name="name" placeholder="web" required>
<label for="target-list">Цели (по одной на строку или через запятую)</label>
<textarea id="target-list" name="targets" rows="2" placeholder="https://hub.docker.com&#10;https://github.com" required></textarea>
<button type="submit">Создать группу</button>
</form>
<div id="targets-table-wrap">
{{template "targets_table" .}}
</div>
{{end}}
{{define "targets_table"}}
<table role="grid">
<thead><tr><th>Группа</th><th>Цели</th><th>Действия</th></tr></thead>
<tbody>
{{range .Items}}
<tr>
<td>{{.Name}}</td>
<td>
<form hx-put="/targets/{{.Name}}" hx-target="#targets-table-wrap" hx-swap="innerHTML" style="display:flex;gap:.5rem;margin:0">
<textarea name="targets" rows="2" style="margin:0">{{join .Targets "\n"}}</textarea>
<button type="submit" class="secondary" style="margin:0">Сохранить</button>
</form>
</td>
<td class="actions-cell">
<button class="contrast" hx-delete="/targets/{{.Name}}" hx-target="#targets-table-wrap" hx-swap="innerHTML" hx-confirm="Удалить группу {{.Name}}?">Удалить</button>
</td>
</tr>
{{end}}
</tbody>
</table>
{{if not .Items}}<p class="muted">Групп целей нет.</p>{{end}}
{{end}}