[pve-devel] [RFC manager 2/4] Add a pool-centered bulk action

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Aug 31 08:45:55 CEST 2017


On 08/30/2017 05:22 PM, Philip Abernethy wrote:
> Uses the memberVSSelector to get a list of all VMs and containers
> in the selected pool.

same as the previous patch, with a few `if (me.poolname)' checks the existing
BulkAction class could me shaped to serve both use cases, reducing code
deduplication and thus inherently bugs and places where to fix this bugs.

> ---
>   www/manager6/window/PoolBulkAction.js | 100 ++++++++++++++++++++++++++++++++++
>   1 file changed, 100 insertions(+)
>   create mode 100644 www/manager6/window/PoolBulkAction.js
> 
> diff --git a/www/manager6/window/PoolBulkAction.js b/www/manager6/window/PoolBulkAction.js
> new file mode 100644
> index 00000000..1fae0ba5
> --- /dev/null
> +++ b/www/manager6/window/PoolBulkAction.js
> @@ -0,0 +1,100 @@
> +Ext.define('PVE.window.PoolBulkAction', {
> +    extend: 'Ext.window.Window',
> +
> +    resizable: true,
> +    width: 800,
> +    modal: true,
> +    layout: {
> +	type: 'fit'
> +    },
> +    border: false,
> +
> +    // the action to be set
> +    // currently there are
> +    // startall
> +    // stopall
> +    action: undefined,
> +
> +    submit: function(params) {
> +
> +    },
> +
> +    initComponent: function() {
> +	var me = this;
> +
> +	if (!me.poolname) {
> +	    throw "no pool name specified";
> +	}
> +
> +	if (!me.action) {
> +	    throw "no action specified";
> +	}
> +
> +	if (!me.btnText) {
> +	    throw "no button text specified";
> +	}
> +
> +	if (!me.title) {
> +	    throw "no title specified";
> +	}
> +
> +	var items = [];
> +
> +	if (me.action === 'startall') {
> +	    items.push({
> +		xtype: 'hiddenfield',
> +		name: 'force',
> +		value: 1
> +	    });
> +	}
> +
> +	items.push({
> +	    xtype: 'membervmselector',
> +	    itemId: 'vms',
> +	    name: 'vms',
> +	    flex: 1,
> +	    height: 300,
> +	    selectAll: true,
> +	    allowBlank: false,
> +	    poolname: me.poolname,
> +	    action: me.action
> +	});
> +
> +	me.formPanel = Ext.create('Ext.form.Panel', {
> +	    bodyPadding: 10,
> +	    border: false,
> +	    layout: {
> +		type: 'vbox',
> +		align: 'stretch'
> +	    },
> +	    fieldDefaults: {
> +		labelWidth: 300,
> +		anchor: '100%'
> +	    },
> +	    items: items
> +	});
> +
> +	var form = me.formPanel.getForm();
> +
> +	var submitBtn = Ext.create('Ext.Button', {
> +	    text: me.btnText,
> +	    handler: function() {
> +		form.isValid();
> +		me.submit(form.getValues());
> +	    }
> +	});
> +
> +	Ext.apply(me, {
> +	    items: [ me.formPanel ],
> +	    buttons: [ submitBtn ]
> +	});
> +
> +	me.callParent();
> +
> +	form.on('validitychange', function() {
> +	    var valid = form.isValid();
> +	    submitBtn.setDisabled(!valid);
> +	});
> +	form.isValid();
> +    }
> +});
> 





More information about the pve-devel mailing list