]> git.proxmox.com Git - pmg-gui.git/blob - js/ViewMailHeaders.js
jslint: rework MailProcessing names to avoid reserved names
[pmg-gui.git] / js / ViewMailHeaders.js
1 /*global Proxmox*/
2 Ext.define('PMG.ViewMailHeaders', {
3 extend: 'Ext.window.Window',
4 alias: 'widget.pmgViewMailHeaders',
5
6 url: undefined,
7
8 width: 600,
9
10 height: 400,
11
12 bodyPadding: 10,
13
14 modal: true,
15
16 layout: {
17 type: 'vbox',
18 align: 'stretch'
19 },
20
21 controller: {
22
23 xclass: 'Ext.app.ViewController',
24
25 init: function(view) {
26
27 var panel = view.lookupReference('contentPanel');
28 var fromField =
29 Proxmox.Utils.API2Request({
30 url: view.url,
31 waitMsgTarget: view,
32 method: 'GET',
33 waitMsgTarget: view,
34 success: function(response, opts) {
35 var data = response.result.data;
36 var from = data.match(/^FROM:\s*(.*\S)\s*$/mi);
37 if (from) {
38 view.lookupReference('fromField').setValue(from[1]);
39 }
40 var to = data.match(/^TO:\s*(.*\S)\s*$/mi);
41 if (to) {
42 view.lookupReference('toField').setValue(to[1]);
43 }
44 var subject = data.match(/^SUBJECT:\s*(.*\S)\s*$/mi);
45 if (subject) {
46 view.lookupReference('subjectField').setValue(subject[1]);
47 }
48 panel.update(Ext.String.htmlEncode(data));
49 },
50 failure: function (response, opts) {
51 view.destroy();
52 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
53 }
54 });
55
56 }
57 },
58
59 items: [
60 {
61 xtype: 'textfield',
62 fieldLabel: gettext('From'),
63 reference: 'fromField',
64 focusable: false,
65 exitable: false
66 },
67 {
68 xtype: 'textfield',
69 fieldLabel: gettext('To'),
70 reference: 'toField',
71 focusable: false,
72 exitable: false
73 },
74 {
75 xtype: 'textfield',
76 fieldLabel: gettext('Subject'),
77 reference: 'subjectField',
78 focusable: false,
79 exitable: false
80 },
81 {
82 xtype: 'displayfield',
83 fieldLabel: gettext('Header')
84 },
85 {
86 xtype: 'panel',
87 bodyPadding: 5,
88 reference: 'contentPanel',
89 flex: 1,
90 autoScroll: true,
91 bodyStyle: 'white-space:pre'
92 }
93 ]
94 });