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=========================================================
 
  20 app.controller('vsclActionDictGridController', function ($scope, PolicyAppService, modalService, $modal){
 
  21     $( "#dialog" ).hide();
 
  23     PolicyAppService.getData('getDictionary/get_VSCLActionData').then(function (data) {
 
  25         $scope.data = JSON.parse(j.data);
 
  26         console.log($scope.data);
 
  27         $scope.vsclActionDictionaryDatas = JSON.parse($scope.data.vsclActionDictionaryDatas);
 
  28         console.log($scope.vsclActionDictionaryDatas);
 
  30         console.log("failed");
 
  33     PolicyAppService.getData('get_LockDownData').then(function(data){
 
  35                  $scope.data = JSON.parse(j.data);
 
  36                  $scope.lockdowndata = JSON.parse($scope.data.lockdowndata);
 
  37                  if($scope.lockdowndata[0].lockdown == true){
 
  38                          $scope.vsclActionDictionaryGrid.columnDefs[0].visible = false;
 
  39                          $scope.gridApi.grid.refresh();
 
  41                          $scope.vsclActionDictionaryGrid.columnDefs[0].visible = true;
 
  42                          $scope.gridApi.grid.refresh();
 
  45                  console.log("failed");
 
  48     $scope.vsclActionDictionaryGrid = {
 
  49         data : 'vsclActionDictionaryDatas',
 
  50         enableFiltering: true,
 
  51         exporterCsvFilename: 'VSCLAction.csv',
 
  53         enableSelectAll: true,
 
  55             field: 'id', enableFiltering: false, headerCellTemplate: '' +
 
  56             '<button id=\'New\' ng-click="grid.appScope.createvsclActionWindow()" class="btn btn-success">' + 'Create</button>',
 
  58             '<button  type="button"  class="btn btn-primary"  ng-click="grid.appScope.editvsclActionWindow(row.entity)"><i class="fa fa-pencil-square-o"></i></button> ' +
 
  59             '<button  type="button"  class="btn btn-danger"  ng-click="grid.appScope.deletevsclAction(row.entity)" ><i class="fa fa-trash-o"></i></button> ',  width: '8%'
 
  61             { field: 'vsclaction', displayName : 'VSCL Action', sort: { direction: 'asc', priority: 0 }},
 
  62             { field: 'description'},
 
  63             {field: 'userCreatedBy.userName', displayName : 'Created By'},
 
  64             {field: 'userModifiedBy.userName', displayName : 'Modified By'},
 
  65             {field: 'createdDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
 
  66             {field: 'modifiedDate',type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' }
 
  68         exporterMenuPdf: false,
 
  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         exporterFieldCallback: function(grid, row, col, input) {
 
  82                         if( col.name == 'createdDate' || col.name == 'modifiedDate') {
 
  83                                 var date = new Date(input);
 
  84                                 return date.toString("yyyy-MM-dd HH:MM:ss a");
 
  89         exporterPdfOrientation: 'portrait',
 
  90         exporterPdfPageSize: 'LETTER',
 
  91         exporterPdfMaxGridWidth: 500,
 
  92         exporterCsvLinkElement: angular.element(document.querySelectorAll(".custom-csv-link-location")),
 
  93         onRegisterApi: function(gridApi){
 
  94                 $scope.gridApi = gridApi;
 
  98     $scope.editvsclAction = null;
 
  99     $scope.createvsclActionWindow = function(){
 
 100         $scope.editvsclAction = null;
 
 101         var modalInstance = $modal.open({
 
 102                 backdrop: 'static', keyboard: false,
 
 103             templateUrl : 'add_vsclAction_popup.html',
 
 104             controller: 'editVsclActionController',
 
 106                 message: function () {
 
 108                         vsclActionDictionaryDatas: $scope.editvsclAction
 
 114         modalInstance.result.then(function(response){
 
 115             console.log('response', response);
 
 116             $scope.vsclActionDictionaryDatas=response.vsclActionDictionaryDatas;
 
 120     $scope.editvsclActionWindow = function(vsclActionDictionaryData) {
 
 121         $scope.editvsclAction = vsclActionDictionaryData;
 
 122         var modalInstance = $modal.open({
 
 123                 backdrop: 'static', keyboard: false,
 
 124             templateUrl : 'add_vsclAction_popup.html',
 
 125             controller: 'editVsclActionController',
 
 127                 message: function () {
 
 129                         vsclActionDictionaryData: $scope.editvsclAction
 
 135         modalInstance.result.then(function(response){
 
 136             console.log('response', response);
 
 137             $scope.vsclActionDictionaryDatas = response.vsclActionDictionaryDatas;
 
 141     $scope.success = false;
 
 142     $scope.deletevsclAction = function(data) {
 
 143         var uuu = "searchDictionary";
 
 144         var postData={data: data, type: "clVSCL"};
 
 145         var searchString = "\n";
 
 150                 contentType: 'application/json',
 
 151                 data: JSON.stringify(postData),
 
 152                 success : function(resultList){
 
 153                         $scope.$apply(function(){
 
 154                                 $scope.list =resultList.result;});
 
 155                         $scope.searchData = JSON.stringify(resultList.result);
 
 156                         $scope.searchDatas = JSON.parse($scope.searchData);        
 
 157                         $scope.success = true;
 
 159                         if($scope.searchDatas.length > 0){
 
 160                                 for(i = 0 ; i < $scope.searchDatas.length; i++){
 
 161                                         searchString += $scope.searchDatas[i] + "\n";
 
 164                                 searchString += "No Policies is Using this Value"
 
 167                         console.log($scope.list);
 
 169                                 modalService.popupConfirmWin("Confirm","You are about to delete the Vscl Action Item  "+data.vsclaction+". \n "+searchString+" \n Do you want to continue?",
 
 171                                         var uuu = "deleteDictionary/cl_dictionary/remove_VsclAction";
 
 172                                         var postData={data: data};
 
 177                                                 contentType: 'application/json',
 
 178                                                 data: JSON.stringify(postData),
 
 179                                                 success : function(data){
 
 180                                                         $scope.$apply(function(){$scope.vsclActionDictionaryDatas=data.vsclActionDictionaryDatas;});
 
 182                                                 error : function(data){
 
 184                                                         modalService.showFailure("Fail","Error while deleting: "+ data.responseText);
 
 190                 error : function(data){
 
 191                         alert("Error while Searching.");