132 lines
6.5 KiB
HTML
132 lines
6.5 KiB
HTML
{{define "diagnostics_page"}}
|
||
<!doctype html>
|
||
<html lang="ru">
|
||
<head>{{template "html_head" .}}<script src="/static/diagnostics.js" defer></script></head>
|
||
<body>
|
||
<div class="bg-grid"></div>
|
||
<input type="checkbox" id="nav-toggle" class="nav-toggle">
|
||
<div class="shell">
|
||
{{template "sidebar_nav" .}}
|
||
<div>
|
||
{{template "topbar_mobile" .}}
|
||
<main class="main">
|
||
<div id="error-banner">{{template "banner_inner" .Banner}}</div>
|
||
<div class="topbar"><h1>Диагностика</h1></div>
|
||
{{template "diagnostics_form" .}}
|
||
{{template "diagnostics_operation" .Operation}}
|
||
<div id="diagnostics-action-result" aria-live="polite"></div>
|
||
{{template "diagnostics_holds" .}}
|
||
</main>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
{{end}}
|
||
|
||
{{define "diagnostics_form"}}
|
||
<div class="panel">
|
||
<div class="panel-body">
|
||
<form id="diagnostics-attach" hx-post="/diagnostics/operations" hx-target="#diagnostics-operation" hx-swap="outerHTML"
|
||
hx-disabled-elt="#diagnostics-submit" hx-indicator="#diagnostics-sending">
|
||
<input type="hidden" id="diagnostics-key" name="operation_id" value="{{.OperationKey}}">
|
||
<div class="field-row">
|
||
<div class="field" style="flex: 1 1 320px;">
|
||
<label for="diag-addresses">Адреса (по одному на строку или через запятую)</label>
|
||
<textarea id="diag-addresses" name="addresses" rows="2" placeholder="203.0.113.10 203.0.113.11" required></textarea>
|
||
</div>
|
||
<div class="field">
|
||
<label for="diag-validator">Валидатор</label>
|
||
{{template "diagnostics_validators" .}}
|
||
</div>
|
||
<div class="field">
|
||
<label for="diag-note">Заметка</label>
|
||
<input type="text" id="diag-note" name="note">
|
||
</div>
|
||
<button id="diagnostics-submit" type="submit" class="btn btn-primary"{{if .Operation.Poll}} disabled{{end}}>Привязать</button>
|
||
<span id="diagnostics-sending" class="htmx-indicator" role="status">Отправляем запрос…</span>
|
||
<span id="diagnostics-connection" role="status" hidden><span></span> <a hidden>Проверить статус</a></span>
|
||
</div>
|
||
</form>
|
||
<p class="muted" style="margin-top:8px">На время диагностики валидатор не берёт задания. Команды (traceroute, curl, tcpdump)
|
||
выполняются вручную по SSH на валидаторе. После работы адрес нужно отвязать. Если выбран конкретный валидатор, а адресов
|
||
несколько, он назначается первому адресу, остальные уходят на любые свободные.</p>
|
||
</div>
|
||
</div>
|
||
|
||
{{end}}
|
||
|
||
{{define "diagnostics_validators"}}
|
||
<select id="diag-validator" name="validator_id" hx-get="/diagnostics/validators"
|
||
hx-trigger="diagnostics-changed from:body" hx-swap="outerHTML">
|
||
<option value="">любой свободный</option>
|
||
{{range .FreeValidators}}<option value="{{.ValidatorID}}">{{.ValidatorID}} ({{.OSPortID}})</option>{{end}}
|
||
</select>
|
||
{{end}}
|
||
|
||
{{define "diagnostics_operation"}}
|
||
<section id="diagnostics-operation" aria-live="polite"
|
||
{{if .Poll}}data-pending="true" hx-get="/diagnostics/operations/{{.ID}}"
|
||
hx-trigger="{{if .Immediate}}load, {{end}}every 1s" hx-swap="outerHTML"{{end}}>
|
||
{{if .Message}}<p role="status">{{.Message}}{{if .RetryID}} <a href="/diagnostics?operation={{.RetryID}}">Проверить статус</a>{{end}}</p>{{end}}
|
||
{{if and .Poll (not .Items) (not .Message)}}<p role="status">Проверяем статус операции…</p>{{end}}
|
||
{{template "diagnostics_results" .Items}}
|
||
</section>
|
||
{{if .NextKey}}<input type="hidden" id="diagnostics-key" name="operation_id" value="{{.NextKey}}" hx-swap-oob="outerHTML">{{end}}
|
||
{{end}}
|
||
|
||
{{define "diagnostics_results"}}
|
||
{{if .}}
|
||
<h2 class="section-title">Результат операции</h2>
|
||
<div class="panel">
|
||
<div class="table-scroll">
|
||
<table>
|
||
<thead><tr><th>Адрес</th><th>Результат</th></tr></thead>
|
||
<tbody>
|
||
{{range .}}
|
||
<tr>
|
||
<td class="mono" data-label="Адрес">{{.Address}}</td>
|
||
<td data-label="Результат">{{if eq .Status "queued"}}<span class="pill">В очереди</span>{{else if eq .Status "running"}}<span class="pill">Привязываем…</span> {{.Reason}}{{else if eq .Status "attached"}}<span class="pill pill-success">привязан к {{.ValidatorID}}</span>{{else if eq .Status "detached"}}<span class="pill pill-success">отвязан</span>{{else}}<span class="pill pill-danger">отказ</span> {{.Reason}}{{end}}</td>
|
||
</tr>
|
||
{{end}}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
{{end}}
|
||
{{end}}
|
||
|
||
{{define "diagnostics_holds"}}
|
||
<div id="diagnostics-wrap" hx-get="/diagnostics/holds" hx-trigger="diagnostics-changed from:body"
|
||
hx-swap="outerHTML">
|
||
<h2 class="section-title">Удерживаемые адреса</h2>
|
||
{{if .Rows}}
|
||
<form id="diag-list" hx-post="/diagnostics/detach" hx-target="#diagnostics-action-result" hx-swap="innerHTML" hx-confirm="Отвязать выбранные адреса?">
|
||
<div class="actions" style="margin-bottom:8px">
|
||
<button type="submit" class="btn btn-ghost btn-sm">Отвязать выбранные</button>
|
||
<button type="button" class="btn btn-danger-ghost btn-sm" hx-post="/diagnostics/detach" hx-vals='{"all":"1"}' hx-target="#diagnostics-action-result" hx-swap="innerHTML" hx-confirm="Отвязать все адреса ({{len .Rows}})?">Отвязать все</button>
|
||
</div>
|
||
<div class="panel">
|
||
<div class="table-scroll">
|
||
<table>
|
||
<thead><tr><th><input type="checkbox" aria-label="Выбрать все" onclick="this.closest('table').querySelectorAll('input[name=addresses]').forEach(cb => cb.checked = this.checked)"></th><th>Адрес</th><th>Валидатор</th><th>fip_id</th><th>С какого времени</th><th>Заметка</th><th></th></tr></thead>
|
||
<tbody>
|
||
{{range .Rows}}
|
||
<tr>
|
||
<td data-label=""><input type="checkbox" name="addresses" value="{{.Address}}"></td>
|
||
<td class="mono" data-label="Адрес">{{.Address}}</td>
|
||
<td class="mono" data-label="Валидатор">{{.ValidatorID}}</td>
|
||
<td class="mono" data-label="fip_id">{{.FIPID}}</td>
|
||
<td data-label="С какого времени">{{fmtTime .CreatedAt}} ({{.Duration}})</td>
|
||
<td data-label="Заметка">{{if .Note}}{{.Note}}{{else}}—{{end}}</td>
|
||
<td data-label=""><button type="button" class="btn btn-danger-ghost btn-sm" hx-post="/diagnostics/detach" hx-vals='{"addresses":"{{.Address}}"}' hx-target="#diagnostics-action-result" hx-swap="innerHTML" hx-confirm="Отвязать {{.Address}}?">Отвязать</button></td>
|
||
</tr>
|
||
{{end}}
|
||
</tbody>
|
||
</table>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
{{else}}<p class="muted">Удерживаемых адресов нет.</p>{{end}}
|
||
</div>
|
||
{{end}}
|