You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bf...@apache.org on 2013/04/03 23:23:28 UTC
git commit: updated refs/heads/ui-add-remove-nics to 93db30e
Updated Branches:
refs/heads/ui-add-remove-nics 21f953ffa -> 93db30e4e
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
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/93db30e4
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/93db30e4
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/93db30e4
Branch: refs/heads/ui-add-remove-nics
Commit: 93db30e4e116b6aa36e1b127ef5f406072fa935b
Parents: 21f953f
Author: Brian Federle <br...@citrix.com>
Authored: Wed Apr 3 14:22:15 2013 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Wed Apr 3 14:23:23 2013 -0700
----------------------------------------------------------------------
ui/scripts/instances.js | 56 ++++++++++++++++++++++++++++++
ui/scripts/ui/widgets/detailView.js | 24 +++++++++++++
2 files changed, 80 insertions(+), 0 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93db30e4/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index 1e3ce45..ddb5622 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -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 },
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/93db30e4/ui/scripts/ui/widgets/detailView.js
----------------------------------------------------------------------
diff --git a/ui/scripts/ui/widgets/detailView.js b/ui/scripts/ui/widgets/detailView.js
index 4b520f9..cd1135c 100644
--- a/ui/scripts/ui/widgets/detailView.js
+++ b/ui/scripts/ui/widgets/detailView.js
@@ -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;
}