node network: refactor bond mode array generation

Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
Dominik Csapak 2019-07-10 11:30:51 +02:00 committed by Thomas Lamprecht
parent 4211996ab0
commit 8311c0b1af
2 changed files with 38 additions and 15 deletions

View File

@ -99,6 +99,29 @@ Ext.define('Proxmox.Utils', { utilities: {
return data; return data;
}, },
bond_mode_gettext_map: {
'802.3ad': 'LACP (802.3ad)',
'lacp-balance-slb': 'LACP (balance-slb)',
'lacp-balance-tcp': 'LACP (balance-tcp)',
},
render_bond_mode: function(value) {
var val = Proxmox.Utils.bond_mode_gettext_map[value];
if (!val) {
val = value || '';
}
return val;
},
bond_mode_array: function(modes) {
var arr = [];
var i;
for (i = 0; i < modes.length; i++) {
arr.push([modes[i], Proxmox.Utils.render_bond_mode(modes[i])]);
}
return arr;
},
getNoSubKeyHtml: function(url) { getNoSubKeyHtml: function(url) {
// url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans // url http://www.proxmox.com/products/proxmox-ve/subscription-service-plans
return Ext.String.format('You do not have a valid subscription for this server. Please visit <a target="_blank" href="{0}">www.proxmox.com</a> to get a list of available options.', url || 'https://www.proxmox.com'); return Ext.String.format('You do not have a valid subscription for this server. Please visit <a target="_blank" href="{0}">www.proxmox.com</a> to get a list of available options.', url || 'https://www.proxmox.com');

View File

@ -8,22 +8,22 @@ Ext.define('Proxmox.form.BondModeSelector', {
var me = this; var me = this;
if (me.openvswitch) { if (me.openvswitch) {
me.comboItems = [ me.comboItems = Proxmox.Utils.bond_mode_array([
['active-backup', 'active-backup'], 'active-backup',
['balance-slb', 'balance-slb'], 'balance-slb',
['lacp-balance-slb', 'LACP (balance-slb)'], 'lacp-balance-slb',
['lacp-balance-tcp', 'LACP (balance-tcp)'] 'lacp-balance-tcp',
]; ]);
} else { } else {
me.comboItems = [ me.comboItems = Proxmox.Utils.bond_mode_array([
['balance-rr', 'balance-rr'], 'balance-rr',
['active-backup', 'active-backup'], 'active-backup',
['balance-xor', 'balance-xor'], 'balance-xor',
['broadcast', 'broadcast'], 'broadcast',
['802.3ad', 'LACP (802.3ad)'], '802.3ad',
['balance-tlb', 'balance-tlb'], 'balance-tlb',
['balance-alb', 'balance-alb'] 'balance-alb',
]; ]);
} }
me.callParent(); me.callParent();