incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: CS-16573: cloudstack UI - register template - encode data passed to API call.
Date Wed, 24 Oct 2012 22:08:58 GMT
Updated Branches:
  refs/heads/master 8e2ebb26a -> 8fff59eb7


CS-16573: cloudstack UI - register template - 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/8fff59eb
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/8fff59eb
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/8fff59eb

Branch: refs/heads/master
Commit: 8fff59eb7632d35a043ed41ca350e9a1dbc9a300
Parents: 8e2ebb2
Author: Jessica Wang <jessica.wang@citrix.com>
Authored: Tue Oct 23 15:16:16 2012 -0700
Committer: Jessica Wang <jessica.wang@citrix.com>
Committed: Wed Oct 24 15:08:35 2012 -0700

----------------------------------------------------------------------
 ui/scripts/templates.js |   63 ++++++++++++++++++++++++++---------------
 1 files changed, 40 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/8fff59eb/ui/scripts/templates.js
----------------------------------------------------------------------
diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js
index 80268fd..aa6468a 100644
--- a/ui/scripts/templates.js
+++ b/ui/scripts/templates.js
@@ -286,34 +286,51 @@
               },
 
               action: function(args) {
-                var array1 = [];
-                array1.push("&name=" + todb(args.data.name));
-                array1.push("&displayText=" + todb(args.data.description));
-                array1.push("&url=" + todb(args.data.url));
-                array1.push("&zoneid=" + args.data.zone);
-                array1.push("&format=" + args.data.format);
-                array1.push("&isextractable=" + (args.data.isExtractable=="on"));
-                array1.push("&passwordEnabled=" + (args.data.isPasswordEnabled=="on"));
-                array1.push("&osTypeId=" + args.data.osTypeId);
-                array1.push("&hypervisor=" + args.data.hypervisor);
-
-                if(args.$form.find('.form-item[rel=isPublic]').css("display") != "none")
-                  array1.push("&ispublic=" + (args.data.isPublic == "on"));
-                if(args.$form.find('.form-item[rel=isFeatured]').css("display") != "none")
-                  array1.push("&isfeatured=" + (args.data.isFeatured == "on"));
+							  var data = {
+								  name: args.data.name,
+									displayText: args.data.description,
+									url: args.data.url,
+									zoneid: args.data.zone,
+									format: args.data.format,
+									isextractable: (args.data.isExtractable=="on"),
+									passwordEnabled: (args.data.isPasswordEnabled=="on"),
+									osTypeId: args.data.osTypeId,
+									hypervisor: args.data.hypervisor
+								};		
+                    
+                if(args.$form.find('.form-item[rel=isPublic]').css("display") != "none")
{
+								  $.extend(data, {
+									  ispublic: (args.data.isPublic == "on")
+									});                  
+								}
+								
+                if(args.$form.find('.form-item[rel=isFeatured]').css("display") != "none")
{
+								  $.extend(data, {
+									  isfeatured: (args.data.isFeatured == "on")
+									});		                 
+								}
 
                 //VMware only (starts here)
-                if(args.$form.find('.form-item[rel=rootDiskControllerType]').css("display")
!= "none" && args.data.rootDiskControllerType != "")
-                  array1.push("&details[0].rootDiskController=" + args.data.rootDiskControllerType);
-                if(args.$form.find('.form-item[rel=nicAdapterType]').css("display") != "none"
&& args.data.nicAdapterType != "")
-                  array1.push("&details[0].nicAdapter=" + args.data.nicAdapterType);
-                if(args.$form.find('.form-item[rel=keyboardType]').css("display") != "none"
&& args.data.keyboardType != "")
-                  array1.push("&details[0].keyboard=" + args.data.keyboardType);
+                if(args.$form.find('.form-item[rel=rootDiskControllerType]').css("display")
!= "none" && args.data.rootDiskControllerType != "") {
+								  $.extend(data, {
+									  'details[0].rootDiskController': args.data.rootDiskControllerType
+									});		
+								}
+                if(args.$form.find('.form-item[rel=nicAdapterType]').css("display") != "none"
&& args.data.nicAdapterType != "") {
+								  $.extend(data, {
+									  'details[0].nicAdapter': args.data.nicAdapterType
+									});
+								}
+                if(args.$form.find('.form-item[rel=keyboardType]').css("display") != "none"
&& args.data.keyboardType != "") {
+								  $.extend(data, {
+									  'details[0].keyboard': args.data.keyboardType
+									});                  
+								}
                 //VMware only (ends here)
 
                 $.ajax({
-                  url: createURL("registerTemplate" + array1.join("")),
-                  dataType: "json",
+                  url: createURL('registerTemplate'),
+                  data: data,
                   success: function(json) {
                     var items = json.registertemplateresponse.template;  //items might have
more than one array element if it's create templates for all zones.
                     args.response.success({data:items[0]});


Mime
View raw message