[pmg-devel] [PATCH pmg-gui v2 1/3] refactor RelayDomains:
Stoiko Ivanov
s.ivanov at proxmox.com
Tue Oct 15 21:46:51 CEST 2019
by making the base-url a static field we can override it and reuse the
component for DKIMDomains.
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
js/RelayDomains.js | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
diff --git a/js/RelayDomains.js b/js/RelayDomains.js
index 2cee2f5..554665c 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,9 @@ Ext.define('PMG.RelayDomains', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.pmgRelayDomains'],
+ baseurl: '/config/domains',
+ domain_desc: gettext('Relay Domain'),
+
initComponent : function() {
var me = this;
@@ -21,7 +20,11 @@ Ext.define('PMG.RelayDomains', {
sorters: {
property: 'domain',
order: 'DESC'
- }
+ },
+ proxy: {
+ type: 'proxmox',
+ url: '/api2/json' + me.baseurl
+ },
});
var reload = function() {
@@ -32,7 +35,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 +47,15 @@ Ext.define('PMG.RelayDomains', {
}
var config = {
- url: "/api2/extjs/config/domains/" + rec.data.domain,
+ url: '/api2/extjs' + me.baseurl + '/' + rec.data.domain,
onlineHelp: 'pmgconfig_mailproxy_relay_domains',
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,7 +86,7 @@ Ext.define('PMG.RelayDomains', {
/*jslint confusion: true*/
var config = {
method: 'POST',
- url: "/api2/extjs/config/domains",
+ url: '/api2/extjs' + me.baseurl,
onlineHelp: 'pmgconfig_mailproxy_relay_domains',
isCreate: true,
subject: gettext("Relay Domain"),
@@ -91,7 +94,7 @@ Ext.define('PMG.RelayDomains', {
{
xtype: 'proxmoxtextfield',
name: 'domain',
- fieldLabel: gettext("Relay Domain")
+ fieldLabel: me.domain_desc
},
{
xtype: 'proxmoxtextfield',
@@ -122,7 +125,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