public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Dominik Csapak <d.csapak@proxmox.com>
To: pmg-devel@lists.proxmox.com
Subject: [pmg-devel] [RFC PATCH pmg-gui 1/1] quarantine content: add checkbox for controlling image loading
Date: Tue, 13 Feb 2024 12:30:50 +0100	[thread overview]
Message-ID: <20240213113050.2349660-3-d.csapak@proxmox.com> (raw)
In-Reply-To: <20240213113050.2349660-1-d.csapak@proxmox.com>

sometimes users don't want to load the images from the quarantine,
even when the admin configured 'viewimages' to on in the config.
(e.g. for privacy reasons)

This checkbox sets/gets the state from the browser local storage
(so it's saved across reloads) to save the users preference of loading
images.

If the backend is set to not load the images, the checkbox doesn't have
any effect.

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 js/AttachmentQuarantine.js            |  4 +++-
 js/Makefile                           |  1 +
 js/SpamQuarantine.js                  |  4 +++-
 js/VirusQuarantine.js                 |  4 +++-
 js/controller/QuarantineController.js | 19 ++++++++++++++++---
 js/form/ViewImages.js                 | 17 +++++++++++++++++
 6 files changed, 43 insertions(+), 6 deletions(-)
 create mode 100644 js/form/ViewImages.js

diff --git a/js/AttachmentQuarantine.js b/js/AttachmentQuarantine.js
index 52bda4c..340c18f 100644
--- a/js/AttachmentQuarantine.js
+++ b/js/AttachmentQuarantine.js
@@ -109,7 +109,9 @@ Ext.define('PMG.AttachmentQuarantine', {
 			},
 			{
 			    xtype: 'tbseparator',
-			    reference: 'themeCheckSep',
+			},
+			{
+			    xtype: 'pmgViewImagesCheckbox',
 			},
 			{
 			    xtype: 'proxmoxcheckbox',
diff --git a/js/Makefile b/js/Makefile
index 78f2b57..f2faef7 100644
--- a/js/Makefile
+++ b/js/Makefile
@@ -2,6 +2,7 @@ include ../defines.mk
 
 JSSRC=							\
 	Utils.js					\
+	form/ViewImages.js				\
 	FilterProxy.js					\
 	LoginView.js					\
 	RoleSelector.js					\
diff --git a/js/SpamQuarantine.js b/js/SpamQuarantine.js
index a390dcf..38d6d52 100644
--- a/js/SpamQuarantine.js
+++ b/js/SpamQuarantine.js
@@ -226,7 +226,9 @@ Ext.define('PMG.SpamQuarantine', {
 			},
 			{
 			    xtype: 'tbseparator',
-			    reference: 'themeCheckSep',
+			},
+			{
+			    xtype: 'pmgViewImagesCheckbox',
 			},
 			{
 			    xtype: 'proxmoxcheckbox',
diff --git a/js/VirusQuarantine.js b/js/VirusQuarantine.js
index 9e5a4fb..c21a09f 100644
--- a/js/VirusQuarantine.js
+++ b/js/VirusQuarantine.js
@@ -122,7 +122,9 @@ Ext.define('PMG.VirusQuarantine', {
 			},
 			{
 			    xtype: 'tbseparator',
-			    reference: 'themeCheckSep',
+			},
+			{
+			    xtype: 'pmgViewImagesCheckbox',
 			},
 			{
 			    xtype: 'proxmoxcheckbox',
diff --git a/js/controller/QuarantineController.js b/js/controller/QuarantineController.js
index 2a24389..5d036a6 100644
--- a/js/controller/QuarantineController.js
+++ b/js/controller/QuarantineController.js
@@ -10,8 +10,10 @@ Ext.define('PMG.controller.QuarantineController', {
 	    preview.setDisabled(true);
 	    return;
 	}
+	let sp = Ext.state.Manager.getProvider();
+	let viewImages = sp.get('view-images') ?? 1;
 
-	let url = `/api2/htmlmail/quarantine/content?id=${rec.data.id}`;
+	let url = `/api2/htmlmail/quarantine/content?view-images=${viewImages}&id=${rec.data.id}`;
 	if (raw) {
 	    url += '&raw=1';
 	}
@@ -49,7 +51,6 @@ Ext.define('PMG.controller.QuarantineController', {
 	let themeButton = me.lookup('themeCheck');
 	themeButton.disable();
 	themeButton.hide();
-	me.lookup('themeCheckSep').hide();
 	me.themed = true;
 	me.toggleTheme();
     },
@@ -62,7 +63,6 @@ Ext.define('PMG.controller.QuarantineController', {
 	themeButton.setValue(true);
 	themeButton.enable();
 	themeButton.show();
-	me.lookup('themeCheckSep').show();
     },
 
     toggleRaw: function(button) {
@@ -74,6 +74,16 @@ Ext.define('PMG.controller.QuarantineController', {
 	me.updatePreview(me.raw, rec);
     },
 
+    toggleImages: function(field, value) {
+	let me = this;
+	let sp = Ext.state.Manager.getProvider();
+	sp.set('view-images', value ? 1 : 0);
+
+	let list = me.lookupReference('list');
+	let rec = list.selModel.getSelection()[0];
+	me.updatePreview(me.raw, rec);
+    },
+
     btnHandler: function(button, e) {
 	let me = this;
 	let action = button.reference;
@@ -228,6 +238,9 @@ Ext.define('PMG.controller.QuarantineController', {
 	'button[reference=raw]': {
 	    click: 'toggleRaw',
 	},
+	'proxmoxcheckbox[reference=toggleImages]': {
+	    change: 'toggleImages',
+	},
 	'proxmoxcheckbox[reference=themeCheck]': {
 	    change: 'toggleTheme',
 	},
diff --git a/js/form/ViewImages.js b/js/form/ViewImages.js
new file mode 100644
index 0000000..8fb6321
--- /dev/null
+++ b/js/form/ViewImages.js
@@ -0,0 +1,17 @@
+Ext.define('PMG.form.ViewImagesCheckbox', {
+    extend: 'Proxmox.form.Checkbox',
+    alias: 'widget.pmgViewImagesCheckbox',
+
+    boxLabel: gettext('View Images'),
+    iconCls: 'fa fa-file-photo-o',
+    reference: 'toggleImages',
+
+    initComponent: function() {
+	let me = this;
+
+	let sp = Ext.state.Manager.getProvider();
+	me.checked = sp.get('view-images') ?? 1;
+
+	me.callParent();
+    },
+});
-- 
2.30.2





  parent reply	other threads:[~2024-02-13 11:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 11:30 [pmg-devel] [RFC PATCH pmg-api/gui] add 'view images' checkbox to quarantine view Dominik Csapak
2024-02-13 11:30 ` [pmg-devel] [RFC PATCH pmg-api 1/1] api: quarantine: allow disabling images for content Dominik Csapak
2024-02-21 14:12   ` Mira Limbeck
2024-02-13 11:30 ` Dominik Csapak [this message]
2024-02-21 14:17   ` [pmg-devel] [RFC PATCH pmg-gui 1/1] quarantine content: add checkbox for controlling image loading Mira Limbeck
2024-02-21 18:51 ` [pmg-devel] [RFC PATCH pmg-api/gui] add 'view images' checkbox to quarantine view Thomas Lamprecht

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=20240213113050.2349660-3-d.csapak@proxmox.com \
    --to=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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal