From 5afff61e6fdfca17d3c1ca5c2a09cf6c72862152 Mon Sep 17 00:00:00 2001 From: dahn Date: Fri, 20 Dec 2019 14:05:09 +0100 Subject: [PATCH] create template from snapshot regression (partly reverted) (#3767) --- ui/scripts/sharedFunctions.js | 102 ++++++++++++++++++++++++++++++++++ ui/scripts/storage.js | 2 +- 2 files changed, 103 insertions(+), 1 deletion(-) diff --git a/ui/scripts/sharedFunctions.js b/ui/scripts/sharedFunctions.js index 2180f058767..d3e6fe870be 100644 --- a/ui/scripts/sharedFunctions.js +++ b/ui/scripts/sharedFunctions.js @@ -2841,6 +2841,7 @@ cloudStack.createTemplateMethod = function (isSnapshot){ isChecked: false } } + }, action: function(args) { var data = { @@ -2898,6 +2899,107 @@ cloudStack.createTemplateMethod = function (isSnapshot){ } }; }; +cloudStack.createTemplateFromSnapshotMethod = function (){ + return { + label: 'label.create.template', + messages: { + confirm: function(args) { + return 'message.create.template'; + }, + notification: function(args) { + return 'label.create.template'; + } + }, + createForm: { + title: 'label.create.template', + desc: '', + + + fields: { + name: { + label: 'label.name', + validation: { + required: true + } + }, + displayText: { + label: 'label.description', + validation: { + required: true + } + }, + osTypeId: { + label: 'label.os.type', + select: function(args) { + $.ajax({ + url: createURL("listOsTypes"), + dataType: "json", + async: true, + success: function(json) { + var ostypes = json.listostypesresponse.ostype; + var items = []; + $(ostypes).each(function() { + items.push({ + id: this.id, + description: this.description + }); + }); + args.response.success({ + data: items + }); + } + }); + } + }, + isPublic: { + label: 'label.public', + isBoolean: true + }, + isPasswordEnabled: { + label: 'label.password.enabled', + isBoolean: true + }, + isdynamicallyscalable: { + label: 'label.dynamically.scalable', + isBoolean: true + } + } + }, + action: function(args) { + var data = { + snapshotid: args.context.snapshots[0].id, + name: args.data.name, + displayText: args.data.displayText, + osTypeId: args.data.osTypeId, + isPublic: (args.data.isPublic == "on"), + passwordEnabled: (args.data.isPasswordEnabled == "on"), + isdynamicallyscalable: (args.data.isdynamicallyscalable == "on") + }; + + $.ajax({ + url: createURL('createTemplate'), + data: data, + success: function(json) { + var jid = json.createtemplateresponse.jobid; + args.response.success({ + _custom: { + jobId: jid, + getUpdatedItem: function(json) { + return {}; //nothing in this snapshot needs to be updated + }, + getActionFilter: function() { + return snapshotActionfilter; + } + } + }); + } + }); + }, + notification: { + poll: pollAsyncJobResult + } + }; +}; cloudStack.addParameterToCommandUrlParameterArrayIfValueIsNotEmpty = function(array, parameterName, value){ if (value != null && value.length > 0) { diff --git a/ui/scripts/storage.js b/ui/scripts/storage.js index a51e8f33492..ab9747990eb 100644 --- a/ui/scripts/storage.js +++ b/ui/scripts/storage.js @@ -1960,7 +1960,7 @@ detailView: { name: 'Snapshot detail', actions: { - createTemplate: cloudStack.createTemplateMethod(true), + createTemplate: cloudStack.createTemplateFromSnapshotMethod(), createVolume: { label: 'label.action.create.volume',