mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6438: Filter out existing IPs in dropdown
This commit is contained in:
parent
9885cf4fb0
commit
4f45c972c3
|
|
@ -179,19 +179,26 @@
|
|||
var primaryIp = nic.ipaddress;
|
||||
var secondaryIps = nic.secondaryip ? nic.secondaryip : [];
|
||||
var ipSelection = [];
|
||||
var existingIps = $(args.context.subItemData).map(
|
||||
function(index, item) { return item.itemIp; }
|
||||
);
|
||||
|
||||
// Add primary IP as default
|
||||
ipSelection.push({
|
||||
id: primaryIp,
|
||||
description: primaryIp + ' (Primary)'
|
||||
});
|
||||
if ($.inArray(primaryIp, existingIps) == -1) {
|
||||
ipSelection.push({
|
||||
id: primaryIp,
|
||||
description: primaryIp + ' (Primary)'
|
||||
});
|
||||
}
|
||||
|
||||
// Add secondary IPs
|
||||
$(secondaryIps).map(function(index, secondaryIp) {
|
||||
ipSelection.push({
|
||||
id: secondaryIp.ipaddress,
|
||||
description: secondaryIp.ipaddress
|
||||
});
|
||||
if ($.inArray(secondaryIp.ipaddress, existingIps) == -1) {
|
||||
ipSelection.push({
|
||||
id: secondaryIp.ipaddress,
|
||||
description: secondaryIp.ipaddress
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
args.response.success({
|
||||
|
|
|
|||
|
|
@ -196,11 +196,21 @@
|
|||
} else if (field.addButton && !options.noSelect) {
|
||||
if (options.multipleAdd) {
|
||||
$addButton.click(function() {
|
||||
var context = $.extend(true, {}, options.context);
|
||||
|
||||
if ($td.hasClass('disabled')) return false;
|
||||
|
||||
var $subItems = $td.closest('.data-item').find('.expandable-listing tr');
|
||||
|
||||
if ($subItems.size()) {
|
||||
context.subItemData = $subItems.map(function() {
|
||||
return $(this).data('json-obj');
|
||||
});
|
||||
}
|
||||
|
||||
_medit.vmList($multi,
|
||||
options.listView,
|
||||
options.context,
|
||||
context,
|
||||
options.multipleAdd, _l('label.add.vms'),
|
||||
addItemAction, {
|
||||
multiRule: multiRule
|
||||
|
|
@ -820,6 +830,8 @@
|
|||
var field = this;
|
||||
var $tr = _medit.multiItem.itemRow(field, itemActions, multiRule, $tbody).appendTo($tbody);
|
||||
|
||||
$tr.data('json-obj', field);
|
||||
|
||||
cloudStack.evenOdd($tbody, 'tr', {
|
||||
even: function($elem) {
|
||||
$elem.addClass('even');
|
||||
|
|
|
|||
Loading…
Reference in New Issue