diff options
author | Luji <lu.ji3@zte.com.cn> | 2016-10-25 08:32:22 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@open-o.org> | 2016-10-25 08:32:22 +0000 |
commit | 6466fe3623423e30de0bd47fc7948be0cdbd4cb8 (patch) | |
tree | fac508acd5a17532a515d9f6cb9035f8269f7e7c | |
parent | 08f640902b64f328aea39cc86a0a2ac37594aebe (diff) | |
parent | eed792fbd8c41f270de8a377005eaa8fff1908d4 (diff) |
Merge "Issue#GSO-46 Add nesting service template parameters to config for GSO service"
-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( |