[pmg-devel] [PATCH pmg-gui v4 1/3] refactor RelayDomains:
Stoiko Ivanov
s.ivanov at proxmox.com
Mon Oct 21 19:23:36 CEST 2019
by making the base-url, the description text and the online help anchor static
fields we can override it and reuse the component for DKIMDomains.
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
js/RelayDomains.js | 33 +++++++++++++++++++--------------
1 file changed, 19 insertions(+), 14 deletions(-)
diff --git a/js/RelayDomains.js b/js/RelayDomains.js
index 2cee2f5..042ba43 100644
--- a/js/RelayDomains.js
+++ b/js/RelayDomains.js
@@ -2,10 +2,6 @@
Ext.define('pmg-domains', {
extend: 'Ext.data.Model',
fields: [ 'domain', 'comment' ],
- proxy: {
- type: 'proxmox',
- url: "/api2/json/config/domains"
- },
idProperty: 'domain'
});
@@ -13,6 +9,11 @@ Ext.define('PMG.RelayDomains', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.pmgRelayDomains'],
+ baseurl: '/config/domains',
+ domain_desc: gettext('Relay Domain'),
+
+ onlineHelp: 'pmgconfig_mailproxy_relay_domains',
+
initComponent : function() {
var me = this;
@@ -21,7 +22,11 @@ Ext.define('PMG.RelayDomains', {
sorters: {
property: 'domain',
order: 'DESC'
- }
+ },
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json' + me.baseurl
+ },
});
var reload = function() {
@@ -32,7 +37,7 @@ Ext.define('PMG.RelayDomains', {
var remove_btn = Ext.createWidget('proxmoxStdRemoveButton', {
selModel: me.selModel,
- baseurl: '/config/domains',
+ baseurl: me.baseurl,
callback: reload,
waitMsgTarget: me
});
@@ -44,15 +49,15 @@ Ext.define('PMG.RelayDomains', {
}
var config = {
- url: "/api2/extjs/config/domains/" + rec.data.domain,
- onlineHelp: 'pmgconfig_mailproxy_relay_domains',
+ url: '/api2/extjs' + me.baseurl + '/' + rec.data.domain,
+ onlineHelp: me.onlineHelp,
method: 'PUT',
- subject: gettext("Relay Domain"),
+ subject: me.domain_desc,
items: [
{
xtype: 'displayfield',
name: 'domain',
- fieldLabel: gettext("Relay Domain")
+ fieldLabel: me.domain_desc
},
{
xtype: 'textfield',
@@ -83,15 +88,15 @@ Ext.define('PMG.RelayDomains', {
/*jslint confusion: true*/
var config = {
method: 'POST',
- url: "/api2/extjs/config/domains",
- onlineHelp: 'pmgconfig_mailproxy_relay_domains',
+ url: '/api2/extjs' + me.baseurl,
+ onlineHelp: me.onlineHelp,
isCreate: true,
subject: gettext("Relay Domain"),
items: [
{
xtype: 'proxmoxtextfield',
name: 'domain',
- fieldLabel: gettext("Relay Domain")
+ fieldLabel: me.domain_desc
},
{
xtype: 'proxmoxtextfield',
@@ -122,7 +127,7 @@ Ext.define('PMG.RelayDomains', {
},
columns: [
{
- header: gettext('Relay Domain'),
+ header: me.domain_desc,
width: 200,
sortable: true,
dataIndex: 'domain'
--
2.20.1
More information about the pmg-devel
mailing list