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