[pve-devel] [PATCH manager v3] fix #1358: ui: show clustername besides 'Datacenter' node, if available

Thomas Lamprecht t.lamprecht at proxmox.com
Fri Nov 16 10:00:00 CET 2018


If we get the cluster name (successful login with '/' Sys.Audit
permissions) then display it in the resource tree's root node.

This updated on login and all ticket refreshs (every 15 minutes).
I currently have no functionallity to refresh it actively on cluster
create over WebUI, as it's not a straight forward change there.
Further, this is something which does not changes often (in
production), and we cannot detect CLI or API triggered (from non-pve
clients) cluster creations anyway.

Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---

changes v2 -> v3:
* do not touch clearTree signature unnecessary
* fix clustername variable name (missed to ammend a hunk change)

 www/manager6/Workspace.js         |  4 ++++
 www/manager6/tree/ResourceTree.js | 12 ++++++++++++
 2 files changed, 16 insertions(+)

diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index f75356c5..e88300f2 100644
--- a/www/manager6/Workspace.js
+++ b/www/manager6/Workspace.js
@@ -22,6 +22,9 @@ Ext.define('PVE.Workspace', {
 	Proxmox.CSRFPreventionToken = loginData.CSRFPreventionToken;
 	Proxmox.UserName = loginData.username;
 
+	var rt = me.down('pveResourceTree');
+	rt.setDatacenterText(loginData.clustername);
+
 	if (loginData.cap) {
 	    Ext.state.Manager.set('GuiCap', loginData.cap);
 	}
@@ -346,6 +349,7 @@ Ext.define('PVE.StdWorkspace', {
 				me.showLogin(); 
 				me.setContent(null);
 				var rt = me.down('pveResourceTree');
+				rt.setDatacenterText(undefined);
 				rt.clearTree();
 
 				// empty the stores of the StatusPanel child items
diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index 165ef733..28135d0e 100644
--- a/www/manager6/tree/ResourceTree.js
+++ b/www/manager6/tree/ResourceTree.js
@@ -410,6 +410,18 @@ Ext.define('PVE.tree.ResourceTree', {
 		me.clearTree();
 		updateTree();
 	    },
+	    setDatacenterText: function(clustername) {
+		var rootnode = me.store.getRootNode();
+
+		var rnodeText = gettext('Datacenter');
+		if (clustername !== undefined) {
+		    rnodeText += ' (' + clustername + ')';
+		}
+
+		rootnode.beginEdit();
+		rootnode.data.text = rnodeText;
+		rootnode.commit();
+	    },
 	    clearTree: function() {
 		pdata.updateCount = 0;
 		var rootnode = me.store.getRootNode();
-- 
2.19.1





More information about the pve-devel mailing list