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 50BD7DE9E for ; Mon, 17 Jul 2023 17:02:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id DCD8BFD3D for ; Mon, 17 Jul 2023 17:01:33 +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 for ; Mon, 17 Jul 2023 17:01:30 +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 08E1B42BB4 for ; Mon, 17 Jul 2023 17:01:26 +0200 (CEST) From: Lukas Wagner To: pve-devel@lists.proxmox.com Date: Mon, 17 Jul 2023 17:00:49 +0200 Message-Id: <20230717150051.710464-65-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230717150051.710464-1-l.wagner@proxmox.com> References: <20230717150051.710464-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.117 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 v3 proxmox-widget-toolkit 64/66] notification: allow to select filter for notification targets 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, 17 Jul 2023 15:02:21 -0000 Signed-off-by: Lukas Wagner --- src/Makefile | 1 + src/form/NotificationFilterSelector.js | 58 +++++++++++++++++++++++++ src/panel/GotifyEditPanel.js | 9 ++++ src/panel/NotificationConfigView.js | 4 ++ src/panel/NotificationGroupEditPanel.js | 9 ++++ src/panel/SendmailEditPanel.js | 9 ++++ src/window/EndpointEditBase.js | 1 + 7 files changed, 91 insertions(+) create mode 100644 src/form/NotificationFilterSelector.js diff --git a/src/Makefile b/src/Makefile index 829081d..f661bb6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -44,6 +44,7 @@ JSSRC= \ form/RoleSelector.js \ form/DiskSelector.js \ form/MultiDiskSelector.js \ + form/NotificationFilterSelector.js \ form/TaskTypeSelector.js \ form/ACME.js \ form/UserSelector.js \ diff --git a/src/form/NotificationFilterSelector.js b/src/form/NotificationFilterSelector.js new file mode 100644 index 0000000..d2ab8be --- /dev/null +++ b/src/form/NotificationFilterSelector.js @@ -0,0 +1,58 @@ +Ext.define('Proxmox.form.NotificationFilterSelector', { + extend: 'Proxmox.form.ComboGrid', + alias: ['widget.pmxNotificationFilterSelector'], + + // set default value to empty array, else it inits it with + // null and after the store load it is an empty array, + // triggering dirtychange + value: [], + valueField: 'name', + displayField: 'name', + deleteEmpty: true, + skipEmptyText: true, + allowBlank: true, + editable: false, + autoSelect: false, + + listConfig: { + columns: [ + { + header: gettext('Filter'), + dataIndex: 'name', + sortable: true, + hideable: false, + flex: 1, + }, + { + header: gettext('Comment'), + dataIndex: 'comment', + sortable: true, + hideable: false, + flex: 2, + }, + ], + }, + + initComponent: function() { + let me = this; + + Ext.apply(me, { + store: { + fields: ['name', 'comment'], + proxy: { + type: 'proxmox', + url: `/api2/json/${me.baseUrl}/filters`, + }, + sorters: [ + { + property: 'name', + direction: 'ASC', + }, + ], + autoLoad: true, + }, + }); + + me.callParent(); + }, +}); diff --git a/src/panel/GotifyEditPanel.js b/src/panel/GotifyEditPanel.js index a661c1a..29cea1e 100644 --- a/src/panel/GotifyEditPanel.js +++ b/src/panel/GotifyEditPanel.js @@ -32,6 +32,15 @@ Ext.define('Proxmox.panel.GotifyEditPanel', { allowBlank: '{!isCreate}', }, }, + { + xtype: 'pmxNotificationFilterSelector', + name: 'filter', + fieldLabel: gettext('Filter'), + cbind: { + deleteEmpty: '{!isCreate}', + baseUrl: '{baseUrl}', + }, + }, ], column1: [], diff --git a/src/panel/NotificationConfigView.js b/src/panel/NotificationConfigView.js index f6e6a8b..2aa04da 100644 --- a/src/panel/NotificationConfigView.js +++ b/src/panel/NotificationConfigView.js @@ -141,6 +141,10 @@ Ext.define('Proxmox.panel.NotificationEndpointView', { initComponent: function() { let me = this; + if (!me.baseUrl) { + throw "baseUrl is not set!"; + } + let menuItems = []; for (const [endpointType, config] of Object.entries( Proxmox.Schema.notificationEndpointTypes).sort()) { diff --git a/src/panel/NotificationGroupEditPanel.js b/src/panel/NotificationGroupEditPanel.js index 0a7a469..39fdbc4 100644 --- a/src/panel/NotificationGroupEditPanel.js +++ b/src/panel/NotificationGroupEditPanel.js @@ -28,6 +28,15 @@ Ext.define('Proxmox.panel.NotificationGroupEditPanel', { column2: [], columnB: [ + { + xtype: 'pmxNotificationFilterSelector', + name: 'filter', + fieldLabel: gettext('Filter'), + cbind: { + deleteEmpty: '{!isCreate}', + baseUrl: '{baseUrl}', + }, + }, { xtype: 'proxmoxtextfield', name: 'comment', diff --git a/src/panel/SendmailEditPanel.js b/src/panel/SendmailEditPanel.js index 9444a8c..c151b92 100644 --- a/src/panel/SendmailEditPanel.js +++ b/src/panel/SendmailEditPanel.js @@ -91,6 +91,15 @@ Ext.define('Proxmox.panel.SendmailEditPanel', { return true; }, }, + { + xtype: 'pmxNotificationFilterSelector', + name: 'filter', + fieldLabel: gettext('Filter'), + cbind: { + deleteEmpty: '{!isCreate}', + baseUrl: '{baseUrl}', + }, + }, ], column1: [], diff --git a/src/window/EndpointEditBase.js b/src/window/EndpointEditBase.js index bcf6879..f94a8e4 100644 --- a/src/window/EndpointEditBase.js +++ b/src/window/EndpointEditBase.js @@ -41,6 +41,7 @@ Ext.define('Proxmox.window.EndpointEditBase', { name: me.name, xtype: endpointConfig.ipanel, isCreate: me.isCreate, + baseUrl: me.baseUrl, type: me.type, }], }); -- 2.39.2