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 3EEAD696DA for ; Fri, 13 Nov 2020 14:17:09 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 35F3D1B159 for ; Fri, 13 Nov 2020 14:16:39 +0100 (CET) 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 2F3DE1B12C for ; Fri, 13 Nov 2020 14:16:38 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E07EB42DD9 for ; Fri, 13 Nov 2020 14:16:37 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Fri, 13 Nov 2020 14:16:14 +0100 Message-Id: <20201113131633.21915-2-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20201113131633.21915-1-f.ebner@proxmox.com> References: <20201113131633.21915-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.025 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 v3 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: Fri, 13 Nov 2020 13:17:09 -0000 so that it selects the correct filter for container templates Signed-off-by: Fabian Ebner --- 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 a879cc19..bc144fa4 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