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 60CA9EA3A for ; Wed, 19 Jul 2023 15:53:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3844B8537 for ; Wed, 19 Jul 2023 15:53:21 +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 ; Wed, 19 Jul 2023 15:53:20 +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 DADF1413F9; Wed, 19 Jul 2023 15:53:19 +0200 (CEST) Message-ID: Date: Wed, 19 Jul 2023 15:53:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Proxmox VE development discussion , Lukas Wagner References: <20230717150051.710464-1-l.wagner@proxmox.com> <20230717150051.710464-66-l.wagner@proxmox.com> From: Dominik Csapak In-Reply-To: <20230717150051.710464-66-l.wagner@proxmox.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 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 - URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [me.name] Subject: Re: [pve-devel] [PATCH v3 proxmox-widget-toolkit 65/66] notification: add ui for managing notification filters 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: Wed, 19 Jul 2023 13:53:21 -0000 more or less the same comments as for 61/66 autoShow, single line if, column use, etc. On 7/17/23 17:00, Lukas Wagner wrote: > Signed-off-by: Lukas Wagner > --- > src/Makefile | 3 +- > src/data/model/NotificationConfig.js | 9 ++ > src/panel/NotificationConfigView.js | 119 +++++++++++++++++++++++++++ > src/window/NotificationFilterEdit.js | 115 ++++++++++++++++++++++++++ > 4 files changed, 245 insertions(+), 1 deletion(-) > create mode 100644 src/window/NotificationFilterEdit.js > > diff --git a/src/Makefile b/src/Makefile > index f661bb6..21fbe76 100644 > --- a/src/Makefile > +++ b/src/Makefile > @@ -89,7 +89,8 @@ JSSRC= \ > window/ACMEAccount.js \ > window/ACMEPluginEdit.js \ > window/ACMEDomains.js \ > - window/EndpointEditBase.js \ > + window/EndpointEditBase.js \ > + window/NotificationFilterEdit.js \ > window/FileBrowser.js \ > window/AuthEditBase.js \ > window/AuthEditOpenId.js \ > diff --git a/src/data/model/NotificationConfig.js b/src/data/model/NotificationConfig.js > index c2ce843..bb4ef85 100644 > --- a/src/data/model/NotificationConfig.js > +++ b/src/data/model/NotificationConfig.js > @@ -6,3 +6,12 @@ Ext.define('proxmox-notification-endpoints', { > }, > idProperty: 'name', > }); > + > +Ext.define('proxmox-notification-filters', { > + extend: 'Ext.data.Model', > + fields: ['name', 'comment'], > + proxy: { > + type: 'proxmox', > + }, > + idProperty: 'name', > +}); > diff --git a/src/panel/NotificationConfigView.js b/src/panel/NotificationConfigView.js > index 2aa04da..c3f7c40 100644 > --- a/src/panel/NotificationConfigView.js > +++ b/src/panel/NotificationConfigView.js > @@ -15,6 +15,17 @@ Ext.define('Proxmox.panel.NotificationConfigView', { > baseUrl: '{baseUrl}', > }, > }, > + { > + region: 'south', > + height: '50%', > + border: false, > + collapsible: true, > + animCollapse: false, > + xtype: 'pmxNotificationFilterView', > + cbind: { > + baseUrl: '{baseUrl}', > + }, > + }, > ], > }); > > @@ -194,3 +205,111 @@ Ext.define('Proxmox.panel.NotificationEndpointView', { > me.store.rstore.proxy.setUrl(`/api2/json/${me.baseUrl}/targets`); > }, > }); > + > +Ext.define('Proxmox.panel.NotificationFilterView', { > + extend: 'Ext.grid.Panel', > + alias: 'widget.pmxNotificationFilterView', > + > + title: gettext('Notification Filters'), > + > + controller: { > + xclass: 'Ext.app.ViewController', > + > + openEditWindow: function(filter) { > + let me = this; > + > + Ext.create('Proxmox.window.NotificationFilterEdit', { > + baseUrl: me.getView().baseUrl, > + name: filter, > + listeners: { > + destroy: () => me.reload(), > + }, > + }).show(); > + }, > + > + openEditForSelectedItem: function() { > + let me = this; > + let view = me.getView(); > + > + let selection = view.getSelection(); > + if (selection.length < 1) return; > + let filterName = selection[0].data.name; > + > + me.openEditWindow(filterName); > + }, > + > + reload: function() { > + let me = this; > + let view = me.getView(); > + view.getStore().rstore.load(); > + }, > + }, > + > + listeners: { > + itemdblclick: 'openEditForSelectedItem', > + activate: 'reload', > + }, > + > + emptyText: gettext('No notification filters configured'), > + > + columns: [ > + { > + dataIndex: 'name', > + text: gettext('Filter Name'), > + renderer: Ext.String.htmlEncode, > + flex: 1, > + }, > + { > + dataIndex: 'comment', > + text: gettext('Comment'), > + renderer: Ext.String.htmlEncode, > + flex: 2, > + }, > + ], > + > + store: { > + type: 'diff', > + autoDestroy: true, > + autoDestroyRstore: true, > + rstore: { > + type: 'update', > + storeid: 'proxmox-notification-filters', > + model: 'proxmox-notification-filters', > + autoStart: true, > + }, > + sorters: 'name', > + }, > + > + initComponent: function() { > + let me = this; > + > + if (!me.baseUrl) { > + throw "baseUrl is not set!"; > + } > + > + Ext.apply(me, { > + tbar: [ > + { > + xtype: 'proxmoxButton', > + text: gettext('Add'), > + handler: () => me.getController().openEditWindow(), > + selModel: false, > + }, > + { > + xtype: 'proxmoxButton', > + text: gettext('Modify'), > + handler: 'openEditForSelectedItem', > + disabled: true, > + }, > + { > + xtype: 'proxmoxStdRemoveButton', > + callback: 'reload', > + baseurl: `${me.baseUrl}/filters`, > + }, > + ], > + }); > + > + me.callParent(); > + me.store.rstore.proxy.setUrl(`/api2/json/${me.baseUrl}/filters`); > + }, > +}); > diff --git a/src/window/NotificationFilterEdit.js b/src/window/NotificationFilterEdit.js > new file mode 100644 > index 0000000..6a48446 > --- /dev/null > +++ b/src/window/NotificationFilterEdit.js > @@ -0,0 +1,115 @@ > +Ext.define('Proxmox.panel.NotificationFilterEditPanel', { > + extend: 'Proxmox.panel.InputPanel', > + xtype: 'pmxNotificationFilterEditPanel', > + mixins: ['Proxmox.Mixin.CBind'], > + > + columnT: [ > + { > + xtype: 'pmxDisplayEditField', > + name: 'name', > + cbind: { > + value: '{name}', > + editable: '{isCreate}', > + }, > + fieldLabel: gettext('Filter Name'), > + allowBlank: false, > + }, > + { > + xtype: 'proxmoxKVComboBox', > + name: 'min-severity', > + fieldLabel: gettext('Minimum Severity'), > + value: null, > + cbind: { > + deleteEmpty: '{!isCreate}', > + }, > + comboItems: [ > + ['info', 'info'], > + ['notice', 'notice'], > + ['warning', 'warning'], > + ['error', 'error'], > + ], > + triggers: { > + clear: { > + cls: 'pmx-clear-trigger', > + weight: -1, > + hidden: false, > + handler: function() { > + this.setValue(''); > + }, > + }, > + }, > + }, > + { > + xtype: 'proxmoxcheckbox', > + fieldLabel: gettext('Invert match'), > + name: 'invert-match', > + uncheckedValue: 0, > + defaultValue: 0, > + cbind: { > + deleteDefaultValue: '{!isCreate}', > + }, > + }, > + ], > + > + column1: [], > + > + column2: [], > + > + columnB: [ > + { > + xtype: 'proxmoxtextfield', > + name: 'comment', > + fieldLabel: gettext('Comment'), > + cbind: { > + deleteEmpty: '{!isCreate}', > + }, > + }, > + ], > +}); > + > +Ext.define('Proxmox.window.NotificationFilterEdit', { > + extend: 'Proxmox.window.Edit', > + > + isAdd: true, > + > + fieldDefaults: { > + labelWidth: 120, > + }, > + > + initComponent: function() { > + let me = this; > + > + me.isCreate = !me.name; > + > + if (!me.baseUrl) { > + throw "baseUrl not set"; > + } > + > + me.url = `/api2/extjs${me.baseUrl}/filters`; > + > + if (me.isCreate) { > + me.method = 'POST'; > + } else { > + me.url += `/${me.name}`; > + me.method = 'PUT'; > + } > + > + me.subject = gettext('Notification Filter'); > + > + Ext.apply(me, { > + items: [{ > + name: me.name, > + xtype: 'pmxNotificationFilterEditPanel', > + isCreate: me.isCreate, > + baseUrl: me.baseUrl, > + }], > + }); > + > + me.callParent(); > + > + if (!me.isCreate) { > + me.load(); > + } > + }, > +}); > +