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 C2791B235 for ; Wed, 23 Nov 2022 15:52:58 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A52E123A06 for ; Wed, 23 Nov 2022 15:52:28 +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 ; Wed, 23 Nov 2022 15:52:24 +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 D718644DA8 for ; Wed, 23 Nov 2022 15:52:23 +0100 (CET) From: Dominik Csapak To: pmg-devel@lists.proxmox.com Date: Wed, 23 Nov 2022 15:52:22 +0100 Message-Id: <20221123145222.834345-3-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221123145222.834345-1-d.csapak@proxmox.com> References: <20221123145222.834345-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.064 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: [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view X-BeenThere: pmg-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Mail Gateway development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Nov 2022 14:52:58 -0000 so that users can filter these quarantine views if they have many mails there. replaced the emailSelection config with a quarantineType configs since we want to have different behaviour for different quaratine types e.g. we want to show 'all' mails by default for the virus/attachment quarantine, but not for the spam one. Signed-off-by: Dominik Csapak --- js/AttachmentQuarantine.js | 2 +- js/QuarantineList.js | 48 ++++++++++++++++++++++++-------------- js/SpamQuarantine.js | 1 - js/VirusQuarantine.js | 2 +- 4 files changed, 32 insertions(+), 21 deletions(-) diff --git a/js/AttachmentQuarantine.js b/js/AttachmentQuarantine.js index 09406e7..4e9bb80 100644 --- a/js/AttachmentQuarantine.js +++ b/js/AttachmentQuarantine.js @@ -43,7 +43,7 @@ Ext.define('PMG.AttachmentQuarantine', { xtype: 'pmgQuarantineList', emptyText: gettext('No data in database'), selModel: 'checkboxmodel', - emailSelection: false, + quarantineType: 'attachment', reference: 'list', region: 'west', width: 500, diff --git a/js/QuarantineList.js b/js/QuarantineList.js index 74163cf..2da02dc 100644 --- a/js/QuarantineList.js +++ b/js/QuarantineList.js @@ -8,7 +8,7 @@ Ext.define('PMG.QuarantineList', { }, config: { - emailSelection: false, + quarantineType: 'spam', notFoundText: gettext('No data in database'), }, @@ -24,13 +24,22 @@ Ext.define('PMG.QuarantineList', { init: function(view) { let me = this; + let emailCombobox = me.lookupReference('email'); if (PMG.view === 'quarantineview') { - view.emailSelection = false; + view.autoLoadAll = false; me.setEmptyText(); + } else { + emailCombobox.setVisible(true); + emailCombobox.setDisabled(false); + emailCombobox.getStore().on('load', me.injectAllOption, me); + } + + + if (view.quarantineType) { + emailCombobox.getStore().getProxy().setExtraParams({ + 'quarantine-type': view.quarantineType, + }); } - let emailCombobox = me.lookupReference('email'); - emailCombobox.setVisible(view.emailSelection); - emailCombobox.setDisabled(!view.emailSelection); let from; if (PMG.QuarantineList.from !== 0) { @@ -70,7 +79,7 @@ Ext.define('PMG.QuarantineList', { me.allowPositionSave = false; let view = me.getView(); let store = view.getStore(); - if (view.emailSelection) { + if (view.quarantineType === 'spam' && PMG.view !== 'quarantineview') { if (!me.lookupReference('email').getSelection()) { return; // if the combobox has no selection we do not reload } @@ -123,7 +132,7 @@ Ext.define('PMG.QuarantineList', { setUser: function(user) { let view = this.getView(); let params = view.getStore().getProxy().getExtraParams(); - if (user === null) { + if (!user) { delete params.pmail; } else { params.pmail = user; @@ -169,10 +178,7 @@ Ext.define('PMG.QuarantineList', { resetEmail: function() { let me = this; - let view = me.getView(); - if (view.emailSelection) { - me.setUser(undefined); - } + me.setUser(undefined); }, changeEmail: function(tb, value) { @@ -264,6 +270,18 @@ Ext.define('PMG.QuarantineList', { } }, + injectAllOption: function(store, records, successfull) { + let me = this; + let view = me.getView(); + if (successfull && records.length > 1) { + store.insert(0, { mail: 'all' }); + } + let emailCombobox = me.lookup('email'); + if (!emailCombobox.getSelection() && view.quarantineType !== 'spam') { + emailCombobox.setSelection(store.getAt(0)); + } + }, + control: { '#': { beforedestroy: 'resetEmail', @@ -314,6 +332,7 @@ Ext.define('PMG.QuarantineList', { { xtype: 'combobox', hidden: true, + disabled: true, displayField: 'mail', valueField: 'mail', listConfig: { @@ -333,13 +352,6 @@ Ext.define('PMG.QuarantineList', { renderer: Ext.htmlEncode, }, ], - listeners: { - load: function(store, records, successfull) { - if (successfull && records.length > 1) { - store.insert(0, { mail: 'all' }); - } - }, - }, }, queryMode: 'local', editable: true, diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js index 7487c8f..1608f18 100644 --- a/js/SpamQuarantine.js +++ b/js/SpamQuarantine.js @@ -143,7 +143,6 @@ Ext.define('PMG.SpamQuarantine', { title: gettext('Spam Quarantine'), xtype: 'pmgQuarantineList', selModel: 'checkboxmodel', - emailSelection: true, reference: 'list', region: 'west', width: 500, diff --git a/js/VirusQuarantine.js b/js/VirusQuarantine.js index ff349ba..65c4fda 100644 --- a/js/VirusQuarantine.js +++ b/js/VirusQuarantine.js @@ -45,7 +45,7 @@ Ext.define('PMG.VirusQuarantine', { xtype: 'pmgQuarantineList', emptyText: gettext('No data in database'), selModel: 'checkboxmodel', - emailSelection: false, + quarantineType: 'virus', reference: 'list', region: 'west', width: 500, -- 2.30.2