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

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Nov 13 12:06:54 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>
---
 www/manager6/Workspace.js         |  2 ++
 www/manager6/tree/ResourceTree.js | 17 +++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/www/manager6/Workspace.js b/www/manager6/Workspace.js
index f75356c5..34fe85f9 100644
--- a/www/manager6/Workspace.js
+++ b/www/manager6/Workspace.js
@@ -22,6 +22,8 @@ Ext.define('PVE.Workspace', {
 	Proxmox.CSRFPreventionToken = loginData.CSRFPreventionToken;
 	Proxmox.UserName = loginData.username;
 
+	Proxmox.ClusterName = loginData.clustername;
+
 	if (loginData.cap) {
 	    Ext.state.Manager.set('GuiCap', loginData.cap);
 	}
diff --git a/www/manager6/tree/ResourceTree.js b/www/manager6/tree/ResourceTree.js
index 165ef733..909c4423 100644
--- a/www/manager6/tree/ResourceTree.js
+++ b/www/manager6/tree/ResourceTree.js
@@ -225,12 +225,29 @@ Ext.define('PVE.tree.ResourceTree', {
 
 	var stateid = 'rid';
 
+	// to avoid frequent rootnode updates if not necessary
+	var clusterName = undefined;
+
 	var updateTree = function() {
 	    var tmp;
 
 	    store.suspendEvents();
 
 	    var rootnode = me.store.getRootNode();
+
+	    if (clusterName !== Proxmox.ClusterName) {
+		clusterName = Proxmox.ClusterName;
+
+		var rnodeText = gettext('Datacenter');
+		if (clusterName !== undefined) {
+		    rnodeText += ' (' + clusterName + ')';
+		}
+
+		rootnode.beginEdit();
+		rootnode.data.text = rnodeText;
+		rootnode.commit();
+	    }
+
 	    // remember selected node (and all parents)
 	    var sm = me.getSelectionModel();
 
-- 
2.19.1





More information about the pve-devel mailing list