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/10/31 21:40:02 UTC
[2/2] git commit: updated refs/heads/master to 0db10ad
VM snapshot: Make multi-select action
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0db10ad5
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0db10ad5
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0db10ad5
Branch: refs/heads/master
Commit: 0db10ad55cd15d00e8fe09d48ae6af671bba7da6
Parents: f930ccd
Author: Brian Federle <br...@citrix.com>
Authored: Thu Oct 31 13:39:40 2013 -0700
Committer: Brian Federle <br...@citrix.com>
Committed: Thu Oct 31 13:39:40 2013 -0700
----------------------------------------------------------------------
ui/scripts/instances.js | 147 ++++++++++++++++++++++++-------------------
1 file changed, 83 insertions(+), 64 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0db10ad5/ui/scripts/instances.js
----------------------------------------------------------------------
diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js
index a3d4ca5..625be51 100644
--- a/ui/scripts/instances.js
+++ b/ui/scripts/instances.js
@@ -16,10 +16,90 @@
// under the License.
(function($, cloudStack) {
var vmMigrationHostObjs;
+
+ var vmSnapshotAction = function(args) {
+ var action = {
+ messages: {
+ notification: function(args) {
+ return 'label.action.vmsnapshot.create';
+ }
+ },
+ label: 'label.action.vmsnapshot.create',
+ addRow: 'false',
+ createForm: {
+ title: 'label.action.vmsnapshot.create',
+ fields: {
+ name: {
+ label: 'label.name',
+ isInput: true
+ },
+ description: {
+ label: 'label.description',
+ isTextarea: true
+ },
+ snapshotMemory: {
+ label: 'label.vmsnapshot.memory',
+ isBoolean: true,
+ isChecked: false
+ }
+ }
+ },
+ action: function(args) {
+ var instances = args.context.instances;
+
+ $(instances).map(function(index, instance) {
+ var array1 = [];
+ array1.push("&snapshotmemory=" + (args.data.snapshotMemory == "on"));
+ var displayname = args.data.name;
+ if (displayname != null && displayname.length > 0) {
+ array1.push("&name=" + todb(displayname));
+ }
+ var description = args.data.description;
+ if (description != null && description.length > 0) {
+ array1.push("&description=" + todb(description));
+ }
+ $.ajax({
+ url: createURL("createVMSnapshot&virtualmachineid=" + instance.id + array1.join("")),
+ dataType: "json",
+ async: true,
+ success: function(json) {
+ var jid = json.createvmsnapshotresponse.jobid;
+ args.response.success({
+ _custom: {
+ jobId: jid,
+ getUpdatedItem: function(json) {
+ return json.queryasyncjobresultresponse.jobresult.virtualmachine;
+ },
+ getActionFilter: function() {
+ return vmActionfilter;
+ }
+ }
+ });
+ }
+ });
+ });
+
+ },
+ notification: {
+ poll: pollAsyncJobResult
+ }
+ };
+
+ if (args && args.listView) {
+ $.extend(action, {
+ isHeader: true,
+ isMultiSelectAction: true
+ });
+ }
+
+ return action;
+ };
+
cloudStack.sections.instances = {
title: 'label.instances',
id: 'instances',
listView: {
+ multiSelect: true,
section: 'instances',
filters: {
all: {
@@ -181,7 +261,8 @@
notification: {
poll: pollAsyncJobResult
}
- }
+ },
+ snapshot: vmSnapshotAction({ listView: true })
},
dataProvider: function(args) {
@@ -246,7 +327,6 @@
success: function(json) {
var items = json.listvirtualmachinesresponse.virtualmachine;
args.response.success({
- actionFilter: vmActionfilter,
data: items
});
}
@@ -470,68 +550,7 @@
poll: pollAsyncJobResult
}
},
- snapshot: {
- messages: {
- notification: function(args) {
- return 'label.action.vmsnapshot.create';
- }
- },
- label: 'label.action.vmsnapshot.create',
- addRow: 'false',
- createForm: {
- title: 'label.action.vmsnapshot.create',
- fields: {
- name: {
- label: 'label.name',
- isInput: true
- },
- description: {
- label: 'label.description',
- isTextarea: true
- },
- snapshotMemory: {
- label: 'label.vmsnapshot.memory',
- isBoolean: true,
- isChecked: false
- }
- }
- },
- action: function(args) {
- var array1 = [];
- array1.push("&snapshotmemory=" + (args.data.snapshotMemory == "on"));
- var displayname = args.data.name;
- if (displayname != null && displayname.length > 0) {
- array1.push("&name=" + todb(displayname));
- }
- var description = args.data.description;
- if (description != null && description.length > 0) {
- array1.push("&description=" + todb(description));
- }
- $.ajax({
- url: createURL("createVMSnapshot&virtualmachineid=" + args.context.instances[0].id + array1.join("")),
- dataType: "json",
- async: true,
- success: function(json) {
- var jid = json.createvmsnapshotresponse.jobid;
- args.response.success({
- _custom: {
- jobId: jid,
- getUpdatedItem: function(json) {
- return json.queryasyncjobresultresponse.jobresult.virtualmachine;
- },
- getActionFilter: function() {
- return vmActionfilter;
- }
- }
- });
- }
- });
-
- },
- notification: {
- poll: pollAsyncJobResult
- }
- },
+ snapshot: vmSnapshotAction(),
destroy: {
label: 'label.action.destroy.instance',
compactLabel: 'label.destroy',