[pmg-devel] [PATCH pmg-gui 2/5] quarantines: add attachment grid to spam and virus quarantine

Dominik Csapak d.csapak at proxmox.com
Fri Nov 4 16:04:22 CET 2022


So that admins can easily see which attachments exist for a mail,
without parsing the 'raw' mail content. Disable the download button
for these quarantines though, since it should not be necessary
to download the attachments for these.

Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
 js/AttachmentGrid.js                  |  6 ++++++
 js/SpamQuarantine.js                  | 17 +++++++++++++++++
 js/VirusQuarantine.js                 | 17 +++++++++++++++++
 js/controller/QuarantineController.js |  8 ++++++++
 4 files changed, 48 insertions(+)

diff --git a/js/AttachmentGrid.js b/js/AttachmentGrid.js
index 7e630de..8943f09 100644
--- a/js/AttachmentGrid.js
+++ b/js/AttachmentGrid.js
@@ -1,6 +1,9 @@
 Ext.define('PMG.grid.AttachmentGrid', {
     extend: 'Ext.grid.GridPanel',
     xtype: 'pmgAttachmentGrid',
+    mixins: ['Proxmox.Mixin.CBind'],
+
+    showDownloads: true,
 
     store: {
 	autoDestroy: true,
@@ -48,6 +51,9 @@ Ext.define('PMG.grid.AttachmentGrid', {
 	},
 	{
 	    header: gettext('Download'),
+	    cbind: {
+		hidden: '{!showDownloads}',
+	    },
 	    renderer: function(value, mD, rec) {
 		var me = this;
 		let url = `/api2/json/quarantine/download?mailid=${me.mailid}&attachmentid=${rec.data.id}`;
diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js
index c86ce79..d3afcc5 100644
--- a/js/SpamQuarantine.js
+++ b/js/SpamQuarantine.js
@@ -219,6 +219,14 @@ Ext.define('PMG.SpamQuarantine', {
 			    enableToggle: true,
 			    iconCls: 'fa fa-bullhorn',
 			},
+			{
+			    xtype: 'button',
+			    reference: 'attachments',
+			    text: gettext('Toggle Attachments'),
+			    enableToggle: true,
+			    pressed: true,
+			    iconCls: 'fa fa-paperclip',
+			},
 			'->',
 			{
 			    xtype: 'button',
@@ -265,6 +273,15 @@ Ext.define('PMG.SpamQuarantine', {
 		    border: false,
 		    reference: 'spaminfo',
 		},
+		{
+		    xtype: 'pmgAttachmentGrid',
+		    minHeight: 50,
+		    maxHeight: 250,
+		    scrollable: true,
+		    reference: 'attachmentlist',
+		    showDownloads: false,
+		    border: false,
+		},
 		{
 		    xtype: 'pmgMailInfo',
 		    hidden: true,
diff --git a/js/VirusQuarantine.js b/js/VirusQuarantine.js
index 47e055c..8580e7a 100644
--- a/js/VirusQuarantine.js
+++ b/js/VirusQuarantine.js
@@ -114,6 +114,14 @@ Ext.define('PMG.VirusQuarantine', {
 			    enableToggle: true,
 			    iconCls: 'fa fa-file-code-o',
 			},
+			{
+			    xtype: 'button',
+			    reference: 'attachments',
+			    text: gettext('Toggle Attachments'),
+			    enableToggle: true,
+			    pressed: true,
+			    iconCls: 'fa fa-paperclip',
+			},
 			'->',
 			{
 			    xtype: 'button',
@@ -142,6 +150,15 @@ Ext.define('PMG.VirusQuarantine', {
 			},
 		    ],
 		},
+		{
+		    xtype: 'pmgAttachmentGrid',
+		    minHeight: 50,
+		    maxHeight: 250,
+		    scrollable: true,
+		    reference: 'attachmentlist',
+		    showDownloads: false,
+		    border: false,
+		},
 		{
 		    xtype: 'pmgMailInfo',
 		    hidden: true,
diff --git a/js/controller/QuarantineController.js b/js/controller/QuarantineController.js
index d47af6a..afc04be 100644
--- a/js/controller/QuarantineController.js
+++ b/js/controller/QuarantineController.js
@@ -41,6 +41,11 @@ Ext.define('PMG.controller.QuarantineController', {
 	me.updatePreview(me.raw, rec);
     },
 
+    toggleAttachments: function(button) {
+	var grid = this.lookup('attachmentlist');
+	grid?.setVisible(!grid?.isVisible());
+    },
+
     btnHandler: function(button, e) {
 	let me = this;
 	let action = button.reference;
@@ -162,6 +167,9 @@ Ext.define('PMG.controller.QuarantineController', {
 	'button[reference=raw]': {
 	    click: 'toggleRaw',
 	},
+	'button[reference=attachments]': {
+	    click: 'toggleAttachments',
+	},
 	'pmgQuarantineList': {
 	    selectionChange: 'onSelectMail',
 	    itemkeypress: 'keyPress',
-- 
2.30.2





More information about the pmg-devel mailing list