2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
23 var editFWServiceGroupController = function ($scope, $modalInstance, message, PapUrlService, UserInfoService, FWDictionaryService, Notification){
24 if(message.serviceGroupDictionaryData==null){
25 $scope.slchoices = [];
26 $scope.label='Add Service Group'
28 $scope.label='Edit Service Group'
29 $scope.disableCd=true;
30 $scope.slchoices = [];
31 var headers = message.serviceGroupDictionaryData.serviceList;
34 if (headers.indexOf(splitEqual) >= 0) {
35 var splitValue = headers.split(splitEqual);
36 for(i = 0; i < splitValue.length; i++){
37 var key = splitValue[i];
38 $scope.slchoices.push({'id':'choice'+i+1, 'option': key});
42 $scope.slchoices.push({'id':'choice'+1, 'option': key});
48 PapUrlService.getPapUrl().then(function(data) {
50 papUrl = config.PAP_URL;
53 FWDictionaryService.getServiceListDictionaryDataByName(papUrl).then(function (data) {
55 $scope.data = JSON.parse(j.data);
56 console.log($scope.data);
57 $scope.serviceListDictionaryDatas = JSON.parse($scope.data.serviceListDictionaryDatas);
58 console.log($scope.serviceListDictionaryDatas);
60 console.log("failed");
64 /*getting user info from session*/
66 UserInfoService.getFunctionalMenuStaticDetailSession()
67 .then(function (response) {
68 loginId = response.userid;
71 $scope.editServiceGroup = message.serviceGroupDictionaryData;
73 $scope.saveFWServiceGroup = function(serviceGroupDictionaryData) {
74 var finalData = extend(serviceGroupDictionaryData, $scope.attributeDatas[0]);
75 var uuu = papUrl + "/ecomp/fw_dictionary/save_serviceGroup.htm";
76 var postData={serviceGroupDictionaryData: finalData, loginId: loginId};
81 contentType: 'application/json',
82 data: JSON.stringify(postData),
83 success : function(data){
84 $scope.$apply(function(){
85 $scope.serviceGroupDictionaryDatas=data.serviceGroupDictionaryDatas;});
86 if($scope.serviceGroupDictionaryDatas == "Duplicate"){
87 Notification.error("FW Service Group Dictionary exists with Same Group Name.")
89 console.log($scope.serviceGroupDictionaryDatas);
90 $modalInstance.close({serviceGroupDictionaryDatas:$scope.serviceGroupDictionaryDatas});
93 error : function(data){
94 alert("Error while saving.");
99 $scope.close = function() {
100 $modalInstance.close();
103 function extend(obj, src) {
104 for (var key in src) {
105 if (src.hasOwnProperty(key)) obj[key] = src[key];
112 $scope.attributeDatas = [{"attributes" : $scope.slchoices}];
113 $scope.addServiceGroupNewChoice = function() {
114 var newItemNo = $scope.slchoices.length+1;
115 $scope.slchoices.push({'id':'choice'+newItemNo});
117 $scope.removeServiceGroupChoice = function() {
118 var lastItem = $scope.slchoices.length-1;
119 $scope.slchoices.splice(lastItem);