[pve-devel] [PATCH manager v2 1/1] gui: show lock in status bar of vms/cts

Dominik Csapak d.csapak at proxmox.com
Thu Mar 21 10:55:20 CET 2019


also add 'tbarSpacing' parameter to ConfigPanel, that controls
the spacing after the title

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* moved lock to the left
* different template symbol (lock) instead of symbol: lock

@thomas: i used your suggestions, but renamed the parameter,
since titleAlign already exists and i do not like negated options
also, this way it is documented as parameter of the class

 www/manager6/lxc/Config.js        | 21 ++++++++++++++++++++-
 www/manager6/panel/ConfigPanel.js |  6 +++++-
 www/manager6/qemu/Config.js       | 19 ++++++++++++++++++-
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/www/manager6/lxc/Config.js b/www/manager6/lxc/Config.js
index 51864f1a..9f219ed4 100644
--- a/www/manager6/lxc/Config.js
+++ b/www/manager6/lxc/Config.js
@@ -160,10 +160,23 @@ Ext.define('PVE.lxc.Config', {
 	    vmid: vmid
 	});
 
+	var statusTxt = Ext.create('Ext.toolbar.TextItem', {
+	    data: {
+		lock: undefined
+	    },
+	    tpl: [
+		'<tpl if="lock">',
+		'<i class="fa fa-lg fa-lock"></i> ({lock})',
+		'</tpl>'
+	    ]
+	});
+
+
 	Ext.apply(me, {
 	    title: Ext.String.format(gettext("Container {0} on node '{1}'"), vm.text, nodename),
 	    hstateid: 'lxctab',
-	    tbar: [ startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
+	    tbarSpacing: false,
+	    tbar: [ statusTxt, '->', startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
 	    defaults: { statusStore: me.statusStore },
 	    items: [
 		{
@@ -314,6 +327,7 @@ Ext.define('PVE.lxc.Config', {
 
 	me.mon(me.statusStore, 'load', function(s, records, success) {
 	    var status;
+	    var lock;
 	    if (!success) {
 		status = 'unknown';
 	    } else {
@@ -321,7 +335,12 @@ Ext.define('PVE.lxc.Config', {
 		status = rec ? rec.data.value : 'unknown';
 		rec = s.data.get('template');
 		template = rec.data.value || false;
+		rec = s.data.get('lock');
+		lock = rec ? rec.data.value : undefined;
 	    }
+
+	    statusTxt.update({ lock: lock });
+
 	    startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
 	    shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
 	    stopBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'stopped');
diff --git a/www/manager6/panel/ConfigPanel.js b/www/manager6/panel/ConfigPanel.js
index e3c71eef..dbdf5050 100644
--- a/www/manager6/panel/ConfigPanel.js
+++ b/www/manager6/panel/ConfigPanel.js
@@ -46,6 +46,8 @@ Ext.define('PVE.panel.Config', {
     showSearch: true, // add a ressource grid with a search button as first tab
     viewFilter: undefined, // a filter to pass to that ressource grid
 
+    tbarSpacing: true, // if true, adds a spacer after the title in tbar
+
     dockedItems: [{
 	// this is needed for the overflow handler
 	xtype: 'toolbar',
@@ -183,7 +185,9 @@ Ext.define('PVE.panel.Config', {
 	    }
 	}
 
-	tbar.unshift('->');
+	if (me.tbarSpacing) {
+	    tbar.unshift('->');
+	}
 	tbar.unshift({
 	    xtype: 'tbtext',
 	    text: title,
diff --git a/www/manager6/qemu/Config.js b/www/manager6/qemu/Config.js
index 38496f4f..0474fdb4 100644
--- a/www/manager6/qemu/Config.js
+++ b/www/manager6/qemu/Config.js
@@ -175,10 +175,22 @@ Ext.define('PVE.qemu.Config', {
 	    vmid: vmid
 	});
 
+	var statusTxt = Ext.create('Ext.toolbar.TextItem', {
+	    data: {
+		lock: undefined
+	    },
+	    tpl: [
+		'<tpl if="lock">',
+		'<i class="fa fa-lg fa-lock"></i> ({lock})',
+		'</tpl>'
+	    ]
+	});
+
 	Ext.apply(me, {
 	    title: Ext.String.format(gettext("Virtual Machine {0} on node '{1}'"), vm.text, nodename),
 	    hstateid: 'kvmtab',
-	    tbar: [ resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
+	    tbarSpacing: false,
+	    tbar: [ statusTxt, '->', resumeBtn, startBtn, shutdownBtn, migrateBtn, consoleBtn, moreBtn ],
 	    defaults: { statusStore: me.statusStore },
 	    items: [
 		{
@@ -331,6 +343,7 @@ Ext.define('PVE.qemu.Config', {
 	    var qmpstatus;
 	    var spice = false;
 	    var xtermjs = false;
+	    var lock;
 
 	    if (!success) {
 		status = qmpstatus = 'unknown';
@@ -341,6 +354,8 @@ Ext.define('PVE.qemu.Config', {
 		qmpstatus = rec ? rec.data.value : 'unknown';
 		rec = s.data.get('template');
 		template = rec.data.value || false;
+		rec = s.data.get('lock');
+		lock = rec ? rec.data.value : undefined;
 
 		spice = s.data.get('spice') ? true : false;
 		xtermjs = s.data.get('serial') ? true : false;
@@ -362,6 +377,8 @@ Ext.define('PVE.qemu.Config', {
 	    consoleBtn.setEnableSpice(spice);
 	    consoleBtn.setEnableXtermJS(xtermjs);
 
+	    statusTxt.update({ lock: lock });
+
 	    startBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status === 'running' || template);
 	    shutdownBtn.setDisabled(!caps.vms['VM.PowerMgmt'] || status !== 'running');
 	    me.down('#removeBtn').setDisabled(!caps.vms['VM.Allocate'] || status !== 'stopped');
-- 
2.11.0





More information about the pve-devel mailing list