public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
	Philipp Hufnagl <p.hufnagl@proxmox.com>
Subject: Re: [pve-devel] [PATCH manager v6 2/2] fix #4849: ui: download to storage: automatically dectect and configure compression
Date: Wed, 23 Aug 2023 11:04:34 +0200	[thread overview]
Message-ID: <ad2def47-e05d-4446-8390-953429a4592f@proxmox.com> (raw)
In-Reply-To: <20230814144217.2082571-3-p.hufnagl@proxmox.com>

a few comments inline

On 8/14/23 16:42, Philipp Hufnagl wrote:
> extends the download iso prompt with a "compression algorithm" drop down
> under advanced. User can configure there if a decompression algorithm
> should be used from the storage backend. The compression algorithm will
> be automatically guessed when calling query_url_metadata
> 
> Signed-off-by: Philipp Hufnagl <p.hufnagl@proxmox.com>
> ---
>   www/manager6/Makefile                       |  1 +
>   www/manager6/form/DecompressionSelector.js  | 13 +++++++++++++
>   www/manager6/window/DownloadUrlToStorage.js | 17 +++++++++++++++++
>   3 files changed, 31 insertions(+)
>   create mode 100644 www/manager6/form/DecompressionSelector.js
> 
> diff --git a/www/manager6/Makefile b/www/manager6/Makefile
> index 7ec9d7a5..42a27548 100644
> --- a/www/manager6/Makefile
> +++ b/www/manager6/Makefile
> @@ -34,6 +34,7 @@ JSSRC= 							\
>   	form/ContentTypeSelector.js			\
>   	form/ControllerSelector.js			\
>   	form/DayOfWeekSelector.js			\
> +	form/DecompressionSelector.js       \
>   	form/DiskFormatSelector.js			\
>   	form/DiskStorageSelector.js			\
>   	form/EmailNotificationSelector.js		\
> diff --git a/www/manager6/form/DecompressionSelector.js b/www/manager6/form/DecompressionSelector.js
> new file mode 100644
> index 00000000..abd19316
> --- /dev/null
> +++ b/www/manager6/form/DecompressionSelector.js
> @@ -0,0 +1,13 @@
> +Ext.define('PVE.form.DecompressionSelector', {
> +    extend: 'Proxmox.form.KVComboBox',
> +    alias: ['widget.pveDecompressionSelector'],
> +    config: {
> +	deleteEmpty: false,
> +    },
> +    comboItems: [
> +		['__default__', Proxmox.Utils.NoneText],
> +		['lzo', 'LZO'],
> +		['gz', 'GZIP'],
> +		['zst', 'ZSTD'],
> +    ],
> +});
> diff --git a/www/manager6/window/DownloadUrlToStorage.js b/www/manager6/window/DownloadUrlToStorage.js
> index 90320da4..559a1c05 100644
> --- a/www/manager6/window/DownloadUrlToStorage.js
> +++ b/www/manager6/window/DownloadUrlToStorage.js
> @@ -49,6 +49,9 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
>   	    vm.set('size', '-');
>   	    vm.set('mimetype', '-');
>   	},
> +	decompressionPossible: function() {
> +	    return this.view.content === 'iso';
> +	},

this is a oneline that's only used one time, i'd rather implement it where we need it
also 'this.getView()' is preferred to 'this.view', but in this case it does not matter because...

>   
>   	urlCheck: function(field) {
>   	    let me = this;
> @@ -66,6 +69,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
>   		params: {
>   		    url: queryParam.url,
>   		    'verify-certificates': queryParam['verify-certificates'],
> +		    'detect-compression': me.decompressionPossible() ? 1 : 0,

if you do it here, there is already a 'view' variable, so you could do

'detect-compression': view.content === 'iso' ? 1 : 0,

(also is it even necessary to cast to 1/0? i'd hoped that we can simply have true/false
here too, so it'd simplify to

'detect-compression': view.content === 'iso'


also, see my notes on the other patch if we even need this

>   		},
>   		waitMsgTarget: view,
>   		failure: res => {
> @@ -84,6 +88,7 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
>   			filename: data.filename || "",
>   			size: (data.size && Proxmox.Utils.format_size(data.size)) || gettext("Unknown"),
>   			mimetype: data.mimetype || gettext("Unknown"),
> +			compression: data.compression || '__default__',
>   		    });
>   		},
>   	    });
> @@ -223,6 +228,18 @@ Ext.define('PVE.window.DownloadUrlToStorage', {
>   	if (!me.storage) {
>   	    throw "no storage ID specified";
>   	}
> +	if (me.content === 'iso') {
> +	    me.items[0].advancedColumn2.push(
> +
> +		{
> +		    xtype: 'pveDecompressionSelector',
> +		    name: 'compression',
> +		    fieldLabel: gettext('Decompression algorithm'),
> +		    allowBlank: true,
> +		    hasNoneOption: true,
> +		    value: '__default__',
> +		});
> +	}

while this works here (by accident?), this pattern is dangerous, because
you modify not the instance items, but the variable of the class itself
(that's not copied before callParent)


so it would be better to always add the field in the 'items' property,
but use the cbind variables to hide/disable it when necessary

>   
>   	me.callParent();
>       },





  reply	other threads:[~2023-08-23  9:04 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-14 14:42 [pve-devel] [PATCH manager/storage v6 0/3] fix #4849: allow download of compressed ISOs Philipp Hufnagl
2023-08-14 14:42 ` [pve-devel] [PATCH manager v6 1/2] fix #4849: api: download to storage: automatically dectect and configure compression Philipp Hufnagl
2023-08-23  9:04   ` Dominik Csapak
2023-08-14 14:42 ` [pve-devel] [PATCH manager v6 2/2] fix #4849: ui: " Philipp Hufnagl
2023-08-23  9:04   ` Dominik Csapak [this message]
2023-08-14 14:42 ` [pve-devel] [PATCH storage v6 1/1] fix #4849: download-url: allow download and decompression of compressed ISOs Philipp Hufnagl
2023-08-23  8:00   ` [pve-devel] applied: " Wolfgang Bumiller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ad2def47-e05d-4446-8390-953429a4592f@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=p.hufnagl@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal