ui/sdn: better spelling and code cleanup

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-04-22 15:06:30 +02:00
parent 78fcb4947d
commit 43d65515e0
6 changed files with 199 additions and 215 deletions

View File

@ -1,6 +1,5 @@
Ext.define('PVE.sdn.ControllerView', {
extend: 'Ext.grid.GridPanel',
alias: ['widget.pveSDNControllerView'],
stateful: true,

View File

@ -58,12 +58,12 @@ Ext.define('PVE.sdn.StatusView', {
},
columns: [
{
header: gettext('sdn'),
header: 'SDN',
width: 80,
dataIndex: 'sdn'
},
{
header: gettext('node'),
header: gettext('Node'),
width: 80,
dataIndex: 'node'
},

View File

@ -1,10 +1,9 @@
Ext.define('PVE.sdn.VnetInputPanel', {
extend: 'Proxmox.panel.InputPanel',
vnet: undefined,
mixins: ['Proxmox.Mixin.CBind'],
onGetValues: function(values) {
var me = this;
let me = this;
if (me.isCreate) {
values.type = 'vnet';
@ -13,11 +12,9 @@ Ext.define('PVE.sdn.VnetInputPanel', {
if (!values.ipv6) {
delete values.ipv6;
}
if (!values.ipv4) {
delete values.ipv4;
}
if (!values.mac) {
delete values.mac;
}
@ -25,44 +22,42 @@ Ext.define('PVE.sdn.VnetInputPanel', {
return values;
},
initComponent : function() {
var me = this;
me.items = [
items: [
{
xtype: me.isCreate ? 'proxmoxtextfield' : 'displayfield',
xtype: 'pmxDisplayEditField',
name: 'vnet',
value: me.vnet,
cbind: {
editable: '{isCreate}',
},
maxLength: 10,
allowBlank: false,
fieldLabel: gettext('Name')
fieldLabel: gettext('Name'),
},
{
xtype: 'textfield',
name: 'alias',
fieldLabel: gettext('alias'),
allowBlank: true
fieldLabel: gettext('Alias'),
allowBlank: true,
},
{
xtype: 'pveSDNZoneSelector',
fieldLabel: gettext('Zone'),
name: 'zone',
value: '',
allowBlank: false
allowBlank: false,
},
{
xtype: 'proxmoxintegerfield',
name: 'tag',
minValue: 1,
maxValue: 16000000,
fieldLabel: gettext('tag'),
allowBlank: false
fieldLabel: gettext('Tag'),
allowBlank: false,
},
{
xtype: 'textfield',
name: 'ipv4',
vtype: 'IPCIDRAddress',
fieldLabel: gettext('ipv4'),
fieldLabel: 'IPv4/CIDR', // do not localize
skipEmptyText: true,
allowBlank: true,
@ -78,27 +73,26 @@ Ext.define('PVE.sdn.VnetInputPanel', {
{
xtype: 'textfield',
name: 'mac',
fieldLabel: gettext('MAC address'),
fieldLabel: gettext('MAC Address'),
vtype: 'MacAddress',
skipEmptyText: true,
allowBlank: true,
emptyText: 'auto'
emptyText: 'auto',
},
];
me.callParent();
}
],
});
Ext.define('PVE.sdn.VnetEdit', {
extend: 'Proxmox.window.Edit',
subject: gettext('VNet'),
vnet: undefined,
initComponent : function() {
initComponent: function() {
var me = this;
me.isCreate = !me.vnet;
me.isCreate = me.vnet === undefined;
if (me.isCreate) {
me.url = '/api2/extjs/cluster/sdn/vnets';
@ -108,14 +102,14 @@ Ext.define('PVE.sdn.VnetEdit', {
me.method = 'PUT';
}
var ipanel = Ext.create('PVE.sdn.VnetInputPanel', {
let ipanel = Ext.create('PVE.sdn.VnetInputPanel', {
isCreate: me.isCreate,
vnet: me.vnet
});
Ext.apply(me, {
subject: gettext('Vnet'),
items: [ ipanel ]
items: [
ipanel,
],
});
me.callParent();
@ -123,11 +117,10 @@ Ext.define('PVE.sdn.VnetEdit', {
if (!me.isCreate) {
me.load({
success: function(response, options) {
var values = response.result.data;
let values = response.result.data;
ipanel.setValues(values);
}
},
});
}
}
},
});

View File

@ -7,9 +7,9 @@ Ext.define('PVE.sdn.VnetView', {
stateId: 'grid-sdn-vnet',
initComponent : function() {
var me = this;
let me = this;
var store = new Ext.data.Store({
let store = new Ext.data.Store({
model: 'pve-sdn-vnet',
proxy: {
type: 'proxmox',
@ -20,31 +20,28 @@ Ext.define('PVE.sdn.VnetView', {
order: 'DESC'
}
});
let reload = () => store.load();
var reload = function() {
store.load();
};
let sm = Ext.create('Ext.selection.RowModel', {});
var sm = Ext.create('Ext.selection.RowModel', {});
let run_editor = function() {
let rec = sm.getSelection()[0];
var run_editor = function() {
var rec = sm.getSelection()[0];
var win = Ext.create('PVE.sdn.VnetEdit',{
vnet: rec.data.vnet
let win = Ext.create('PVE.sdn.VnetEdit',{
autoShow: true,
vnet: rec.data.vnet,
});
win.on('destroy', reload);
win.show();
};
var edit_btn = new Proxmox.button.Button({
let edit_btn = new Proxmox.button.Button({
text: gettext('Edit'),
disabled: true,
selModel: sm,
handler: run_editor
handler: run_editor,
});
var remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
let remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
selModel: sm,
baseurl: '/cluster/sdn/vnets/',
callback: reload
@ -61,11 +58,11 @@ Ext.define('PVE.sdn.VnetView', {
{
text: gettext('Create'),
handler: function() {
var win = Ext.create('PVE.sdn.VnetEdit',{
type: 'vnet'
let win = Ext.create('PVE.sdn.VnetEdit', {
autoShow: true,
type: 'vnet',
});
win.on('destroy', reload);
win.show();
}
},
remove_btn,
@ -86,55 +83,46 @@ Ext.define('PVE.sdn.VnetView', {
});
}
},
],
columns: [
{
header: 'ID',
flex: 2,
sortable: true,
dataIndex: 'vnet'
},
{
header: gettext('alias'),
header: gettext('Alias'),
flex: 1,
sortable: true,
dataIndex: 'alias',
},
{
header: gettext('zone'),
header: gettext('Zone'),
flex: 1,
sortable: true,
dataIndex: 'zone',
},
{
header: gettext('tag'),
header: gettext('Tag'),
flex: 1,
sortable: true,
dataIndex: 'tag',
},
{
header: gettext('ipv4'),
header: 'IPv4/CIDR',
flex: 1,
sortable: true,
dataIndex: 'ipv4',
},
{
header: gettext('ipv6'),
header: 'IPv6/CIDR',
flex: 1,
sortable: true,
dataIndex: 'ipv6',
},
{
header: gettext('mac'),
header: 'MAC',
flex: 1,
sortable: true,
dataIndex: 'mac',
},
{
header: gettext('mtu'),
header: 'MTU',
flex: 1,
sortable: true,
dataIndex: 'mtu',
},
],
@ -151,7 +139,15 @@ Ext.define('PVE.sdn.VnetView', {
Ext.define('pve-sdn-vnet', {
extend: 'Ext.data.Model',
fields: [
'type'
'alias',
'ipv4',
'ipv6',
'mac',
'mtu',
'tag',
'type',
'vnet',
'zone',
],
idProperty: 'vnet'
});

View File

@ -1,6 +1,5 @@
Ext.define('PVE.sdn.ZoneContentView', {
extend: 'Ext.grid.GridPanel',
alias: 'widget.pveSDNZoneContentView',
stateful: true,
@ -57,7 +56,7 @@ Ext.define('PVE.sdn.ZoneContentView', {
],
columns: [
{
header: gettext('Vnet'),
header: 'VNet',
flex: 1,
sortable: true,
dataIndex: 'vnet'
@ -68,7 +67,7 @@ Ext.define('PVE.sdn.ZoneContentView', {
dataIndex: 'status',
},
{
header: gettext('Status details'),
header: gettext('Details'),
width: 20,
dataIndex: 'statusmsg',
},

View File

@ -7,7 +7,7 @@ Ext.define('PVE.sdn.ZoneView', {
stateId: 'grid-sdn-zone',
createSDNEditWindow: function(type, sid) {
var schema = PVE.Utils.sdnzoneSchema[type];
let schema = PVE.Utils.sdnzoneSchema[type];
if (!schema || !schema.ipanel) {
throw "no editor registered for zone type: " + type;
}
@ -24,9 +24,9 @@ Ext.define('PVE.sdn.ZoneView', {
},
initComponent : function() {
var me = this;
let me = this;
var store = new Ext.data.Store({
let store = new Ext.data.Store({
model: 'pve-sdn-zone',
proxy: {
type: 'proxmox',
@ -38,45 +38,45 @@ Ext.define('PVE.sdn.ZoneView', {
},
});
var reload = function() {
let reload = function() {
store.load();
};
var sm = Ext.create('Ext.selection.RowModel', {});
let sm = Ext.create('Ext.selection.RowModel', {});
var run_editor = function() {
var rec = sm.getSelection()[0];
let run_editor = function() {
let rec = sm.getSelection()[0];
if (!rec) {
return;
}
var type = rec.data.type,
let type = rec.data.type,
zone = rec.data.zone;
me.createSDNEditWindow(type, zone);
};
var edit_btn = new Proxmox.button.Button({
let edit_btn = new Proxmox.button.Button({
text: gettext('Edit'),
disabled: true,
selModel: sm,
handler: run_editor
});
var remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
let remove_btn = Ext.create('Proxmox.button.StdRemoveButton', {
selModel: sm,
baseurl: '/cluster/sdn/zones/',
callback: reload
});
// else we cannot dynamically generate the add menu handlers
var addHandleGenerator = function(type) {
let addHandleGenerator = function(type) {
return function() { me.createSDNEditWindow(type); };
};
var addMenuItems = [], type;
let addMenuItems = [], type;
/*jslint forin: true */
for (type in PVE.Utils.sdnzoneSchema) {
var zone = PVE.Utils.sdnzoneSchema[type];
let zone = PVE.Utils.sdnzoneSchema[type];
if (zone.hideAdd) {
continue;
}
@ -124,20 +124,17 @@ Ext.define('PVE.sdn.ZoneView', {
{
header: 'ID',
flex: 2,
sortable: true,
dataIndex: 'zone'
},
{
header: gettext('Type'),
flex: 1,
sortable: true,
dataIndex: 'type',
renderer: PVE.Utils.format_sdnzone_type
},
{
header: gettext('Nodes'),
flex: 1,
sortable: true,
flex: 3,
dataIndex: 'nodes',
},
],