[pve-devel] [PATCH manager 4/6 v2] gui: add MDevSelector

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Nov 22 08:35:17 CET 2018


On 11/20/18 5:13 PM, Dominik Csapak wrote:
> this is used to select a mediated device type
> 

pciid seems a bit of a strange name, maybe I'm just not used to it and
pci_id pciID doesn't has the best ring on it either, so looks OK (besides
the API path fixup from manager 2/6 which will affect this too.)

> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
>  www/manager6/Makefile             |   1 +
>  www/manager6/form/MDevSelector.js | 102 ++++++++++++++++++++++++++++++++++++++
>  2 files changed, 103 insertions(+)
>  create mode 100644 www/manager6/form/MDevSelector.js
> 
> diff --git a/www/manager6/Makefile b/www/manager6/Makefile
> index 03fc93e0..d900ec88 100644
> --- a/www/manager6/Makefile
> +++ b/www/manager6/Makefile
> @@ -42,6 +42,7 @@ JSSRC= 				                 	\
>  	form/DiskStorageSelector.js			\
>  	form/BridgeSelector.js				\
>  	form/PCISelector.js				\
> +	form/MDevSelector.js				\
>  	form/SecurityGroupSelector.js			\
>  	form/IPRefSelector.js				\
>  	form/IPProtocolSelector.js			\
> diff --git a/www/manager6/form/MDevSelector.js b/www/manager6/form/MDevSelector.js
> new file mode 100644
> index 00000000..4317ec28
> --- /dev/null
> +++ b/www/manager6/form/MDevSelector.js
> @@ -0,0 +1,102 @@
> +Ext.define('PVE.form.MDevSelector', {
> +    extend: 'Proxmox.form.ComboGrid',
> +    xtype: 'pveMDevSelector',
> +
> +    store: {
> +	fields: [ 'type','available', 'description' ],
> +	filterOnLoad: true,
> +	sorters: [
> +	    {
> +		property : 'type',
> +		direction: 'ASC'
> +	    }
> +	]
> +    },
> +    autoSelect: false,
> +    valueField: 'type',
> +    displayField: 'type',
> +    listConfig: {
> +	columns: [
> +	    {
> +		header: gettext('Type'),
> +		dataIndex: 'type',
> +		flex: 1
> +	    },
> +	    {
> +		header: gettext('Available'),
> +		dataIndex: 'available',
> +		width: 80
> +	    },
> +	    {
> +		header: gettext('Description'),
> +		dataIndex: 'description',
> +		flex: 1,
> +		renderer: function(value) {
> +		    if (!value) {
> +			return '';
> +		    }
> +
> +		    return value.split('\n').join('<br>');
> +		}
> +	    }
> +	]
> +    },
> +
> +    setPciID: function(pciid, force) {
> +	var me = this;
> +
> +	if (!force && (!pciid || (me.pciid === pciid))) {
> +	    return;
> +	}
> +
> +	me.pciid = pciid;
> +
> +	me.setProxy({
> +	    type: 'proxmox',
> +	    url: '/api2/json/nodes/' + me.nodename + '/scan/mdev',
> +	    extraParams: {
> +		pciid: me.pciid
> +	    }
> +	});
> +    },
> +
> +
> +    setNodename: function(nodename) {
> +	var me = this;
> +
> +	if (!nodename || (me.nodename === nodename)) {
> +	    return;
> +	}
> +
> +	me.nodename = nodename;
> +
> +	me.setProxy({
> +	    type: 'proxmox',
> +	    url: '/api2/json/nodes/' + me.nodename + '/scan/mdev',
> +	    extraParms: {
> +		pciid: me.pciid
> +	    }
> +	});
> +    },
> +
> +    setProxy: function(proxy) {
> +	var me = this;
> +	me.store.setProxy(proxy);
> +	me.store.load();
> +    },
> +
> +    initComponent: function() {
> +	var me = this;
> +
> +	if (!me.nodename) {
> +	    throw 'no node name specified';
> +	}
> +
> +        me.callParent();
> +
> +	if (me.pciid) {
> +	    me.setPciID(me.pciid, true);
> +	}
> +    }
> +});
> +
> 





More information about the pve-devel mailing list