An admin-controlled scenario that repeats what the operator does by hand: clear the IP queue, scan and enqueue all free Floating IPs, wait until every queued address reaches a terminal state (so results are in the Registry), then wait a configurable interval and start over. - control-api: new auto_cycle singleton table (migration 0008) holding enabled/interval/max-run settings and persisted phase state, so the cycle survives restarts; engine in orchestrator/autocycle.go driven from the existing loop tick with an injectable "now" for deterministic tests. - Interval (default 1h, min 60s) and max wait (default unlimited, timeout outcome) are runtime settings, never hardcoded. - The periodic fip_scan_interval_seconds scan is skipped while the cycle is enabled. An emptied queue mid-cycle counts as finished; stopping during the pause keeps the last cycle's outcome. - API: GET/PUT /api/v1/admin/auto-cycle, POST .../start, POST .../stop. - admin-dashboard: "Автоматический цикл" panel on /settings and an "Автоцикл активен" indicator on /overview. - Tests for db, orchestrator, httpapi and dashboard; run-local-e2e.sh now exercises a full auto cycle; docs updated; bin/ rebuilt with refreshed SHA256SUMS. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
79 lines
3.5 KiB
HTML
79 lines
3.5 KiB
HTML
{{define "overview_stats"}}
|
|
<div class="stat-grid">
|
|
<div class="stat-card accented"><span class="value">{{.Status.TotalIPs}}</span><span class="label">всего IP</span></div>
|
|
<div class="stat-card"><span class="value">{{.Status.TotalValidators}}</span><span class="label">валидаторов</span></div>
|
|
{{range $state, $count := .Status.IPsByState}}
|
|
<div class="stat-card{{if eq $state "failed"}} bad{{else if eq $state "checking"}} accented{{end}}"><span class="value">{{$count}}</span><span class="label">{{$state}}</span></div>
|
|
{{end}}
|
|
</div>
|
|
{{with .AutoCycle}}{{if .Enabled}}
|
|
<p class="muted" id="overview-auto-cycle" style="margin-top:12px"><span class="pill pill-info">Автоцикл активен</span> · {{.PhaseLabel}} · следующий запуск: {{fmtTime .NextRunAt}}</p>
|
|
{{end}}{{end}}
|
|
{{end}}
|
|
|
|
{{/* Out-of-band counterpart of overview_stats, appended to every
|
|
/overview/fragment response alongside overview_tables (the actual
|
|
hx-target) — same OOB idiom as templates/layout.html's error_banner.
|
|
Needed because overview_stats lives outside the polled #overview-tables
|
|
div (see overview.html) so the DOM order can be stats -> filter form ->
|
|
tables, yet the stat counts still refresh on every poll tick. */}}
|
|
{{define "overview_stats_oob"}}<div id="overview-stats" hx-swap-oob="true">{{template "overview_stats" .}}</div>{{end}}
|
|
|
|
{{define "overview_tables"}}
|
|
<h2 class="section-title">Текущая проверка</h2>
|
|
{{if .CurrentItems}}
|
|
<div class="panel">
|
|
<div class="table-scroll">
|
|
<table>
|
|
<thead><tr><th>Адрес</th><th>Состояние</th><th>Валидатор</th><th>Попытка</th><th>Назначено</th></tr></thead>
|
|
<tbody>
|
|
{{range .CurrentItems}}
|
|
{{$b := ipBadge .State .OverallResult .FIPAssociatedAt 0}}
|
|
<tr>
|
|
<td class="addr" data-label="Адрес"><a href="/ips/{{.IPAddress}}">{{.IPAddress}}</a></td>
|
|
<td data-label="Состояние"><span class="pill {{$b.Class}}">{{$b.Label}}</span></td>
|
|
<td data-label="Валидатор">{{deref .OwnerValidatorID}}</td>
|
|
<td class="num" data-label="Попытка">{{.AttemptNumber}}</td>
|
|
<td class="num" data-label="Назначено">{{fmtTime .AssignedAt}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{{else}}
|
|
{{if or .Query .StatusFilter}}<p class="muted">Ничего не найдено по текущему фильтру.</p>
|
|
{{else}}<p class="muted">Сейчас нет адресов в обработке.</p>{{end}}
|
|
{{end}}
|
|
|
|
<h2 class="section-title">Последние {{.LastN}} завершённых</h2>
|
|
<div class="breakdown">
|
|
<span>pass <b>{{index .Breakdown "pass"}}</b></span>
|
|
<span>partial <b>{{index .Breakdown "partial"}}</b></span>
|
|
<span>fail <b>{{index .Breakdown "fail"}}</b></span>
|
|
<span>cancelled <b>{{index .Breakdown "cancelled"}}</b></span>
|
|
</div>
|
|
{{if .LastCompleted}}
|
|
<div class="panel">
|
|
<div class="table-scroll">
|
|
<table>
|
|
<thead><tr><th>Адрес</th><th>Итог</th><th>Завершено</th></tr></thead>
|
|
<tbody>
|
|
{{range .LastCompleted}}
|
|
{{$b := ipBadge .State .OverallResult .FIPAssociatedAt 0}}
|
|
<tr>
|
|
<td class="addr" data-label="Адрес"><a href="/ips/{{.IPAddress}}">{{.IPAddress}}</a></td>
|
|
<td data-label="Итог"><span class="pill {{$b.Class}}">{{$b.Label}}</span></td>
|
|
<td class="num" data-label="Завершено">{{fmtTime .AggregatedAt}}</td>
|
|
</tr>
|
|
{{end}}
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
{{else}}
|
|
{{if or .Query .StatusFilter}}<p class="muted">Ничего не найдено по текущему фильтру.</p>
|
|
{{else}}<p class="muted">Пока ничего не завершено.</p>{{end}}
|
|
{{end}}
|
|
{{end}}
|