]> git.proxmox.com Git - pmg-gui.git/blob - js/ViewMailHeaders.js
tree wide: eslint --fix
[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 var panel = view.lookupReference('contentPanel');
27 var fromField =
28 Proxmox.Utils.API2Request({
29 url: view.url,
30 waitMsgTarget: view,
31 method: 'GET',
32 success: function(response, opts) {
33 var data = response.result.data;
34 var from = data.match(/^FROM:\s*(.*\S)\s*$/mi);
35 if (from) {
36 view.lookupReference('fromField').setValue(from[1]);
37 }
38 var to = data.match(/^TO:\s*(.*\S)\s*$/mi);
39 if (to) {
40 view.lookupReference('toField').setValue(to[1]);
41 }
42 var subject = data.match(/^SUBJECT:\s*(.*\S)\s*$/mi);
43 if (subject) {
44 view.lookupReference('subjectField').setValue(subject[1]);
45 }
46 panel.update(Ext.String.htmlEncode(data));
47 },
48 failure: function(response, opts) {
49 view.destroy();
50 Ext.Msg.alert(gettext('Error'), response.htmlStatus);
51 },
52 });
53 },
54 },
55
56 items: [
57 {
58 xtype: 'textfield',
59 fieldLabel: gettext('From'),
60 reference: 'fromField',
61 focusable: false,
62 exitable: false,
63 },
64 {
65 xtype: 'textfield',
66 fieldLabel: gettext('To'),
67 reference: 'toField',
68 focusable: false,
69 exitable: false,
70 },
71 {
72 xtype: 'textfield',
73 fieldLabel: gettext('Subject'),
74 reference: 'subjectField',
75 focusable: false,
76 exitable: false,
77 },
78 {
79 xtype: 'displayfield',
80 fieldLabel: gettext('Header'),
81 },
82 {
83 xtype: 'panel',
84 bodyPadding: 5,
85 reference: 'contentPanel',
86 flex: 1,
87 autoScroll: true,
88 bodyStyle: 'white-space:pre',
89 },
90 ],
91 });