]> git.proxmox.com Git - pmg-gui.git/blob - js/MailProxyRelaying.js
fix #1701: add port option for smarthost
[pmg-gui.git] / js / MailProxyRelaying.js
1 /*global Proxmox*/
2 Ext.define('PMG.MailProxyRelaying', {
3 extend: 'Proxmox.grid.ObjectGrid',
4 alias: ['widget.pmgMailProxyRelaying'],
5
6 monStoreErrors: true,
7
8 initComponent : function() {
9 var me = this;
10
11 me.add_text_row('relay', gettext('Default Relay'),
12 { deleteEmpty: true, defaultValue: Proxmox.Utils.noneText });
13
14 me.add_integer_row('relayport', gettext('SMTP Port'),
15 { defaultValue: 25, deleteEmpty: true,
16 minValue: 1, maxValue: 65535 });
17
18 me.add_boolean_row('relaynomx', gettext('Disable MX lookup'));
19
20 me.rows.smarthost = {
21 required: true,
22 multiKey: ['smarthost', 'smarthostport'],
23 header: gettext('Smarthost'),
24 renderer: function() {
25 var host = me.getObjectValue('smarthost', undefined);
26 var port = me.getObjectValue('smarthostport', undefined);
27 var result = '';
28 if (host) {
29 if (port) {
30 if (host.match(Proxmox.Utils.IP6_match)) {
31 result = "[" + host + "]:" + port;
32 } else {
33 result = host + ':' + port;
34 }
35 } else {
36 result = host;
37 }
38 }
39 if (result === '') {
40 result = Proxmox.Utils.noneText;
41 }
42 return result;
43 },
44 editor: {
45 xtype: 'proxmoxWindowEdit',
46 subject: gettext('Smarthost'),
47 fieldDefaults: {
48 labelWidth: 100
49 },
50 items: [
51 {
52 xtype: 'proxmoxtextfield',
53 name: 'smarthost',
54 deleteEmpty: true,
55 emptyText: Proxmox.Utils.noneText,
56 fieldLabel: gettext('Smarthost')
57 },
58 {
59 xtype: 'proxmoxintegerfield',
60 name: 'smarthostport',
61 deleteEmpty: true,
62 minValue: 1,
63 maxValue: 65535,
64 emptyText: Proxmox.Utils.defaultText,
65 fieldLabel: gettext('Port')
66 }
67 ]
68 }
69 };
70
71 me.rows.smarthostport = { visible: false };
72
73 var baseurl = '/config/mail';
74
75 me.selModel = Ext.create('Ext.selection.RowModel', {});
76
77 Ext.apply(me, {
78 tbar: [{
79 text: gettext('Edit'),
80 xtype: 'proxmoxButton',
81 disabled: true,
82 handler: function() { me.run_editor(); },
83 selModel: me.selModel
84 }],
85 url: '/api2/json' + baseurl,
86 editorConfig: {
87 url: '/api2/extjs' + baseurl
88 },
89 interval: 5000,
90 cwidth1: 200,
91 listeners: {
92 itemdblclick: me.run_editor
93 }
94 });
95
96 me.callParent();
97
98 me.on('activate', me.rstore.startUpdate);
99 me.on('destroy', me.rstore.stopUpdate);
100 me.on('deactivate', me.rstore.stopUpdate);
101 }
102 });