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