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('protocolListDictGridController', function ($scope, FWDictionaryService,modalService, $modal, PapUrlService){
24 $( "#dialog" ).hide();
27 PapUrlService.getPapUrl().then(function(data) {
29 papUrl = config.PAP_URL;
32 FWDictionaryService.getProtocolListDictionaryData(papUrl).then(function (data) {
34 $scope.data = JSON.parse(j.data);
35 console.log($scope.data);
36 $scope.protocolListDictionaryDatas = JSON.parse($scope.data.protocolListDictionaryDatas);
37 console.log($scope.protocolListDictionaryDatas);
39 console.log("failed");
42 FWDictionaryService.getProtocolListDictionaryData(papUrl).then(function (data) {
44 $scope.data = JSON.parse(j.data);
45 console.log($scope.data);
46 $scope.protocolListDictionaryDatas = JSON.parse($scope.data.protocolListDictionaryDatas);
47 console.log($scope.protocolListDictionaryDatas);
49 console.log("failed");
54 $scope.protocolListDictionaryGrid = {
55 data : 'protocolListDictionaryDatas',
56 enableFiltering: true,
57 exporterCsvFilename: 'ProtocolList.csv',
59 enableSelectAll: true,
61 field: 'id', enableFiltering: false, headerCellTemplate: '' +
62 '<button id=\'New\' ng-click="grid.appScope.createNewFWProtocolListWindow()" class="btn btn-success">' + 'Create</button>',
64 '<button type="button" class="btn btn-primary" ng-click="grid.appScope.editFWProtocolListWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
65 '<button type="button" class="btn btn-danger" ng-click="grid.appScope.deleteFWProtocolList(row.entity)" ><i class="fa fa-trash-o"></i></button> ', width: '8%'
66 },{ field: 'protocolName', displayName : 'Protocol Name'},
67 { field: 'description' }
69 exporterPdfDefaultStyle: {fontSize: 9},
70 exporterPdfTableStyle: {margin: [30, 30, 30, 30]},
71 exporterPdfTableHeaderStyle: {fontSize: 10, bold: true, italics: true, color: 'red'},
72 exporterPdfHeader: { text: "My Header", style: 'headerStyle' },
73 exporterPdfFooter: function ( currentPage, pageCount ) {
74 return { text: currentPage.toString() + ' of ' + pageCount.toString(), style: 'footerStyle' };
76 exporterPdfCustomFormatter: function ( docDefinition ) {
77 docDefinition.styles.headerStyle = { fontSize: 22, bold: true };
78 docDefinition.styles.footerStyle = { fontSize: 10, bold: true };
81 exporterPdfOrientation: 'portrait',
82 exporterPdfPageSize: 'LETTER',
83 exporterPdfMaxGridWidth: 500,
84 exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
85 onRegisterApi: function(gridApi){
86 $scope.gridApi = gridApi;
91 $scope.editProtocolList = null;
92 $scope.createNewFWProtocolListWindow = function(){
93 $scope.editProtocolList = null;
94 var modalInstance = $modal.open({
95 backdrop: 'static', keyboard: false,
96 templateUrl : 'add_FWProtocolList_popup.html',
97 controller: 'editFWProtocolListController',
99 message: function () {
101 protocolListDictionaryDatas: $scope.editProtocolList
107 modalInstance.result.then(function(response){
108 console.log('response', response);
109 $scope.protocolListDictionaryDatas=response.protocolListDictionaryDatas;
113 $scope.editFWProtocolListWindow = function(protocolListDictionaryData) {
114 $scope.editProtocolList = protocolListDictionaryData;
115 var modalInstance = $modal.open({
116 backdrop: 'static', keyboard: false,
117 templateUrl : 'add_FWProtocolList_popup.html',
118 controller: 'editFWProtocolListController',
120 message: function () {
122 protocolListDictionaryData: $scope.editProtocolList
128 modalInstance.result.then(function(response){
129 console.log('response', response);
130 $scope.protocolListDictionaryDatas = response.protocolListDictionaryDatas;
134 $scope.deleteFWProtocolList = function(data) {
135 modalService.popupConfirmWin("Confirm","You are about to delete the Protocol List "+data.protocolName+". Do you want to continue?",
137 var uuu = papUrl + "/ecomp/fw_dictionary/remove_protocol.htm";
138 var postData={data: data};
143 contentType: 'application/json',
144 data: JSON.stringify(postData),
145 success : function(data){
146 $scope.$apply(function(){$scope.protocolListDictionaryDatas=data.protocolListDictionaryDatas;});
148 error : function(data){
150 modalService.showFailure("Fail","Error while deleting: "+ data.responseText);