diff --git a/ui/scripts/templates.js b/ui/scripts/templates.js index 085a3ee719a..14964c48a8e 100644 --- a/ui/scripts/templates.js +++ b/ui/scripts/templates.js @@ -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 00000 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) {