aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuji7 <lu.ji3@zte.com.cn>2016-09-15 00:07:33 +0800
committerLuji7 <lu.ji3@zte.com.cn>2016-09-15 00:07:33 +0800
commita5777c5b1a0b42ccdbbf7ee793b4717a118cbb84 (patch)
tree81600a739eb68253854c68c1504245fde3d2ffc2
parent55c653d27f5c5042c3fb0adddce32500501e7b70 (diff)
render template parameters tab
Change-Id: I093a8b6b8cc37bc3aea0b79e8e0e65277caa5c4e Signed-off-by: Luji7 <lu.ji3@zte.com.cn>
-rw-r--r--openo-portal/portal-lifecyclemgr/js/gsolcm.js67
1 files changed, 67 insertions, 0 deletions
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 = '<div class="form-group">' +
+ '<label class="col-sm-3 control-label">' +
+ '<span>' + parameters[i].description + '</span>'+
+ generateRequiredLabel(parameters[i]) +
+ '</label>' +
+ '<div class="col-sm-7">' +
+ '<input type="text" id="'+ parameters[i].id +'" name="parameter description" class="form-control" placeholder="' +
+ parameters[i].description + '" value="'+ parameters[i].value +'" />' +
+ '</div></div>';
+
+ components = components + component;
+ }
+ return components;
+}
+
function createGsoServiceInstance(s1ServiceUrl, serviceInstance) {
var gsoLcmUri = '/openoapi/lifecyclemgr/v1/services';
var parameter = {