You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by je...@apache.org on 2012/10/24 23:54:25 UTC

[2/2] git commit: CS-16573: cloudstack UI - upload volume, create template from volume, create template from snapshot, create volume from snapshot - encode data passed to API call.

CS-16573: cloudstack UI - upload volume, create template from volume, create template from snapshot, create volume from snapshot - encode data passed to API call.


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/145d0a7f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/145d0a7f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/145d0a7f

Branch: refs/heads/master
Commit: 145d0a7f76d7d2d423eda2b231eb66f873794535
Parents: de1fd5d
Author: Jessica Wang <je...@citrix.com>
Authored: Tue Oct 23 13:46:26 2012 -0700
Committer: Jessica Wang <je...@citrix.com>
Committed: Wed Oct 24 14:53:42 2012 -0700

----------------------------------------------------------------------
 ui/scripts/storage.js |  105 +++++++++++++++++++++----------------------
 1 files changed, 51 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/145d0a7f/ui/scripts/storage.js
----------------------------------------------------------------------
diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js
index b224abd..1a9ef0e 100644
--- a/ui/scripts/storage.js
+++ b/ui/scripts/storage.js
@@ -239,18 +239,22 @@
               },
 
               action: function(args) {
-                var array1 = [];
-                array1.push("&name=" + todb(args.data.name));
-                array1.push("&zoneId=" + args.data.availabilityZone);
-								array1.push("&format=" + args.data.format);
-								array1.push("&url=" + todb(args.data.url));
-								if(args.data.checksum != null && args.data.checksum.length > 0)
-								  array1.push("&checksum=" + todb(args.data.checksum));
+							  var data = {
+								  name: args.data.name,
+									zoneId: args.data.availabilityZone,
+									format: args.data.format,
+									url: args.data.url
+								};
+							                
+								if(args.data.checksum != null && args.data.checksum.length > 0) {
+								  $.extend(data, {
+									  checksum: args.data.checksum
+									});
+								}
                 
                 $.ajax({
-                  url: createURL("uploadVolume" + array1.join("")),
-                  dataType: "json",
-                  async: true,
+                  url: createURL('uploadVolume'),
+                  data: data,                 
                   success: function(json) {										  
 										var jid = json.uploadvolumeresponse.jobid;
 										args.response.success(
@@ -874,28 +878,24 @@
                   }
                 },
                 action: function(args) {
-                  /*
-                   var isValid = true;
-                   isValid &= validateString("Name", $thisDialog.find("#create_template_name"), $thisDialog.find("#create_template_name_errormsg"));
-                   isValid &= validateString("Display Text", $thisDialog.find("#create_template_desc"), $thisDialog.find("#create_template_desc_errormsg"));
-                   if (!isValid)
-                   return;
-                   $thisDialog.dialog("close");
-                   */
-
-                  var array1 = [];
-                  array1.push("&name=" + todb(args.data.name));
-                  array1.push("&displayText=" + todb(args.data.displayText));
-                  array1.push("&osTypeId=" + args.data.osTypeId);
-                  array1.push("&isPublic=" + (args.data.isPublic=="on"));
-                  array1.push("&passwordEnabled=" + (args.data.isPasswordEnabled=="on"));
-                  if(args.$form.find('.form-item[rel=isFeatured]').css("display") != "none")
-                      array1.push("&isfeatured=" + (args.data.isFeatured == "on"));
+                  var data = {
+									  volumeId: args.context.volumes[0].id,
+									  name: args.data.name,
+										displayText: args.data.displayText,
+										osTypeId: args.data.osTypeId,
+										isPublic: (args.data.isPublic=="on"),
+										passwordEnabled: (args.data.isPasswordEnabled=="on")
+									};
+								                 
+                  if(args.$form.find('.form-item[rel=isFeatured]').css("display") != "none") {
+									  $.extend(data, {
+										  isfeatured: (args.data.isFeatured == "on")
+										});
+									}
 
                   $.ajax({
-                    url: createURL("createTemplate&volumeId=" + args.context.volumes[0].id + array1.join("")),
-                    dataType: "json",
-                    async: true,
+                    url: createURL('createTemplate'),
+                    data: data,                    
                     success: function(json) {
                       var jid = json.createtemplateresponse.jobid;
                       args.response.success(
@@ -1251,26 +1251,18 @@
                   }
                 },
                 action: function(args) {
-                  /*
-                   var isValid = true;
-                   isValid &= validateString("Name", $thisDialog.find("#create_template_name"), $thisDialog.find("#create_template_name_errormsg"));
-                   isValid &= validateString("Display Text", $thisDialog.find("#create_template_desc"), $thisDialog.find("#create_template_desc_errormsg"));
-                   if (!isValid)
-                   return;
-                   $thisDialog.dialog("close");
-                   */
-
-                  var array1 = [];
-                  array1.push("&name=" + todb(args.data.name));
-                  array1.push("&displayText=" + todb(args.data.displayText));
-                  array1.push("&osTypeId=" + args.data.osTypeId);
-                  array1.push("&isPublic=" + (args.data.isPublic=="on"));
-                  array1.push("&passwordEnabled=" + (args.data.isPasswordEnabled=="on"));
-
+                  var data = {
+									  snapshotid: args.context.snapshots[0].id,
+										name: args.data.name,
+										displayText: args.data.displayText,
+										osTypeId: args.data.osTypeId,
+										isPublic: (args.data.isPublic=="on"),
+										passwordEnabled: (args.data.isPasswordEnabled=="on")
+									};
+								
                   $.ajax({
-                    url: createURL("createTemplate&snapshotid=" + args.context.snapshots[0].id + array1.join("")),
-                    dataType: "json",
-                    async: true,
+                    url: createURL('createTemplate'),
+                    data: data,                   
                     success: function(json) {
                       var jid = json.createtemplateresponse.jobid;
                       args.response.success(
@@ -1316,13 +1308,14 @@
                   }
                 },
                 action: function(args) {
-                  var array1 = [];
-                  array1.push("&name=" + todb(args.data.name));
+								  var data = {
+									  snapshotid: args.context.snapshots[0].id,
+										name: args.data.name
+									};								                
 
                   $.ajax({
-                    url: createURL("createVolume&snapshotid=" + args.context.snapshots[0].id + array1.join("")),
-                    dataType: "json",
-                    async: true,
+                    url: createURL('createVolume'),
+                    data: data,                    
                     success: function(json) {
                       var jid = json.createvolumeresponse.jobid;
                       args.response.success(
@@ -1464,6 +1457,7 @@
         }
       }
     }
+		allowedActions.push("createTemplate");
     return allowedActions;
   };
 
@@ -1480,6 +1474,9 @@
       allowedActions.push("createVolume");
     }
     allowedActions.push("remove");
+		
+		allowedActions.push("createVolume");
+		allowedActions.push("createTemplate");
     return allowedActions;
   }