mirror of
https://git.proxmox.com/git/pmg-gui
synced 2025-08-18 09:44:18 +00:00
MyNetworks.js: add GUI for trusted networks
This commit is contained in:
parent
c51d3f79dd
commit
96feba894b
@ -27,7 +27,7 @@ Ext.define('PMG.MailProxyConfiguration', {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: gettext('Networks'),
|
title: gettext('Networks'),
|
||||||
html: "Networks"
|
xtype: 'pmgMyNetworks'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: gettext('TLS'),
|
title: gettext('TLS'),
|
||||||
|
@ -8,6 +8,7 @@ JSSRC= \
|
|||||||
MailProxyPorts.js \
|
MailProxyPorts.js \
|
||||||
MailProxyOptions.js \
|
MailProxyOptions.js \
|
||||||
Transport.js \
|
Transport.js \
|
||||||
|
MyNetworks.js \
|
||||||
RelayDomains.js \
|
RelayDomains.js \
|
||||||
MailProxyConfiguration.js \
|
MailProxyConfiguration.js \
|
||||||
ConfigPanel.js \
|
ConfigPanel.js \
|
||||||
|
157
js/MyNetworks.js
Normal file
157
js/MyNetworks.js
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
Ext.define('pmg-mynetworks', {
|
||||||
|
extend: 'Ext.data.Model',
|
||||||
|
fields: [ 'cidr', 'comment' ],
|
||||||
|
proxy: {
|
||||||
|
type: 'proxmox',
|
||||||
|
url: "/api2/json/config/mynetworks"
|
||||||
|
},
|
||||||
|
idProperty: 'cidr'
|
||||||
|
});
|
||||||
|
|
||||||
|
Ext.define('PMG.MyNetworks', {
|
||||||
|
extend: 'Ext.grid.GridPanel',
|
||||||
|
alias: ['widget.pmgMyNetworks'],
|
||||||
|
|
||||||
|
initComponent : function() {
|
||||||
|
var me = this;
|
||||||
|
|
||||||
|
var store = new Ext.data.Store({
|
||||||
|
model: 'pmg-mynetworks',
|
||||||
|
sorters: {
|
||||||
|
property: 'cidr',
|
||||||
|
order: 'DESC'
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var reload = function() {
|
||||||
|
store.load();
|
||||||
|
};
|
||||||
|
|
||||||
|
me.selModel = Ext.create('Ext.selection.RowModel', {});
|
||||||
|
|
||||||
|
var remove_btn = Ext.createWidget('proxmoxButton', {
|
||||||
|
text: gettext('Remove'),
|
||||||
|
disabled: true,
|
||||||
|
selModel: me.selModel,
|
||||||
|
confirmMsg: function (rec) {
|
||||||
|
return Ext.String.format(
|
||||||
|
gettext('Are you sure you want to remove entry {0}'),
|
||||||
|
"'" + rec.data.cidr + "'");
|
||||||
|
},
|
||||||
|
handler: function(btn, event, rec) {
|
||||||
|
Proxmox.Utils.API2Request({
|
||||||
|
url: '/config/mynetworks/' + rec.data.cidr,
|
||||||
|
method: 'DELETE',
|
||||||
|
waitMsgTarget: me,
|
||||||
|
callback: function() {
|
||||||
|
reload();
|
||||||
|
},
|
||||||
|
failure: function (response, opts) {
|
||||||
|
Ext.Msg.alert(gettext('Error'), response.htmlStatus);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var run_editor = function() {
|
||||||
|
var rec = me.selModel.getSelection()[0];
|
||||||
|
if (!rec) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var config = {
|
||||||
|
url: "/api2/extjs/config/mynetworks/" + rec.data.cidr,
|
||||||
|
method: 'PUT',
|
||||||
|
subject: gettext("Trusted Network"),
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
xtype: 'displayfield',
|
||||||
|
name: 'cidr',
|
||||||
|
fieldLabel: 'CIDR'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
xtype: 'textfield',
|
||||||
|
name: 'comment',
|
||||||
|
fieldLabel: gettext("Comment")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
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 = {
|
||||||
|
method: 'POST',
|
||||||
|
url: "/api2/extjs/config/mynetworks",
|
||||||
|
create: true,
|
||||||
|
subject: gettext("Trusted Network"),
|
||||||
|
items: [
|
||||||
|
{
|
||||||
|
xtype: 'proxmoxtextfield',
|
||||||
|
name: 'cidr',
|
||||||
|
fieldLabel: 'CIDR'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
xtype: 'proxmoxtextfield',
|
||||||
|
name: 'comment',
|
||||||
|
fieldLabel: gettext("Comment")
|
||||||
|
}
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
var win = Ext.createWidget('proxmoxWindowEdit', config);
|
||||||
|
|
||||||
|
win.on('destroy', reload);
|
||||||
|
win.show();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
remove_btn
|
||||||
|
];
|
||||||
|
|
||||||
|
Proxmox.Utils.monStoreErrors(me, store);
|
||||||
|
|
||||||
|
Ext.apply(me, {
|
||||||
|
store: store,
|
||||||
|
tbar: tbar,
|
||||||
|
viewConfig: {
|
||||||
|
trackOver: false
|
||||||
|
},
|
||||||
|
columns: [
|
||||||
|
{
|
||||||
|
header: gettext('Trusted Netowrk'),
|
||||||
|
width: 200,
|
||||||
|
sortable: true,
|
||||||
|
dataIndex: 'cidr'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
header: gettext('Comment'),
|
||||||
|
sortable: false,
|
||||||
|
renderer: Ext.String.htmlEncode,
|
||||||
|
dataIndex: 'comment',
|
||||||
|
flex: 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
listeners: {
|
||||||
|
itemdblclick: run_editor,
|
||||||
|
activate: reload
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
me.callParent();
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user