2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2018 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=========================================================
21 app.controller('policyDashboardCRUDDataController', function ($scope, PolicyAppService, modalService, $modal){
22 console.log("policyDashboardCRUDDataController called");
24 $('#dashBoardAdvanceSearch').hide();
26 $scope.papCRUDTableDatasTemp = [];
28 $scope.dashboardAdsearch = { isDelected: 'both', stage: 'both', scope: "", ttlDate_after: "", ttlDate_before: ""};
30 PolicyAppService.getData('get_DashboardPolicyCRUDData').then(function(data){
33 $scope.data = JSON.parse(j.data);
34 console.log($scope.data);
35 $scope.papStatusCRUDDatas =JSON.parse($scope.data.papStatusCRUDData);
36 if($scope.papStatusCRUDDatas != null){
37 for(i = 0; i < $scope.papStatusCRUDDatas.length; i++){
38 $scope.papCRUDTableDatasTemp.push($scope.papStatusCRUDDatas[i].map);
41 $scope.papCRUDTableDatas = $scope.papCRUDTableDatasTemp;
45 console.log("failed");
48 $scope.papCRUDStatusDatas = {
49 data : 'papCRUDTableDatas',
50 enableFiltering: true,
51 columnDefs: [{ field: 'id', displayName :'id'},
52 {field: 'scope', displayName :'Scope'},
53 {field: 'policyName', displayName :'Policy Name'},
54 {field: 'version', displayName :'Version'},
55 {field: 'stage', displayName :'Stage'},
56 {field: 'createdBy', displayName :'Created By'},
57 {field: 'deleted', displayName :'Deleted'},
58 {field: 'deleteReasonCode', displayName :'Deleted Reason'},
59 {field: 'deletedBy' , displayName :'Deleted By'},
60 {field: 'modifiedBy' , displayName :'Modified By'},
61 {field: 'createdDate', displayName :'Created Date'},
62 {field: 'modifiedDate', displayName :'Modified Date'}
64 onRegisterApi: function(gridApi){
65 $scope.gridApi = gridApi;
69 $('#ttlDate_after').datepicker({
70 dateFormat: 'yy-mm-dd',
73 onSelect: function(date) {
74 angular.element($('#ttlDate_after')).triggerHandler('input');
78 $('#ttlDate_before').datepicker({
79 dateFormat: 'yy-mm-dd',
82 onSelect: function(date) {
83 angular.element($('#ttlDate_before')).triggerHandler('input');
87 $scope.refresh = function(){
88 $scope.modal('advancedSearch', true);
89 $scope.temp.policy = "";
93 $scope.advancedSearch = function(){
95 $('#dashBoardAdvanceSearch').toggle();
96 if($('#advancedSearchArrow').hasClass('arrowdown')){
97 $('#advancedSearchArrow').removeClass("arrowdown");
98 $('#advancedSearchArrow').addClass("arrowup");
101 $('#advancedSearchArrow').removeClass("arrowup");
102 $('#advancedSearchArrow').addClass("arrowdown");
107 $scope.startAdvancedSearch = function(data){
109 console.log("startAdvancedSearch called");
110 console.log(data.isDelected);
111 console.log(data.stage);
112 console.log(data.scope);
113 console.log(data.ttlDate_after);
114 console.log(data.ttlDate_before);
116 if(data.scope == null){
120 var uuu = "dashboardController/dashboardAdvancedSearch.htm";
122 var postData={policyData: data};
127 contentType: 'application/json',
128 data: JSON.stringify(postData),
129 success : function(data){
130 console.log("dashboardAdvancedSearch data returned: " + data);
132 $scope.$apply(function(){
135 $scope.data = JSON.parse(j.data);
136 console.log($scope.data);
137 $scope.papStatusCRUDDatas =JSON.parse($scope.data.policyStatusCRUDData);
139 $scope.papCRUDTableDatasTemp = [];
141 for(i = 0; i < $scope.papStatusCRUDDatas.length; i++){
142 $scope.papCRUDTableDatasTemp.push($scope.papStatusCRUDDatas[i].map);
145 $scope.papCRUDTableDatas = $scope.papCRUDTableDatasTemp;
147 $scope.gridApi.grid.refresh();
150 error : function(data){
151 console.log("dashboardAdvancedSearch Failed: data returned as " + data);