ui: tree/ResourceTree: show Tags in tree

and update the treenodes when the tags change.
since we change the vm node text (which we pass through to the config
panel), we have to change how we generate the text there slightly
(otherwise that would include the rendered tags)

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2022-11-16 16:48:13 +01:00 committed by Thomas Lamprecht
parent d70be8cd73
commit 366558a79d
4 changed files with 21 additions and 3 deletions

View File

@ -293,6 +293,12 @@ Ext.define('PVE.data.ResourceStore', {
sortable: true,
width: 100,
},
tags: {
header: gettext('Tags'),
type: 'string',
hidden: true,
sortable: true,
},
};
let fields = [];

View File

@ -206,8 +206,10 @@ Ext.define('PVE.lxc.Config', {
},
});
let vm_text = `${vm.vmid} (${vm.name})`;
Ext.apply(me, {
title: Ext.String.format(gettext("Container {0} on node '{1}'"), vm.text, nodename),
title: Ext.String.format(gettext("Container {0} on node '{1}'"), vm_text, nodename),
hstateid: 'lxctab',
tbarSpacing: false,
tbar: [statusTxt, tagsContainer, '->', startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn],

View File

@ -242,8 +242,10 @@ Ext.define('PVE.qemu.Config', {
},
});
let vm_text = `${vm.vmid} (${vm.name})`;
Ext.apply(me, {
title: Ext.String.format(gettext("Virtual Machine {0} on node '{1}'"), vm.text, nodename),
title: Ext.String.format(gettext("Virtual Machine {0} on node '{1}'"), vm_text, nodename),
hstateid: 'kvmtab',
tbarSpacing: false,
tbar: [statusTxt, tagsContainer, '->', resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn],

View File

@ -5,6 +5,8 @@ Ext.define('PVE.tree.ResourceTree', {
extend: 'Ext.tree.TreePanel',
alias: ['widget.pveResourceTree'],
userCls: 'proxmox-tags-circle',
statics: {
typeDefaults: {
node: {
@ -114,6 +116,8 @@ Ext.define('PVE.tree.ResourceTree', {
}
}
info.text += PVE.Utils.renderTags(info.tags, PVE.Utils.tagOverrides);
info.text = status + info.text;
},
@ -226,6 +230,10 @@ Ext.define('PVE.tree.ResourceTree', {
let stateid = 'rid';
const changedFields = [
'text', 'running', 'template', 'status', 'qmpstatus', 'hastate', 'lock', 'tags',
];
let updateTree = function() {
store.suspendEvents();
@ -261,7 +269,7 @@ Ext.define('PVE.tree.ResourceTree', {
}
// tree item has been updated
for (const field of ['text', 'running', 'template', 'status', 'qmpstatus', 'hastate', 'lock']) {
for (const field of changedFields) {
if (item.data[field] !== olditem.data[field]) {
changed = true;
break;