X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fwebapp%2Fapp%2FpolicyApp%2Fpolicy-models%2FEditor%2FPolicyTemplateController%2FDCAEMicroServicePolicyController.js;h=5ae453aef8b184adc63f68e7b4c950639a3aca06;hb=7727ac7ce0b25e07dcdc1a29962356c6bf9c94d9;hp=d0f44d46ee92f92a368530b700e73bc06fe2dca2;hpb=a330af579866dacbe595e2e4ad1dd29cd3c96945;p=policy%2Fengine.git diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js index d0f44d46e..5ae453aef 100644 --- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js +++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DCAEMicroServicePolicyController.js @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * ECOMP Policy Engine + * ONAP Policy Engine * ================================================================================ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ @@ -17,13 +17,42 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -angular.module('abs').controller('dcaeMicroServiceController', function ($scope, $window, $compile, PolicyAppService, modalService, $modal, Notification) { +angular.module('abs').controller('dcaeMicroServiceController', ['$scope', '$window', '$compile', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, $window, $compile, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) { $("#dialog").hide(); + + $scope.policyNavigator; $scope.isCheck = false; $scope.savebutton = true; - $scope.finalPath = null; + $scope.refreshCheck = false; + + if(!$scope.temp.policy.editPolicy && !$scope.temp.policy.readOnly){ + $scope.temp.policy = { + policyType : "Config", + configPolicyType : "Micro Service" + } + }; + + $scope.refresh = function(){ + if($scope.refreshCheck){ + $scope.policyNavigator.refresh(); + } + $scope.modal('createNewPolicy', true); + $scope.temp.policy = ""; + }; + + $scope.modal = function(id, hide) { + return $('#' + id).modal(hide ? 'hide' : 'show'); + }; + + $('#ttlDate').datepicker({ + dateFormat: 'dd/mm/yy', + changeMonth: true, + changeYear: true, + onSelect: function(date) { + angular.element($('#ttlDate')).triggerHandler('input'); + } + }); -// $scope.temp.policy.ttlDate = "2016-12-31"; if ($scope.temp.policy.editPolicy != undefined|| $scope.temp.policy.readOnly != undefined){ if ($scope.temp.policy.configName == undefined){ $scope.isCheck = false; @@ -34,12 +63,12 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, $scope.isCheck = false; } - PolicyAppService.getData('getDictionary/get_EcompNameDataByName').then(function (data) { + PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) { var j = data; $scope.data = JSON.parse(j.data); console.log($scope.data); - $scope.ecompNameDictionaryDatas = JSON.parse($scope.data.ecompNameDictionaryDatas); - console.log($scope.ecompNameDictionaryDatas); + $scope.onapNameDictionaryDatas = JSON.parse($scope.data.onapNameDictionaryDatas); + console.log($scope.onapNameDictionaryDatas); }, function (error) { console.log("failed"); }); @@ -150,10 +179,14 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, var addElement = parentElement.childElementCount + 1; clone.id = ''+value+'@'+addElement; clone.value = ''; + clone.className += ' child_single'; //here cloned is single element document.getElementById("div."+value).appendChild(clone); plainAttributeKeys.push(''+value+'@'+addElement); }else{ div = document.getElementById("div."+value+"@0"); + + div.className += ' children_group'; //here is div with a group of children. + var childElement = parentElement.firstElementChild; var countParent = parentElement.childElementCount; var childElementString = childElement.innerHTML; @@ -186,7 +219,6 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, plainAttributeKeys.push(inputs[i].id); } } else { -// removeValues.push(inputs[i].id); plainAttributeKeys.push(inputs[i].id); } }else { @@ -225,6 +257,12 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, $scope.removeChoice = function(value) { console.log(value); if(value != undefined){ + var c = document.getElementById("div."+value).childElementCount; + + if(c == 1){ + Notification.error("The original one is not removable."); + return; + } document.getElementById("div."+value).removeChild(document.getElementById("div."+value).lastChild); } }; @@ -282,9 +320,14 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, var plainAttributeKeys = []; $scope.dcaeModelData = data[0].dcaeModelData; $scope.dcaeJsonDate = data[0].jsonValue; + $scope.allManyTrueKeys = data[0].allManyTrueKeys; + console.log("$scope.allManyTrueKeys: " + $scope.allManyTrueKeys); + console.log("$scope.dcaeJsonDate: " + $scope.dcaeJsonDate); var attributes = $scope.dcaeModelData.attributes; var refAttributes = $scope.dcaeModelData.ref_attributes; - var subAttributes = $scope.dcaeModelData.sub_attributes; + var subAttributes = $scope.dcaeModelData.sub_attributes; + console.log("subAttributes: " + subAttributes); + console.log("refAttributes: " + refAttributes); var enumAttributes = $scope.dcaeModelData.enumValues; var annotation = $scope.dcaeModelData.annotation; var dictionary = $scope.microServiceAttributeDictionaryDatas; @@ -303,25 +346,23 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } - if (dictionary!= null || dictionary>1){ - if (dictionary!= null || dictionary.length>1){ - for (m=0; m < dictionary.length; m += 1){ - var keyCompare = dictionary[m].name; - var valueCompare = dictionary[m].value; - var valueModel = dictionary[m].modelName; - var conpairService = serviceName; - if (valueModel.includes('-v')){ - conpairService = service; - } - if(valueModel.localeCompare(conpairService) == 0){ - console.log(valueCompare); - dictionaryList.push(dictionary[m]); - if (!dictionaryNameList.includes(dictionary[m].name)){ - dictionaryNameList.push(dictionary[m].name) - } - } - } - } + if (dictionary!= null && dictionary.length>1){ + for (m=0; m < dictionary.length; m += 1){ + var keyCompare = dictionary[m].name; + var valueCompare = dictionary[m].value; + var valueModel = dictionary[m].modelName; + var conpairService = serviceName; + if (valueModel.includes('-v')){ + conpairService = service; + } + if(valueModel.localeCompare(conpairService) == 0){ + console.log(valueCompare); + dictionaryList.push(dictionary[m]); + if (!dictionaryNameList.includes(dictionary[m].name)){ + dictionaryNameList.push(dictionary[m].name) + } + } + } } $scope.temp.policy.ruleGridData = []; @@ -329,29 +370,45 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, $scope.jsonLayout($scope.dcaeJsonDate); }); + if($scope.temp.policy.editPolicy || $scope.temp.policy.readOnly){ var checkData = []; var data = []; - if($scope.temp.policy.ruleData != null){ - var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData); - propNames.forEach(function(name) { - data.push(name); - }); - for(a = 0; a < data.length; a++){ - var splitPlainAttributeKey1 = data[a].split("."); - if(splitPlainAttributeKey1[0].indexOf("@") != -1){ - var key = splitPlainAttributeKey1[0]; - checkData.push(key); - } - } - var unique = checkData.filter(onlyUnique); - for(i =0; i < unique.length; i++){ - if(unique[i].indexOf("@0") == -1){ - var finalkey = unique[i].split("@")[0]; - $scope.addNewChoice(finalkey); - } - } - } + if($scope.temp.policy.ruleData != null){ + var propNames = Object.getOwnPropertyNames($scope.temp.policy.ruleData); + propNames.forEach(function(name) { + data.push(name); + }); + + var extraElements = data; + + if(plainAttributeKeys != null){ + for(b = 0; b < plainAttributeKeys.length; b++){ // remove already populated elements from extraElements array + var newValue = plainAttributeKeys[b].split("*"); + for(a = 0; a < data.length; a++){ + if(data[a] === newValue[0]){ + extraElements.splice(a, 1); + } + } + } + + //--- populate these extral elements generated from clicking add button + for(a = 0; a < extraElements.length; a++){ + if(extraElements[a].includes("@")){ + var n = extraElements[a].lastIndexOf("@"); + var key = extraElements[a].substring(0, n+2); //include @x in key also by n+2 since x can be 1, or 2, or 3 + checkData.push(key); + } + } + var unique = checkData.filter(onlyUnique); + for(i =0; i < unique.length; i++){ + //remove @x and let addNewChoice add @1 or @2... + var newKey = unique[i].substring(0, unique[i].length-2); + $scope.addNewChoice(newKey); + } + } + } + } var ele = angular.element(document.getElementById("DynamicTemplate")); $compile(ele.contents())($scope); @@ -384,11 +441,20 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } function getList(attribute) { - + var enumName = attribute; + console.log("In getList: attribute => " + attribute); + if(attribute){ + if(attribute.includes(":")){ + enumName = attribute.split(":")[0]; + } + } var baseEnum = $scope.dcaeModelData.enumValues; - var enumList = baseEnum.split(splitEnum); + var enumList = []; + if(baseEnum != null){ + enumList = baseEnum.split(splitEnum); + } var enumAttributes; - var patternTest = new RegExp(attribute); + var patternTest = new RegExp(enumName); for (k=0; k < enumList.length; k += 1){ if(patternTest.test(enumList[k]) == true){ enumAttributes = enumList[k].trim(); @@ -399,12 +465,9 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, enumAttributes = enumAttributes.replace("[", ""); enumAttributes = enumAttributes.replace("]", ""); enumAttributes = enumAttributes.replace(/ /g, ''); - var dropListAfterCommaSplit = enumAttributes.split(splitEqual); listemunerateValues = dropListAfterCommaSplit[1].split(splitComma); - - enumKeyList.push(attribute); - + //enumKeyList.push(attribute); return listemunerateValues; } @@ -423,12 +486,13 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, return Object.prototype.toString.call(arrayTest) === '[object Array]'; } var lableList = []; - function deconstructJSON(dataTest, level , name) { var array = false; var label = level; var stringValue = "java.lang.String"; + var string = "string"; var intValue = "int"; + var integerValue = "integer"; var double = "double"; var boolean = "boolean"; var baseLevel = level; @@ -440,6 +504,7 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, for (key in dataTest) { array = isArray(dataTest[key]); console.log(key , dataTest[key]); + if (!!dataTest[key] && typeof(dataTest[key])=="object") { if (array==false && key!=="0"){ $scope.labelLayout(label, key, array ); @@ -481,16 +546,43 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, if (dataTest[key].includes('required-true')){ isRequired = true; } - console.log("attirbuteLabel = " + attirbuteLabel); + + var subAttributes = $scope.dcaeModelData.sub_attributes; + + if(subAttributes){ + var jsonObject = JSON.parse(subAttributes); + var allkeys = Object.keys(jsonObject); + if(allkeys){ + for (var k = 0; k < allkeys.length; k++) { + var keyValue = allkeys[k]; + console.log(" keyValue:jsonObject["+keyValue+ "]: " + jsonObject[keyValue]); + if(jsonObject[keyValue]){ + var tempObject = jsonObject[keyValue]; + if(tempObject && tempObject[key]){ + if (tempObject[key].includes('required-true')){ + isRequired = true; + } + } + } + } + } + } + switch (dataTest[key].split(splitcolon)[0]){ case stringValue: - $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired); + $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text"); break; + case string: + $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text"); + break; case intValue: - $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired); + $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "number"); break; + case integerValue: + $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "number"); + break; case double: - $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired); + $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "double"); break; case boolean: $scope.dropBoxLayout(attirbuteLabel, attributekey, array, dataTest[key], getBooleanList()); @@ -499,10 +591,11 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, if (dataTest[key].includes('dictionary-')){ var list = getDictionary(dataTest[key].split('dictionary-')[1]); }else{ + //--- get dropdown values from enumValues var list = getList(dataTest[key]); } - if (list.length===0){ - $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired); + if (list.length===0){ //not dropdown element + $scope.attributeBox(attributekey, array, attirbuteLabel, defaultValue, isRequired, "text"); }else{ $scope.dropBoxLayout(attirbuteLabel, attributekey, array, dataTest[key], list); } @@ -517,7 +610,7 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } - $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired){ + $scope.attributeBox = function(attibuteKey, attributeManyKey, labelValue, defaultValue, isRequired, dataType ){ $scope.temp.policy.ruleGridData.push(attibuteKey); var br = document.createElement("BR"); @@ -550,7 +643,14 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, var textField = document.createElement("INPUT"); textField.setAttribute("class" , "form-control"); - textField.setAttribute("type" , "text"); + if(dataType){ + if(dataType == "double"){ + textField.setAttribute("type" , "number"); + textField.setAttribute("step" , "any"); + }else{ + textField.setAttribute("type" , dataType); + } + } textField.setAttribute("style" , "width:300px;"); textField.setAttribute("ng-disabled" , "temp.policy.readOnly"); var checkKey; @@ -563,21 +663,26 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, var buttonaddLabel = document.createTextNode("+"); addButton.appendChild(buttonaddLabel); addButton.setAttribute("id", labelValue + attibuteKey); - addButton.setAttribute("class", "btn btn-default"); + addButton.setAttribute("class", "btn btn-add-remove"); addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + attibuteKey+'");'); addButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); var removeButton = document.createElement("BUTTON"); var buttonremoveLabel = document.createTextNode("-"); removeButton.appendChild(buttonremoveLabel); - removeButton.setAttribute("class", "btn btn-default"); + removeButton.setAttribute("class", "btn btn-add-remove"); removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue + attibuteKey+'");'); removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); document.getElementById(divID).appendChild(addButton); document.getElementById(divID).appendChild(removeButton); - document.getElementById(divID).appendChild(label); - document.getElementById(divID).appendChild(textField); - document.getElementById(divID).appendChild(br); + document.getElementById(divID).appendChild(label); + var id = "div."+labelValue+attibuteKey; + var divTag = document.createElement("div"); + divTag.setAttribute("id", id); + document.getElementById(divID).appendChild(divTag); + textField.className += ' first_child'; + divTag.appendChild(textField); document.getElementById(divID).appendChild(divTag); + }else{ checkKey = labelValue + attibuteKey; textField.setAttribute("id" , ''+labelValue +attibuteKey+''); @@ -590,6 +695,16 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } + if(divID.includes("@0") && divID.includes("div.")){ + var firstChild_Id = divID.split("@0")[0]; + var firstChild_element = document.getElementById(firstChild_Id); + if(firstChild_element){ + firstChild_element.className += ' children_group'; //here is a div with a group of children. + } + } + console.log('firstChild_Id: ' + firstChild_Id); + console.log('divID: ' + divID); + if (defaultValue.length > 0){ if(defaultValue.includes(":")){ defaultValue = defaultValue.split(":")[0]; @@ -642,18 +757,20 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, var labeltext = document.createTextNode(lableName); label.appendChild(labeltext); + + var subAttributes = $scope.dcaeModelData.sub_attributes; if(labelManyKey){ var addButton = document.createElement("BUTTON"); var buttonLabel = document.createTextNode("+"); addButton.appendChild(buttonLabel); - addButton.setAttribute("class", "btn btn-default"); + addButton.setAttribute("class", "btn btn-add-remove"); addButton.setAttribute("ng-click" , 'addNewChoice("'+labelValue + lableName+'");'); addButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); var removeButton = document.createElement("BUTTON"); var buttonremoveLabel = document.createTextNode("-"); removeButton.appendChild(buttonremoveLabel); - removeButton.setAttribute("class", "btn btn-default"); + removeButton.setAttribute("class", "btn btn-add-remove"); removeButton.setAttribute("ng-click" , 'removeChoice("'+labelValue +lableName+'");'); removeButton.setAttribute("ng-disabled" , "temp.policy.readOnly"); document.getElementById(divID).appendChild(addButton); @@ -665,17 +782,21 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, document.getElementById(divID).appendChild(divTag); var divTag = document.createElement("div"); - divTag.setAttribute("id", id +'@0'); + divTag.setAttribute("id", id +'@0'); + + divTag.className += ' children_group'; //here is div with a group of children. + document.getElementById(id).appendChild(divTag); }else{ var divTag = document.createElement("div"); divTag.setAttribute("id", "div."+labelValue+lableName); + divTag.className += ' children_group'; //here is div with a group of children. document.getElementById(divID).appendChild(label); - document.getElementById(divID).appendChild(divTag); + document.getElementById(divID).appendChild(divTag); } }; - $scope.dropBoxLayout = function(labelLevel, attributeName, many , refValue, listemunerateValues){ + $scope.dropBoxLayout = function(labelLevel, attributeName, many , refValue, listemunerateValues, isRequired){ var br = document.createElement("BR"); if (labelLevel.length < 1){ @@ -688,8 +809,30 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, var label = document.createElement("Label") if (matching.includes(attributeName)){ var labeltext = document.createTextNode(attributeName + "*!"); + label.appendChild(labeltext); }else { var labeltext = document.createTextNode(attributeName); + var isRequired = false; + var refAttributes = $scope.dcaeModelData.ref_attributes; + if(refAttributes){ + var refAttributesList = refAttributes.split(splitComma); + for (k = 0; k < refAttributesList.length; k++){ + var refAttribute = refAttributesList[k].split(splitEqual); + + if (attributeName == refAttribute[0].trim() && refAttribute[1].includes("required-true")){ + isRequired = true; + } + } + } + + if(isRequired){ + requiredLabName = attributeName+ " *"; + labeltext = document.createTextNode(requiredLabName); + }else{ + labeltext = document.createTextNode(attributeName); + } + + label.appendChild(labeltext); } label.appendChild(labeltext); @@ -698,13 +841,24 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, listField.setAttribute("style" , "width:300px;"); listField.setAttribute("ng-disabled" , "temp.policy.readOnly"); + if(isRequired){ + listField.setAttribute("required", true); + } + var optionFirst = document.createElement('option'); + optionFirst.setAttribute('value', ""); + listField.appendChild(optionFirst); + for (i=0; i < listemunerateValues.length; i += 1) { option = document.createElement('option'); option.setAttribute('value', listemunerateValues[i]); option.appendChild(document.createTextNode(listemunerateValues[i])); + option.setAttribute('value', listemunerateValues[i]); listField.appendChild(option); } - listField.setAttribute("id" , ''+ labelLevel + attributeName + '');; + listField.setAttribute("id" , ''+ labelLevel + attributeName + ''); + + enumKeyList.push(attributeName); + document.getElementById(divID).appendChild(label); document.getElementById(divID).appendChild(br); @@ -750,6 +904,11 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } $scope.savePolicy = function(policy){ + if(policy.itemContent != undefined){ + $scope.refreshCheck = true; + $scope.policyNavigator = policy.itemContent; + policy.itemContent = ""; + } $scope.savebutton = false; var splitAt = '*'; var dot ='.'; @@ -757,7 +916,7 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, if(plainAttributeKeys != null){ for(a = 0; a < plainAttributeKeys.length; a++){ var splitPlainAttributeKey = plainAttributeKeys[a].split(splitAt); - console.log(splitPlainAttributeKey[1]); + console.log("splitPlainAttributeKey: " + splitPlainAttributeKey); var searchElement = document.getElementById(splitPlainAttributeKey[0]); var key = splitPlainAttributeKey[0]; if(searchElement == null){ @@ -774,28 +933,20 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, if (elumentLocation > 1){ enumKey = keySplit[keySplit.length - 1]; } - var aWhiteSpace = " "; - if (enumKeyList.indexOf(enumKey) != -1){ - if (splitPlainAttributeKey[1].indexOf("true") !== -1){ + //check it is undefined or not + if (enumKeyList != undefined && enumKeyList.indexOf(enumKey) != -1){ + if (splitPlainAttributeKey[1]!= undefined && splitPlainAttributeKey[1].indexOf("true") !== -1){ var multiSlect = []; for ( var i = 0; i < searchElement.selectedOptions.length; i++) { multiSlect.push(searchElement.selectedOptions[i].value); } jsonPolicy[key]= multiSlect; }else{ - //set a space due to empty value caused JSON format error in PolicyRestAdapter and remove it in back-end. - if(searchElement.value == ""){ - searchElement.value = aWhiteSpace; - } console.log(" searchElement.value = > " + searchElement.value); jsonPolicy[key]= searchElement.value; } } else { if(searchElement.value != null){ - //set a default value due to empty value caused JSON format error in PolicyRestAdapter - if(searchElement.value == ""){ - searchElement.value = aWhiteSpace; - } console.log(" searchElement.value = > " + searchElement.value); jsonPolicy[key]= searchElement.value; } @@ -867,6 +1018,11 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, }else{ jsonPolicy[key]= searchElement.value; } + if(searchElement.getAttribute("required")){ + if(!searchElement.value){ + return; + } + } } else { if(searchElement.value != null){ jsonPolicy[key]= searchElement.value; @@ -881,6 +1037,32 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } } var uuu = "policyController/validate_policy.htm"; + + console.log("$scope.isCheck:" + $scope.isCheck); + + if($scope.isCheck == true){ + if(("configName" in policy) == false){ + Notification.error("Validation Failed: configName is required"); + $scope.savebutton = true; + return; + } + if(("location" in policy) == false){ + Notification.error("Validation Failed: location is required"); + $scope.savebutton = true; + return; + } + if(("uuid" in policy) == false){ + Notification.error("Validation Failed: uuid is required"); + $scope.savebutton = true; + return; + } + if(("policyScope" in policy) == false){ + Notification.error("Validation Failed: policyScope is required"); + $scope.savebutton = true; + return; + } + } + var postData={policyData: policy, policyJSON : jsonPolicy}; $.ajax({ type : 'POST', @@ -926,4 +1108,4 @@ angular.module('abs').controller('dcaeMicroServiceController', function ($scope, } return obj; } -}); \ No newline at end of file +}]); \ No newline at end of file