mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-08 11:16:47 +00:00
The VM lists lose their inline scripts and handlers: host_groups.js collapses a host's VMs in the grouped list, new_vm_dialog.js reads the new-VM dialog's CPU bars and capacity lines, and console_window.js (loaded by every page) opens a console button's window, on the lists and on the VM page alike. A list row's Start no longer calls the please-wait dialog, which the list pages do not have (the call only raised an error). The VM page's URL placeholders take the __name__ form the other pages use.
24 lines
1.2 KiB
JavaScript
24 lines
1.2 KiB
JavaScript
// The VM list grouped by host (allinstances_index_grouped.html): a host's
|
|
// VMs collapse under its row. A collapsed host's VM rows are hidden by its
|
|
// table body's class, so the search (table_filter.js, the hidden attribute)
|
|
// can still hide them too.
|
|
function set_host_collapsed(tbody, collapsed) {
|
|
$(tbody).toggleClass('host-collapsed', collapsed);
|
|
$(tbody).find('[aria-controls]').attr('aria-expanded', !collapsed);
|
|
$(tbody).find('.host-chevron').toggleClass('bi-chevron-down', collapsed).toggleClass('bi-chevron-up', !collapsed);
|
|
$(tbody).find('.host-collapsed-badge').toggleClass('d-none', !collapsed);
|
|
// expanded while any host is, as the next click collapses them all
|
|
$('#hide-all-instances').attr('aria-expanded', $('tbody.searchable').not('.host-collapsed').length > 0);
|
|
}
|
|
|
|
// every host the same way: collapsed, unless all already are
|
|
$('#hide-all-instances').on('click', function () {
|
|
var bodies = $('tbody.searchable');
|
|
var collapse = bodies.not('.host-collapsed').length > 0;
|
|
bodies.each(function () { set_host_collapsed(this, collapse); });
|
|
});
|
|
|
|
$('.host-toggle').on('click', function () {
|
|
var tbody = $(this).closest('tbody');
|
|
set_host_collapsed(tbody, !tbody.hasClass('host-collapsed'));
|
|
});
|