|
|
|
|
@ -144,6 +144,7 @@ function renderAgent(agent) {
|
|
|
|
|
button.dataset.hostId = String(agent.host_id);
|
|
|
|
|
button.setAttribute('aria-controls', 'agent-settings-drawer');
|
|
|
|
|
button.setAttribute('aria-haspopup', 'dialog');
|
|
|
|
|
button.setAttribute('aria-expanded', 'false');
|
|
|
|
|
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', '');
|
|
|
|
|
@ -192,6 +193,10 @@ function renderList() {
|
|
|
|
|
group.append(header, nodes); list.append(group);
|
|
|
|
|
}
|
|
|
|
|
if (!visible) list.append(text('p', 'cloud-admin-host-empty', '没有符合当前筛选条件的 Agent。'));
|
|
|
|
|
if (byId('agent-settings-drawer')?.open) {
|
|
|
|
|
state.drawerOpener = list.querySelector(`[data-host-id="${state.selected}"]`);
|
|
|
|
|
state.drawerOpener?.setAttribute('aria-expanded', 'true');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function renderHealth(agent) {
|
|
|
|
|
@ -234,11 +239,11 @@ function generateAgentSecret() {
|
|
|
|
|
return btoa(String.fromCharCode(...bytes)).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/u, '');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function configFragment(agent, secret) {
|
|
|
|
|
function configFragment(agent, secret, redact = false) {
|
|
|
|
|
return JSON.stringify({
|
|
|
|
|
panel_url: location.origin,
|
|
|
|
|
agent_id: String(agent?.agent_id || agent?.host_id || ''),
|
|
|
|
|
agent_secret: secret,
|
|
|
|
|
agent_secret: redact ? '••••••••••••••••••••••••••••••••' : secret,
|
|
|
|
|
}, null, 2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -272,7 +277,8 @@ function renderSecretDraft(agent) {
|
|
|
|
|
|| (rotating && !state.rotationConfirmed);
|
|
|
|
|
const box = byId('agent-settings-config-box');
|
|
|
|
|
box.hidden = !hasDraft;
|
|
|
|
|
byId('agent-settings-config-preview').textContent = hasDraft ? configFragment(agent, secret) : '';
|
|
|
|
|
byId('agent-settings-config-preview').textContent = hasDraft
|
|
|
|
|
? configFragment(agent, secret, !state.secretVisible) : '';
|
|
|
|
|
const generateLabel = byId('agent-settings-generate').querySelector('span');
|
|
|
|
|
generateLabel.textContent = agent?.secret_configured ? '生成新密钥(轮换)' : '生成安全密钥';
|
|
|
|
|
byId('agent-settings-secret-help').textContent = hasDraft && agent?.secret_configured
|
|
|
|
|
@ -302,7 +308,6 @@ function finishDrawerClose() {
|
|
|
|
|
state.drawerScroll = null;
|
|
|
|
|
if (state.drawerOpener?.isConnected) state.drawerOpener.focus({ preventScroll: true });
|
|
|
|
|
state.drawerOpener = null;
|
|
|
|
|
clearSecretDraft();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function openDrawer(opener) {
|
|
|
|
|
@ -311,11 +316,14 @@ function openDrawer(opener) {
|
|
|
|
|
if (drawer.open) return;
|
|
|
|
|
lockDrawerScroll();
|
|
|
|
|
window.VenixDrawerMotion.openDrawerWithMotion(drawer);
|
|
|
|
|
opener?.setAttribute('aria-expanded', 'true');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function closeDrawer() {
|
|
|
|
|
const drawer = byId('agent-settings-drawer');
|
|
|
|
|
if (!drawer?.open) return;
|
|
|
|
|
state.drawerOpener?.setAttribute('aria-expanded', 'false');
|
|
|
|
|
clearSecretDraft();
|
|
|
|
|
void window.VenixDrawerMotion.closeDrawerWithMotion(drawer).then(closed => {
|
|
|
|
|
if (closed) finishDrawerClose();
|
|
|
|
|
});
|
|
|
|
|
|