refator_comm1

This commit is contained in:
Mateusz Gruszczyński
2025-10-18 22:34:51 +02:00
parent fda2b721b3
commit 8e3d191233
2 changed files with 11 additions and 13 deletions

View File

@@ -55,6 +55,11 @@ function rebuildTargetSelect(selectEl, currentNode, nodes) {
if (idx >= 0) selectEl.selectedIndex = idx;
}
function setMigrateDisabled(tr, disabled) {
const btn = tr.querySelector('.act-migrate');
if (btn) btn.disabled = !!disabled;
}
export async function renderVMAdmin() {
injectOnceCSS();
stopAllAdminWatches();
@@ -78,12 +83,9 @@ export async function renderVMAdmin() {
const sel = `<select class="form-select form-select-sm target-node" style="min-width:160px">
${availableNodes.map(n => `<option value="${n}" ${n === x.node ? 'disabled selected' : ''}>${n}</option>`).join('')}
</select>`;
const tools = `<div class="d-flex align-items-center gap-2">
<button class="btn btn-outline-primary btn-sm act-migrate">Migrate (offline)</button>
<button class="btn btn-outline-secondary btn-sm act-status">Details</button>
</div>`;
// Kolumny: SID | TYPE | NAME | NODE | ACTIONS | TARGET | TOOLS
return rowHTML([sid, type.toUpperCase(), nameCell, node, actions, sel, tools], `data-sid="${sid}"`);
const migrateBtn = `<button class="btn btn-outline-primary btn-sm act-migrate">Migrate (offline)</button>`;
// Kolumny: SID | TYPE | NAME | NODE | ACTIONS | TARGET | MIGRATE
return rowHTML([sid, type.toUpperCase(), nameCell, node, actions, sel, migrateBtn], `data-sid="${sid}"`);
});
setRows(tbody, rows);
@@ -155,10 +157,6 @@ export async function renderVMAdmin() {
tr.querySelector('.act-shutdown')?.addEventListener('click',() => doAction('shutdown'));
tr.querySelector('.act-migrate')?.addEventListener('click', () => doAction('migrate', true));
tr.querySelector('.act-status')?.addEventListener('click', async () => {
flashDot(nameCell);
});
ensureWatchOn();
});