]>
Commit | Line | Data |
---|---|---|
ff735274 | 1 | /*global Proxmox*/ |
c51d3f79 DM |
2 | Ext.define('pmg-transport', { |
3 | extend: 'Ext.data.Model', | |
d895a746 | 4 | fields: [ 'domain', 'host', 'protocol', { name: 'port', type: 'integer' }, |
c51d3f79 DM |
5 | { name: 'use_mx', type: 'boolean' }, 'comment' ], |
6 | proxy: { | |
7 | type: 'proxmox', | |
8 | url: "/api2/json/config/transport" | |
9 | }, | |
10 | idProperty: 'domain' | |
11 | }); | |
12 | ||
13 | Ext.define('PMG.Transport', { | |
14 | extend: 'Ext.grid.GridPanel', | |
15 | alias: ['widget.pmgTransport'], | |
16 | ||
17 | initComponent : function() { | |
c502e50c | 18 | let me = this; |
c51d3f79 | 19 | |
c502e50c | 20 | let store = new Ext.data.Store({ |
c51d3f79 DM |
21 | model: 'pmg-transport', |
22 | sorters: { | |
23 | property: 'domain', | |
24 | order: 'DESC' | |
25 | } | |
26 | }); | |
c502e50c TL |
27 | Proxmox.Utils.monStoreErrors(me, store, true); |
28 | let reload = () => store.load(); | |
c51d3f79 DM |
29 | |
30 | me.selModel = Ext.create('Ext.selection.RowModel', {}); | |
31 | ||
b357057e | 32 | var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', { |
c51d3f79 | 33 | selModel: me.selModel, |
b357057e DM |
34 | baseurl: '/config/transport', |
35 | callback: reload, | |
36 | waitMsgTarget: me | |
c51d3f79 DM |
37 | }); |
38 | ||
39 | var common_properties = [ | |
40 | { | |
41 | xtype: 'textfield', | |
42 | name: 'host', | |
43 | fieldLabel: gettext("Host") | |
44 | }, | |
d895a746 JZ |
45 | { |
46 | xtype: 'proxmoxKVComboBox', | |
47 | name: 'protocol', | |
48 | fieldLabel: gettext('Protocol'), | |
49 | deleteEmpty: false, | |
50 | comboItems: [ | |
51 | [ 'smtp', 'SMTP' ], | |
52 | [ 'lmtp', 'LMTP' ] | |
53 | ], | |
54 | allowBlank: true, | |
55 | value: 'smtp' | |
56 | }, | |
c51d3f79 DM |
57 | { |
58 | xtype: 'proxmoxintegerfield', | |
59 | name: 'port', | |
60 | value: 25, | |
61 | minValue: 1, | |
62 | maxValue: 65535, | |
63 | fieldLabel: gettext("Port") | |
64 | }, | |
65 | { | |
66 | xtype: 'proxmoxcheckbox', | |
67 | name: 'use_mx', | |
68 | checked: true, | |
69 | uncheckedValue: 0, | |
d895a746 | 70 | fieldLabel: gettext("Use MX (SMTP)") |
c51d3f79 DM |
71 | }, |
72 | { | |
73 | xtype: 'textfield', | |
74 | name: 'comment', | |
75 | fieldLabel: gettext("Comment") | |
76 | } | |
77 | ]; | |
78 | ||
79 | var edit_properties = common_properties.slice(); | |
80 | edit_properties.unshift({ | |
81 | xtype: 'displayfield', | |
82 | name: 'domain', | |
83 | fieldLabel: gettext("Relay Domain") | |
84 | }); | |
85 | ||
86 | var create_properties = common_properties.slice(); | |
87 | create_properties.unshift({ | |
88 | xtype: 'proxmoxtextfield', | |
89 | name: 'domain', | |
90 | fieldLabel: gettext("Relay Domain") | |
91 | }); | |
92 | ||
c502e50c TL |
93 | let run_editor = function() { |
94 | let rec = me.selModel.getSelection()[0]; | |
c51d3f79 DM |
95 | if (!rec) { |
96 | return; | |
97 | } | |
98 | ||
99 | var config = { | |
100 | url: "/api2/extjs/config/transport/" + rec.data.domain, | |
573a6e8b | 101 | onlineHelp: 'pmgconfig_mailproxy_transports', |
c51d3f79 DM |
102 | method: 'PUT', |
103 | subject: gettext("Transport"), | |
104 | items: edit_properties | |
105 | }; | |
106 | ||
107 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
108 | ||
109 | win.load(); | |
110 | win.on('destroy', reload); | |
111 | win.show(); | |
112 | }; | |
113 | ||
114 | var tbar = [ | |
115 | { | |
116 | xtype: 'proxmoxButton', | |
117 | text: gettext('Edit'), | |
118 | disabled: true, | |
119 | selModel: me.selModel, | |
120 | handler: run_editor | |
121 | }, | |
122 | { | |
123 | text: gettext('Create'), | |
124 | handler: function() { | |
125 | var config = { | |
126 | method: 'POST', | |
127 | url: "/api2/extjs/config/transport", | |
573a6e8b | 128 | onlineHelp: 'pmgconfig_mailproxy_transports', |
18b5b6ad | 129 | isCreate: true, |
c51d3f79 DM |
130 | subject: gettext("Transport"), |
131 | items: create_properties | |
132 | }; | |
133 | ||
134 | var win = Ext.createWidget('proxmoxWindowEdit', config); | |
135 | ||
136 | win.on('destroy', reload); | |
137 | win.show(); | |
138 | } | |
139 | }, | |
140 | remove_btn | |
141 | ]; | |
142 | ||
2f8fe1a3 | 143 | Proxmox.Utils.monStoreErrors(me, store, true); |
c51d3f79 DM |
144 | |
145 | Ext.apply(me, { | |
146 | store: store, | |
147 | tbar: tbar, | |
148 | viewConfig: { | |
149 | trackOver: false | |
150 | }, | |
151 | columns: [ | |
152 | { | |
153 | header: gettext('Relay Domain'), | |
154 | width: 200, | |
c51d3f79 DM |
155 | dataIndex: 'domain' |
156 | }, | |
157 | { | |
158 | header: gettext('Host'), | |
159 | width: 200, | |
c51d3f79 DM |
160 | dataIndex: 'host' |
161 | }, | |
d895a746 JZ |
162 | { |
163 | header: gettext('Protocol'), | |
164 | width: 200, | |
d895a746 JZ |
165 | dataIndex: 'protocol' |
166 | }, | |
c51d3f79 DM |
167 | { |
168 | header: gettext('Port'), | |
169 | width: 80, | |
c51d3f79 DM |
170 | dataIndex: 'port' |
171 | }, | |
172 | { | |
d895a746 | 173 | header: gettext('Use MX (SMTP)'), |
c51d3f79 DM |
174 | width: 80, |
175 | renderer: Proxmox.Utils.format_boolean, | |
c51d3f79 DM |
176 | dataIndex: 'use_mx' |
177 | }, | |
178 | { | |
179 | header: gettext('Comment'), | |
c51d3f79 DM |
180 | renderer: Ext.String.htmlEncode, |
181 | dataIndex: 'comment', | |
182 | flex: 1 | |
183 | } | |
184 | ], | |
185 | listeners: { | |
186 | itemdblclick: run_editor, | |
187 | activate: reload | |
188 | } | |
189 | }); | |
190 | ||
191 | me.callParent(); | |
192 | } | |
193 | }); |