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 A26F769697 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 9BF1A256F6 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 8753A256E4 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 51F6C4639A 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:08 +0100 Message-Id: <20210311092208.27221-4-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 4/4] fix #2745: ui: backup: allow specifying remove parameter for manual backup 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 and also show the retention options that will be used for a given storage. A user with Datastore.AllocateSpace and VM.Backup can already remove backups from the GUI manually, so it shouldn't be a problem if they can set the remove flag when starting a manual backup in the GUI. Signed-off-by: Fabian Ebner --- Changes from v2: * hide Prune checkbox if there are no prune-settings or if keep-all=1 * also show the retention options that are going to be used www/manager6/window/Backup.js | 67 +++++++++++++++++++++++++++++++++-- 1 file changed, 65 insertions(+), 2 deletions(-) diff --git a/www/manager6/window/Backup.js b/www/manager6/window/Backup.js index a6dc1798..886ef6f2 100644 --- a/www/manager6/window/Backup.js +++ b/www/manager6/window/Backup.js @@ -36,6 +36,39 @@ Ext.define('PVE.window.Backup', { emptyText: Proxmox.Utils.noneText, }); + const keepNames = [ + 'keep-last', + 'keep-hourly', + 'keep-daily', + 'keep-weekly', + 'keep-monthly', + 'keep-yearly', + ]; + + let pruneSettings = keepNames.map( + name => Ext.create('Ext.form.field.Display', { + name: name, + fieldLabel: gettext(name), + hidden: true, + disabled: true, + }), + ); + + let removeCheckbox = Ext.create('Proxmox.form.Checkbox', { + name: 'remove', + checked: false, + hidden: true, + uncheckedValue: 0, + fieldLabel: gettext('Prune'), + autoEl: { + tag: 'div', + 'data-qtip': gettext('Prune older backups afterwards'), + }, + handler: function(checkbox, value) { + pruneSettings.forEach(field => field.setDisabled(!value)); + }, + }); + let initialDefaults = false; var storagesel = Ext.create('PVE.form.StorageSelector', { @@ -74,6 +107,35 @@ Ext.define('PVE.window.Backup', { } initialDefaults = true; + + // always update storage dependent properties + if (data['prune-backups'] !== undefined) { + const keepParams = PVE.Parser.parsePropertyString( + data["prune-backups"], + ); + if (!keepParams['keep-all']) { + removeCheckbox.setHidden(false); + pruneSettings.forEach(function(field) { + const keep = keepParams[field.name]; + if (keep) { + field.setValue(keep); + field.setHidden(false); + } else { + field.reset(); + field.setHidden(true); + } + }); + return; + } + } + + // no defaults or keep-all=1 + removeCheckbox.setHidden(true); + removeCheckbox.setValue(false); + pruneSettings.forEach(function(field) { + field.reset(); + field.setHidden(true); + }); }, failure: function(response, opts) { Ext.Msg.alert(gettext('Error'), response.htmlStatus); @@ -96,7 +158,8 @@ Ext.define('PVE.window.Backup', { modeSelector, compressionSelector, mailtoField, - ], + removeCheckbox, + ].concat(pruneSettings), }); var form = me.formPanel.getForm(); @@ -110,7 +173,7 @@ Ext.define('PVE.window.Backup', { storage: storage, vmid: me.vmid, mode: values.mode, - remove: 0, + remove: values.remove, }; if (values.mailto) { -- 2.20.1