From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.csapak@proxmox.com>
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 UTF8SMTPS id E17E269544
 for <pmg-devel@lists.proxmox.com>; Mon, 22 Mar 2021 16:46:45 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with UTF8SMTP id D4DE227072
 for <pmg-devel@lists.proxmox.com>; Mon, 22 Mar 2021 16:46:45 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [212.186.127.180])
 (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 UTF8SMTPS id 9951327063
 for <pmg-devel@lists.proxmox.com>; Mon, 22 Mar 2021 16:46:44 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with UTF8SMTP id 52EFA42697;
 Mon, 22 Mar 2021 16:46:44 +0100 (CET)
Message-ID: <b4011a48-3931-ee46-7025-21355e31d2b2@proxmox.com>
Date: Mon, 22 Mar 2021 16:46:43 +0100
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:87.0) Gecko/20100101
 Thunderbird/87.0
Content-Language: en-US
To: Thomas Lamprecht <t.lamprecht@proxmox.com>, pmg-devel@lists.proxmox.com
References: <20210322090046.26278-1-t.lamprecht@proxmox.com>
 <20210322090046.26278-3-t.lamprecht@proxmox.com>
From: Dominik Csapak <d.csapak@proxmox.com>
In-Reply-To: <20210322090046.26278-3-t.lamprecht@proxmox.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.181 Adjusted score from AWL reputation of From: address
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 NICE_REPLY_A           -0.001 Looks like a legit reply (A)
 RCVD_IN_DNSWL_MED        -2.3 Sender listed at https://www.dnswl.org/,
 medium trust
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: Re: [pmg-devel] [PATCH] fix #3164: allow one to display all
 quarantined spam mails
X-BeenThere: pmg-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Mail Gateway development discussion
 <pmg-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pmg-devel>, 
 <mailto:pmg-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pmg-devel/>
List-Post: <mailto:pmg-devel@lists.proxmox.com>
List-Help: <mailto:pmg-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel>, 
 <mailto:pmg-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Mon, 22 Mar 2021 15:46:45 -0000

like discussed off-list, LGTM

Reviewed-By: Dominik Csapak <d.csapak@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@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,
>