Registry: trend chart, always-pass indicator, subnet columns in the address list dialog

- Registry: "Динамика по запускам" chart (Chart.js 4.5.1, vendored) over finalized
  runs per target or site, % or count, subnet and calendar period filters;
  GET /admin/registry/trend
- Registry: clickable "Всегда проходили" indicator with the address list and CSV;
  GET /admin/registry/always-pass and /always-pass/list
- Address list dialog: "Подсеть" and "Метка подсети" columns from the
  administrator's subnet list (shared db.SubnetMatcher), per-subnet summary chips
  with a client-side filter; "прочие" renamed to "вне списка подсетей"
- Rebuild control-api and admin-dashboard binaries; plans and summaries in
  docs/changes, README, API and USAGE updated

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
ayurishchevandClaude Sonnet 5.5 committed 2026-10-08 13:15:02 +03:00
1 parent c13139cd41
commit 1536723196
50 files changed
+3560 -154

No files matched your search

+67 -14
View File
@@ -27,33 +27,86 @@
if (d.showModal) d.showModal(); else d.setAttribute('open', '');
}
/* m: title, note, scope ("Запуск" by default), runLabel, cols, rows, hints
(column index -> text), cellHints (column index -> function of the value),
dist (HTML above the table), csvURL (the file behind "Скачать CSV"). */
function fill(m) {
cur = m;
$('an-dlg-title').textContent = m.title + ' · ' + fmt(m.rows.length);
$('an-dlg-note').textContent = (m.scope || 'Запуск') + ': ' + m.runLabel + '. ' + m.note;
$('an-dlg-dist').hidden = !m.dist;
$('an-dlg-dist').innerHTML = m.dist || '';
var hint = m.hints || {};
$('an-dlg-tbl').innerHTML = '<thead><tr>' + m.cols.map(function (c, i) {
return hint[i] ? '<th ' + tipAttr(hint[i]) + ' tabindex="0">' + esc(c) + '<span class="an-hint" aria-hidden="true">ⓘ</span></th>' : '<th>' + esc(c) + '</th>';
}).join('') + '</tr></thead><tbody>' + m.rows.map(function (x) {
var SUBNET_HINT = 'Подсеть из списка в настройках, в которую входит адрес (самая узкая из подходящих). «вне списка подсетей» — адрес не входит ни в одну; при пустом списке адреса группируются по /24.';
var LABEL_HINT = 'Название подсети, которое задал администратор в настройках. Пусто, если метки нет.';
var MAX_CHIPS = 8;
var subIdx = -1; // index of the "Подсеть" column of the list shown, -1 if none
var subSel = ''; // the subnet chosen in the summary, '' for all
function rowsHTML(m) {
return m.rows.filter(function (x) { return !subSel || x[subIdx] === subSel; }).map(function (x) {
return '<tr>' + x.map(function (v, i) {
var h = m.cellHints && m.cellHints[i] ? m.cellHints[i](v) : '';
return '<td class="' + (i < 2 ? 'an-a' : '') + '"' + (h ? ' ' + tipAttr(h) : '') + '>' + esc(v) + '</td>';
}).join('') + '</tr>';
}).join('') + '</tbody>';
}).join('');
}
/* chips "subnet - N addresses": the largest MAX_CHIPS, a click filters the rows shown */
function renderSubnets(m) {
var box = $('an-dlg-subs');
if (!box) {
box = document.createElement('div');
box.id = 'an-dlg-subs';
box.className = 'an-subs';
$('an-dlg-dist').insertAdjacentElement('afterend', box);
}
box.innerHTML = '';
box.hidden = subIdx < 0 || !m.rows.length;
if (box.hidden) return;
var cnt = {};
m.rows.forEach(function (x) { cnt[x[subIdx]] = (cnt[x[subIdx]] || 0) + 1; });
var names = Object.keys(cnt).sort(function (a, b) { return cnt[b] - cnt[a] || (a < b ? -1 : 1); });
var shown = names.slice(0, MAX_CHIPS);
if (subSel && shown.indexOf(subSel) < 0) shown.push(subSel);
var html = '<span class="an-subs-h">Подсети</span>' + shown.map(function (n) {
return '<button type="button" class="an-sub-chip" data-sub="' + esc(n) + '" aria-pressed="' + (n === subSel) + '">' + esc(n) + ' — ' + fmt(cnt[n]) + '</button>';
}).join('');
if (names.length > shown.length) html += '<span class="an-subs-more">ещё ' + fmt(names.length - shown.length) + '</span>';
if (subSel) html += '<span class="an-subs-more">показано ' + fmt(cnt[subSel]) + ' из ' + fmt(m.rows.length) + '</span>';
box.innerHTML = html;
}
/* m: title, note, scope ("Запуск" by default), runLabel, cols, rows, hints
(column index -> text), cellHints (column index -> function of the value),
dist (HTML above the table), csvURL (the file behind "Скачать CSV").
A list with a "Подсеть" column gets the subnet summary and filter; copying
and the CSV file always carry the whole list. */
function fill(m) {
cur = m;
subSel = '';
subIdx = m.cols.indexOf('Подсеть');
$('an-dlg-title').textContent = m.title + ' · ' + fmt(m.rows.length);
$('an-dlg-note').textContent = (m.scope || 'Запуск') + ': ' + m.runLabel + '. ' + m.note;
$('an-dlg-dist').hidden = !m.dist;
$('an-dlg-dist').innerHTML = m.dist || '';
var hint = {};
m.cols.forEach(function (c, i) {
if (c === 'Подсеть') hint[i] = SUBNET_HINT; else if (c === 'Метка подсети') hint[i] = LABEL_HINT;
});
Object.keys(m.hints || {}).forEach(function (k) { hint[k] = m.hints[k]; });
$('an-dlg-tbl').innerHTML = '<thead><tr>' + m.cols.map(function (c, i) {
return hint[i] ? '<th ' + tipAttr(hint[i]) + ' tabindex="0">' + esc(c) + '<span class="an-hint" aria-hidden="true">ⓘ</span></th>' : '<th>' + esc(c) + '</th>';
}).join('') + '</tr></thead><tbody>' + rowsHTML(m) + '</tbody>';
renderSubnets(m);
$('an-dlg-msg').textContent = '';
}
document.addEventListener('click', function (e) {
var c = e.target.closest ? e.target.closest('.an-sub-chip') : null;
if (!c || !cur || subIdx < 0) return;
subSel = subSel === c.dataset.sub ? '' : c.dataset.sub;
$('an-dlg-tbl').querySelector('tbody').innerHTML = rowsHTML(cur);
renderSubnets(cur);
});
/* Opens the dialog with the title and "Загрузка…", fetches the list as JSON;
resolves with it, or with null (and a message in the dialog) on a failure. */
function load(url, title) {
$('an-dlg-title').textContent = title;
$('an-dlg-note').textContent = 'Загрузка…';
$('an-dlg-dist').hidden = true;
if ($('an-dlg-subs')) $('an-dlg-subs').hidden = true;
$('an-dlg-tbl').innerHTML = '';
$('an-dlg-msg').textContent = '';
cur = null;