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 872ED7097A for ; Mon, 6 Sep 2021 13:32:39 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 80D8710357 for ; Mon, 6 Sep 2021 13:32:39 +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 0BFB810329 for ; Mon, 6 Sep 2021 13:32:37 +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 D63F3445C7 for ; Mon, 6 Sep 2021 13:32:36 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Mon, 6 Sep 2021 13:32:27 +0200 Message-Id: <20210906113231.61790-3-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210906113231.61790-1-f.ebner@proxmox.com> References: <20210906113231.61790-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.384 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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 Subject: [pve-devel] [PATCH manager 2/6] ui: factor out input panel for editing prune settings 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: Mon, 06 Sep 2021 11:32:39 -0000 To be re-used for configuring job-specific retention options for backups. Signed-off-by: Fabian Ebner --- www/manager6/Makefile | 1 + www/manager6/panel/EditPruneInputPanel.js | 97 +++++++++++++++++++++++ www/manager6/storage/Base.js | 96 +--------------------- 3 files changed, 99 insertions(+), 95 deletions(-) create mode 100644 www/manager6/panel/EditPruneInputPanel.js diff --git a/www/manager6/Makefile b/www/manager6/Makefile index 75d355a5..3f81d9c4 100644 --- a/www/manager6/Makefile +++ b/www/manager6/Makefile @@ -79,6 +79,7 @@ JSSRC= \ grid/Replication.js \ grid/ResourceGrid.js \ panel/ConfigPanel.js \ + panel/EditPruneInputPanel.js \ panel/HealthWidget.js \ panel/IPSet.js \ panel/NotesView.js \ diff --git a/www/manager6/panel/EditPruneInputPanel.js b/www/manager6/panel/EditPruneInputPanel.js new file mode 100644 index 00000000..d58db208 --- /dev/null +++ b/www/manager6/panel/EditPruneInputPanel.js @@ -0,0 +1,97 @@ +/* + * Input panel for prune settings with a keep-all option intended to be used as + * part of an edit/create window. + */ +Ext.define('PVE.panel.EditPruneInputPanel', { + extend: 'Proxmox.panel.PruneInputPanel', + xtype: 'pveEditPruneInputPanel', + mixins: ['Proxmox.Mixin.CBind'], + + onlineHelp: 'vzdump_retention', + + onGetValues: function(formValues) { + if (this.needMask) { // isMasked() may not yet be true if not rendered once + return {}; + } else if (this.isCreate && !this.rendered) { + return { 'prune-backups': 'keep-all=1' }; + } + delete formValues.delete; + let retention = PVE.Parser.printPropertyString(formValues); + if (retention === '') { + if (this.isCreate) { + return {}; + } + // always delete old 'maxfiles' on edit, we map it to keep-last on window load + return { + 'delete': ['prune-backups', 'maxfiles'], + }; + } + let options = { 'prune-backups': retention }; + if (!this.isCreate) { + options.delete = 'maxfiles'; + } + return options; + }, + + updateComponents: function() { + let me = this; + + let keepAll = me.down('proxmoxcheckbox[name=keep-all]').getValue(); + let anyValue = false; + me.query('pmxPruneKeepField').forEach(field => { + anyValue = anyValue || field.getValue() !== null; + field.setDisabled(keepAll); + }); + me.down('component[name=no-keeps-hint]').setHidden(anyValue || keepAll); + }, + + listeners: { + afterrender: function(panel) { + if (panel.needMask) { + panel.down('component[name=no-keeps-hint]').setHtml(''); + panel.mask( + gettext('Backup content type not available for this storage.'), + ); + } else if (panel.isCreate) { + panel.down('proxmoxcheckbox[name=keep-all]').setValue(true); + } + panel.down('component[name=pbs-hint]').setHidden(!panel.isPBS); + + panel.query('pmxPruneKeepField').forEach(field => { + field.on('change', panel.updateComponents, panel); + }); + panel.updateComponents(); + }, + }, + + columnT: { + xtype: 'proxmoxcheckbox', + name: 'keep-all', + boxLabel: gettext('Keep all backups'), + listeners: { + change: function(field, newValue) { + let panel = field.up('pveEditPruneInputPanel'); + panel.updateComponents(); + }, + }, + }, + + columnB: [ + { + xtype: 'component', + userCls: 'pmx-hint', + name: 'no-keeps-hint', + hidden: true, + padding: '5 1', + html: gettext('Without any keep option, the node\'s vzdump.conf or `keep-all` is used as fallback for backup jobs'), + }, + { + xtype: 'component', + userCls: 'pmx-hint', + name: 'pbs-hint', + hidden: true, + padding: '5 1', + html: gettext("It's preferred to configure backup retention directly on the Proxmox Backup Server."), + }, + ], +}); diff --git a/www/manager6/storage/Base.js b/www/manager6/storage/Base.js index ee8b54e8..862c981b 100644 --- a/www/manager6/storage/Base.js +++ b/www/manager6/storage/Base.js @@ -55,100 +55,6 @@ Ext.define('PVE.panel.StorageBase', { }, }); -Ext.define('PVE.panel.StoragePruneInputPanel', { - extend: 'Proxmox.panel.PruneInputPanel', - xtype: 'pveStoragePruneInputPanel', - mixins: ['Proxmox.Mixin.CBind'], - - onlineHelp: 'vzdump_retention', - - onGetValues: function(formValues) { - if (this.needMask) { // isMasked() may not yet be true if not rendered once - return {}; - } else if (this.isCreate && !this.rendered) { - return { 'prune-backups': 'keep-all=1' }; - } - delete formValues.delete; - let retention = PVE.Parser.printPropertyString(formValues); - if (retention === '') { - if (this.isCreate) { - return {}; - } - // always delete old 'maxfiles' on edit, we map it to keep-last on window load - return { - 'delete': ['prune-backups', 'maxfiles'], - }; - } - let options = { 'prune-backups': retention }; - if (!this.isCreate) { - options.delete = 'maxfiles'; - } - return options; - }, - - updateComponents: function() { - let me = this; - - let keepAll = me.down('proxmoxcheckbox[name=keep-all]').getValue(); - let anyValue = false; - me.query('pmxPruneKeepField').forEach(field => { - anyValue = anyValue || field.getValue() !== null; - field.setDisabled(keepAll); - }); - me.down('component[name=no-keeps-hint]').setHidden(anyValue || keepAll); - }, - - listeners: { - afterrender: function(panel) { - if (panel.needMask) { - panel.down('component[name=no-keeps-hint]').setHtml(''); - panel.mask( - gettext('Backup content type not available for this storage.'), - ); - } else if (panel.isCreate) { - panel.down('proxmoxcheckbox[name=keep-all]').setValue(true); - } - panel.down('component[name=pbs-hint]').setHidden(!panel.isPBS); - - panel.query('pmxPruneKeepField').forEach(field => { - field.on('change', panel.updateComponents, panel); - }); - panel.updateComponents(); - }, - }, - - columnT: { - xtype: 'proxmoxcheckbox', - name: 'keep-all', - boxLabel: gettext('Keep all backups'), - listeners: { - change: function(field, newValue) { - let panel = field.up('pveStoragePruneInputPanel'); - panel.updateComponents(); - }, - }, - }, - - columnB: [ - { - xtype: 'component', - userCls: 'pmx-hint', - name: 'no-keeps-hint', - hidden: true, - padding: '5 1', - html: gettext('Without any keep option, the node\'s vzdump.conf or `keep-all` is used as fallback for backup jobs'), - }, - { - xtype: 'component', - userCls: 'pmx-hint', - name: 'pbs-hint', - hidden: true, - padding: '5 1', - html: gettext("It's preferred to configure backup retention directly on the Proxmox Backup Server."), - }, - ], -}); - Ext.define('PVE.storage.BaseEdit', { extend: 'Proxmox.window.Edit', @@ -191,7 +97,7 @@ Ext.define('PVE.storage.BaseEdit', { items: [ me.ipanel, { - xtype: 'pveStoragePruneInputPanel', + xtype: 'pveEditPruneInputPanel', title: gettext('Backup Retention'), isCreate: me.isCreate, isPBS: me.ipanel.isPBS, -- 2.30.2