mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CS-16573: cloudstack UI - update template - encode data passed to API call.
This commit is contained in:
parent
5e451f899c
commit
ef83621c5b
@ -414,54 +414,83 @@
|
|||||||
edit: {
|
edit: {
|
||||||
label: 'label.edit',
|
label: 'label.edit',
|
||||||
action: function(args) {
|
action: function(args) {
|
||||||
var array1 = [];
|
//***** updateTemplate *****
|
||||||
array1.push("&name=" + todb(args.data.name));
|
var data = {
|
||||||
array1.push("&displaytext=" + todb(args.data.displaytext));
|
id: args.context.templates[0].id,
|
||||||
array1.push("&ostypeid=" + args.data.ostypeid);
|
zoneid: args.context.templates[0].zoneid,
|
||||||
array1.push("&passwordenabled=" + (args.data.passwordenabled=="on"));
|
name: args.data.name,
|
||||||
|
displaytext: args.data.displaytext,
|
||||||
|
ostypeid: args.data.ostypeid,
|
||||||
|
passwordenabled: (args.data.passwordenabled=="on")
|
||||||
|
};
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateTemplate&id=" + args.context.templates[0].id + "&zoneid=" + args.context.templates[0].zoneid + array1.join("")),
|
url: createURL('updateTemplate'),
|
||||||
dataType: "json",
|
data: data,
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
//API returns an incomplete embedded object (some properties are missing in the embedded template object)
|
//API returns an incomplete embedded object (some properties are missing in the embedded template object)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var array2 = [];
|
|
||||||
|
|
||||||
//array2.push("&ispublic=" + (args.data.ispublic=="on"));
|
//***** updateTemplatePermissions *****
|
||||||
if(args.data.ispublic == "on")
|
var data = {
|
||||||
array2.push("&ispublic=true");
|
id: args.context.templates[0].id,
|
||||||
else if(args.data.ispublic == "off")
|
zoneid: args.context.templates[0].zoneid
|
||||||
array2.push("&ispublic=false");
|
};
|
||||||
|
|
||||||
//if args.data.ispublic is undefined, do not pass ispublic to API call.
|
//if args.data.ispublic is undefined, do not pass ispublic to API call.
|
||||||
|
if(args.data.ispublic == "on") {
|
||||||
if(args.data.isfeatured == "on")
|
$.extend(data, {
|
||||||
array2.push("&isfeatured=true");
|
ispublic: true
|
||||||
else if(args.data.isfeatured == "off")
|
});
|
||||||
array2.push("&isfeatured=false");
|
}
|
||||||
|
else if(args.data.ispublic == "off") {
|
||||||
|
$.extend(data, {
|
||||||
|
ispublic: false
|
||||||
|
});
|
||||||
|
}
|
||||||
//if args.data.isfeatured is undefined, do not pass isfeatured to API call.
|
//if args.data.isfeatured is undefined, do not pass isfeatured to API call.
|
||||||
|
if(args.data.isfeatured == "on") {
|
||||||
if(args.data.isextractable == "on")
|
$.extend(data, {
|
||||||
array2.push("&isextractable=true");
|
isfeatured: true
|
||||||
else if(args.data.isextractable == "off")
|
});
|
||||||
array2.push("&isextractable=false");
|
}
|
||||||
|
else if(args.data.isfeatured == "off") {
|
||||||
|
$.extend(data, {
|
||||||
|
isfeatured: false
|
||||||
|
}); }
|
||||||
//if args.data.isextractable is undefined, do not pass isextractable to API call.
|
//if args.data.isextractable is undefined, do not pass isextractable to API call.
|
||||||
|
if(args.data.isextractable == "on") {
|
||||||
|
$.extend(data, {
|
||||||
|
isextractable: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else if(args.data.isextractable == "off") {
|
||||||
|
$.extend(data, {
|
||||||
|
isextractable: false
|
||||||
|
});
|
||||||
|
}
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("updateTemplatePermissions&id=" + args.context.templates[0].id + "&zoneid=" + args.context.templates[0].zoneid + array2.join("")),
|
url: createURL('updateTemplatePermissions'),
|
||||||
dataType: "json",
|
data: data,
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
//API doesn't return an embedded object
|
//API doesn't return an embedded object
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
//***** listTemplates *****
|
||||||
//So, we call listTemplates API to get a complete template object
|
//So, we call listTemplates API to get a complete template object
|
||||||
|
var data = {
|
||||||
|
id: args.context.templates[0].id,
|
||||||
|
zoneid: args.context.templates[0].zoneid,
|
||||||
|
templatefilter: 'self'
|
||||||
|
};
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: createURL("listTemplates&id=" + args.context.templates[0].id + "&zoneid=" + args.context.templates[0].zoneid + "&templatefilter=self"),
|
url: createURL('listTemplates'),
|
||||||
dataType: "json",
|
data: data,
|
||||||
async: false,
|
async: false,
|
||||||
success: function(json){
|
success: function(json){
|
||||||
var item = json.listtemplatesresponse.template;
|
var item = json.listtemplatesresponse.template;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user