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 A7E5799E7A for ; Tue, 14 Nov 2023 14:07:34 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 88E5B30E67 for ; Tue, 14 Nov 2023 14:07:04 +0100 (CET) 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 for ; Tue, 14 Nov 2023 14:07:02 +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 4666C4298F for ; Tue, 14 Nov 2023 14:00:21 +0100 (CET) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Tue, 14 Nov 2023 13:59:52 +0100 Message-Id: <20231114130000.565122-45-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231114130000.565122-1-l.wagner@proxmox.com> References: <20231114130000.565122-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.009 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 T_SCC_BODY_TEXT_LINE -0.01 - Subject: [pve-devel] [PATCH v2 proxmox-widget-toolkit 44/52] notification ui: add enable checkbox for targets/matchers 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: Tue, 14 Nov 2023 13:07:34 -0000 Add a 'enable' checkbox for targets and matchers in their edit windows. Also show a new 'enable' column in the overview panel. The parameter in the config is actually called 'disable', so the UI needs to invert the setting in the appropriate on{Get,Set}Values hooks. Signed-off-by: Lukas Wagner --- src/data/model/NotificationConfig.js | 4 ++-- src/panel/GotifyEditPanel.js | 30 +++++++++++++++++++++++++++ src/panel/NotificationConfigView.js | 12 +++++++++++ src/panel/SendmailEditPanel.js | 28 ++++++++++++++++++++++++- src/panel/SmtpEditPanel.js | 23 +++++++++++++++++++- src/window/NotificationMatcherEdit.js | 30 +++++++++++++++++++++++++++ 6 files changed, 123 insertions(+), 4 deletions(-) diff --git a/src/data/model/NotificationConfig.js b/src/data/model/NotificationConfig.js index f447db4..9171515 100644 --- a/src/data/model/NotificationConfig.js +++ b/src/data/model/NotificationConfig.js @@ -1,6 +1,6 @@ Ext.define('proxmox-notification-endpoints', { extend: 'Ext.data.Model', - fields: ['name', 'type', 'comment'], + fields: ['name', 'type', 'comment', 'disable'], proxy: { type: 'proxmox', }, @@ -9,7 +9,7 @@ Ext.define('proxmox-notification-endpoints', { Ext.define('proxmox-notification-matchers', { extend: 'Ext.data.Model', - fields: ['name', 'comment'], + fields: ['name', 'comment', 'disable'], proxy: { type: 'proxmox', }, diff --git a/src/panel/GotifyEditPanel.js b/src/panel/GotifyEditPanel.js index 5d814e5..7e6ecd8 100644 --- a/src/panel/GotifyEditPanel.js +++ b/src/panel/GotifyEditPanel.js @@ -16,6 +16,13 @@ Ext.define('Proxmox.panel.GotifyEditPanel', { fieldLabel: gettext('Endpoint Name'), allowBlank: false, }, + { + xtype: 'proxmoxcheckbox', + name: 'enable', + fieldLabel: gettext('Enable'), + allowBlank: false, + checked: true, + }, { xtype: 'proxmoxtextfield', fieldLabel: gettext('Server URL'), @@ -41,4 +48,27 @@ Ext.define('Proxmox.panel.GotifyEditPanel', { }, }, ], + + onSetValues: (values) => { + values.enable = !values.disable; + + delete values.disable; + return values; + }, + + onGetValues: function(values) { + let me = this; + + if (values.enable) { + if (!me.isCreate) { + Proxmox.Utils.assemble_field_data(values, { 'delete': 'disable' }); + } + } else { + values.disable = 1; + } + + delete values.enable; + + return values; + }, }); diff --git a/src/panel/NotificationConfigView.js b/src/panel/NotificationConfigView.js index 6a9bc20..ba69298 100644 --- a/src/panel/NotificationConfigView.js +++ b/src/panel/NotificationConfigView.js @@ -119,6 +119,12 @@ Ext.define('Proxmox.panel.NotificationEndpointView', { emptyText: gettext('No notification targets configured'), columns: [ + { + dataIndex: 'disable', + text: gettext('Enable'), + renderer: (disable) => Proxmox.Utils.renderEnabledIcon(!disable), + align: 'center', + }, { dataIndex: 'name', text: gettext('Target Name'), @@ -250,6 +256,12 @@ Ext.define('Proxmox.panel.NotificationMatcherView', { emptyText: gettext('No notification matchers configured'), columns: [ + { + dataIndex: 'disable', + text: gettext('Enable'), + renderer: (disable) => Proxmox.Utils.renderEnabledIcon(!disable), + align: 'center', + }, { dataIndex: 'name', text: gettext('Matcher Name'), diff --git a/src/panel/SendmailEditPanel.js b/src/panel/SendmailEditPanel.js index 17f2d4f..930c4db 100644 --- a/src/panel/SendmailEditPanel.js +++ b/src/panel/SendmailEditPanel.js @@ -27,6 +27,13 @@ Ext.define('Proxmox.panel.SendmailEditPanel', { fieldLabel: gettext('Endpoint Name'), allowBlank: false, }, + { + xtype: 'proxmoxcheckbox', + name: 'enable', + fieldLabel: gettext('Enable'), + allowBlank: false, + checked: true, + }, { // provides 'mailto' and 'mailto-user' fields xtype: 'pmxEmailRecipientPanel', @@ -67,7 +74,26 @@ Ext.define('Proxmox.panel.SendmailEditPanel', { }, ], - onGetValues: (values) => { + onSetValues: (values) => { + values.enable = !values.disable; + + delete values.disable; + return values; + }, + + onGetValues: function(values) { + let me = this; + + if (values.enable) { + if (!me.isCreate) { + Proxmox.Utils.assemble_field_data(values, { 'delete': 'disable' }); + } + } else { + values.disable = 1; + } + + delete values.enable; + if (values.mailto) { values.mailto = values.mailto.split(/[\s,;]+/); } diff --git a/src/panel/SmtpEditPanel.js b/src/panel/SmtpEditPanel.js index ab21217..218485d 100644 --- a/src/panel/SmtpEditPanel.js +++ b/src/panel/SmtpEditPanel.js @@ -49,6 +49,13 @@ Ext.define('Proxmox.panel.SmtpEditPanel', { fieldLabel: gettext('Endpoint Name'), allowBlank: false, }, + { + xtype: 'proxmoxcheckbox', + name: 'enable', + fieldLabel: gettext('Enable'), + allowBlank: false, + checked: true, + }, ], column1: [ @@ -161,15 +168,27 @@ Ext.define('Proxmox.panel.SmtpEditPanel', { ], onGetValues: function(values) { + let me = this; + if (values.mailto) { values.mailto = values.mailto.split(/[\s,;]+/); } - if (!values.authentication && !this.isCreate) { + if (!values.authentication && !me.isCreate) { Proxmox.Utils.assemble_field_data(values, { 'delete': 'username' }); Proxmox.Utils.assemble_field_data(values, { 'delete': 'password' }); } + if (values.enable) { + if (!me.isCreate) { + Proxmox.Utils.assemble_field_data(values, { 'delete': 'disable' }); + } + } else { + values.disable = 1; + } + + delete values.enable; + delete values.authentication; return values; @@ -177,6 +196,8 @@ Ext.define('Proxmox.panel.SmtpEditPanel', { onSetValues: function(values) { values.authentication = !!values.username; + values.enable = !values.disable; + delete values.disable; return values; }, diff --git a/src/window/NotificationMatcherEdit.js b/src/window/NotificationMatcherEdit.js index fb55e17..c0dfa34 100644 --- a/src/window/NotificationMatcherEdit.js +++ b/src/window/NotificationMatcherEdit.js @@ -14,6 +14,13 @@ Ext.define('Proxmox.panel.NotificationMatcherGeneralPanel', { fieldLabel: gettext('Matcher Name'), allowBlank: false, }, + { + xtype: 'proxmoxcheckbox', + name: 'enable', + fieldLabel: gettext('Enable'), + allowBlank: false, + checked: true, + }, { xtype: 'proxmoxtextfield', name: 'comment', @@ -23,6 +30,29 @@ Ext.define('Proxmox.panel.NotificationMatcherGeneralPanel', { }, }, ], + + + onSetValues: function(values) { + values.enable = !values.disable; + + delete values.disable; + return values; + }, + + onGetValues: function(values) { + let me = this; + + if (values.enable) { + if (!me.isCreate) { + Proxmox.Utils.assemble_field_data(values, { 'delete': 'disable' }); + } + } else { + values.disable = 1; + } + delete values.enable; + + return values; + }, }); Ext.define('Proxmox.panel.NotificationMatcherTargetPanel', { -- 2.39.2