]>
Commit | Line | Data |
---|---|---|
cd3d4213 DM |
1 | Ext.define('PMG.ViewMailHeaders', { |
2 | extend: 'Ext.window.Window', | |
3 | alias: 'widget.pmgViewMailHeaders', | |
4 | ||
5 | url: undefined, | |
6 | ||
7 | width: 600, | |
8 | ||
9 | height: 400, | |
10 | ||
11 | bodyPadding: 10, | |
12 | ||
13 | modal: true, | |
14 | ||
15 | layout: { | |
16 | type: 'vbox', | |
c87d46fb | 17 | align: 'stretch', |
cd3d4213 DM |
18 | }, |
19 | ||
20 | controller: { | |
cd3d4213 DM |
21 | xclass: 'Ext.app.ViewController', |
22 | ||
86a53192 | 23 | toggleRaw: function(field, newValue) { |
9f5e96df DC |
24 | let me = this; |
25 | let view = me.getView(); | |
86a53192 | 26 | view.raw = !newValue; |
9f5e96df DC |
27 | me.loadData(view.url); |
28 | }, | |
29 | ||
30 | setData: function(data) { | |
31 | let view = this.getView(); | |
32 | let panel = view.lookupReference('contentPanel'); | |
33 | let from = data.match(/^FROM:\s*(.*\S)\s*$/mi); | |
34 | if (from) { | |
35 | view.lookupReference('fromField').setValue(from[1]); | |
36 | } | |
37 | let to = data.match(/^TO:\s*(.*\S)\s*$/mi); | |
38 | if (to) { | |
39 | view.lookupReference('toField').setValue(to[1]); | |
40 | } | |
41 | let subject = data.match(/^SUBJECT:\s*(.*\S)\s*$/mi); | |
42 | if (subject) { | |
43 | view.lookupReference('subjectField').setValue(subject[1]); | |
44 | } | |
45 | panel.update(Ext.String.htmlEncode(data)); | |
46 | }, | |
47 | ||
48 | loadData: function(url) { | |
49 | let me = this; | |
50 | let view = me.getView(); | |
51 | if (!view.raw) { | |
52 | url += "?decode-header=1"; | |
53 | } | |
cd3d4213 | 54 | Proxmox.Utils.API2Request({ |
9f5e96df | 55 | url, |
cd3d4213 DM |
56 | waitMsgTarget: view, |
57 | method: 'GET', | |
12359425 | 58 | success: response => me.setData(response.result.data), |
c87d46fb | 59 | failure: function(response, opts) { |
cd3d4213 DM |
60 | view.destroy(); |
61 | Ext.Msg.alert(gettext('Error'), response.htmlStatus); | |
c87d46fb | 62 | }, |
cd3d4213 | 63 | }); |
c87d46fb | 64 | }, |
9f5e96df DC |
65 | |
66 | init: function(view) { | |
67 | let me = this; | |
68 | me.loadData(view.url); | |
69 | }, | |
cd3d4213 DM |
70 | }, |
71 | ||
72 | items: [ | |
73 | { | |
74 | xtype: 'textfield', | |
75 | fieldLabel: gettext('From'), | |
76 | reference: 'fromField', | |
77 | focusable: false, | |
c87d46fb | 78 | exitable: false, |
cd3d4213 DM |
79 | }, |
80 | { | |
81 | xtype: 'textfield', | |
82 | fieldLabel: gettext('To'), | |
83 | reference: 'toField', | |
84 | focusable: false, | |
c87d46fb | 85 | exitable: false, |
cd3d4213 DM |
86 | }, |
87 | { | |
88 | xtype: 'textfield', | |
89 | fieldLabel: gettext('Subject'), | |
90 | reference: 'subjectField', | |
91 | focusable: false, | |
c87d46fb | 92 | exitable: false, |
cd3d4213 DM |
93 | }, |
94 | { | |
86a53192 TL |
95 | xtype: 'container', |
96 | layout: 'hbox', | |
97 | items: [ | |
98 | { | |
99 | xtype: 'displayfield', | |
100 | fieldLabel: gettext('Header'), | |
101 | flex: 1, | |
102 | }, | |
103 | { | |
104 | xtype: 'checkbox', | |
105 | reference: 'raw', | |
106 | boxLabel: gettext('Decode'), | |
107 | value: true, | |
108 | iconCls: 'fa fa-file-code-o', | |
109 | handler: 'toggleRaw', | |
110 | }, | |
111 | ], | |
cd3d4213 DM |
112 | }, |
113 | { | |
114 | xtype: 'panel', | |
115 | bodyPadding: 5, | |
116 | reference: 'contentPanel', | |
117 | flex: 1, | |
118 | autoScroll: true, | |
c87d46fb TL |
119 | bodyStyle: 'white-space:pre', |
120 | }, | |
121 | ], | |
cd3d4213 | 122 | }); |