From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: Dominik Csapak <d.csapak@proxmox.com>, pmg-devel@lists.proxmox.com
Subject: [pmg-devel] applied: [PATCH pmg-gui 2/2] AttachmentGrid: filter attachment with content-disposition by default
Date: Fri, 11 Nov 2022 18:59:25 +0100 [thread overview]
Message-ID: <40412296-fb22-4884-be30-8a8d4a25cc88@proxmox.com> (raw)
In-Reply-To: <20221107143620.1898890-4-d.csapak@proxmox.com>
s/AttachmentGrid/attachment grid/ in the subject gives a slightly better
searchable tag.
Am 07/11/2022 um 15:36 schrieb Dominik Csapak:
> normally, attachments are given the 'content-disposition: attachment'
> mime attribute, so we use that to filter the attachements
>
> but since we're dealing with spam & virus mails here, and that field
> is client controlled, give the user a way to toggle the remaining parts
> of the mail too.
>
> added the checkbox in the header part, but that made it necessary to
> manually implement the expand/collapse toggle (since the tools are on
> the wrong side of the default toggle)
>
> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
> ---
> js/AttachmentGrid.js | 61 ++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 50 insertions(+), 11 deletions(-)
>
>
applied, thanks! I moved the checkbox into the tbar, as I don't think it is
something often wanted/used, as while yes, the content-disposition is user
controllable, most (all?) MUAs only show it if set so even spammers/attackers
have it in their interest to set it if they actually want to make it useable/
downloadable.
That then allows to turn back on the native titleCollapse, which I find a bit
more ergonomic. Slight drawback is tohave 1.5 rows "wasted" due to the tbar,
but one can still see 6 attachments just fine and IMO not really a concern
(tbh. I'd just drop that checkbox if it really is deemed to use to much space
in the tbar).
> @@ -35,8 +71,15 @@ Ext.define('PMG.grid.AttachmentGrid', {
> view.updateTitleStats(-1);
> return;
> }
> - let totalSize = records.reduce((sum, { data }) => sum + data.size, 0);
> - view.updateTitleStats(records.length, totalSize);
> + let count = 0;
> + let totalSize = records.reduce((sum, { data }) => {
> + if (data['content-disposition'] === 'attachment') {
> + count++;
> + return sum + data.size;
> + }
> + return sum;
> + }, 0);
for such thing's it IMO simpler to use a .filter first, i.e., I reworked it to:
let attachments = records.filter(({ data }) => data['content-disposition'] === 'attachment');
let totalSize = attachments.reduce((sum, { data }) => sum + data.size, 0);
view.updateTitleStats(attachments.length, totalSize);
> + view.updateTitleStats(count, totalSize);
> },
> },
>
prev parent reply other threads:[~2022-11-11 17:59 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-07 14:36 [pmg-devel] [PATCH pmg-api/pmg-gui] filter attachments in quarantines Dominik Csapak
2022-11-07 14:36 ` [pmg-devel] [PATCH pmg-api 1/1] api: quarantine: add 'content-disposition' field to listattachments Dominik Csapak
2022-11-07 15:57 ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-07 14:36 ` [pmg-devel] [PATCH pmg-gui 1/2] AttachmentGrid: fix typo Dominik Csapak
2022-11-07 15:54 ` [pmg-devel] applied: " Thomas Lamprecht
2022-11-07 14:36 ` [pmg-devel] [PATCH pmg-gui 2/2] AttachmentGrid: filter attachment with content-disposition by default Dominik Csapak
2022-11-11 17:59 ` Thomas Lamprecht [this message]
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=40412296-fb22-4884-be30-8a8d4a25cc88@proxmox.com \
--to=t.lamprecht@proxmox.com \
--cc=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