]> git.proxmox.com Git - pmg-gui.git/blob - js/MailProxyTLSDestinations.js
dkim settings: improve label for signing domain source selection
[pmg-gui.git] / js / MailProxyTLSDestinations.js
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 direction: 'ASC',
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 let me = this;
91
92 let rstore = Ext.create('Proxmox.data.UpdateStore', {
93 model: 'pmg-tls-policy',
94 storeid: 'pmg-mailproxy-tls-store-' + ++Ext.idSeed,
95 });
96
97 let store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore });
98
99 let reload = () => rstore.load();
100
101 me.selModel = Ext.create('Ext.selection.RowModel', {});
102
103 var run_editor = function() {
104 var rec = me.selModel.getSelection()[0];
105 if (!rec) {
106 return;
107 }
108
109 var win = Ext.createWidget('pmgTLSDestinationEdit', {
110 destination: rec.data.destination,
111 });
112
113 win.load();
114 win.on('destroy', reload);
115 win.show();
116 };
117
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 {
131 xtype: 'proxmoxButton',
132 disabled: true,
133 text: gettext('Edit'),
134 handler: run_editor,
135 },
136 {
137 xtype: 'proxmoxStdRemoveButton',
138 baseurl: '/config/tlspolicy',
139 callback: reload,
140 waitMsgTarget: me,
141 },
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,
150 listeners: {
151 itemdblclick: run_editor,
152 activate: reload,
153 },
154 });
155
156 me.on('activate', rstore.startUpdate);
157 me.on('destroy', rstore.stopUpdate);
158 me.on('deactivate', rstore.stopUpdate);
159 me.callParent();
160 },
161 });