diff --git a/web/public/cloud/admin.css b/web/public/cloud/admin.css index 3f8ce2fe..ccc2f5a5 100644 --- a/web/public/cloud/admin.css +++ b/web/public/cloud/admin.css @@ -1276,6 +1276,61 @@ font-weight: 800; } +.cloud-agent-checklist { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 10px; + margin: 0; + padding: 0; + list-style: none; +} + +.cloud-agent-checklist-step { + display: flex; + align-items: center; + gap: 10px; + min-height: 54px; + padding: 11px 13px; + border: 1px solid #dce5ef; + border-radius: 9px; + color: #667085; + background: #f8fafc; + font-weight: 800; +} + +.cloud-agent-checklist-mark { + flex: 0 0 28px; + width: 28px; + height: 28px; + display: grid; + place-items: center; + border-radius: 50%; + color: #667085; + background: #e7edf3; + font-size: 12px; +} + +.cloud-agent-checklist-step.is-current { + border-color: rgba(13, 148, 136, 0.35); + color: #0f766e; + background: rgba(20, 184, 166, 0.06); +} + +.cloud-agent-checklist-step.is-current .cloud-agent-checklist-mark { + color: #fff; + background: #0f9f92; +} + +.cloud-agent-checklist-step.is-done { + color: #087f5b; + background: #f0fdf7; +} + +.cloud-agent-checklist-step.is-done .cloud-agent-checklist-mark { + color: #fff; + background: #12a67e; +} + .cloud-admin-startup-button { grid-column: 1 / -1; justify-self: start; diff --git a/web/public/cloud/agent-settings.js b/web/public/cloud/agent-settings.js index 0ed5b2bc..abb5bec7 100644 --- a/web/public/cloud/agent-settings.js +++ b/web/public/cloud/agent-settings.js @@ -4,6 +4,7 @@ const canManage = root?.dataset.canManage === '1'; const state = { csrf: window.ADMIN_CSRF_TOKEN || '', agents: [], regions: [], summary: {}, selected: null, busy: false, expandedRegions: new Set(), regionsInitialized: false, + drawerOpener: null, drawerScroll: null, }; function notice(message, error = false) { @@ -139,6 +140,8 @@ function renderAgent(agent) { const button = text('button', 'cloud-admin-host cloud-admin-agent-row', ''); button.type = 'button'; button.dataset.hostId = String(agent.host_id); + button.setAttribute('aria-controls', 'agent-settings-drawer'); + button.setAttribute('aria-haspopup', 'dialog'); button.setAttribute('aria-label', `配置 Agent ${agent.host_name || agent.agent_id}`); if (String(agent.host_id) === String(state.selected)) button.setAttribute('aria-current', 'true'); const heading = text('span', 'cloud-admin-host-heading', ''); @@ -149,7 +152,13 @@ function renderAgent(agent) { const metrics = text('span', 'cloud-admin-host-metrics', ''); metrics.append(text('span', '', `版本 ${agent.last_agent_version || '--'}`), text('span', '', `最近测试 ${lastTestText(agent)}`)); button.append(heading, statuses, path, metrics); - button.addEventListener('click', () => { state.selected = String(agent.host_id); renderList(); fill(agent); }); + button.addEventListener('click', () => { + state.selected = String(agent.host_id); + fill(agent); + renderList(); + const opener = byId('agent-settings-list').querySelector(`[data-host-id="${agent.host_id}"]`); + openDrawer(opener); + }); return button; } @@ -196,10 +205,62 @@ function renderHealth(agent) { for (const [label, value] of rows) { health.append(text('dt', '', label), text('dd', '', value)); } } +function renderChecklist(agent) { + const checklist = byId('agent-settings-checklist'); + checklist.replaceChildren(); + const steps = [ + ['保存连接身份', agent.secret_configured === true], + ['更新宿主机配置并重启 Agent', agent.ready === true], + ['完成宿主机存储注册', agent.storage_configured === true], + ['通过健康与必要能力测试', agent.ready === true], + ]; + const firstIncomplete = steps.findIndex(([, done]) => !done); + for (const [index, [label, done]] of steps.entries()) { + const item = text('li', 'cloud-agent-checklist-step', ''); + if (done) item.classList.add('is-done'); + else if (index === firstIncomplete) item.classList.add('is-current'); + const mark = text('span', 'cloud-agent-checklist-mark', done ? '✓' : String(index + 1)); + item.append(mark, text('span', '', label)); + checklist.append(item); + } +} + +function lockDrawerScroll() { + state.drawerScroll = { x: window.scrollX, y: window.scrollY }; + document.body.style.setProperty('--admin-instance-scroll-top', `${-state.drawerScroll.y}px`); + document.documentElement.classList.add('admin-instance-detail-open'); +} + +function finishDrawerClose() { + document.documentElement.classList.remove('admin-instance-detail-open'); + document.body.style.removeProperty('--admin-instance-scroll-top'); + if (state.drawerScroll) window.scrollTo({ left: state.drawerScroll.x, top: state.drawerScroll.y, behavior: 'instant' }); + state.drawerScroll = null; + if (state.drawerOpener?.isConnected) state.drawerOpener.focus({ preventScroll: true }); + state.drawerOpener = null; +} + +function openDrawer(opener) { + const drawer = byId('agent-settings-drawer'); + state.drawerOpener = opener || null; + if (drawer.open) return; + lockDrawerScroll(); + window.VenixDrawerMotion.openDrawerWithMotion(drawer); +} + +function closeDrawer() { + const drawer = byId('agent-settings-drawer'); + if (!drawer?.open) return; + void window.VenixDrawerMotion.closeDrawerWithMotion(drawer).then(closed => { + if (closed) finishDrawerClose(); + }); +} + function fill(agent) { byId('agent-settings-host-id').value = agent?.host_id || ''; byId('agent-settings-revision').value = String(agent?.revision || 0); byId('agent-settings-title').textContent = agent ? `Agent 上行连接 · ${agent.host_name}` : '选择计算节点'; + byId('agent-settings-panel-url').value = location.origin; byId('agent-settings-agent-id').value = agent?.agent_id || agent?.host_id || ''; byId('agent-settings-secret').value = ''; byId('agent-settings-secret').placeholder = agent?.secret_configured ? '已配置,留空保留现有密钥' : '首次配置必须填写至少 32 位密钥'; @@ -208,6 +269,7 @@ function fill(agent) { byId('agent-settings-save').disabled = !canManage || !agent || state.busy; byId('agent-settings-test').disabled = !canManage || !agent?.enabled || !agent?.secret_configured || state.busy; renderHealth(agent || {}); + renderChecklist(agent || {}); } async function load() { @@ -273,6 +335,9 @@ async function testConnection() { if (root) { byId('agent-settings-form').addEventListener('submit', save); byId('agent-settings-test').addEventListener('click', testConnection); + byId('agent-settings-close').addEventListener('click', closeDrawer); + byId('agent-settings-drawer').addEventListener('cancel', event => { event.preventDefault(); closeDrawer(); }); + byId('agent-settings-drawer').addEventListener('click', event => { if (event.target === event.currentTarget) closeDrawer(); }); byId('agent-settings-search').addEventListener('input', renderList); byId('agent-settings-region-filter').addEventListener('change', renderList); byId('agent-settings-state-filter').addEventListener('change', renderList); diff --git a/web/resources/views/venix/admin/cloud/agents.tpl b/web/resources/views/venix/admin/cloud/agents.tpl index a635e800..7c6c6f95 100644 --- a/web/resources/views/venix/admin/cloud/agents.tpl +++ b/web/resources/views/venix/admin/cloud/agents.tpl @@ -37,47 +37,49 @@
+ + -
-
-
-
-

Connection

-
选择计算节点
-

PHP 持久化并签名任务,本机 Go Gateway 通过 Agent 主动建立的 WSS 连接下发。

-
- -
- - -
-
-
- - -
把此 ID 与面板 HTTPS 地址、下面保存的同一密钥写入该宿主机 Agent 配置。
-
-
- - -
密钥不会从服务器返回到浏览器。
-
-
- -
-
+ +
+

Agent Connection

选择计算节点

+ +
+
+
+
接入进度

按顺序完成身份保存、宿主机配置、存储注册和能力测试。

+
    +
    + + + +
    +
    连接身份

    Agent 主动连接面板,不需要配置入站管理端口。

    +
    +
    +
    将面板地址、Agent ID 和同一密钥写入该宿主机 Agent 配置。
    -
    -
    +
    +
    连接密钥

    密钥由 cloud_data_key 派生用途密钥密封保存,保存后不再回显。

    +
    +
    密钥不会从服务器返回到浏览器。
    +
    -
    + +
    +
    健康与能力

    显示当前配置版本最近一次完整测试的结果。

    +
    +
    - +
    + 测试会通过当前 WSS 会话读取健康与能力;全部通过才标记就绪。 +
    + + +
    +
    + {include file='admin/static_footer.tpl'} diff --git a/web/resources/views/venix/layout_assets.tpl b/web/resources/views/venix/layout_assets.tpl index 94a663af..f070aad9 100644 --- a/web/resources/views/venix/layout_assets.tpl +++ b/web/resources/views/venix/layout_assets.tpl @@ -1,2 +1,2 @@ {* Shared Venix CSS/JS cache key. Increment whenever a shared browser asset changes. *} -{assign var=venix_asset_version value='2026103105' scope='global'} +{assign var=venix_asset_version value='2026103106' scope='global'} diff --git a/web/tests/AdminAgentRegionUiContractTest.php b/web/tests/AdminAgentRegionUiContractTest.php index 05269f23..6afcece7 100644 --- a/web/tests/AdminAgentRegionUiContractTest.php +++ b/web/tests/AdminAgentRegionUiContractTest.php @@ -23,6 +23,9 @@ $assert(str_contains($template, 'id="agent-settings-summary"') && str_contains($template, 'id="agent-settings-search"') && str_contains($template, 'id="agent-settings-region-filter"') && str_contains($template, 'id="agent-settings-state-filter"') + && str_contains($template, 'id="agent-settings-drawer"') + && str_contains($template, 'data-admin-agent-settings-drawer') + && str_contains($template, 'id="agent-settings-checklist"') && str_contains($template, 'aria-controls="agent-settings-list"'), 'Agent page is missing its summary or region filters.'); $assert(str_contains($script, 'state.regions = Array.isArray(payload.regions)') @@ -32,14 +35,18 @@ $assert(str_contains($script, 'state.regions = Array.isArray(payload.regions)') && str_contains($script, 'function renderAgent(') && str_contains($script, 'function replaceAgent(') && str_contains($script, 'function refreshSummaryFromAgents(') + && str_contains($script, 'function renderChecklist(') + && str_contains($script, 'function openDrawer(') + && str_contains($script, 'function closeDrawer(') && str_contains($script, "agent.status === 'ready'"), 'Agent browser module does not render grouped status projections.'); $assert(str_contains($styles, '.cloud-admin-agent-directory') && str_contains($styles, '.cloud-admin-agent-filters') - && str_contains($styles, '.cloud-admin-agent-row'), + && str_contains($styles, '.cloud-admin-agent-row') + && str_contains($styles, '.cloud-agent-checklist-step'), 'Agent region layout styles are missing.'); $assert(preg_match("/venix_asset_version value='([0-9]+)'/", $assets, - $match) === 1 && (int) $match[1] >= 2026103105, + $match) === 1 && (int) $match[1] >= 2026103106, 'Agent region UI requires a new shared asset version.'); echo "Administrator Agent region UI contracts passed.\n";