public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Reiter <s.reiter@proxmox.com>
To: pve-devel@lists.proxmox.com, pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-widget-toolkit 2/3] FileBrowser: remove PBS dependencies
Date: Thu,  1 Apr 2021 17:34:43 +0200	[thread overview]
Message-ID: <20210401153444.8711-3-s.reiter@proxmox.com> (raw)
In-Reply-To: <20210401153444.8711-1-s.reiter@proxmox.com>

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 <s.reiter@proxmox.com>
---
 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





  parent reply	other threads:[~2021-04-01 15:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-01 15:34 [pbs-devel] [PATCH 0/3] Move FileBrowser to widget-toolkit Stefan Reiter
2021-04-01 15:34 ` [pbs-devel] [PATCH proxmox-widget-toolkit 1/3] window: add FileBrowser Stefan Reiter
2021-04-13  6:00   ` [pbs-devel] applied: " Thomas Lamprecht
2021-04-01 15:34 ` Stefan Reiter [this message]
2021-04-13  6:00   ` [pbs-devel] applied: [PATCH proxmox-widget-toolkit 2/3] FileBrowser: remove PBS dependencies Thomas Lamprecht
2021-04-01 15:34 ` [pbs-devel] [PATCH proxmox-backup 3/3] use FileBrowser from proxmox-widget-toolkit Stefan Reiter
2021-04-13  7:15   ` [pbs-devel] applied: " Thomas Lamprecht

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=20210401153444.8711-3-s.reiter@proxmox.com \
    --to=s.reiter@proxmox.com \
    --cc=pbs-devel@lists.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