From a5777c5b1a0b42ccdbbf7ee793b4717a118cbb84 Mon Sep 17 00:00:00 2001 From: Luji7 Date: Thu, 15 Sep 2016 00:07:33 +0800 Subject: render template parameters tab Change-Id: I093a8b6b8cc37bc3aea0b79e8e0e65277caa5c4e Signed-off-by: Luji7 --- openo-portal/portal-lifecyclemgr/js/gsolcm.js | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'openo-portal') diff --git a/openo-portal/portal-lifecyclemgr/js/gsolcm.js b/openo-portal/portal-lifecyclemgr/js/gsolcm.js index f3988a19..1a94feba 100644 --- a/openo-portal/portal-lifecyclemgr/js/gsolcm.js +++ b/openo-portal/portal-lifecyclemgr/js/gsolcm.js @@ -13,6 +13,73 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +var templateParameters = { + templateName: '', + parameters: [] +}; + +function renderTemplateParametersTab() { + templateParameters = fetchTemplateParameterDefinitions(templateParameters); + var components = transfromToComponents(templateParameters.parameters); + document.getElementById("parameterTab").innerHTML = components; +} + +function fetchTemplateParameterDefinitions(parameters) { + var serviceTemplate = parameters.name; + var currentServiceTemplate = $("#svcTempl").val(); + // Do not need to fetch template parameters if template do not change in UI. + if(serviceTemplate === currentServiceTemplate) { + return; + } + var queryParametersUri = '/openoapi/catalog/v1/servicetemplates/' + currentServiceTemplate + '/parameters'; + var inputParameters = []; + $.ajax({ + type : "GET", + async: false, + url : queryParametersUri, + contentType : "application/json", + dataType : "json", + success : function(jsonResp) { + var inputs = jsonResp.inputs; + var i; + for( i = 0; i < inputs.length; i += 1) { + inputParameters[i] = { + name: inputs[i].name, + type: inputs[i].type, + description: inputs[i].description, + defaultValue: inputs[i].defaultValue, + required: inputs[i].required, + id: 'parameter_' + i, + value: inputs[i].defaultValue + }; + } + }, + error : function(xhr, ajaxOptions, thrownError) { + alert("Error on page : " + xhr.responseText); + } + }); + return { name: currentServiceTemplate, parameters: inputParameters }; +} + +function transfromToComponents(parameters) { + var components = ''; + var i; + for( i = 0; i < parameters.length; i += 1) { + var component = '
' + + '' + + '
' + + '' + + '
'; + + components = components + component; + } + return components; +} + function createGsoServiceInstance(s1ServiceUrl, serviceInstance) { var gsoLcmUri = '/openoapi/lifecyclemgr/v1/services'; var parameter = { -- cgit 1.2.3-korg