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

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 15 13:31:47 CET 2018


On 11/15/18 1:30 PM, Thomas Lamprecht wrote:
> 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 v1 -> v2:
> * don't save in a global object and autoupdate, rather add a helper function
>   and set it explicitly on login.
> * also clear it explicitly on logout, which is way easier with above change
> 
> Thanks to Dominik for the review and basic idea.
> 
>  www/manager6/Workspace.js         |  4 ++++
>  www/manager6/tree/ResourceTree.js | 14 +++++++++++++-
>  2 files changed, 17 insertions(+), 1 deletion(-)
> 
> 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..3e8c40d5 100644
> --- a/www/manager6/tree/ResourceTree.js
> +++ b/www/manager6/tree/ResourceTree.js
> @@ -410,7 +410,19 @@ Ext.define('PVE.tree.ResourceTree', {
>  		me.clearTree();
>  		updateTree();
>  	    },
> -	    clearTree: function() {
> +	    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(reset) {
                               ^^^^^
clearTree's signature should not get touched, rebase leftover I overlooked, sorry.

>  		pdata.updateCount = 0;
>  		var rootnode = me.store.getRootNode();
>  		rootnode.collapse();
> 





More information about the pve-devel mailing list