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