From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view
Date: Wed, 23 Nov 2022 15:52:22 +0100 [thread overview]
Message-ID: <20221123145222.834345-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20221123145222.834345-1-d.csapak@proxmox.com>
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 <d.csapak@proxmox.com>
---
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
next prev parent reply other threads:[~2022-11-23 14:52 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-23 14:52 [pmg-devel] [PATCH pmg-api/pmg-gui] fix #3287: allow filtering by mail for all qurantine views Dominik Csapak
2022-11-23 14:52 ` [pmg-devel] [PATCH pmg-api 1/1] fix #3287: add pmail parameter to virus/attch. quarantine list Dominik Csapak
2022-11-24 13:23 ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-23 14:52 ` Dominik Csapak [this message]
2022-11-25 14:26 ` [pmg-devel] applied: [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221123145222.834345-3-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pmg-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox