* [pmg-devel] [PATCH pmg-api/pmg-gui] fix #3287: allow filtering by mail for all qurantine views
@ 2022-11-23 14:52 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-23 14:52 ` [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view Dominik Csapak
0 siblings, 2 replies; 5+ messages in thread
From: Dominik Csapak @ 2022-11-23 14:52 UTC (permalink / raw)
To: pmg-devel
by introducing the 'pmail' parameter for the virus and attachment
quarantine api calls to, and adding the email combobox for them in the
gui
pmg-api:
Dominik Csapak (1):
fix #3287: add pmail parameter to virus/attch. quarantine list
src/PMG/API2/Quarantine.pm | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
pmg-gui:
Dominik Csapak (1):
fix #3287: add recipient filter for virus/attach. quarantine view
js/AttachmentQuarantine.js | 2 +-
js/QuarantineList.js | 48 ++++++++++++++++++++++++--------------
js/SpamQuarantine.js | 1 -
js/VirusQuarantine.js | 2 +-
4 files changed, 32 insertions(+), 21 deletions(-)
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pmg-devel] [PATCH pmg-api 1/1] fix #3287: add pmail parameter to virus/attch. quarantine list
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 ` Dominik Csapak
2022-11-24 13:23 ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-23 14:52 ` [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view Dominik Csapak
1 sibling, 1 reply; 5+ messages in thread
From: Dominik Csapak @ 2022-11-23 14:52 UTC (permalink / raw)
To: pmg-devel
so that we can filter by the recipient email
for that we also have to add the quarantine type to the 'spamusers' api
call, or else we cannot list which recipients have mails in the
respective quarantine
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
src/PMG/API2/Quarantine.pm | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm
index ddf7c04..71aaf0c 100644
--- a/src/PMG/API2/Quarantine.pm
+++ b/src/PMG/API2/Quarantine.pm
@@ -389,6 +389,12 @@ __PACKAGE__->register_method ({
}});
+my $quar_type_map = {
+ spam => 'S',
+ attachment => 'A',
+ virus => 'V',
+};
+
__PACKAGE__->register_method ({
name => 'spamusers',
path => 'spamusers',
@@ -400,6 +406,13 @@ __PACKAGE__->register_method ({
properties => {
starttime => get_standard_option('pmg-starttime'),
endtime => get_standard_option('pmg-endtime'),
+ 'quarantine-type' => {
+ description => 'Query this type of quarantine for users.',
+ type => 'string',
+ default => 'spam',
+ optional => 1,
+ enum => [keys $quar_type_map->%*],
+ },
},
},
returns => {
@@ -427,14 +440,16 @@ __PACKAGE__->register_method ({
my $start = $param->{starttime} // (time - 86400);
my $end = $param->{endtime} // ($start + 86400);
+ my $quar_type = $param->{'quarantine-type'} // 'spam';
+
my $sth = $dbh->prepare(
"SELECT DISTINCT pmail " .
"FROM CMailStore, CMSReceivers WHERE " .
"time >= $start AND time < $end AND " .
- "QType = 'S' AND CID = CMailStore_CID AND RID = CMailStore_RID " .
+ "QType = ? AND CID = CMailStore_CID AND RID = CMailStore_RID " .
"AND Status = 'N' ORDER BY pmail");
- $sth->execute();
+ $sth->execute($quar_type_map->{$quar_type});
while (my $ref = $sth->fetchrow_hashref()) {
push @$res, { mail => $ref->{pmail} };
@@ -657,6 +672,7 @@ __PACKAGE__->register_method ({
properties => {
starttime => get_standard_option('pmg-starttime'),
endtime => get_standard_option('pmg-endtime'),
+ pmail => $pmail_param_type,
},
},
returns => {
@@ -706,7 +722,7 @@ __PACKAGE__->register_method ({
},
code => sub {
my ($param) = @_;
- return $quarantine_api->($param, 'V');
+ return $quarantine_api->($param, 'V', defined($param->{pmail}));
}});
__PACKAGE__->register_method ({
@@ -720,6 +736,7 @@ __PACKAGE__->register_method ({
properties => {
starttime => get_standard_option('pmg-starttime'),
endtime => get_standard_option('pmg-endtime'),
+ pmail => $pmail_param_type,
},
},
returns => {
@@ -765,7 +782,7 @@ __PACKAGE__->register_method ({
},
code => sub {
my ($param) = @_;
- return $quarantine_api->($param, 'A');
+ return $quarantine_api->($param, 'A', defined($param->{pmail}));
}});
__PACKAGE__->register_method ({
--
2.30.2
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view
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-23 14:52 ` Dominik Csapak
2022-11-25 14:26 ` [pmg-devel] applied: " Thomas Lamprecht
1 sibling, 1 reply; 5+ messages in thread
From: Dominik Csapak @ 2022-11-23 14:52 UTC (permalink / raw)
To: pmg-devel
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
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pmg-devel] applied: [PATCH pmg-api 1/1] fix #3287: add pmail parameter to virus/attch. quarantine list
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 ` Thomas Lamprecht
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2022-11-24 13:23 UTC (permalink / raw)
To: Dominik Csapak, pmg-devel
Am 23/11/2022 um 15:52 schrieb Dominik Csapak:
> so that we can filter by the recipient email
> for that we also have to add the quarantine type to the 'spamusers' api
> call, or else we cannot list which recipients have mails in the
> respective quarantine
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> src/PMG/API2/Quarantine.pm | 25 +++++++++++++++++++++----
> 1 file changed, 21 insertions(+), 4 deletions(-)
>
>
applied, thanks!
FWIW and nothing too important: we now could drop the $check_pmail param and
do that purely inline, all call sites pass defined($param->{pmail}) for that
anyway
^ permalink raw reply [flat|nested] 5+ messages in thread
* [pmg-devel] applied: [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view
2022-11-23 14:52 ` [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view Dominik Csapak
@ 2022-11-25 14:26 ` Thomas Lamprecht
0 siblings, 0 replies; 5+ messages in thread
From: Thomas Lamprecht @ 2022-11-25 14:26 UTC (permalink / raw)
To: Dominik Csapak, pmg-devel
Am 23/11/2022 um 15:52 schrieb Dominik Csapak:
> 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(-)
>
>
applied, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-11-25 14:26 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [pmg-devel] [PATCH pmg-gui 1/1] fix #3287: add recipient filter for virus/attach. quarantine view Dominik Csapak
2022-11-25 14:26 ` [pmg-devel] applied: " Thomas Lamprecht
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox