[pve-devel] [PATCH manager v2 2/4] spice: Add enhancements form component

Dominik Csapak d.csapak at proxmox.com
Wed Sep 18 12:11:49 CEST 2019


On 9/17/19 11:35 AM, Aaron Lauterer wrote:
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
>   www/manager6/Makefile                         |  1 +
>   www/manager6/form/SpiceEnhancementSelector.js | 72 +++++++++++++++++++
>   2 files changed, 73 insertions(+)
>   create mode 100644 www/manager6/form/SpiceEnhancementSelector.js
> 
> diff --git a/www/manager6/Makefile b/www/manager6/Makefile
> index 82e25c79..aa460c3b 100644
> --- a/www/manager6/Makefile
> +++ b/www/manager6/Makefile
> @@ -66,6 +66,7 @@ JSSRC= 				                 	\
>   	form/CalendarEvent.js				\
>   	form/CephPoolSelector.js			\
>   	form/PermPathSelector.js			\
> +	form/SpiceEnhancementSelector.js		\
>   	dc/Tasks.js					\
>   	dc/Log.js					\
>   	panel/StatusPanel.js				\
> diff --git a/www/manager6/form/SpiceEnhancementSelector.js b/www/manager6/form/SpiceEnhancementSelector.js
> new file mode 100644
> index 00000000..cbafd502
> --- /dev/null
> +++ b/www/manager6/form/SpiceEnhancementSelector.js
> @@ -0,0 +1,72 @@
> +Ext.define('PVE.form.SpiceEnhancementSelector', {
> +    extend: 'Proxmox.panel.InputPanel',
> +    alias: 'widget.pveSpiceEnhancementSelector',
> +    insideWizard: false,
> +
> +    initComponent: function() {
> +	var me = this;
> +        me.items = [
> +	    {
> +		xtype: 'displayfield',
> +		value: gettext('Spice enhancements') + ':',
> +		hidden: !me.insideWizard
> +	    },
> +	    {
> +		xtype: 'proxmoxcheckbox',
> +		itemId: 'foldersharing',
> +		name: 'foldersharing',
> +		submitValue: false,
> +		fieldLabel: gettext('Folder sharing'),
> +		uncheckedValue: 0,
> +	    },
> +	    {
> +		xtype: 'proxmoxKVComboBox',
> +		itemId: 'videostreaming',
> +		name: 'videostreaming',
> +		submitValue: false,
> +		value: 'off',
> +		fieldLabel: gettext('Video streaming'),
> +		comboItems: [
> +		    ['off', 'off'],
> +		    ['all', 'all'],
> +		    ['filter', 'filter'],
> +		],
> +	    },
> +	];
> +

like stefan already mentioned, i would also like to see the items 
declared directly on the class isntead of in the initcomponent

if (as i guess) you had problems with the '!me.insideWizard',
look at our 'cbind' mixin and what it can do

may result in a little more intial work on your side, but
should result in cleaner code

> +	me.callParent();
> +    },
> +
> +    // handle submitted values manually to work in the VM create wizard as well.
> +    // without submitValue = false the fields would be added to the config
> +    onGetValues: function() {
> +	var me = this;
> +	if (me.disabled) {
> +	    return;
> +	}
> +
> +	var values = {};
> +	var foldersharing = me.down('field[name=foldersharing]').getValue();
> +	var videostreaming = me.down('field[name=videostreaming]').getValue();

i am very certain that if you defined items with an 'itemId' you can do
me.getComponent('itemId-of-component') which is a bit nicer and should 
be much faster

> +
> +	if (videostreaming !== "off") {
> +	    values.videostreaming = videostreaming;
> +	}
> +	if (foldersharing) {
> +	    values.foldersharing = 1;
> +	}
> +	if (Ext.Object.isEmpty(values)) {
> +	    return { 'delete': 'spice_enhancements' };
> +	}
> +	var enhancements = PVE.Parser.printPropertyString(values);
> +	return { spice_enhancements: enhancements };
> +    },
> +
> +    setValues: function(values) {
> +	if (values.spice_enhancements) {
> +	    var enhancements = PVE.Parser.parsePropertyString(values.spice_enhancements);
> +	    enhancements['foldersharing'] = PVE.Parser.parseBoolean(enhancements['foldersharing'], 0);
> +	    this.callParent([enhancements]);
> +	}
> +    },
> +});
> 





More information about the pve-devel mailing list