public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v4 manager 2/3] ui: backup: fill in some of the configured vzdump defaults
Date: Tue,  6 Apr 2021 12:41:51 +0200	[thread overview]
Message-ID: <20210406104152.11014-2-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210406104152.11014-1-f.ebner@proxmox.com>

Do not fill in the default for compression, because the initial default for the
backend is to not compress, while the current default for the UI is zstd, which
is preferable.

The 'defaults' API call expects the user to have permissions on the storage,
because retention options are storage-dependent. Use a flag initialDefaults to
make sure storage-independent properties are only set once, so they are not
reset when a user changes the storage after editing them.

Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---

No changes from v3.

 www/manager6/window/Backup.js | 52 +++++++++++++++++++++++++++--------
 1 file changed, 40 insertions(+), 12 deletions(-)

diff --git a/www/manager6/window/Backup.js b/www/manager6/window/Backup.js
index 615073f3..a6dc1798 100644
--- a/www/manager6/window/Backup.js
+++ b/www/manager6/window/Backup.js
@@ -24,6 +24,20 @@ Ext.define('PVE.window.Backup', {
 	    fieldLabel: gettext('Compression'),
 	});
 
+	let modeSelector = Ext.create('PVE.form.BackupModeSelector', {
+	    fieldLabel: gettext('Mode'),
+	    value: 'snapshot',
+	    name: 'mode',
+	});
+
+	let mailtoField = Ext.create('Ext.form.field.Text', {
+	    fieldLabel: gettext('Send email to'),
+	    name: 'mailto',
+	    emptyText: Proxmox.Utils.noneText,
+	});
+
+	let initialDefaults = false;
+
 	var storagesel = Ext.create('PVE.form.StorageSelector', {
 	    nodename: me.nodename,
 	    name: 'storage',
@@ -41,6 +55,30 @@ Ext.define('PVE.window.Backup', {
 		    } else if (!compressionSelector.getEditable()) {
 			compressionSelector.setDisabled(false);
 		    }
+
+		    Proxmox.Utils.API2Request({
+			url: `/nodes/${me.nodename}/vzdump/defaults`,
+			method: 'GET',
+			params: {
+			    storage: v,
+			},
+			waitMsgTarget: me,
+			success: function(response, opts) {
+			    const data = response.result.data;
+
+			    if (!initialDefaults && data.mailto !== undefined) {
+				mailtoField.setValue(data.mailto);
+			    }
+			    if (!initialDefaults && data.mode !== undefined) {
+				modeSelector.setValue(data.mode);
+			    }
+
+			    initialDefaults = true;
+			},
+			failure: function(response, opts) {
+			    Ext.Msg.alert(gettext('Error'), response.htmlStatus);
+			},
+		    });
 		},
 	    },
 	});
@@ -55,19 +93,9 @@ Ext.define('PVE.window.Backup', {
 	    },
 	    items: [
 		storagesel,
-		{
-		    xtype: 'pveBackupModeSelector',
-		    fieldLabel: gettext('Mode'),
-		    value: 'snapshot',
-		    name: 'mode',
-		},
+		modeSelector,
 		compressionSelector,
-		{
-		    xtype: 'textfield',
-		    fieldLabel: gettext('Send email to'),
-		    name: 'mailto',
-		    emptyText: Proxmox.Utils.noneText,
-		},
+		mailtoField,
 	    ],
 	});
 
-- 
2.20.1





  reply	other threads:[~2021-04-06 10:42 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-06 10:41 [pve-devel] [PATCH v4 manager 1/3] api: vzdump: add call to get currently " Fabian Ebner
2021-04-06 10:41 ` Fabian Ebner [this message]
2021-05-03 13:02   ` [pve-devel] applied: [PATCH v4 manager 2/3] ui: backup: fill in some of the " Thomas Lamprecht
2021-04-06 10:41 ` [pve-devel] [PATCH v4 manager 3/3] fix #2745: ui: backup: allow specifying remove parameter for manual backup Fabian Ebner
2021-05-03 13:02 ` [pve-devel] applied: [PATCH v4 manager 1/3] api: vzdump: add call to get currently configured vzdump defaults 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=20210406104152.11014-2-f.ebner@proxmox.com \
    --to=f.ebner@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