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('psServiceDictGridController', function ($scope, PolicyScopeService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 PolicyScopeService.getPSServiceDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.psServiceDictionaryDatas = JSON.parse($scope.data.psServiceDictionaryDatas);
37 console.log($scope.psServiceDictionaryDatas);
39 console.log("failed");
43 $scope.psServiceDictionaryGrid = {
44 data : 'psServiceDictionaryDatas',
45 enableFiltering: true,
47 field: 'id', enableFiltering: false, headerCellTemplate: '' +
48 '<button id=\'New\' ng-click="grid.appScope.createNewPSServiceWindow()" class="btn btn-success">' + 'Create</button>',
50 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editPSServiceWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
51 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deletePSService(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
52 },{ field: 'name', displayName : 'Service Name'},
53 { field: 'descriptionValue' }
57 $scope.editPSService = null;
58 $scope.createNewPSServiceWindow = function(){
59 $scope.editPSService = null;
60 var modalInstance = $modal.open({
61 backdrop: 'static', keyboard: false,
62 templateUrl : 'add_PSService_popup.html',
63 controller: 'editPSServiceController',
65 message: function () {
67 psServiceDictionaryDatas: $scope.editPSService
73 modalInstance.result.then(function(response){
74 console.log('response', response);
75 $scope.psServiceDictionaryDatas=response.psServiceDictionaryDatas;
79 $scope.editPSServiceWindow = function(psServiceDictionaryData) {
80 $scope.editPSService = psServiceDictionaryData;
81 var modalInstance = $modal.open({
82 backdrop: 'static', keyboard: false,
83 templateUrl : 'add_PSService_popup.html',
84 controller: 'editPSServiceController',
86 message: function () {
88 psServiceDictionaryData: $scope.editPSService
94 modalInstance.result.then(function(response){
95 console.log('response', response);
96 $scope.psServiceDictionaryDatas = response.psServiceDictionaryDatas;
100 $scope.deletePSService = function(data) {
101 modalService.popupConfirmWin("Confirm","You are about to delete the Port List "+data.name+". Do you want to continue?",
103 var uuu = papUrl + "/ecomp/ps_dictionary/remove_PSService.htm";
104 var postData={data: data};
109 contentType: 'application/json',
110 data: JSON.stringify(postData),
111 success : function(data){
112 $scope.$apply(function(){$scope.psServiceDictionaryDatas=data.psServiceDictionaryDatas;});
114 error : function(data){
116 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);