diff options
author | Luji7 <lu.ji3@zte.com.cn> | 2016-09-15 01:04:10 +0800 |
---|---|---|
committer | Luji7 <lu.ji3@zte.com.cn> | 2016-09-15 01:04:10 +0800 |
commit | 17050c32372d6f3f9d9bec94fe7939eb3fca25d1 (patch) | |
tree | 036f73363fee630d53c000179ed1654e6738cdbb /openo-portal | |
parent | 56c2439e74a5a17a6ca864371d4c3a621be566c4 (diff) |
add create service instance event registration
Change-Id: Id41cc785f25e454b3cdf569491d69619e17cc329
Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
Diffstat (limited to 'openo-portal')
-rw-r--r-- | openo-portal/portal-lifecyclemgr/js/gsolcm.js | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/openo-portal/portal-lifecyclemgr/js/gsolcm.js b/openo-portal/portal-lifecyclemgr/js/gsolcm.js index d66df947..86cc10b0 100644 --- a/openo-portal/portal-lifecyclemgr/js/gsolcm.js +++ b/openo-portal/portal-lifecyclemgr/js/gsolcm.js @@ -24,12 +24,81 @@ var lcmHandler = function(){ 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) { + var serviceInstance = { + serviceTemplateId: $('#svcTempl').val(), + serviceName: $('#svcName').val(), + serviceDescription: $('#svcDesc').val(), + serviceParameters: collectServiceParameters(templateParameters) + } + var s1ServiceUrl = '/openoapi/servicegateway/v1/services'; + var serviceTemplate = fetchServiceTemplateBy(serviceInstance.serviceTemplateId); + if(serviceTemplate === undefined) { + return; + } + if(serviceTemplate.csarType === 'GSAR') { + serviceInstance.serviceInstanceId = createGsoServiceInstance(s1ServiceUrl, serviceInstance); + }else if(serviceTemplate.csarType === 'NSAR' || serviceTemplate.csarType === 'NFAR') { + serviceInstance.serviceInstanceId = createNfvoServiceInstance(s1ServiceUrl, serviceInstance); + }else if(serviceTemplate.csarType === 'SSAR') { + serviceInstance.serviceInstanceId = createSdnoServiceInstance(s1ServiceUrl, serviceInstance); + } } }; +function collectServiceParameters(parameters) { + var serviceParameters = {}; + var i; + for( i = 0; i < parameters.length; i += 1) { + serviceParameters[parameters.name] = $('#' + parameters[i].id).val(); + } + return serviceParameters; +} + +function fetchServiceTemplateBy(templateId) { + var serviceTemplateUri = '/openoapi/catalog/v1/servicetemplates/'+ templateId; + var template; + $.ajax({ + type : "GET", + async: false, + url : serviceTemplateUri, + contentType : "application/json", + dataType : "json", + success : function(jsonResp) { + template = { + name: jsonResp.templateName, + gsarId: jsonResp.csarId + } + }, + error : function(xhr, ajaxOptions, thrownError) { + alert("Error on page : " + xhr.responseText); + } + }); + if(template === undefined) { + return template; + } + var queryCsarUri = '/openoapi/catalog/v1/csars/' + template.gsarId; + $.ajax({ + type : "GET", + async: false, + url : queryCsarUri, + contentType : "application/json", + dataType : "json", + success : function(jsonResp) { + template.csarType = jsonResp.type + }, + error : function(xhr, ajaxOptions, thrownError) { + alert("Error on page : " + xhr.responseText); + } + }); + return template; +} + function renderTemplateParametersTab() { templateParameters = fetchTemplateParameterDefinitions(templateParameters); var components = transfromToComponents(templateParameters.parameters); @@ -92,6 +161,14 @@ function transfromToComponents(parameters) { return components; } +function generateRequiredLabel(parameter) { + var requiredLabel = ''; + if(parameter.required === 'true') { + requiredLabel = '<span class="required">*</span>'; + } + return requiredLabel; +} + function createGsoServiceInstance(s1ServiceUrl, serviceInstance) { var gsoLcmUri = '/openoapi/lifecyclemgr/v1/services'; var parameter = { |