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