mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
The page showed memory as MiB counts ("16768 MiB"), the destination and
the shut-off switch apart from the list, and a Migrate button below the
whole list that did not say how many VMs it would migrate. Now the list
is one card: "host -> destination" (a choice when there are several) and
the shut-off switch in its header, sizes as on the Computes and Balance
pages, and a footer that stays in sight below a long list with the
number at once and a "Migrate the chosen VMs" button that counts the
ticked VMs and is off while none is.
28 lines
1.2 KiB
JavaScript
28 lines
1.2 KiB
JavaScript
// The Bulk Migrate page: another destination reloads the list; the header
|
|
// box ticks or unticks every VM that can migrate, "Also migrate the
|
|
// shut-off VMs" the shut-off ones. The Migrate button counts the ticked
|
|
// VMs and is off while none is.
|
|
function tick(selector, checked) {
|
|
document.querySelectorAll(selector).forEach(function (box) {
|
|
box.checked = checked;
|
|
});
|
|
}
|
|
function count() {
|
|
const ticked = document.querySelectorAll("input[name=instance]:checked").length;
|
|
const button = document.getElementById("bulk-migrate-submit");
|
|
if (button) {
|
|
button.disabled = ticked === 0;
|
|
document.getElementById("bulk-migrate-count").textContent = ticked;
|
|
}
|
|
}
|
|
document.getElementById("bulk-migrate-target")?.addEventListener("change", function (event) {
|
|
event.target.form.submit();
|
|
});
|
|
document.getElementById("bulk-migrate-all")?.addEventListener("change", function (event) {
|
|
tick("input[name=instance]:not(:disabled)", event.target.checked);
|
|
});
|
|
document.getElementById("bulk-migrate-shut-off")?.addEventListener("change", function (event) {
|
|
tick("input[data-shut-off]:not(:disabled)", event.target.checked);
|
|
});
|
|
document.addEventListener("change", count);
|
|
count();
|