1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2026-12-03 17:36:05 +00:00

feat: tags for VMs and hosts

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.
This commit is contained in:
catborise 2026-11-18 19:27:36 +03:00
parent 810abe7475
commit 149530f8df
26 changed files with 1202 additions and 778 deletions

View file

@ -0,0 +1,5 @@
<?xml version="1.0" ?>
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-tag" viewBox="0 0 16 16">
<path d="M6 4.5a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0m-1 0a.5.5 0 1 0-1 0 .5.5 0 0 0 1 0"/>
<path d="M2 1h4.586a1 1 0 0 1 .707.293l7 7a1 1 0 0 1 0 1.414l-4.586 4.586a1 1 0 0 1-1.414 0l-7-7A1 1 0 0 1 1 6.586V2a1 1 0 0 1 1-1m0 5.586 7 7L13.586 9l-7-7H2z"/>
</svg>

After

Width:  |  Height:  |  Size: 408 B

View file

@ -6,3 +6,17 @@ document.querySelectorAll("select[data-searchable]").forEach(function (select) {
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,
},
});
});