Merge pull request #1101 from ustcweizhou/add-select-template-dropdown

[4.6] Add select template dropdown when reinstall VM

* pr/1101:
  Add select template dropdown when reinstall VM

Signed-off-by: Remi Bergsma <github@remi.nl>
This commit is contained in:
Remi Bergsma 2015-11-28 14:54:10 +01:00
commit 399d052f8d

View File

@ -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) {