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 9D9A169696 for ; Thu, 11 Mar 2021 10:22:14 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 93EAA256F5 for ; Thu, 11 Mar 2021 10:22:14 +0100 (CET) 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 70AF0256DC for ; Thu, 11 Mar 2021 10:22:13 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 3388A46391 for ; Thu, 11 Mar 2021 10:22:13 +0100 (CET) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 11 Mar 2021 10:22:07 +0100 Message-Id: <20210311092208.27221-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210311092208.27221-1-f.ebner@proxmox.com> References: <20210311092208.27221-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.002 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 Subject: [pve-devel] [PATCH v3 manager 3/4] ui: backup: fill in some of the configured vzdump defaults X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Mar 2021 09:22:14 -0000 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 --- New in 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