Ext.define('PVE.FirewallAliasEdit', {
- extend: 'PVE.window.Edit',
+ extend: 'Proxmox.window.Edit',
base_url: undefined,
-
+
alias_name: undefined,
- initComponent : function() {
+ width: 400,
+ initComponent: function() {
var me = this;
me.isCreate = (me.alias_name === undefined);
if (me.isCreate) {
- me.url = '/api2/extjs' + me.base_url;
- me.method = 'POST';
- } else {
- me.url = '/api2/extjs' + me.base_url + '/' + me.alias_name;
- me.method = 'PUT';
- }
-
- var items = [
+ me.url = '/api2/extjs' + me.base_url;
+ me.method = 'POST';
+ } else {
+ me.url = '/api2/extjs' + me.base_url + '/' + me.alias_name;
+ me.method = 'PUT';
+ }
+
+ var items = [
{
xtype: 'textfield',
name: me.isCreate ? 'name' : 'rename',
fieldLabel: gettext('Name'),
- allowBlank: false
+ allowBlank: false,
},
{
xtype: 'textfield',
name: 'cidr',
fieldLabel: gettext('IP/CIDR'),
- allowBlank: false
+ allowBlank: false,
},
{
xtype: 'textfield',
name: 'comment',
- fieldLabel: gettext('Comment')
- }
+ fieldLabel: gettext('Comment'),
+ },
];
- var ipanel = Ext.create('PVE.panel.InputPanel', {
+ var ipanel = Ext.create('Proxmox.panel.InputPanel', {
isCreate: me.isCreate,
- items: items
+ items: items,
});
Ext.apply(me, {
subject: gettext('Alias'),
isAdd: true,
- items: [ ipanel ]
+ items: [ipanel],
});
me.callParent();
if (!me.isCreate) {
me.load({
- success: function(response, options) {
+ success: function(response, options) {
var values = response.result.data;
values.rename = values.name;
ipanel.setValues(values);
- }
+ },
});
}
- }
+ },
});
Ext.define('pve-fw-aliases', {
extend: 'Ext.data.Model',
- fields: [ 'name', 'cidr', 'comment', 'digest' ],
- idProperty: 'name'
+ fields: ['name', 'cidr', 'comment', 'digest'],
+ idProperty: 'name',
});
Ext.define('PVE.FirewallAliases', {
title: gettext('Alias'),
- initComponent : function() {
-
+ initComponent: function() {
var me = this;
if (!me.base_url) {
var store = new Ext.data.Store({
model: 'pve-fw-aliases',
proxy: {
- type: 'pve',
- url: "/api2/json" + me.base_url
+ type: 'proxmox',
+ url: "/api2/json" + me.base_url,
},
sorters: {
property: 'name',
- order: 'DESC'
- }
+ order: 'DESC',
+ },
});
var sm = Ext.create('Ext.selection.RowModel', {});
var oldrec = sm.getSelection()[0];
store.load(function(records, operation, success) {
if (oldrec) {
- var rec = store.findRecord('name', oldrec.data.name);
+ var rec = store.findRecord('name', oldrec.data.name, 0, false, true, true);
if (rec) {
sm.select(rec);
}
var win = Ext.create('PVE.FirewallAliasEdit', {
base_url: me.base_url,
- alias_name: rec.data.name
+ alias_name: rec.data.name,
});
win.show();
win.on('destroy', reload);
};
- me.editBtn = new PVE.button.Button({
+ me.editBtn = new Proxmox.button.Button({
text: gettext('Edit'),
disabled: true,
selModel: sm,
- handler: run_editor
+ handler: run_editor,
});
- me.addBtn = Ext.create('Ext.Button', {
+ me.addBtn = Ext.create('Ext.Button', {
text: gettext('Add'),
handler: function() {
var win = Ext.create('PVE.FirewallAliasEdit', {
- base_url: me.base_url
+ base_url: me.base_url,
});
win.on('destroy', reload);
win.show();
- }
+ },
});
- me.removeBtn = new PVE.button.Button({
- text: gettext('Remove'),
+ me.removeBtn = Ext.create('Proxmox.button.StdRemoveButton', {
selModel: sm,
- disabled: true,
- handler: function() {
- var rec = sm.getSelection()[0];
- if (!rec) {
- return;
- }
- PVE.Utils.API2Request({
- url: me.base_url + '/' + rec.data.name,
- method: 'DELETE',
- waitMsgTarget: me,
- failure: function(response, options) {
- Ext.Msg.alert(gettext('Error'), response.htmlStatus);
- },
- callback: reload
- });
- }
+ baseurl: me.base_url + '/',
+ callback: reload,
});
Ext.apply(me, {
store: store,
- tbar: [ me.addBtn, me.removeBtn, me.editBtn ],
+ tbar: [me.addBtn, me.removeBtn, me.editBtn],
selModel: sm,
columns: [
- { header: gettext('Name'), dataIndex: 'name', width: 100 },
- { header: gettext('IP/CIDR'), dataIndex: 'cidr', width: 100 },
- { header: gettext('Comment'), dataIndex: 'comment', renderer: Ext.String.htmlEncode, flex: 1 }
+ {
+ header: gettext('Name'),
+ dataIndex: 'name',
+ flex: 1,
+ },
+ {
+ header: gettext('IP/CIDR'),
+ dataIndex: 'cidr',
+ flex: 1,
+ },
+ {
+ header: gettext('Comment'),
+ dataIndex: 'comment',
+ renderer: Ext.String.htmlEncode,
+ flex: 3,
+ },
],
listeners: {
- itemdblclick: run_editor
- }
+ itemdblclick: run_editor,
+ },
});
me.callParent();
me.on('activate', reload);
- }
+ },
});