mirror of
https://github.com/retspen/webvirtcloud
synced 2026-11-10 12:16:49 +00:00
refactor(instances): the VM lists' scripts load from static files
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.
This commit is contained in:
parent
e143fe353a
commit
946629b035
11 changed files with 98 additions and 91 deletions
24
static/js/host_groups.js
Normal file
24
static/js/host_groups.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
// 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'));
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue