mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
UI, instance nics tab: Implement 'add network' action
-Change detail widget to support 'add' action on per-nic/item detail groups -Implement add network/NIC action on instances NIC tab
This commit is contained in:
parent
21f953ffa4
commit
93db30e4e1
@ -1227,6 +1227,62 @@
|
||||
nics: {
|
||||
title: 'label.nics',
|
||||
multiple: true,
|
||||
actions: {
|
||||
add: {
|
||||
label: 'Add network to VM',
|
||||
messages: {
|
||||
confirm: function(args) {
|
||||
return 'Please confirm that you would like to add a new VM NIC for this network.';
|
||||
},
|
||||
notification: function(args) {
|
||||
return 'Add network to VM';
|
||||
}
|
||||
},
|
||||
createForm: {
|
||||
title: 'Add network to VM',
|
||||
desc: 'Please specify the network that you would like to add this VM to. A new NIC will be added for this network.',
|
||||
fields: {
|
||||
networkid: {
|
||||
label: 'label.network',
|
||||
select: function(args) {
|
||||
$.ajax({
|
||||
url: createURL('listNetworks'),
|
||||
data: {
|
||||
listAll: true,
|
||||
zoneid: args.context.instances[0].zoneid
|
||||
},
|
||||
success: function(json) {
|
||||
args.response.success({
|
||||
data: $.map(json.listnetworksresponse.network, function(network) {
|
||||
return {
|
||||
id: network.id,
|
||||
description: network.name
|
||||
};
|
||||
})
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
action: function(args) {
|
||||
$.ajax({
|
||||
url: createURL('addNicToVirtualMachine'),
|
||||
data: {
|
||||
virtualmachineid: args.context.instances[0].id,
|
||||
networkid: args.data.networkid
|
||||
},
|
||||
success: function(json) {
|
||||
args.response.success({
|
||||
_custom: { jobId: json.addnictovirtualmachineresponse.jobid }
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
notification: { poll: pollAsyncJobResult }
|
||||
}
|
||||
},
|
||||
fields: [
|
||||
{
|
||||
name: { label: 'label.name', header: true },
|
||||
|
||||
@ -771,6 +771,7 @@
|
||||
var hiddenFields;
|
||||
var context = detailViewArgs ? detailViewArgs.context : cloudStack.context;
|
||||
var isMultiple = tabData.multiple || tabData.isMultiple;
|
||||
var actions = tabData.actions;
|
||||
|
||||
if (isMultiple) {
|
||||
context[tabData.id] = data;
|
||||
@ -1074,6 +1075,29 @@
|
||||
}
|
||||
});
|
||||
|
||||
// Add item action
|
||||
if (tabData.multiple && tabData.actions && tabData.actions.add) {
|
||||
$tabContent.append(
|
||||
$('<div>').addClass('button add').append(
|
||||
$('<span>').addClass('icon').html(' '),
|
||||
$('<span>').html(_l(tabData.actions.add.label))
|
||||
).click(function() {
|
||||
uiActions.standard(
|
||||
$detailView,
|
||||
{ actions: tabData.actions, actionName: 'add' }, {
|
||||
noRefresh: true,
|
||||
complete: function(args) {
|
||||
loadTabContent(
|
||||
$detailView.find('div.detail-group:visible'),
|
||||
$detailView.data('view-args')
|
||||
);
|
||||
}
|
||||
}
|
||||
)
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user