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 app.controller('serviceDictGridController', function ($scope, PapUrlService, CLDictionaryService,modalService, $modal){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 CLDictionaryService.getServiceDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.closedLoopServiceDictionaryDatas = JSON.parse($scope.data.closedLoopServiceDictionaryDatas);
37 console.log($scope.closedLoopServiceDictionaryDatas);
39 console.log("failed");
44 $scope.serviceDictionaryGrid = {
45 data : 'closedLoopServiceDictionaryDatas',
46 enableFiltering: true,
48 field: 'id', enableFiltering: false, headerCellTemplate: '' +
49 '<button id=\'New\' ng-click="grid.appScope.createNewServiceDictWindow()" class="btn btn-success">' + 'Create</button>',
51 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editServiceDictWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
52 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteServiceDict(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
54 { field: 'serviceName', displayName : 'Service Name'},
55 { field: 'description'},
56 {field: 'userCreatedBy.userName', displayName : 'Created By'},
57 {field: 'userModifiedBy.userName', displayName : 'Modified By'},
58 {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
59 {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
63 $scope.editCLService = null;
64 $scope.createNewServiceDictWindow = function(){
65 $scope.editCLService = null;
66 var modalInstance = $modal.open({
67 backdrop: 'static', keyboard: false,
68 templateUrl : 'add_CLService_popup.html',
69 controller: 'editCLServiceController',
71 message: function () {
73 closedLoopServiceDictionaryDatas: $scope.editCLService
79 modalInstance.result.then(function(response){
80 console.log('response', response);
81 $scope.closedLoopServiceDictionaryDatas=response.closedLoopServiceDictionaryDatas;
85 $scope.editServiceDictWindow = function(closedLoopServiceDictionaryData) {
86 $scope.editCLService = closedLoopServiceDictionaryData;
87 var modalInstance = $modal.open({
88 backdrop: 'static', keyboard: false,
89 templateUrl : 'add_CLService_popup.html',
90 controller: 'editCLServiceController',
92 message: function () {
94 closedLoopServiceDictionaryData: $scope.editCLService
100 modalInstance.result.then(function(response){
101 console.log('response', response);
102 $scope.closedLoopServiceDictionaryDatas = response.closedLoopServiceDictionaryDatas;
106 $scope.deleteServiceDict = function(data) {
107 var uuu = "searchDictionary.htm";
108 var postData={data: data, type: "clService"};
109 var searchString = "\n";
114 contentType: 'application/json',
115 data: JSON.stringify(postData),
116 success : function(resultList){
117 $scope.$apply(function(){
118 $scope.list =resultList.result;});
119 $scope.searchData = JSON.stringify(resultList.result);
120 $scope.searchDatas = JSON.parse($scope.searchData);
121 $scope.success = true;
123 if($scope.searchDatas.length > 0){
124 for(i = 0 ; i < $scope.searchDatas.length; i++){
125 searchString += $scope.searchDatas[i].name + "\n";
128 searchString += "No Policies is Using this Value"
131 console.log($scope.list);
133 modalService.popupConfirmWin("Confirm","You are about to delete the Service Dictionary "+data.serviceName+". \n "+searchString+" \n Do you want to continue?",
135 var uuu = papUrl + "/ecomp/cl_dictionary/remove_Service.htm";
136 var postData={data: data};
141 contentType: 'application/json',
142 data: JSON.stringify(postData),
143 success : function(data){
144 $scope.$apply(function(){$scope.closedLoopServiceDictionaryDatas=data.closedLoopServiceDictionaryDatas;});
146 error : function(data){
148 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
154 error : function(data){
155 alert("Error while Searching.");