feat(instances): show app-installed AmneziaWG, not only panel-created

The instances section listed only panel-managed instances, so an
AmneziaWG container set up by the Amnezia desktop app (e.g.
amnezia-awg2) did not appear as a card.

/api/instances now iterates ALL effective profiles (env-discovered +
managed): resolves each container, reads ListenPort and peer count,
and detects the variant from the interface config (S3/S4 -> awg2,
S1/S2 -> awg, wg0 -> legacy). Native (non-managed) instances are
flagged managed:false.

UI: native cards get an "приложение Amnezia" tag and hide the Удалить
button (the panel must not tear down app-managed containers); they
keep Подключения and Стоп/Старт. Stop/start now resolve the real
container name so they work for native instances too.

Verified live: native amnezia-awg2 shows as "AmneziaWG 2.0" port
37395 (managed:false) alongside a panel-created Legacy :5534.
This commit is contained in:
andrey271192
2026-06-16 21:40:42 +03:00
parent 546c1127f8
commit cdd47f157b
3 changed files with 58 additions and 17 deletions

View File

@@ -1454,12 +1454,18 @@ async function loadInstances() {
? `<button class="btn small ghost" data-act="stop" data-id="${i.id}">■ Стоп</button>`
: `<button class="btn small primary" data-act="start" data-id="${i.id}">▶ Старт</button>`;
const badge = m.badge ? `<span class="inst-badge">${m.badge}</span>` : "";
const srcTag = i.managed
? ""
: `<span class="inst-src" title="Контейнер развёрнут приложением Amnezia">приложение Amnezia</span>`;
const delBtn = i.managed
? `<button class="btn small warn" data-act="delete" data-id="${i.id}" data-label="${escapeHtmlSafe(m.title)}">Удалить</button>`
: "";
return `<div class="inst-card">
<div class="inst-card-head">
<div class="inst-ico">${m.icon}</div>
${toggle}
</div>
<div class="inst-title">${escapeHtmlSafe(m.title)} ${badge}</div>
<div class="inst-title">${escapeHtmlSafe(m.title)} ${badge} ${srcTag}</div>
<div class="inst-desc muted">${escapeHtmlSafe(i.variantMeta?.desc || "")}</div>
<div class="inst-status-row">${status}</div>
<div class="inst-stats">
@@ -1468,7 +1474,7 @@ async function loadInstances() {
</div>
<div class="inst-actions">
<button class="btn small ghost" data-act="use" data-id="${i.id}">Подключения</button>
<button class="btn small warn" data-act="delete" data-id="${i.id}" data-label="${escapeHtmlSafe(m.title)}">Удалить</button>
${delBtn}
</div>
</div>`;
}).join("");