From cce126789f4b61a074fc1467dfb5cebb39f2d460 Mon Sep 17 00:00:00 2001 From: Luji7 Date: Thu, 29 Sep 2016 18:44:33 +0800 Subject: Changes for the new portal LCM pages. Change-Id: Ibc34356a5d6e98ce8f5df6393ca124db02ebeac0 Signed-off-by: Luji7 --- .../src/main/webapp/lifecyclemgr/js/gsolcm.js | 184 ++++++++++----------- 1 file changed, 84 insertions(+), 100 deletions(-) (limited to 'openo-portal') diff --git a/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js b/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js index 42a5aa7f..bd906821 100644 --- a/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js +++ b/openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js @@ -14,31 +14,31 @@ * limitations under the License. */ var templateParameters = { - templateName: '', + changed: true, parameters: [] }; -var service_instance_insert_index = 0; - var lcmHandler = function () { this._addOwnEvents(); }; lcmHandler.prototype = { _addOwnEvents: function () { - $('a[data-toggle="tab"]').on('show.bs.tab', this.beforeParameterTabShow); $('#createNS').click(this.okAction); }, - beforeParameterTabShow: function (event) { - renderTemplateParametersTab(); - }, - okAction: function (event) { + okAction: function () { + var vimLocation = $('#vim_location').val(); + if(vimLocation == undefined || vimLocation == 'select') { + alert('Location must be selected in Template Parameters'); + return; + } + var serviceInstance = { - serviceTemplateId: $('#svcTempl').val(), + serviceTemplateId: $("#svcTempl").val(), serviceName: $('#svcName').val(), - serviceDescription: $('#svcDesc').val(), - serviceParameters: collectServiceParameters(templateParameters.parameters), - vimLocation: $('#vim_location').val() + description: $('#svcDesc').val(), + inputParameters: collectServiceParameters(templateParameters.parameters), + vimLocation: vimLocation }; var gatewayService = 'http://localhost:8080/openoapi/servicegateway/v1/services'; $.when( @@ -46,6 +46,7 @@ lcmHandler.prototype = { ).then( function(template) { serviceInstance.templateName = template.name; + serviceInstance.serviceType = template.serviceType; return createNetworkServiceInstance(template, serviceInstance, gatewayService); } ).then( @@ -57,17 +58,23 @@ lcmHandler.prototype = { } }; -function renderTemplateParametersTab() { +function initParameterTab() { + if (!templateParameters.changed) { + return; + } + var svcTempl = $("#svcTempl").val(); + if ('select' === svcTempl) { + document.getElementById("templateParameterTab").innerHTML = ''; + return; + } $.when( fetchTemplateParameterDefinitions(templateParameters), fetchVimInfo() - ).then(function(templateParameterResponse, vimsInfoResponse) { + ).then(function (templateParameterResponse, vimsInfoResponse) { templateParameters = translateToTemplateParameters(templateParameterResponse[0].inputs); var vims = translateToVimInfo(vimsInfoResponse[0]); - var components = transfromToComponents(templateParameters.parameters, vims); - - //TODO need to address the issue of the dynamic loading of parameter tab,,, - // document.getElementById("parameterTab").innerHTML = components; + var components = transformToComponents(templateParameters.parameters, vims); + document.getElementById("templateParameterTab").innerHTML = components; }); } @@ -102,7 +109,7 @@ function translateToTemplateParameters(inputs) { value: inputs[i].defaultValue }; } - return {name: $("#svcTempl").val(), parameters: inputParameters}; + return {changed: false, parameters: inputParameters}; } function translateToVimInfo(vims) { @@ -118,11 +125,11 @@ function translateToVimInfo(vims) { return result; } -function transfromToComponents(parameters, vims) { +function transformToComponents(parameters, vims) { var components = ''; var i; for (i = 0; i < parameters.length; i += 1) { - var component = '
' + + var component = '
' + '' + @@ -145,7 +152,7 @@ function generateRequiredLabel(parameter) { } function generateLocationComponent(vims) { - var component = '
' + + var component = '
' + '