[pve-devel] [PATCH v4 manager 2/3] ui: backup: fill in some of the configured vzdump defaults

Fabian Ebner f.ebner at proxmox.com
Tue Apr 6 12:41:51 CEST 2021


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 at 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






More information about the pve-devel mailing list