public inbox for pbs-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH widget-toolkit 1/1] window/FileBrowser: add optional 'tar.zst' button
Date: Tue, 12 Apr 2022 13:04:15 +0200	[thread overview]
Message-ID: <20220412110418.3360746-4-d.csapak@proxmox.com> (raw)
In-Reply-To: <20220412110418.3360746-1-d.csapak@proxmox.com>

only show it when enabled in config (so that we can hide it where
that is not supported, which is in PVE right now)

also changes the text between 'Download' and 'Download .zip' depending
if the selected entry is a directory or not

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 src/window/FileBrowser.js | 39 ++++++++++++++++++++++++++++++++++-----
 1 file changed, 34 insertions(+), 5 deletions(-)

diff --git a/src/window/FileBrowser.js b/src/window/FileBrowser.js
index 99a7a85..2efa988 100644
--- a/src/window/FileBrowser.js
+++ b/src/window/FileBrowser.js
@@ -75,6 +75,9 @@ Ext.define("Proxmox.window.FileBrowser", {
 	    'f': true, // "normal" files
 	    'd': true, // directories
 	},
+
+	// set to true to show the tar download button
+	enableTar: false,
     },
 
     controller: {
@@ -89,7 +92,15 @@ Ext.define("Proxmox.window.FileBrowser", {
 	    return url.href;
 	},
 
-	downloadFile: function() {
+	downloadTar: function() {
+	    this.downloadFile(true);
+	},
+
+	downloadZip: function() {
+	    this.downloadFile(false);
+	},
+
+	downloadFile: function(tar) {
 	    let me = this;
 	    let view = me.getView();
 	    let tree = me.lookup('tree');
@@ -105,7 +116,12 @@ Ext.define("Proxmox.window.FileBrowser", {
 	    params.filepath = data.filepath;
 	    atag.download = data.text;
 	    if (data.type === 'd') {
-		atag.download += ".zip";
+		if (tar) {
+		    params.tar = 1;
+		    atag.download += ".tar.zst";
+		} else {
+		    atag.download += ".zip";
+		}
 	    }
 	    atag.href = me.buildUrl(view.downloadURL, params);
 	    atag.click();
@@ -120,12 +136,18 @@ Ext.define("Proxmox.window.FileBrowser", {
 
 	    let data = selection[0].data;
 	    let canDownload = view.downloadURL && view.downloadableFileTypes[data.type];
-	    me.lookup('downloadBtn').setDisabled(!canDownload);
+	    let zipBtn = me.lookup('downloadBtn');
+	    let tarBtn = me.lookup('downloadTar');
+	    zipBtn.setDisabled(!canDownload);
+	    tarBtn.setDisabled(!canDownload);
+	    zipBtn.setText(data.type === 'd' ? gettext('Download .zip') : gettext('Download'));
+	    tarBtn.setVisible(data.type === 'd' && view.enableTar);
 	},
 
 	errorHandler: function(error, msg) {
 	    let me = this;
 	    me.lookup('downloadBtn').setDisabled(true);
+	    me.lookup('downloadTar').setDisabled(true);
 	    if (me.initialLoadDone) {
 		Ext.Msg.alert(gettext('Error'), msg);
 		return true;
@@ -245,8 +267,15 @@ Ext.define("Proxmox.window.FileBrowser", {
 
     buttons: [
 	{
-	    text: gettext('Download'),
-	    handler: 'downloadFile',
+	    text: gettext('Download .tar.zst'),
+	    handler: 'downloadTar',
+	    reference: 'downloadTar',
+	    hidden: true,
+	    disabled: true,
+	},
+	{
+	    text: gettext('Download .zip'),
+	    handler: 'downloadZip',
 	    reference: 'downloadBtn',
 	    disabled: true,
 	},
-- 
2.30.2





  parent reply	other threads:[~2022-04-12 11:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 11:04 [pbs-devel] [PATCH proxmox/widget-toolkit/proxmox-backup] add tar.zst support for file download Dominik Csapak
2022-04-12 11:04 ` [pbs-devel] [PATCH proxmox 1/2] proxmox-compression: add async tar builder Dominik Csapak
2022-04-13  7:36   ` [pbs-devel] applied-series: " Wolfgang Bumiller
2022-04-12 11:04 ` [pbs-devel] [PATCH proxmox 2/2] proxmox-compression: add streaming zstd encoder Dominik Csapak
2022-04-12 11:04 ` Dominik Csapak [this message]
2022-04-13  8:37   ` [pbs-devel] applied: [PATCH widget-toolkit 1/1] window/FileBrowser: add optional 'tar.zst' button Wolfgang Bumiller
2022-04-12 11:04 ` [pbs-devel] [PATCH proxmox-backup 1/3] pbs-client: add 'create_tar' helper function Dominik Csapak
2022-04-13  8:34   ` [pbs-devel] applied-series: " Wolfgang Bumiller
2022-04-12 11:04 ` [pbs-devel] [PATCH proxmox-backup 2/3] api: admin/datastore: add tar support for pxar_file_download Dominik Csapak
2022-04-12 11:04 ` [pbs-devel] [PATCH proxmox-backup 3/3] ui: datastore/Content: enable tar download in ui Dominik Csapak

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=20220412110418.3360746-4-d.csapak@proxmox.com \
    --to=d.csapak@proxmox.com \
    --cc=pbs-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