From 6e5a05d5c97f96afa656596016fb11df6c222dfb Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Fri, 16 Jan 2015 13:53:19 +0100 Subject: [PATCH] Add select template dropdown when reinstall VM --- ui/scripts/instances.js | 48 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/ui/scripts/instances.js b/ui/scripts/instances.js index 5096297f5df..56d05a006b7 100644 --- a/ui/scripts/instances.js +++ b/ui/scripts/instances.js @@ -858,10 +858,56 @@ return null; } }, + createForm: { + title: 'label.reinstall.vm', + desc: 'message.reinstall.vm', + isWarning: true, + fields: { + template: { + label: 'label.select.a.template', + select: function(args) { + var data = { + templatefilter: 'featured' + }; + $.ajax({ + url: createURL('listTemplates'), + data: data, + async: false, + success: function(json) { + var templates = json.listtemplatesresponse.template; + var items = [{ + id: -1, + description: '' + }]; + $(templates).each(function() { + items.push({ + id: this.id, + description: this.name + }); + }); + args.response.success({ + data: items + }); + } + }); + } + } + } + }, action: function(args) { + var dataObj = { + virtualmachineid: args.context.instances[0].id + }; + if (args.data.template != -1) { + $.extend(dataObj, { + templateid: args.data.template + }); + } + $.ajax({ - url: createURL("restoreVirtualMachine&virtualmachineid=" + args.context.instances[0].id), + url: createURL("restoreVirtualMachine"), + data: dataObj, dataType: "json", async: true, success: function(json) {