]>
Commit | Line | Data |
---|---|---|
0c77683d SI |
1 | Ext.define('pmg-tls-policy', { |
2 | extend: 'Ext.data.Model', | |
c87d46fb | 3 | fields: ['destination', 'policy'], |
06c37f16 | 4 | idProperty: 'destination', |
e762dd67 SI |
5 | proxy: { |
6 | type: 'proxmox', | |
c87d46fb | 7 | url: '/api2/json/config/tlspolicy', |
e762dd67 SI |
8 | }, |
9 | sorters: { | |
06c37f16 | 10 | property: 'destination', |
18722987 | 11 | direction: 'ASC', |
c87d46fb | 12 | }, |
e762dd67 SI |
13 | }); |
14 | ||
0f5a92f0 | 15 | Ext.define('PMG.TLSDestinationEdit', { |
e762dd67 | 16 | extend: 'Proxmox.window.Edit', |
0f5a92f0 | 17 | xtype: 'pmgTLSDestinationEdit', |
573a6e8b | 18 | onlineHelp: 'pmgconfig_mailproxy_tls', |
e762dd67 SI |
19 | |
20 | subject: gettext('TLS Policy'), | |
c87d46fb | 21 | initComponent: function() { |
e762dd67 SI |
22 | var me = this; |
23 | ||
c87d46fb | 24 | var isCreate = !Ext.isDefined(me.destination); |
e762dd67 | 25 | |
06c37f16 | 26 | var url = '/api2/extjs/config/tlspolicy' + (isCreate ? '' : '/' + me.destination); |
e762dd67 SI |
27 | var method = isCreate ? 'POST' : 'PUT'; |
28 | var text = isCreate ? 'Create' : 'Edit'; | |
29 | ||
30 | var items = [ | |
31 | { | |
32 | xtype: isCreate ? 'proxmoxtextfield' : 'displayfield', | |
06c37f16 | 33 | name: 'destination', |
c87d46fb | 34 | fieldLabel: gettext('Destination'), |
e762dd67 SI |
35 | }, |
36 | { | |
37 | xtype: 'proxmoxKVComboBox', | |
38 | name: 'policy', | |
39 | fieldLabel: gettext('Policy'), | |
40 | deleteEmpty: false, | |
41 | comboItems: [ | |
c87d46fb TL |
42 | ['none', 'none'], |
43 | ['may', 'may'], | |
44 | ['encrypt', 'encrypt'], | |
45 | ['dane', 'dane'], | |
46 | ['dane-only', 'dane-only'], | |
47 | ['fingerprint', 'fingerprint'], | |
48 | ['verify', 'verify'], | |
49 | ['secure', 'secure'], | |
e762dd67 SI |
50 | ], |
51 | allowBlank: true, | |
c87d46fb TL |
52 | value: 'encrypt', |
53 | }, | |
e762dd67 SI |
54 | ]; |
55 | ||
56 | Ext.apply(me, { | |
57 | url: url, | |
58 | method: method, | |
59 | items: items, | |
c87d46fb | 60 | text: text, |
e762dd67 SI |
61 | }); |
62 | ||
63 | me.callParent(); | |
c87d46fb | 64 | }, |
0c77683d SI |
65 | }); |
66 | ||
0f5a92f0 | 67 | Ext.define('PMG.MailProxyTLSDestinations', { |
0c77683d | 68 | extend: 'Ext.grid.GridPanel', |
0f5a92f0 | 69 | alias: ['widget.pmgMailProxyTLSDestinations'], |
0c77683d | 70 | |
e762dd67 | 71 | viewConfig: { |
c87d46fb | 72 | trackOver: false, |
e762dd67 SI |
73 | }, |
74 | columns: [ | |
75 | { | |
0f5a92f0 | 76 | header: gettext('Destination'), |
e762dd67 SI |
77 | width: 200, |
78 | sortable: true, | |
c87d46fb | 79 | dataIndex: 'destination', |
e762dd67 SI |
80 | }, |
81 | { | |
82 | header: gettext('Policy'), | |
83 | sortable: false, | |
84 | dataIndex: 'policy', | |
c87d46fb TL |
85 | flex: 1, |
86 | }, | |
e762dd67 SI |
87 | ], |
88 | ||
c87d46fb | 89 | initComponent: function() { |
5b13e123 | 90 | let me = this; |
0c77683d | 91 | |
5b13e123 | 92 | let rstore = Ext.create('Proxmox.data.UpdateStore', { |
0c77683d | 93 | model: 'pmg-tls-policy', |
c87d46fb | 94 | storeid: 'pmg-mailproxy-tls-store-' + ++Ext.idSeed, |
0c77683d SI |
95 | }); |
96 | ||
5b13e123 | 97 | let store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore }); |
0c77683d | 98 | |
5b13e123 | 99 | let reload = () => rstore.load(); |
0c77683d SI |
100 | |
101 | me.selModel = Ext.create('Ext.selection.RowModel', {}); | |
102 | ||
0c77683d SI |
103 | var run_editor = function() { |
104 | var rec = me.selModel.getSelection()[0]; | |
105 | if (!rec) { | |
106 | return; | |
107 | } | |
108 | ||
0f5a92f0 | 109 | var win = Ext.createWidget('pmgTLSDestinationEdit', { |
c87d46fb | 110 | destination: rec.data.destination, |
e762dd67 | 111 | }); |
0c77683d SI |
112 | |
113 | win.load(); | |
114 | win.on('destroy', reload); | |
115 | win.show(); | |
116 | }; | |
117 | ||
5b13e123 TL |
118 | let tbar = [ |
119 | { | |
120 | text: gettext('Create'), | |
121 | handler: () => Ext.createWidget('pmgTLSDestinationEdit', { | |
122 | autoLoad: true, | |
123 | autoShow: true, | |
124 | listeners: { | |
125 | destroy: () => reload(), | |
126 | }, | |
127 | }), | |
128 | }, | |
129 | '-', | |
130 | { | |
0c77683d | 131 | xtype: 'proxmoxButton', |
0c77683d | 132 | disabled: true, |
e762dd67 | 133 | text: gettext('Edit'), |
c87d46fb | 134 | handler: run_editor, |
0c77683d | 135 | }, |
e762dd67 SI |
136 | { |
137 | xtype: 'proxmoxStdRemoveButton', | |
138 | baseurl: '/config/tlspolicy', | |
139 | callback: reload, | |
c87d46fb TL |
140 | waitMsgTarget: me, |
141 | }, | |
0c77683d SI |
142 | ]; |
143 | ||
144 | Proxmox.Utils.monStoreErrors(me, store, true); | |
145 | ||
146 | Ext.apply(me, { | |
147 | store: store, | |
148 | tbar: tbar, | |
149 | run_editor: run_editor, | |
0c77683d SI |
150 | listeners: { |
151 | itemdblclick: run_editor, | |
c87d46fb TL |
152 | activate: reload, |
153 | }, | |
0c77683d SI |
154 | }); |
155 | ||
156 | me.on('activate', rstore.startUpdate); | |
157 | me.on('destroy', rstore.stopUpdate); | |
158 | me.on('deactivate', rstore.stopUpdate); | |
159 | me.callParent(); | |
c87d46fb | 160 | }, |
0c77683d | 161 | }); |