[pmg-devel] [PATCH pmg-gui] Implement TLS Policy Setting
Stoiko Ivanov
s.ivanov at proxmox.com
Wed Sep 26 14:58:34 CEST 2018
* add js/MailProxyTLSDomains.js for setting per domain TLS policies
* add js/MailProxyTLSPanel.js as a wrapper for the current MailProxyTLS.js and
MailProxyTLSDomains.js
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
The MailProxyTLSPanel.js takes inspiration from PVE's HA-Status,
the relayEvents is taken from js/ClamAVDatabase.js
It would probably make sense to rename js/MailProxyTLS.js to
js/MailProxyTLSOptions.js and js/MailProxyTLSPanel.js to js/MailProxyTLS.js for
consistency with the other components, but the patch would obfuscate the actual
changes (glad to send a follow-up if we agree on the rename).
js/MailProxyConfiguration.js | 2 +-
js/MailProxyTLSDomains.js | 158 +++++++++++++++++++++++++++++++++++++++++++
js/MailProxyTLSPanel.js | 36 ++++++++++
js/Makefile | 2 +
4 files changed, 197 insertions(+), 1 deletion(-)
create mode 100644 js/MailProxyTLSDomains.js
create mode 100644 js/MailProxyTLSPanel.js
diff --git a/js/MailProxyConfiguration.js b/js/MailProxyConfiguration.js
index 1b2f2fd..6902cb4 100644
--- a/js/MailProxyConfiguration.js
+++ b/js/MailProxyConfiguration.js
@@ -42,7 +42,7 @@ Ext.define('PMG.MailProxyConfiguration', {
{
itemId: 'tls',
title: gettext('TLS'),
- xtype: 'pmgMailProxyTLS'
+ xtype: 'pmgMailProxyTLSPanel'
},
{
itemId: 'whitelist',
diff --git a/js/MailProxyTLSDomains.js b/js/MailProxyTLSDomains.js
new file mode 100644
index 0000000..419573c
--- /dev/null
+++ b/js/MailProxyTLSDomains.js
@@ -0,0 +1,158 @@
+/*global Proxmox*/
+Ext.define('pmg-tls-policy', {
+ extend: 'Ext.data.Model',
+ fields: [ 'domain', 'policy' ],
+ idProperty: 'domain'
+});
+
+Ext.define('PMG.MailProxyTLSDomains', {
+ extend: 'Ext.grid.GridPanel',
+ alias: ['widget.pmgMailProxyTLSDomains'],
+
+ initComponent : function() {
+ var me = this;
+
+ var baseurl = '/config/tlspolicy';
+ var rstore = Ext.create('Proxmox.data.UpdateStore', {
+ model: 'pmg-tls-policy',
+ storeid: 'pmg-mailproxy-tls-store-' + (++Ext.idSeed),
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json' + baseurl
+ },
+ sorters: {
+ property: 'domain',
+ order: 'DESC'
+ }
+ });
+
+ var store = Ext.create('Proxmox.data.DiffStore', { rstore: rstore});
+
+ var reload = function() {
+ store.load();
+ };
+
+ me.selModel = Ext.create('Ext.selection.RowModel', {});
+
+ var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', {
+ selModel: me.selModel,
+ baseurl: baseurl,
+ callback: reload,
+ waitMsgTarget: me
+ });
+
+ var policy_selector_properties = {
+ xtype: 'proxmoxKVComboBox',
+ name: 'policy',
+ fieldLabel: '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'
+ };
+
+ var run_editor = function() {
+ var rec = me.selModel.getSelection()[0];
+ if (!rec) {
+ return;
+ }
+
+ var config = {
+ url: '/api2/extjs' + baseurl + '/' + rec.data.domain,
+ method: 'PUT',
+ subject: gettext('TLS Policy'),
+ items: [
+ {
+ xtype: 'displayfield',
+ name: 'domain',
+ fieldLabel: gettext('Domain')
+ },
+ policy_selector_properties
+ ]
+ };
+
+ var win = Ext.createWidget('proxmoxWindowEdit', config);
+
+ win.load();
+ win.on('destroy', reload);
+ win.show();
+ };
+
+ var tbar = [
+ {
+ xtype: 'proxmoxButton',
+ text: gettext('Edit'),
+ disabled: true,
+ selModel: me.selModel,
+ handler: run_editor
+ },
+ {
+ text: gettext('Create'),
+ handler: function() {
+ var config = {
+ url: '/api2/extjs' + baseurl,
+ method: 'POST',
+ subject: gettext('TLS Policy'),
+ isCreate: true,
+ items: [
+ {
+ xtype: 'proxmoxtextfield',
+ name: 'domain',
+ fieldLabel: gettext('Domain')
+ }, policy_selector_properties
+ ]
+ };
+
+ var win = Ext.createWidget('proxmoxWindowEdit', config);
+
+ win.on('destroy', reload);
+ win.show();
+ }
+ },
+ remove_btn
+ ];
+
+ Proxmox.Utils.monStoreErrors(me, store, true);
+
+ Ext.apply(me, {
+ store: store,
+ tbar: tbar,
+ run_editor: run_editor,
+ viewConfig: {
+ trackOver: false
+ },
+ columns: [
+ {
+ header: gettext('Domain'),
+ width: 200,
+ sortable: true,
+ dataIndex: 'domain'
+ },
+ {
+ header: gettext('Policy'),
+ sortable: false,
+ dataIndex: 'policy',
+ flex: 1
+ }
+ ],
+ listeners: {
+ itemdblclick: run_editor,
+ activate: reload
+ }
+ });
+
+ me.on('activate', rstore.startUpdate);
+ me.on('destroy', rstore.stopUpdate);
+ me.on('deactivate', rstore.stopUpdate);
+ me.callParent();
+ }
+});
diff --git a/js/MailProxyTLSPanel.js b/js/MailProxyTLSPanel.js
new file mode 100644
index 0000000..a7abc78
--- /dev/null
+++ b/js/MailProxyTLSPanel.js
@@ -0,0 +1,36 @@
+Ext.define('PMG.MailProxyTLSPanel', {
+ extend: 'Ext.panel.Panel',
+ alias: 'widget.pmgMailProxyTLSPanel',
+
+ layout: {
+ type: 'vbox',
+ align: 'stretch'
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ var tlsSettings = Ext.create('PMG.MailProxyTLS', {
+ xtype: 'pmgMailProxyTLS',
+ title: gettext('Settings'),
+ border: 0,
+ collapsible: true,
+ padding: '0 0 20 0'
+ });
+
+ var tlsDomains = Ext.create('PMG.MailProxyTLSDomains', {
+ xtype: 'pmgMailProxyTLSDomains',
+ title: gettext('TLS Domain Policy'),
+ border: 0,
+ collapsible: true,
+ padding: '0 0 20 0'
+ });
+
+ me.items = [ tlsSettings, tlsDomains ];
+
+ me.callParent();
+
+ tlsSettings.relayEvents(me, ['activate', 'deactivate', 'destroy']);
+ tlsDomains.relayEvents(me, ['activate', 'deactivate', 'destroy']);
+ }
+});
diff --git a/js/Makefile b/js/Makefile
index 069fc7b..882cbc4 100644
--- a/js/Makefile
+++ b/js/Makefile
@@ -41,6 +41,8 @@ JSSRC= \
MailProxyPorts.js \
MailProxyOptions.js \
MailProxyTLS.js \
+ MailProxyTLSPanel.js \
+ MailProxyTLSDomains.js \
Transport.js \
MyNetworks.js \
RelayDomains.js \
--
2.11.0
More information about the pmg-devel
mailing list