[pve-devel] [RFC manager 1/2] NodeSelector: add disallowedNodes configuration property

Dietmar Maurer dietmar at proxmox.com
Thu Nov 17 16:14:36 CET 2016


Wouldn't it be simpler if we define a filter function?

> On November 17, 2016 at 3:00 PM Thomas Lamprecht <t.lamprecht at proxmox.com>
> wrote:
> 
> 
> This can be used to mask out some nodes from the node selector.
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
> 
> this will be used in the next patch
> 
>  www/manager6/form/NodeSelector.js | 28 +++++++++++++++++++++++++++-
>  1 file changed, 27 insertions(+), 1 deletion(-)
> 
> diff --git a/www/manager6/form/NodeSelector.js
> b/www/manager6/form/NodeSelector.js
> index 7193b97..fcdda77 100644
> --- a/www/manager6/form/NodeSelector.js
> +++ b/www/manager6/form/NodeSelector.js
> @@ -7,6 +7,9 @@ Ext.define('PVE.form.NodeSelector', {
>  
>      selectCurNode: false,
>  
> +    // do not allow those nodes (array)
> +    disallowedNodes: undefined,
> +
>      // only allow those nodes (array)
>      allowedNodes: undefined,
>      // set default value to empty array, else it inits it with
> @@ -96,6 +99,29 @@ Ext.define('PVE.form.NodeSelector', {
>          }
>  
>          me.callParent();
> -        me.getStore().load();
> +        me.getStore().load({
> +	    callback: function(records) {
> +		var disallowedRecords = [];
> +
> +		Ext.Array.each(me.disallowedNodes, function(node) {
> +		    var rec = me.store.findRecord(me.valueField, node);
> +		    if (rec) {
> +			disallowedRecords.push(rec);
> +		    }
> +		});
> +
> +		me.store.remove(disallowedRecords);
> +
> +		// ensure that there is still a valid default selection
> +		var rec = me.store.first();
> +		if (rec && rec.data) {
> +		    var def = rec.data[me.valueField];
> +		    me.setValue(def, true);
> +		} else {
> +		    me.setValue('', true);
> +		}
> +	    }
> +	});
> +
>      }
>  });
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list