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] [PATCH pmg-gui] postfix queues: show decoded headers by default
Date: Thu,  3 Feb 2022 09:29:24 +0100	[thread overview]
Message-ID: <20220203082925.1780071-2-d.csapak@proxmox.com> (raw)
In-Reply-To: <20220203082925.1780071-1-d.csapak@proxmox.com>

and add a toggle button to show the raw headers

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
 js/ViewMailHeaders.js | 67 ++++++++++++++++++++++++++++++++-----------
 1 file changed, 50 insertions(+), 17 deletions(-)

diff --git a/js/ViewMailHeaders.js b/js/ViewMailHeaders.js
index 0ee369b..c56f965 100644
--- a/js/ViewMailHeaders.js
+++ b/js/ViewMailHeaders.js
@@ -21,27 +21,43 @@ Ext.define('PMG.ViewMailHeaders', {
 
 	xclass: 'Ext.app.ViewController',
 
-	init: function(view) {
-	    var panel = view.lookupReference('contentPanel');
+	toggleRaw: function(btn) {
+	    let me = this;
+	    let view = me.getView();
+	    view.raw = !view.raw;
+	    me.loadData(view.url);
+	},
+
+	setData: function(data) {
+	    let view = this.getView();
+	    let panel = view.lookupReference('contentPanel');
+	    let from = data.match(/^FROM:\s*(.*\S)\s*$/mi);
+	    if (from) {
+		view.lookupReference('fromField').setValue(from[1]);
+	    }
+	    let to = data.match(/^TO:\s*(.*\S)\s*$/mi);
+	    if (to) {
+		view.lookupReference('toField').setValue(to[1]);
+	    }
+	    let subject = data.match(/^SUBJECT:\s*(.*\S)\s*$/mi);
+	    if (subject) {
+		view.lookupReference('subjectField').setValue(subject[1]);
+	    }
+	    panel.update(Ext.String.htmlEncode(data));
+	},
+
+	loadData: function(url) {
+	    let me = this;
+	    let view = me.getView();
+	    if (!view.raw) {
+		url += "?decode-header=1";
+	    }
 	    Proxmox.Utils.API2Request({
-		url: view.url,
+		url,
 		waitMsgTarget: view,
 		method: 'GET',
 		success: function(response, opts) {
-		    var data = response.result.data;
-		    var from = data.match(/^FROM:\s*(.*\S)\s*$/mi);
-		    if (from) {
-			view.lookupReference('fromField').setValue(from[1]);
-		    }
-		    var to = data.match(/^TO:\s*(.*\S)\s*$/mi);
-		    if (to) {
-			view.lookupReference('toField').setValue(to[1]);
-		    }
-		    var subject = data.match(/^SUBJECT:\s*(.*\S)\s*$/mi);
-		    if (subject) {
-			view.lookupReference('subjectField').setValue(subject[1]);
-		    }
-		    panel.update(Ext.String.htmlEncode(data));
+		    me.setData(response.result.data);
 		},
 		failure: function(response, opts) {
 		    view.destroy();
@@ -49,8 +65,25 @@ Ext.define('PMG.ViewMailHeaders', {
 		},
 	    });
 	},
+
+	init: function(view) {
+	    let me = this;
+	    me.loadData(view.url);
+	},
     },
 
+    buttons: [
+	{
+	    xtype: 'button',
+	    reference: 'raw',
+	    text: gettext('Toggle Raw'),
+	    enableToggle: true,
+	    iconCls: 'fa fa-file-code-o',
+	    handler: 'toggleRaw',
+	},
+	'->',
+    ],
+
     items: [
 	{
 	    xtype: 'textfield',
-- 
2.30.2





  reply	other threads:[~2022-02-03  8:29 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-03  8:29 [pmg-devel] [PATCH pmg-api] api/postfix: add 'decode-headers' to postfix queue read Dominik Csapak
2022-02-03  8:29 ` Dominik Csapak [this message]
2022-02-03 11:32   ` [pmg-devel] applied: [PATCH pmg-gui] postfix queues: show decoded headers by default Thomas Lamprecht
2022-02-03 11:33 ` [pmg-devel] applied: [PATCH pmg-api] api/postfix: add 'decode-headers' to postfix queue read 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=20220203082925.1780071-2-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