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 4E1C079FB3 for ; Thu, 6 May 2021 14:17:08 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 30E2C2025A for ; Thu, 6 May 2021 14:16:38 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 8B686201FC for ; Thu, 6 May 2021 14:16:36 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 6496A4649E for ; Thu, 6 May 2021 14:16:36 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Thu, 6 May 2021 14:16:32 +0200 Message-Id: <20210506121632.8417-7-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210506121632.8417-1-f.ebner@proxmox.com> References: <20210506121632.8417-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.003 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [field.name] Subject: [pve-devel] [PATCH v5 manager 6/6] fix #2745: ui: backup window: 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, 06 May 2021 12:17:08 -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 v4: * Don't use gettext on a variable and use 'Keep Last' instead of 'keep-last', etc. as labels. * Only show retention settings when the prune checkbox is set. * Do not hide zero/undefined retention options, now that there's more space with the two-column layout. * Use labelWidth 110 for retention options, so German (and maybe other) translations of labels do not wrap www/manager6/window/Backup.js | 92 ++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/www/manager6/window/Backup.js b/www/manager6/window/Backup.js index a1e34674..7048c366 100644 --- a/www/manager6/window/Backup.js +++ b/www/manager6/window/Backup.js @@ -36,6 +36,38 @@ Ext.define('PVE.window.Backup', { emptyText: Proxmox.Utils.noneText, }); + const keepNames = [ + ['keep-last', gettext('Keep Last')], + ['keep-hourly', gettext('Keep Hourly')], + ['keep-daily', gettext('Keep Daily')], + ['keep-weekly', gettext('Keep Weekly')], + ['keep-monthly', gettext('Keep Monthly')], + ['keep-yearly', gettext('Keep Yearly')], + ]; + + let pruneSettings = keepNames.map( + name => Ext.create('Ext.form.field.Display', { + name: name[0], + fieldLabel: name[1], + hidden: 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.setHidden(!value)); + }, + }); + let initialDefaults = false; var storagesel = Ext.create('PVE.form.StorageSelector', { @@ -82,6 +114,30 @@ 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); + } else { + field.reset(); + } + }); + return; + } + } + + // no defaults or keep-all=1 + removeCheckbox.setHidden(true); + removeCheckbox.setValue(false); + pruneSettings.forEach(field => field.reset()); }, failure: function(response, opts) { initialDefaults = true; @@ -98,11 +154,45 @@ Ext.define('PVE.window.Backup', { column1: [ storagesel, modeSelector, + removeCheckbox, ], column2: [ compressionSelector, mailtoField, ], + columnB: [{ + layout: 'hbox', + border: false, + defaults: { + border: false, + layout: 'anchor', + flex: 1, + }, + items: [ + { + padding: '0 10 0 0', + defaults: { + labelWidth: 110, + }, + items: [ + pruneSettings[0], + pruneSettings[2], + pruneSettings[4], + ], + }, + { + padding: '0 0 0 10', + defaults: { + labelWidth: 110, + }, + items: [ + pruneSettings[1], + pruneSettings[3], + pruneSettings[5], + ], + }, + ], + }], }); var submitBtn = Ext.create('Ext.Button', { @@ -114,7 +204,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