From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id CBC3C624D9 for ; Wed, 16 Sep 2020 14:51:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 98A7E240E2 for ; Wed, 16 Sep 2020 14:50:51 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 54263240B6 for ; Wed, 16 Sep 2020 14:50:50 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 05AE8453DA for ; Wed, 16 Sep 2020 14:50:50 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Wed, 16 Sep 2020 14:50:22 +0200 Message-Id: <20200916125041.4151-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200916125041.4151-1-f.ebner@proxmox.com> References: <20200916125041.4151-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.066 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH v2 manager 01/20] fix extension filter for upload window X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Sep 2020 12:51:21 -0000 so that it selects the correct filter for container templates Signed-off-by: Fabian Ebner --- new in v2 www/manager6/storage/ContentView.js | 43 ++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/www/manager6/storage/ContentView.js b/www/manager6/storage/ContentView.js index 194ad42e..9e710d3a 100644 --- a/www/manager6/storage/ContentView.js +++ b/www/manager6/storage/ContentView.js @@ -193,6 +193,30 @@ Ext.define('PVE.storage.Upload', { hidden: true }); + let acceptedExtensions = { + iso: ".img, .iso", + vztmpl: ".tar.gz, .tar.xz", + }; + + let defaultContent = me.contents[0] || ''; + + let fileField = Ext.create('Ext.form.field.File', { + name: 'filename', + buttonText: gettext('Select File...'), + allowBlank: false, + setAccept: function(content) { + let acceptString = acceptedExtensions[content] || ''; + this.fileInputEl.set({ + accept: acceptString, + }); + }, + listeners: { + afterrender: function(cmp) { + cmp.setAccept(defaultContent); + }, + }, + }); + me.formPanel = Ext.create('Ext.form.Panel', { method: 'POST', waitMsgTarget: true, @@ -209,22 +233,15 @@ Ext.define('PVE.storage.Upload', { cts: me.contents, fieldLabel: gettext('Content'), name: 'content', - value: me.contents[0] || '', - allowBlank: false - }, - { - xtype: 'filefield', - name: 'filename', - buttonText: gettext('Select File...'), + value: defaultContent, allowBlank: false, listeners: { - afterrender: function(cmp) { - cmp.fileInputEl.set({ - accept: '.img, .iso' - }); - } - } + change: function(cmp, newValue, oldValue) { + fileField.setAccept(newValue); + }, + }, }, + fileField, pbar ] }); -- 2.20.1