diff options
author | Luji7 <lu.ji3@zte.com.cn> | 2016-10-25 16:26:23 +0800 |
---|---|---|
committer | Luji7 <lu.ji3@zte.com.cn> | 2016-10-25 16:26:23 +0800 |
commit | eed792fbd8c41f270de8a377005eaa8fff1908d4 (patch) | |
tree | 4e0035cd540e21cfc88524692bb3bca3548123e8 | |
parent | 06a7b9bebe691538e13edb57d309d3f33543c766 (diff) |
Issue#GSO-46 Add nesting service template parameters to config for GSO service
Change-Id: If853766873fb4e79d1d3fa562a93bca998233f91
Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
-rw-r--r-- | openo-portal/portal-lifecyclemgr/src/main/webapp/lifecyclemgr/js/gsolcm.js | 84 |
1 files changed, 81 insertions, 3 deletions
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 4b135f70..49b34e80 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 @@ -81,16 +81,94 @@ function initParameterTab() { function generateTemplateParametersComponent(templateId) { var defer = $.Deferred(); $.when( - fetchTemplateParameterDefinitions(templateId) + fetchTemplateParameterDefinitions(templateId), + fetchGsoNestingTemplateParameters(templateId) ).then( - function (templateParameterResponse) { - templateParameters = translateToTemplateParameters(templateParameterResponse.inputs); + function (templateParameterResponse, nestingTempatesParas) { + var inputParas = concat(templateParameterResponse[0].inputs, nestingTempatesParas); + templateParameters = translateToTemplateParameters(inputParas); defer.resolve(transformToComponents(templateParameters.parameters)); } ); return defer; } +function fetchGsoNestingTemplateParameters(templateId) { + var defer = $.Deferred(); + var nestingParams = []; + $.when( + fetchServiceTemplateBy(templateId) + ).then( + function(template) { + if(template.serviceType === 'GSO') { + return fetchNodeTemplates(templateId); + } + // There are no nesting template parameters for non GSO. + defer.reslove([]); + } + ).then( + function(nodeTemplates) { + var count = nodeTemplates.length; + if(count ===0) { + defer.resolve([]); + return; + } + var params = $.Deferred(); + params.progress(function(inputs) { + pushAll(nestingParams, inputs); + count--; + if(count === 0) { + defer.resolve(nestingParams); + } + }); + nodeTemplates.forEach(function(nodeTemplate) { + var nestingNodeUri = '/openoapi/catalog/v1/servicetemplate/nesting?nodeTypeIds=' + nodeTemplate.type; + $.when( + $.ajax({ + type: "GET", + url: nestingNodeUri + }) + ).then( + function(serviceTemplates) { + var oneNodeParameters = [] + serviceTemplates.forEach(function(serviceTemplate) { + pushAll(oneNodeParameters, serviceTemplate.inputs.map(function(input) { + input.name = nodeTemplate.type + '.' + input.name; + return input; + })); + }) + params.notify(oneNodeParameters); + } + ); + }); + } + ); + return defer; +} + +function fetchNodeTemplates(templateId) { + var nodeTemplateUri = '/openoapi/catalog/v1/servicetemplates/'+ templateId +'/nodetemplates'; + return $.ajax({ + type: "GET", + url: nodeTemplateUri + }); +} + +function concat(array1, array2) { + var result = []; + pushAll(result, array1); + pushAll(result, array2); + return result; +} + +function pushAll(acc, array) { + var result = acc; + array.forEach(function(element) { + result.push(element) + }) + return result; +} + function generateLocationComponent(templateId) { var defer = $.Deferred(); $.when( |