diff options
author | jin xin <j00101220@huawei.com> | 2016-10-25 08:45:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@open-o.org> | 2016-10-25 08:45:12 +0000 |
commit | f11be1108c568ee3af7e4008afa167fd5fca6dc8 (patch) | |
tree | b3b0ea27f4732177d7c95fc6f17420641da5b1fb /openo-portal/portal-lifecyclemgr/src | |
parent | 194cd1911efd9e3c8ea67a2a8e7f62626106c092 (diff) | |
parent | 21f08afe440859650a44c4d18c0c4327f26487ab (diff) |
Merge "Issue#GSO-46 Add nesting service template parameters to config for GSO service" into sun
Diffstat (limited to 'openo-portal/portal-lifecyclemgr/src')
-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( |