[pmg-devel] [PATCH] fix #3164: allow one to display all quarantined spam mails

Dominik Csapak d.csapak at proxmox.com
Mon Mar 22 16:46:43 CET 2021


like discussed off-list, LGTM

Reviewed-By: Dominik Csapak <d.csapak at proxmox.com>

On 3/22/21 10:00, Thomas Lamprecht wrote:
> If the API call returned more than one pmail entry, inject an "all"
> entry which, if selected, drops the user parameter and loads the
> quarantine mails of all users from the backend.
> 
> The webinterface has only some issues regarding deselection (all in
> the grid header or if we need to deselect due to the search filtering
> out some elements) - for that the underlying issue was found and a
> widget toolkit patch was provided.
> 
> The rest seems now pretty performant, albeit more than a few 100k
> mails may become a problem here. But, in such big setups the mail
> admin won't tinker to much whith the users mail anyway, if they are
> even alowed to do so depending on their jurisdictions privacy laws
> and companies privacy policy.
> 
> So, basically this is more for evaluation or for smaller setups but
> got quite often requested, and as there's not more data
> exposed/returned then already available I see no real argument
> against it.
> 
> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>   js/QuarantineList.js | 26 +++++++++++++++++++++++---
>   1 file changed, 23 insertions(+), 3 deletions(-)
> 
> diff --git a/js/QuarantineList.js b/js/QuarantineList.js
> index c5cab6e..9280489 100644
> --- a/js/QuarantineList.js
> +++ b/js/QuarantineList.js
> @@ -76,6 +76,10 @@ Ext.define('PMG.QuarantineList', {
>   		}
>   		me.setEmptyText();
>   	    }
> +	    // deselect all first, else ExtJS does some funky O(n^3) comparissions as it tries
> +	    // to keep the selection, but we do not care for that on a new load anyway
> +	    view.getSelectionModel().deselectAll();
> +
>   	    store.load(function() {
>   		if (me.savedPosition !== undefined) {
>   		    if (store.getCount() - 1 < me.savedPosition) {
> @@ -112,7 +116,11 @@ Ext.define('PMG.QuarantineList', {
>   	setUser: function(user) {
>   	    let view = this.getView();
>   	    let params = view.getStore().getProxy().getExtraParams();
> -	    params.pmail = user;
> +	    if (user === null) {
> +		delete params.pmail;
> +	    } else {
> +		params.pmail = user;
> +	    }
>   	    view.getStore().getProxy().setExtraParams(params);
>   	    view.user = user;
>   	},
> @@ -164,7 +172,11 @@ Ext.define('PMG.QuarantineList', {
>   	    let me = this;
>   	    me.savedPosition = undefined;
>   	    me.allowPositionSave = false;
> -	    me.setUser(value);
> +	    if (value === 'all') {
> +		me.setUser(null);
> +	    } else {
> +		me.setUser(value);
> +	    }
>   	    me.load();
>   	},
>   
> @@ -214,7 +226,8 @@ Ext.define('PMG.QuarantineList', {
>   		return match;
>   	    });
>   	    if (toDeselect.length > 0) {
> -		sm.deselect(toDeselect);
> +		sm.deselect(toDeselect, true);
> +		sm.maybeFireSelectionChange(true);
>   	    }
>   	    return selectedRecordId !== null && clearSelectedMail;
>   	},
> @@ -313,6 +326,13 @@ 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,
> 





More information about the pmg-devel mailing list