mirror of
https://github.com/retspen/webvirtcloud
synced 2026-12-02 17:06:09 +00:00
One list of tag names (lower case letters, digits, dot, dash, underscore; up to 32) given to VMs and hosts. A superuser sets a VM's tags on its Options tab and a host's on its form; Tom Select suggests the tags there are and makes a new one typed. The VM list, the VM page and the hosts list show them as badges, to everyone who sees the VM or host. A VM's tags stay with it: an out-of-band move adds them to those on the new host's record, and a VM that leaves its host keeps them on the Removed VMs page (a VM with only tags too) and gets them back when it returns. Setting them is audited and held against the VM's move.
22 lines
1,012 B
JavaScript
22 lines
1,012 B
JavaScript
// A <select data-searchable> of many users or VMs gets a search box (Tom Select).
|
|
document.querySelectorAll("select[data-searchable]").forEach(function (select) {
|
|
new TomSelect(select, {
|
|
// the box leaves its focused, taller look at once: else the next tap's
|
|
// button moves away under the finger on a phone
|
|
onItemAdd: function () { this.blur(); },
|
|
});
|
|
});
|
|
|
|
// A <select multiple data-tags>: the tags there are, and a new one typed (the server checks it).
|
|
document.querySelectorAll("select[data-tags]").forEach(function (select) {
|
|
new TomSelect(select, {
|
|
create: true, persist: false, createFilter: /^[A-Za-z0-9][A-Za-z0-9._-]{0,31}$/,
|
|
render: {
|
|
// the page's own words (data-add): the library's are English
|
|
option_create: function (data, escape) {
|
|
return '<div class="create">' + escape(select.dataset.add.replace("%(tag)s", data.input)) + "</div>";
|
|
},
|
|
no_results: null,
|
|
},
|
|
});
|
|
});
|