1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-02 17:06:09 +00:00
webvirtcloud/static/js/balance.js
catborise 1259c11591 fix(computes): the Balance page shows each host's load as bars
The page was a bare table of rounded GiB totals, a footnote shown also
when nothing would move, three tables with their own columns and a
Migrate button far below the list. Now:

- a breadcrumb back to Computes and a one-line description;
- a card per host with its running VMs' memory and vCPUs now and after,
  as bars on one scale, so the imbalance and its fix show at a glance;
- the proposed migrations in one card, "host -> destination" in one
  column, sizes as on the Computes page, and the number at once with a
  "Migrate N VMs" button in its footer;
- the VMs that stay (kept by the user, or unable to move) in one table
  with the reason;
- a success message when the hosts are balanced.

The VM boxes join the proposal's form by their form attribute, so the
migrations' form holds the list.
2026-11-16 08:11:47 +03:00

18 lines
682 B
JavaScript

// The Balance page: unticking a VM keeps it where it is, ticking it again
// lets it move; either makes the proposal again. The header box ticks or
// unticks every VM listed. The boxes sit in the page's tables and belong
// to the proposal's form by their form attribute.
const form = document.getElementById("balance-form");
document.addEventListener("change", function (event) {
if (!form || event.target.form !== form) {
return;
}
if (event.target.id === "balance-all") {
for (const box of form.elements) {
if (box.name === "vm") {
box.checked = event.target.checked;
}
}
}
form.submit();
});