cloudstack 3.0 new UI - template page - from actions from listView since they are available in detailView.

This commit is contained in:
Jessica Wang 2012-01-06 15:19:29 -08:00
parent e671124930
commit 8f96a8539c
1 changed files with 1 additions and 173 deletions

View File

@ -285,179 +285,7 @@
args.complete();
}
}
},
copyTemplate: {
label: 'Copy template',
addRow: 'false',
messages: {
confirm: function(args) {
return 'Are you sure you want to copy template?';
},
notification: function(args) {
return 'Copying template';
}
},
createForm: {
title: 'Copy template',
desc: 'Please select a zone for your new template to be stored',
fields: {
destinationZoneId: {
label: 'Destination zone',
validation: { required: true },
select: function(args) {
$.ajax({
url: createURL("listZones&available=true"),
dataType: "json",
async: true,
success: function(json) {
args.response.success({
data: $.map(
$.grep(
json.listzonesresponse.zone ? json.listzonesresponse.zone : [],
function(zone) {
return zone.id != args.context.templates[0].zoneid;
}
),
function(zone) {
return {
id: zone.id,
description: zone.name
};
}
)
});
}
});
}
}
}
},
action: function(args) {
$.ajax({
url: createURL("copyTemplate&id=" + args.context.templates[0].id + "&sourcezoneid=" + args.context.templates[0].zoneid + "&destzoneid=" + args.data.destinationZoneId),
dataType: "json",
async: true,
success: function(json) {
var jid = json.copytemplateresponse.jobid;
args.response.success(
{_custom:
{jobId: jid,
getUpdatedItem: function(json) {
return {}; //nothing in this template needs to be updated
},
getActionFilter: function() {
return templateActionfilter;
}
}
}
);
}
});
},
notification: {
poll: pollAsyncJobResult
}
},
downloadTemplate: {
label: 'Download template',
messages: {
confirm: function(args) {
return 'Are you sure you want to download template ?';
},
success: function(args) {
return 'Template is being downloaded.';
},
notification: function(args) {
return 'Downloading template';
},
complete: function(args) {
var url = decodeURIComponent(args.url);
var htmlMsg = 'Please click <a href="#">00000</a> to download template';
var htmlMsg2 = htmlMsg.replace(/#/, url).replace(/00000/, url);
return htmlMsg2;
}
},
action: function(args) {
var apiCmd = "extractTemplate&mode=HTTP_DOWNLOAD&id=" + args.context.templates[0].id;
if(args.context.templates[0].zoneid != null)
apiCmd += "&zoneid=" + args.context.templates[0].zoneid;
$.ajax({
url: createURL(apiCmd),
dataType: "json",
async: true,
success: function(json) {
var jid = json.extracttemplateresponse.jobid;
args.response.success(
{_custom:
{jobId: jid,
getUpdatedItem: function(json) {
return json.queryasyncjobresultresponse.jobresult.template;
},
getActionFilter: function() {
return templateActionfilter;
}
}
}
);
}
});
},
notification: {
poll: pollAsyncJobResult
}
},
'delete': {
label: 'Delete template',
messages: {
confirm: function(args) {
return 'Are you sure you want to delete template ?';
},
success: function(args) {
return 'template is being deleted.';
},
notification: function(args) {
return 'Deleting template';
},
complete: function(args) {
return 'template has been deleted.';
}
},
action: function(args) {
var array1 = [];
if (args.context.templates[0].zoneid != null)
array1.push("&zoneid=" + args.context.templates[0].zoneid);
$.ajax({
url: createURL("deleteTemplate&id=" + args.context.templates[0].id + array1.join("")),
dataType: "json",
async: true,
success: function(json) {
var jid = json.deletetemplateresponse.jobid;
args.response.success(
{_custom:
{jobId: jid,
getUpdatedItem: function(json) {
return {}; //nothing in this template needs to be updated, in fact, this whole template has being deleted
},
getActionFilter: function() {
return templateActionfilter;
}
}
}
);
}
});
},
notification: {
poll: pollAsyncJobResult
}
}
}
},
dataProvider: function(args) {