fix(ui): collapsible panels with arrow + tighter clients table

Use details/summary for WARP, cascade, users; fix broken users markup.
Fold long last_config hints; fixed table columns; widen shell max width.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Андрей Бобырев
2026-05-14 20:11:45 +03:00
parent 8f1d7a7c4a
commit 47842a4047
4 changed files with 256 additions and 65 deletions

View File

@@ -1,6 +1,6 @@
{ {
"name": "amnezia-admin", "name": "amnezia-admin",
"version": "1.1.5", "version": "1.1.6",
"private": true, "private": true,
"description": "Web-панель AmneziaWG: несколько инстансов, WARP, каскад/Endpoint, экспорт .conf (Docker)", "description": "Web-панель AmneziaWG: несколько инстансов, WARP, каскад/Endpoint, экспорт .conf (Docker)",
"license": "MIT", "license": "MIT",

View File

@@ -551,11 +551,17 @@ function renderRows(clients) {
); );
nameWrap.append(strong, renameWrap); nameWrap.append(strong, renameWrap);
if (!c.exportAvailable) { if (!c.exportAvailable) {
const hintFold = document.createElement("details");
hintFold.className = "hint-mini";
const sum = document.createElement("summary");
sum.textContent = "Нет готового .conf на сервере (last_config)";
hintFold.appendChild(sum);
const exHint = document.createElement("p"); const exHint = document.createElement("p");
exHint.className = "muted export-missing-hint"; exHint.className = "muted export-missing-hint";
exHint.textContent = exHint.textContent =
"Конфиг с сервера недоступен (нет last_config). Создайте клиента с нужным Endpoint в блоке «Новый клиент под каскад» ниже или возьмите ключ из приложения Amnezia."; "Конфиг с сервера недоступен (нет last_config). Создайте клиента с нужным Endpoint в блоке «Новый клиент под каскад» ниже или возьмите ключ из приложения Amnezia.";
nameWrap.appendChild(exHint); hintFold.appendChild(exHint);
nameWrap.appendChild(hintFold);
} }
nameTd.appendChild(nameWrap); nameTd.appendChild(nameWrap);

View File

@@ -90,71 +90,95 @@
<p id="status" class="status" role="status"></p> <p id="status" class="status" role="status"></p>
<section class="panel warp-panel" id="warp-panel" hidden> <details class="panel-fold warp-panel" id="warp-panel" hidden>
<div class="panel-head"> <summary class="fold-summary">
<h2>Cloudflare WARP</h2> <span class="fold-arrow" aria-hidden="true"></span>
<span class="muted" id="warp-status-line"></span> <span class="fold-titles">
<span class="fold-h">Cloudflare WARP</span>
<span class="muted fold-meta" id="warp-status-line"></span>
</span>
</summary>
<div class="panel-fold-body">
<p class="muted warp-intro">
<strong>Необязательно.</strong> Если достаточно обычного AmneziaWG без выхода части клиентов через Cloudflare — раздел можно не трогать (статус «Не установлен» — норма).
Если WARP нужен: выход в интернет через Cloudflare для <em>выбранных</em> клиентов (правила маршрутизации и NAT в контейнере).
Один раз на хосте VPS под root: в каталоге с репозиторием выполните <code class="inline">bash scripts/warp-amnezia.sh install</code>.
Затем отметьте клиентов ниже и нажмите «Применить» (контейнер AWG перезапустится). Убрать WARP полностью: <code class="inline">bash scripts/warp-amnezia.sh uninstall</code> — см. README.
</p>
<div id="warp-actions" class="warp-actions"></div>
<div id="warp-client-list" class="warp-client-list"></div>
<details class="raw warp-raw">
<summary>Вывод wg show warp</summary>
<pre id="warp-wg-show"></pre>
</details>
</div> </div>
<p class="muted warp-intro"> </details>
<strong>Необязательно.</strong> Если достаточно обычного AmneziaWG без выхода части клиентов через Cloudflare — раздел можно не трогать (статус «Не установлен» — норма).
Если WARP нужен: выход в интернет через Cloudflare для <em>выбранных</em> клиентов (правила маршрутизации и NAT в контейнере).
Один раз на хосте VPS под root: в каталоге с репозиторием выполните <code class="inline">bash scripts/warp-amnezia.sh install</code>.
Затем отметьте клиентов ниже и нажмите «Применить» (контейнер AWG перезапустится). Убрать WARP полностью: <code class="inline">bash scripts/warp-amnezia.sh uninstall</code> — см. README.
</p>
<div id="warp-actions" class="warp-actions"></div>
<div id="warp-client-list" class="warp-client-list"></div>
<details class="raw warp-raw">
<summary>Вывод wg show warp</summary>
<pre id="warp-wg-show"></pre>
</details>
</section>
<section class="panel cascade-panel" id="cascade-panel"> <details class="panel-fold cascade-panel" id="cascade-panel" open>
<div class="panel-head"> <summary class="fold-summary">
<h2>Новый клиент под каскад</h2> <span class="fold-arrow" aria-hidden="true"></span>
<span class="fold-titles">
<span class="fold-h">Новый клиент под каскад</span>
<span class="muted fold-meta">Создать peer и скачать .conf</span>
</span>
</summary>
<div class="panel-fold-body">
<p class="muted cascade-intro">
Укажите <strong>Endpoint</strong> — публичный IP или DNS узла, <em>куда клиент будет подключаться первым шагом</em>
(промежуточный сервер, домашний роутер с пробросом порта и т.д.). Порт по умолчанию совпадает с <code class="inline">ListenPort</code> этого инстанса.
Клиент будет <strong>создан на текущем сервере AmneziaWG</strong> (новые ключи); IP в туннеле можно задать явно или оставить пустым — подберём свободный в той же подсети, что у остальных.
</p>
<form id="cascade-form" class="cascade-form">
<label for="cascade-endpoint">Endpoint (хост для клиента)</label>
<input id="cascade-endpoint" type="text" placeholder="Например 203.0.113.50 или ddns.example.com" required autocomplete="off">
<label for="cascade-port">Порт Endpoint</label>
<input id="cascade-port" type="number" min="1" max="65535" placeholder="Пусто — как у сервера" autocomplete="off">
<label for="cascade-tunnel-ip">IP в VPN-туннеле (необязательно)</label>
<input id="cascade-tunnel-ip" type="text" placeholder="Например 10.8.1.20 — та же подсеть /24 что у других" autocomplete="off">
<label for="cascade-name">Имя в таблице</label>
<input id="cascade-name" type="text" placeholder="Например Телефон через узел X" autocomplete="off">
<button type="submit" class="btn primary">Создать на сервере и скачать .conf</button>
</form>
</div> </div>
<p class="muted cascade-intro"> </details>
Укажите <strong>Endpoint</strong> — публичный IP или DNS узла, <em>куда клиент будет подключаться первым шагом</em>
(промежуточный сервер, домашний роутер с пробросом порта и т.д.). Порт по умолчанию совпадает с <code class="inline">ListenPort</code> этого инстанса.
Клиент будет <strong>создан на текущем сервере AmneziaWG</strong> (новые ключи); IP в туннеле можно задать явно или оставить пустым — подберём свободный в той же подсети, что у остальных.
</p>
<form id="cascade-form" class="cascade-form">
<label for="cascade-endpoint">Endpoint (хост для клиента)</label>
<input id="cascade-endpoint" type="text" placeholder="Например 203.0.113.50 или ddns.example.com" required autocomplete="off">
<label for="cascade-port">Порт Endpoint</label> <details class="panel-fold" id="users-panel" open>
<input id="cascade-port" type="number" min="1" max="65535" placeholder="Пусто — как у сервера" autocomplete="off"> <summary class="fold-summary">
<span class="fold-arrow" aria-hidden="true"></span>
<label for="cascade-tunnel-ip">IP в VPN-туннеле (необязательно)</label> <span class="fold-titles">
<input id="cascade-tunnel-ip" type="text" placeholder="Например 10.8.1.20 — та же подсеть /24 что у других" autocomplete="off"> <span class="fold-h">Пользователи</span>
<span class="muted fold-meta" id="peer-count"></span>
<label for="cascade-name">Имя в таблице</label> </span>
<input id="cascade-name" type="text" placeholder="Например Телефон через узел X" autocomplete="off"> </summary>
<div class="panel-fold-body">
<button type="submit" class="btn primary">Создать на сервере и скачать .conf</button> <div class="table-wrap">
</form> <table class="clients-table">
</section> <thead>
<tr>
<section class="panel" id="users-panel"> <th>Имя</th>
<span class="muted" id="peer-count"></span> <th>IP</th>
<th>Статус</th>
<th>Последнее отключение</th>
<th class="th-actions">Действия</th>
</tr>
</thead>
<tbody id="rows"></tbody>
</table>
</div>
</div> </div>
<div class="table-wrap"> </details>
<table>
<thead>
<tr>
<th>Имя</th>
<th>IP</th>
<th>Статус</th>
<th>Последнее отключение</th>
<th></th>
</tr>
</thead>
<tbody id="rows"></tbody>
</table>
</div>
</section>
<details class="raw" id="wg-raw-details"> <details class="raw panel-fold-raw" id="wg-raw-details">
<summary class="fold-summary fold-summary--raw">
<span class="fold-arrow" aria-hidden="true"></span>
<span class="fold-titles">
<span class="fold-h">Вывод awg show (отладка)</span>
</span>
</summary>
<pre id="wg-show"></pre> <pre id="wg-show"></pre>
</details> </details>
</div> </div>

View File

@@ -28,7 +28,7 @@ body.page {
.shell { .shell {
flex: 1 0 auto; flex: 1 0 auto;
max-width: 960px; max-width: min(1120px, 100%);
margin: 0 auto; margin: 0 auto;
padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1rem, 3vw, 1.5rem) 3rem; padding: clamp(1.5rem, 4vw, 2.5rem) clamp(1rem, 3vw, 1.5rem) 3rem;
} }
@@ -437,13 +437,151 @@ h1 {
font-size: 1rem; font-size: 1rem;
} }
/* Сворачиваемые блоки (стрелка в summary, как disclosure) */
.panel-fold {
margin-top: 1rem;
border: 1px solid var(--line);
border-radius: 16px;
background: var(--card);
overflow: hidden;
}
.panel-fold > summary.fold-summary {
list-style: none;
display: flex;
align-items: flex-start;
gap: 0.65rem;
padding: 0.95rem 1.1rem;
cursor: pointer;
user-select: none;
border-bottom: 1px solid transparent;
}
.panel-fold[open] > summary.fold-summary {
border-bottom-color: var(--line);
}
.panel-fold > summary.fold-summary::-webkit-details-marker {
display: none;
}
.fold-arrow {
flex-shrink: 0;
width: 0;
height: 0;
margin-top: 0.32rem;
border-style: solid;
border-width: 5px 0 5px 8px;
border-color: transparent transparent transparent var(--accent);
transition: transform 0.15s ease;
}
.panel-fold[open] > summary.fold-summary .fold-arrow {
transform: rotate(90deg);
margin-top: 0.42rem;
}
.fold-titles {
display: flex;
flex-wrap: wrap;
align-items: baseline;
gap: 0.35rem 1rem;
flex: 1;
min-width: 0;
}
.fold-h {
font-weight: 700;
font-size: 1rem;
margin: 0;
}
.fold-meta {
font-size: 0.82rem;
}
.panel-fold-body {
padding: 0 1.1rem 1.1rem;
}
.panel-fold-body > .warp-intro:first-child,
.panel-fold-body > .cascade-intro:first-child {
margin-top: 0.85rem;
}
.panel-fold-raw {
margin-top: 1rem;
}
.panel-fold-raw > summary.fold-summary--raw {
list-style: none;
display: flex;
align-items: flex-start;
gap: 0.65rem;
padding: 0.65rem 0;
cursor: pointer;
user-select: none;
}
.panel-fold-raw[open] > summary.fold-summary--raw .fold-arrow {
transform: rotate(90deg);
margin-top: 0.42rem;
}
.panel-fold-raw > summary.fold-summary--raw::-webkit-details-marker {
display: none;
}
.panel-fold-raw > pre {
margin-top: 0.5rem;
}
.th-actions {
width: 1%;
white-space: nowrap;
text-align: right;
}
.table-wrap {
overflow-x: auto;
}
.muted { .muted {
color: var(--muted); color: var(--muted);
font-size: 0.88rem; font-size: 0.88rem;
} }
.table-wrap { table.clients-table {
overflow-x: auto; table-layout: fixed;
}
.clients-table th:nth-child(1),
.clients-table td:nth-child(1) {
width: 26%;
vertical-align: top;
}
.clients-table th:nth-child(2),
.clients-table td:nth-child(2) {
width: 17%;
}
.clients-table th:nth-child(3),
.clients-table td:nth-child(3) {
width: 14%;
}
.clients-table th:nth-child(4),
.clients-table td:nth-child(4) {
width: 22%;
}
.clients-table .name-cell {
min-width: 0;
}
.clients-table td.actions {
vertical-align: top;
} }
table { table {
@@ -525,7 +663,30 @@ tr:last-child td {
margin: 0.35rem 0 0; margin: 0.35rem 0 0;
font-size: 0.72rem; font-size: 0.72rem;
line-height: 1.35; line-height: 1.35;
max-width: 22rem; max-width: none;
}
.hint-mini {
margin-top: 0.35rem;
border: 1px solid var(--line);
border-radius: 8px;
padding: 0.35rem 0.5rem;
background: rgba(0, 0, 0, 0.18);
}
.hint-mini summary {
cursor: pointer;
font-size: 0.72rem;
color: var(--muted);
list-style: none;
}
.hint-mini summary::-webkit-details-marker {
display: none;
}
.hint-mini .export-missing-hint {
margin: 0.4rem 0 0;
} }
.profile-hint { .profile-hint {