[pmg-devel] [PATCH pmg-gui] postfix queues: show decoded headers by default
Dominik Csapak
d.csapak at proxmox.com
Thu Feb 3 09:29:24 CET 2022
and add a toggle button to show the raw headers
Signed-off-by: Dominik Csapak <d.csapak at 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
More information about the pmg-devel
mailing list