Skip to content

Commit 399d052

Browse files
committed
Merge pull request apache#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>
2 parents 48ade05 + 6e5a05d commit 399d052

1 file changed

Lines changed: 47 additions & 1 deletion

File tree

‎ui/scripts/instances.js‎

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,10 +858,56 @@
858858
return null;
859859
}
860860
},
861+
createForm: {
862+
title: 'label.reinstall.vm',
863+
desc: 'message.reinstall.vm',
864+
isWarning: true,
865+
fields: {
866+
template: {
867+
label: 'label.select.a.template',
868+
select: function(args) {
869+
var data = {
870+
templatefilter: 'featured'
871+
};
872+
$.ajax({
873+
url: createURL('listTemplates'),
874+
data: data,
875+
async: false,
876+
success: function(json) {
877+
var templates = json.listtemplatesresponse.template;
878+
var items = [{
879+
id: -1,
880+
description: ''
881+
}];
882+
$(templates).each(function() {
883+
items.push({
884+
id: this.id,
885+
description: this.name
886+
});
887+
});
888+
args.response.success({
889+
data: items
890+
});
891+
}
892+
});
893+
}
894+
}
895+
}
896+
},
861897

862898
action: function(args) {
899+
var dataObj = {
900+
virtualmachineid: args.context.instances[0].id
901+
};
902+
if (args.data.template != -1) {
903+
$.extend(dataObj, {
904+
templateid: args.data.template
905+
});
906+
}
907+
863908
$.ajax({
864-
url: createURL("restoreVirtualMachine&virtualmachineid=" + args.context.instances[0].id),
909+
url: createURL("restoreVirtualMachine"),
910+
data: dataObj,
865911
dataType: "json",
866912
async: true,
867913
success: function(json) {

0 commit comments

Comments
 (0)