pmg-gui/js/MailProxyTLSDestinations.js
Stoiko Ivanov 0f5a92f010 rename TLSDomain to TLSDestination
with the changes for fixing #1948 it is now possible to define tls policies
for destinations (remote domains or next-hop transports) instead of only for
Domains.
This patch reflects this addition by renaming all occurences of Domain with
Destination.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
Reviewed-By: Dominik Csapak <d.csapak@proxmox.com>
2020-03-24 18:10:51 +01:00

164 lines
3.3 KiB
JavaScript

/*global Proxmox*/
Ext.define('pmg-tls-policy', {
extend: 'Ext.data.Model',
fields: [ 'destination', 'policy' ],
idProperty: 'destination',
proxy: {
type: 'proxmox',
url: '/api2/json/config/tlspolicy'
},
sorters: {
property: 'destination',
order: 'DESC'
}
});
Ext.define('PMG.TLSDestinationEdit', {
extend: 'Proxmox.window.Edit',
xtype: 'pmgTLSDestinationEdit',
onlineHelp: 'pmgconfig_mailproxy_tls',
subject: gettext('TLS Policy'),
initComponent : function() {
var me = this;
var isCreate = ! Ext.isDefined(me.destination);
var url = '/api2/extjs/config/tlspolicy' + (isCreate ? '' : '/' + me.destination);
var method = isCreate ? 'POST' : 'PUT';
var text = isCreate ? 'Create' : 'Edit';
var items = [
{
xtype: isCreate ? 'proxmoxtextfield' : 'displayfield',
name: 'destination',
fieldLabel: gettext('Destination')
},
{
xtype: 'proxmoxKVComboBox',
name: 'policy',
fieldLabel: gettext('Policy'),
deleteEmpty: false,
comboItems: [
[ 'none', 'none' ],
[ 'may', 'may' ],
[ 'encrypt', 'encrypt' ],
[ 'dane', 'dane' ],
[ 'dane-only', 'dane-only' ],
[ 'fingerprint', 'fingerprint' ],
[ 'verify', 'verify' ],
[ 'secure', 'secure' ]
],
allowBlank: true,
value: 'encrypt'
}
];
Ext.apply(me, {
url: url,
method: method,
items: items,
text: text
});
me.callParent();
}
});
Ext.define('PMG.MailProxyTLSDestinations', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.pmgMailProxyTLSDestinations'],
viewConfig: {
trackOver: false
},
columns: [
{
header: gettext('Destination'),
width: 200,
sortable: true,
dataIndex: 'destination'
},
{
header: gettext('Policy'),
sortable: false,
dataIndex: 'policy',
flex: 1
}
],
initComponent : function() {
var me = this;
var rstore = Ext.create('Proxmox.data.UpdateStore', {
model: 'pmg-tls-policy',
storeid: 'pmg-mailproxy-tls-store-' + (++Ext.idSeed)
});
var store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore});
var reload = function() {
rstore.load();
};
me.selModel = Ext.create('Ext.selection.RowModel', {});
var run_editor = function() {
var rec = me.selModel.getSelection()[0];
if (!rec) {
return;
}
var win = Ext.createWidget('pmgTLSDestinationEdit', {
destination: rec.data.destination
});
win.load();
win.on('destroy', reload);
win.show();
};
var tbar = [
{
xtype: 'proxmoxButton',
disabled: true,
text: gettext('Edit'),
handler: run_editor
},
{
text: gettext('Create'),
handler: function() {
var win = Ext.createWidget('pmgTLSDestinationEdit');
win.load();
win.on('destroy', reload);
win.show();
}
},
{
xtype: 'proxmoxStdRemoveButton',
baseurl: '/config/tlspolicy',
callback: reload,
waitMsgTarget: me
}
];
Proxmox.Utils.monStoreErrors(me, store, true);
Ext.apply(me, {
store: store,
tbar: tbar,
run_editor: run_editor,
listeners: {
itemdblclick: run_editor,
activate: reload
}
});
me.on('activate', rstore.startUpdate);
me.on('destroy', rstore.stopUpdate);
me.on('deactivate', rstore.stopUpdate);
me.callParent();
}
});