mirror of
https://git.proxmox.com/git/proxmox-widget-toolkit
synced 2025-06-27 14:15:40 +00:00
node network view: move add-menu generation to common helper
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
bcd21f899e
commit
f6efb0d487
@ -150,7 +150,7 @@ Ext.define('Proxmox.node.NetworkView', {
|
|||||||
del_btn.setDisabled(!rec);
|
del_btn.setDisabled(!rec);
|
||||||
};
|
};
|
||||||
|
|
||||||
let find_next_iface_id = function(prefix) {
|
let findNextFreeInterfaceId = function(prefix) {
|
||||||
for (let next = 0; next <= 9999; next++) {
|
for (let next = 0; next <= 9999; next++) {
|
||||||
let id = `${prefix}${next.toString()}`;
|
let id = `${prefix}${next.toString()}`;
|
||||||
if (!store.getById(id)) {
|
if (!store.getById(id)) {
|
||||||
@ -162,53 +162,32 @@ Ext.define('Proxmox.node.NetworkView', {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let menu_items = [];
|
let menu_items = [];
|
||||||
|
let addEditWindowToMenu = (iType, iDefault) => {
|
||||||
|
menu_items.push({
|
||||||
|
text: Proxmox.Utils.render_network_iface_type(iType),
|
||||||
|
handler: () => Ext.create('Proxmox.node.NetworkEdit', {
|
||||||
|
autoShow: true,
|
||||||
|
nodename: me.nodename,
|
||||||
|
iftype: iType,
|
||||||
|
iface_default: findNextFreeInterfaceId(iDefault ?? iType),
|
||||||
|
onlineHelp: 'sysadmin_network_configuration',
|
||||||
|
listeners: {
|
||||||
|
destroy: () => reload(),
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
if (me.types.indexOf('bridge') !== -1) {
|
if (me.types.indexOf('bridge') !== -1) {
|
||||||
menu_items.push({
|
addEditWindowToMenu('bridge', 'vmbr');
|
||||||
text: Proxmox.Utils.render_network_iface_type('bridge'),
|
|
||||||
handler: function() {
|
|
||||||
let win = Ext.create('Proxmox.node.NetworkEdit', {
|
|
||||||
nodename: me.nodename,
|
|
||||||
iftype: 'bridge',
|
|
||||||
iface_default: find_next_iface_id('vmbr'),
|
|
||||||
onlineHelp: 'sysadmin_network_configuration',
|
|
||||||
});
|
|
||||||
win.on('destroy', reload);
|
|
||||||
win.show();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.types.indexOf('bond') !== -1) {
|
if (me.types.indexOf('bond') !== -1) {
|
||||||
menu_items.push({
|
addEditWindowToMenu('bond');
|
||||||
text: Proxmox.Utils.render_network_iface_type('bond'),
|
|
||||||
handler: function() {
|
|
||||||
let win = Ext.create('Proxmox.node.NetworkEdit', {
|
|
||||||
nodename: me.nodename,
|
|
||||||
iftype: 'bond',
|
|
||||||
iface_default: find_next_iface_id('bond'),
|
|
||||||
onlineHelp: 'sysadmin_network_configuration',
|
|
||||||
});
|
|
||||||
win.on('destroy', reload);
|
|
||||||
win.show();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.types.indexOf('vlan') !== -1) {
|
if (me.types.indexOf('vlan') !== -1) {
|
||||||
menu_items.push({
|
addEditWindowToMenu('vlan');
|
||||||
text: Proxmox.Utils.render_network_iface_type('vlan'),
|
|
||||||
handler: function() {
|
|
||||||
let win = Ext.create('Proxmox.node.NetworkEdit', {
|
|
||||||
nodename: me.nodename,
|
|
||||||
iftype: 'vlan',
|
|
||||||
iface_default: find_next_iface_id('vlan'),
|
|
||||||
onlineHelp: 'sysadmin_network_configuration',
|
|
||||||
});
|
|
||||||
win.on('destroy', reload);
|
|
||||||
win.show();
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (me.types.indexOf('ovs') !== -1) {
|
if (me.types.indexOf('ovs') !== -1) {
|
||||||
@ -216,43 +195,20 @@ Ext.define('Proxmox.node.NetworkView', {
|
|||||||
menu_items.push({ xtype: 'menuseparator' });
|
menu_items.push({ xtype: 'menuseparator' });
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_items.push(
|
addEditWindowToMenu('OVSBridge', 'vmbr');
|
||||||
{
|
addEditWindowToMenu('OVSBond', 'bond');
|
||||||
text: Proxmox.Utils.render_network_iface_type('OVSBridge'),
|
|
||||||
handler: function() {
|
menu_items.push({
|
||||||
let win = Ext.create('Proxmox.node.NetworkEdit', {
|
text: Proxmox.Utils.render_network_iface_type('OVSIntPort'),
|
||||||
nodename: me.nodename,
|
handler: () => Ext.create('Proxmox.node.NetworkEdit', {
|
||||||
iftype: 'OVSBridge',
|
autoShow: true,
|
||||||
iface_default: find_next_iface_id('vmbr'),
|
nodename: me.nodename,
|
||||||
});
|
iftype: 'OVSIntPort',
|
||||||
win.on('destroy', reload);
|
listeners: {
|
||||||
win.show();
|
destroy: () => reload(),
|
||||||
},
|
},
|
||||||
},
|
}),
|
||||||
{
|
});
|
||||||
text: Proxmox.Utils.render_network_iface_type('OVSBond'),
|
|
||||||
handler: function() {
|
|
||||||
let win = Ext.create('Proxmox.node.NetworkEdit', {
|
|
||||||
nodename: me.nodename,
|
|
||||||
iftype: 'OVSBond',
|
|
||||||
iface_default: find_next_iface_id('bond'),
|
|
||||||
});
|
|
||||||
win.on('destroy', reload);
|
|
||||||
win.show();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
{
|
|
||||||
text: Proxmox.Utils.render_network_iface_type('OVSIntPort'),
|
|
||||||
handler: function() {
|
|
||||||
let win = Ext.create('Proxmox.node.NetworkEdit', {
|
|
||||||
nodename: me.nodename,
|
|
||||||
iftype: 'OVSIntPort',
|
|
||||||
});
|
|
||||||
win.on('destroy', reload);
|
|
||||||
win.show();
|
|
||||||
},
|
|
||||||
},
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let renderer_generator = function(fieldname) {
|
let renderer_generator = function(fieldname) {
|
||||||
|
Loading…
Reference in New Issue
Block a user