From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <f.ebner@proxmox.com> 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 6A91170ED0 for <pve-devel@lists.proxmox.com>; Tue, 6 Apr 2021 12:42:28 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 56EB82C61F for <pve-devel@lists.proxmox.com>; Tue, 6 Apr 2021 12:41:58 +0200 (CEST) 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 33BDA2C613 for <pve-devel@lists.proxmox.com>; Tue, 6 Apr 2021 12:41:57 +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 E56A341D47 for <pve-devel@lists.proxmox.com>; Tue, 6 Apr 2021 12:41:56 +0200 (CEST) From: Fabian Ebner <f.ebner@proxmox.com> To: pve-devel@lists.proxmox.com Date: Tue, 6 Apr 2021 12:41:52 +0200 Message-Id: <20210406104152.11014-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210406104152.11014-1-f.ebner@proxmox.com> References: <20210406104152.11014-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.007 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 v4 manager 3/3] 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 <pve-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/> List-Post: <mailto:pve-devel@lists.proxmox.com> List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe> X-List-Received-Date: Tue, 06 Apr 2021 10:42:28 -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 <f.ebner@proxmox.com> --- No changes from v3. 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