[pve-devel] [PATCH manager v3 3/4] gui: add tags to guest status line
Dominik Csapak
d.csapak at proxmox.com
Thu Oct 31 13:36:30 CET 2019
this way they are always visible when a user has selected a vm
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/lxc/Config.js | 23 ++++++++++++++++++++---
www/manager6/qemu/Config.js | 24 +++++++++++++++++++++---
2 files changed, 41 insertions(+), 6 deletions(-)
diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 0f81c1da..8d7a7f1d 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -163,21 +163,35 @@ Ext.define('PVE.lxc.Config', {
var statusTxt = Ext.create('Ext.toolbar.TextItem', {
data: {
- lock: undefined
+ lock: undefined,
+ tags: [],
},
tpl: [
'<tpl if="lock">',
'<i class="fa fa-lg fa-lock"></i> ({lock})',
+ '</tpl>',
+ ' ',
+ '<tpl if="tags.length > 0">',
+ '<tpl for="tags" between=" ">',
+ '{.}',
+ '</tpl>',
+ '<tpl else>',
+ gettext('No Tags'),
'</tpl>'
]
});
+ var tagEditBtn = Ext.create('PVE.button.TagEditButton', {
+ hidden: !caps.vms['VM.Config.Options'],
+ editurl: base_url + '/config',
+ callback: () => { me.statusStore.load(); },
+ });
Ext.apply(me, {
title: Ext.String.format(gettext("Container {0} on node '{1}'"), vm.text, nodename),
hstateid: 'lxctab',
tbarSpacing: false,
- tbar: [ statusTxt, '->', startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
+ tbar: [ statusTxt, tagEditBtn, '->', startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
defaults: { statusStore: me.statusStore },
items: [
{
@@ -329,6 +343,7 @@ Ext.define('PVE.lxc.Config', {
me.mon(me.statusStore, 'load', function(s, records, success) {
var status;
var lock;
+ var tags;
if (!success) {
status = 'unknown';
} else {
@@ -338,9 +353,11 @@ Ext.define('PVE.lxc.Config', {
template = rec.data.value || false;
rec = s.data.get('lock');
lock = rec ? rec.data.value : undefined;
+ rec = s.data.get('tags');
+ tags = rec ? rec.data.value.split(/[,; ]/).map(val => Proxmox.Utils.getTagElement(val) ) : [];
}
- statusTxt.update({ lock: lock });
+ statusTxt.update({ lock: lock, tags: tags });
startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index ccf30a9b..6a45445d 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -205,20 +205,35 @@ Ext.define('PVE.qemu.Config', {
var statusTxt = Ext.create('Ext.toolbar.TextItem', {
data: {
- lock: undefined
+ lock: undefined,
+ tags: [],
},
tpl: [
'<tpl if="lock">',
'<i class="fa fa-lg fa-lock"></i> ({lock})',
+ '</tpl>',
+ ' ',
+ '<tpl if="tags.length > 0">',
+ '<tpl for="tags" between=" ">',
+ '{.}',
+ '</tpl>',
+ '<tpl else>',
+ gettext('No Tags'),
'</tpl>'
]
});
+ var tagEditBtn = Ext.create('PVE.button.TagEditButton', {
+ hidden: !caps.vms['VM.Config.Options'],
+ editurl: base_url + '/config',
+ callback: () => { me.statusStore.load(); },
+ });
+
Ext.apply(me, {
title: Ext.String.format(gettext("Virtual Machine {0} on node '{1}'"), vm.text, nodename),
hstateid: 'kvmtab',
tbarSpacing: false,
- tbar: [ statusTxt, '->', resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
+ tbar: [ statusTxt, tagEditBtn, '->', resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
defaults: { statusStore: me.statusStore },
items: [
{
@@ -372,6 +387,7 @@ Ext.define('PVE.qemu.Config', {
var spice = false;
var xtermjs = false;
var lock;
+ var tags;
if (!success) {
status = qmpstatus = 'unknown';
@@ -384,6 +400,8 @@ Ext.define('PVE.qemu.Config', {
template = rec.data.value || false;
rec = s.data.get('lock');
lock = rec ? rec.data.value : undefined;
+ rec = s.data.get('tags');
+ tags = rec ? rec.data.value.split(',').map(val => Proxmox.Utils.getTagElement(val) ) : [];
spice = s.data.get('spice') ? true : false;
xtermjs = s.data.get('serial') ? true : false;
@@ -407,7 +425,7 @@ Ext.define('PVE.qemu.Config', {
consoleBtn.setEnableSpice(spice);
consoleBtn.setEnableXtermJS(xtermjs);
- statusTxt.update({ lock: lock });
+ statusTxt.update({ lock: lock, tags: tags });
startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
--
2.20.1
More information about the pve-devel
mailing list