]> git.proxmox.com Git - pmg-gui.git/blame - js/MailProxyTLSDestinations.js
mobile: set button color in mail view similar to quarantine list
[pmg-gui.git] / js / MailProxyTLSDestinations.js
CommitLineData
0c77683d
SI
1Ext.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 15Ext.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 67Ext.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() {
0c77683d
SI
90 var me = this;
91
0c77683d
SI
92 var rstore = Ext.create('Proxmox.data.UpdateStore', {
93 model: 'pmg-tls-policy',
c87d46fb 94 storeid: 'pmg-mailproxy-tls-store-' + ++Ext.idSeed,
0c77683d
SI
95 });
96
c87d46fb 97 var store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore });
0c77683d
SI
98
99 var reload = function() {
3155688b 100 rstore.load();
0c77683d
SI
101 };
102
103 me.selModel = Ext.create('Ext.selection.RowModel', {});
104
0c77683d
SI
105 var run_editor = function() {
106 var rec = me.selModel.getSelection()[0];
107 if (!rec) {
108 return;
109 }
110
0f5a92f0 111 var win = Ext.createWidget('pmgTLSDestinationEdit', {
c87d46fb 112 destination: rec.data.destination,
e762dd67 113 });
0c77683d
SI
114
115 win.load();
116 win.on('destroy', reload);
117 win.show();
118 };
119
120 var tbar = [
121 {
122 xtype: 'proxmoxButton',
0c77683d 123 disabled: true,
e762dd67 124 text: gettext('Edit'),
c87d46fb 125 handler: run_editor,
0c77683d
SI
126 },
127 {
128 text: gettext('Create'),
129 handler: function() {
0f5a92f0 130 var win = Ext.createWidget('pmgTLSDestinationEdit');
0c77683d 131
e762dd67 132 win.load();
0c77683d
SI
133 win.on('destroy', reload);
134 win.show();
c87d46fb 135 },
0c77683d 136 },
e762dd67
SI
137 {
138 xtype: 'proxmoxStdRemoveButton',
139 baseurl: '/config/tlspolicy',
140 callback: reload,
c87d46fb
TL
141 waitMsgTarget: me,
142 },
0c77683d
SI
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,
0c77683d
SI
151 listeners: {
152 itemdblclick: run_editor,
c87d46fb
TL
153 activate: reload,
154 },
0c77683d
SI
155 });
156
157 me.on('activate', rstore.startUpdate);
158 me.on('destroy', rstore.stopUpdate);
159 me.on('deactivate', rstore.stopUpdate);
160 me.callParent();
c87d46fb 161 },
0c77683d 162});