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