mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +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: {
|
nics: {
|
||||||
title: 'label.nics',
|
title: 'label.nics',
|
||||||
multiple: true,
|
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: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: { label: 'label.name', header: true },
|
name: { label: 'label.name', header: true },
|
||||||
|
|||||||
@ -771,6 +771,7 @@
|
|||||||
var hiddenFields;
|
var hiddenFields;
|
||||||
var context = detailViewArgs ? detailViewArgs.context : cloudStack.context;
|
var context = detailViewArgs ? detailViewArgs.context : cloudStack.context;
|
||||||
var isMultiple = tabData.multiple || tabData.isMultiple;
|
var isMultiple = tabData.multiple || tabData.isMultiple;
|
||||||
|
var actions = tabData.actions;
|
||||||
|
|
||||||
if (isMultiple) {
|
if (isMultiple) {
|
||||||
context[tabData.id] = data;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user