1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-11-08 11:16:47 +00:00
webvirtcloud/static/js/sort_tables.js
catborise 7cf12b997b feat(tables): tables sort with tablesort, the grouped VM list within each host
sortable.js 0.8.0 (abandoned since 2014) sorted only a table's first
body: in the grouped VM list the first host's row moved among its VMs
and the other hosts never sorted, and memory sorted as text ("1024 MB"
before "512 MB"). tablesort 5.7.1 sorts each table body on its own and
keeps a row marked data-sort-method="none" in place, so hosts stay in
name order with their row on top and their VMs sort below it. Memory,
vCPUs and volume sizes sort by their numbers (data-sort). Headers are
reachable by keyboard and carry aria-sort.

base.html loads tablesort for every table marked data-sortable; the
per-page sortable includes and sortable-theme-bootstrap.css go, so these
tables take the theme's table style like the others. The grouped list's
row numbers go (meaningless once sorted). The VM owners and VM logs
tables were marked sortable but never loaded the script; they stay
unsorted.
2026-10-24 19:02:51 +03:00

6 lines
317 B
JavaScript

// Every table marked data-sortable sorts by a click on, or Enter in, a column
// header (tablesort.min.js). Each table body sorts on its own; a row or
// header with data-sort-method="none" stays where it is.
document.querySelectorAll("table[data-sortable]").forEach(function (table) {
new Tablesort(table);
});