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 1926A70195; Thu, 1 Apr 2021 17:35:25 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id E1D4B82A4; Thu, 1 Apr 2021 17:34:54 +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 37CB28270; Thu, 1 Apr 2021 17:34:54 +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 04F9145923; Thu, 1 Apr 2021 17:34:54 +0200 (CEST) From: Stefan Reiter To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com Date: Thu, 1 Apr 2021 17:34:43 +0200 Message-Id: <20210401153444.8711-3-s.reiter@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210401153444.8711-1-s.reiter@proxmox.com> References: <20210401153444.8711-1-s.reiter@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.012 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [atag.download] Subject: [pbs-devel] [PATCH proxmox-widget-toolkit 2/3] FileBrowser: remove PBS dependencies X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Apr 2021 15:35:25 -0000 Don't construct any URLs locally, instead have them (and their static parameters) be passed in. This removes the need to have the datastore. Signed-off-by: Stefan Reiter --- src/window/FileBrowser.js | 52 ++++++++++++++------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js index 82fd1b2..d8e75f4 100644 --- a/src/window/FileBrowser.js +++ b/src/window/FileBrowser.js @@ -80,23 +80,19 @@ Ext.define("Proxmox.window.FileBrowser", { let atag = document.createElement('a'); atag.download = data.text; - let params = { - 'backup-id': view['backup-id'], - 'backup-type': view['backup-type'], - 'backup-time': view['backup-time'], - }; + let params = { ...view.extraParams }; params.filepath = data.filepath; atag.download = data.text; if (data.type === 'd') { atag.download += ".zip"; } - atag.href = me - .buildUrl(`/api2/json/admin/datastore/${view.datastore}/pxar-file-download`, params); + atag.href = me.buildUrl(view.downloadUrl, params); atag.click(); }, fileChanged: function() { let me = this; + let view = me.getView(); let tree = me.lookup('tree'); let selection = tree.getSelection(); if (!selection || selection.length < 1) return; @@ -104,17 +100,19 @@ Ext.define("Proxmox.window.FileBrowser", { let data = selection[0].data; let canDownload = false; - switch (data.type) { - case 'h': - case 'f': - canDownload = true; - break; - case 'd': - if (data.depth > 1) { + if (view.downloadUrl) { + switch (data.type) { + case 'h': + case 'f': canDownload = true; - } - break; - default: break; + break; + case 'd': + if (data.depth > 1) { + canDownload = true; + } + break; + default: break; + } } me.lookup('downloadBtn').setDisabled(!canDownload); @@ -124,28 +122,16 @@ Ext.define("Proxmox.window.FileBrowser", { let me = this; let tree = me.lookup('tree'); - if (!view['backup-id']) { - throw "no backup-id given"; - } - - if (!view['backup-type']) { - throw "no backup-id given"; - } - - if (!view['backup-time']) { - throw "no backup-id given"; + if (!view.listUrl) { + throw "no list URL given"; } let store = tree.getStore(); let proxy = store.getProxy(); Proxmox.Utils.monStoreErrors(tree, store, true); - proxy.setUrl(`/api2/json/admin/datastore/${view.datastore}/catalog`); - proxy.setExtraParams({ - 'backup-id': view['backup-id'], - 'backup-type': view['backup-type'], - 'backup-time': view['backup-time'], - }); + proxy.setUrl(view.listUrl); + proxy.setExtraParams(view.extraParams); store.load(() => { let root = store.getRoot(); root.expand(); // always expand invisible root node -- 2.20.1