* [pmg-devel] [PATCH pmg-api/pmg-gui] filter attachments in quarantines @ 2022-11-07 14:36 Dominik Csapak 2022-11-07 14:36 ` [pmg-devel] [PATCH pmg-api 1/1] api: quarantine: add 'content-disposition' field to listattachments Dominik Csapak ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Dominik Csapak @ 2022-11-07 14:36 UTC (permalink / raw) To: pmg-devel with this series, we filter the attachments in the pmg quarantine view by 'content-disposition: attachment' pmg-gui 1/2 is only a typo fix an more or less unrelated pmg-api: Dominik Csapak (1): api: quarantine: add 'content-disposition' field to listattachments src/PMG/API2/Quarantine.pm | 1 + 1 file changed, 1 insertion(+) pmg-gui: Dominik Csapak (2): AttachmentGrid: fix typo AttachmentGrid: filter attachment with content-disposition by default js/AttachmentGrid.js | 63 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 51 insertions(+), 12 deletions(-) -- 2.30.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] [PATCH pmg-api 1/1] api: quarantine: add 'content-disposition' field to listattachments 2022-11-07 14:36 [pmg-devel] [PATCH pmg-api/pmg-gui] filter attachments in quarantines Dominik Csapak @ 2022-11-07 14:36 ` 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 14:36 ` [pmg-devel] [PATCH pmg-gui 2/2] AttachmentGrid: filter attachment with content-disposition by default Dominik Csapak 2 siblings, 1 reply; 7+ messages in thread From: Dominik Csapak @ 2022-11-07 14:36 UTC (permalink / raw) To: pmg-devel this can be useful to filter for 'real' attachments vs standard mail mime parts Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- src/PMG/API2/Quarantine.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PMG/API2/Quarantine.pm b/src/PMG/API2/Quarantine.pm index 09d9cc9..a75ef20 100644 --- a/src/PMG/API2/Quarantine.pm +++ b/src/PMG/API2/Quarantine.pm @@ -991,6 +991,7 @@ my $get_attachments = sub { id => $id, name => $name, size => $size, + 'content-disposition' => $part->head->mime_attr('content-disposition'), 'content-type' => $part->head->mime_attr('content-type'), }; $entry->{path} = $attachment_path if $with_path; -- 2.30.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] applied: [PATCH pmg-api 1/1] api: quarantine: add 'content-disposition' field to listattachments 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 ` Thomas Lamprecht 0 siblings, 0 replies; 7+ messages in thread From: Thomas Lamprecht @ 2022-11-07 15:57 UTC (permalink / raw) To: Dominik Csapak, pmg-devel Am 07/11/2022 um 15:36 schrieb Dominik Csapak: > this can be useful to filter for 'real' attachments vs standard mail > mime parts > > Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> > --- > src/PMG/API2/Quarantine.pm | 1 + > 1 file changed, 1 insertion(+) > > applied, thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] [PATCH pmg-gui 1/2] AttachmentGrid: fix typo 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 14:36 ` 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 2 siblings, 1 reply; 7+ messages in thread From: Dominik Csapak @ 2022-11-07 14:36 UTC (permalink / raw) To: pmg-devel s/Attachements/Attachments/ Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> --- js/AttachmentGrid.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/AttachmentGrid.js b/js/AttachmentGrid.js index eaac638..3187a58 100644 --- a/js/AttachmentGrid.js +++ b/js/AttachmentGrid.js @@ -44,7 +44,7 @@ Ext.define('PMG.grid.AttachmentGrid', { let me = this; let title; if (count > 0) { - title = Ext.String.format(gettext('{0} Attachements'), count); + title = Ext.String.format(gettext('{0} Attachments'), count); title += ` (${Proxmox.Utils.format_size(totalSize)})`; if (me.collapsible) { me.expand(); -- 2.30.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] applied: [PATCH pmg-gui 1/2] AttachmentGrid: fix typo 2022-11-07 14:36 ` [pmg-devel] [PATCH pmg-gui 1/2] AttachmentGrid: fix typo Dominik Csapak @ 2022-11-07 15:54 ` Thomas Lamprecht 0 siblings, 0 replies; 7+ messages in thread From: Thomas Lamprecht @ 2022-11-07 15:54 UTC (permalink / raw) To: Dominik Csapak, pmg-devel Am 07/11/2022 um 15:36 schrieb Dominik Csapak: > s/Attachements/Attachments/ > > Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> > --- > js/AttachmentGrid.js | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > applied, thanks! ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] [PATCH pmg-gui 2/2] AttachmentGrid: filter attachment with content-disposition by default 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 14:36 ` [pmg-devel] [PATCH pmg-gui 1/2] AttachmentGrid: fix typo Dominik Csapak @ 2022-11-07 14:36 ` Dominik Csapak 2022-11-11 17:59 ` [pmg-devel] applied: " Thomas Lamprecht 2 siblings, 1 reply; 7+ messages in thread From: Dominik Csapak @ 2022-11-07 14:36 UTC (permalink / raw) To: pmg-devel 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(-) diff --git a/js/AttachmentGrid.js b/js/AttachmentGrid.js index 3187a58..b6d8b4a 100644 --- a/js/AttachmentGrid.js +++ b/js/AttachmentGrid.js @@ -11,16 +11,52 @@ Ext.define('PMG.grid.AttachmentGrid', { minHeight: 50, maxHeight: 250, scrollable: true, + collapsed: true, - collapsible: true, - titleCollapse: true, + tools: [ + { + xtype: 'checkbox', + boxLabel: gettext('show all parts'), + boxLabelAlgign: 'before', + listeners: { + change: function(cb, value) { + let grid = this.up('pmgAttachmentGrid'); + let store = grid.getStore(); + store.clearFilter(); + if (!value) { + store.filter({ + property: 'content-disposition', + value: 'attachment', + }); + } + }, + }, + }, + { + type: 'down', + handler: function() { + let me = this; + let type = me.type === 'up' ? 'down' : 'up'; + me.up('pmgAttachmentGrid').toggleCollapse(); + me.setType(type); + }, + }, + ], + + header: { + padding: '6 10 6 10', // make same height as normal panel + }, store: { autoDestroy: true, - fields: ['name', 'content-type', 'size'], + fields: ['name', 'content-type', 'size', 'content-disposition'], proxy: { type: 'proxmox', }, + filters: { + property: 'content-disposition', + value: 'attachment', + }, }, controller: { @@ -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); + view.updateTitleStats(count, totalSize); }, }, @@ -46,14 +89,10 @@ Ext.define('PMG.grid.AttachmentGrid', { if (count > 0) { title = Ext.String.format(gettext('{0} Attachments'), count); title += ` (${Proxmox.Utils.format_size(totalSize)})`; - if (me.collapsible) { - me.expand(); - } + me.expand(); } else { title = gettext('No Attachments'); - if (me.collapsible) { - me.collapse(); - } + me.collapse(); } me.setTitle(title); }, -- 2.30.2 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [pmg-devel] applied: [PATCH pmg-gui 2/2] AttachmentGrid: filter attachment with content-disposition by default 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 0 siblings, 0 replies; 7+ messages in thread From: Thomas Lamprecht @ 2022-11-11 17:59 UTC (permalink / raw) To: Dominik Csapak, pmg-devel 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); > }, > }, > ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-11 17:59 UTC | newest] Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 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 ` [pmg-devel] applied: " Thomas Lamprecht
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.Service provided by Proxmox Server Solutions GmbH | Privacy | Legal