Initial OpenECOMP policy/engine commit
[policy/engine.git] / ecomp-sdk-app / src / main / webapp / app / policyApp / controller / dashboardController.js
1 /*-
2  * ============LICENSE_START=======================================================
3  * ECOMP Policy Engine
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
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
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=========================================================
19  */
20
21 app.controller('policyDashboardHealthController', function ($scope,DashboardService,modalService, $modal){
22         $( "#dialog" ).hide();
23     $scope.pdpTableDatas = [];
24     $scope.papTableDatas = [];
25     $scope.policyActivityTableDatas = [];
26         DashboardService.getSystemAlertData().then(function(data){
27                 var j = data;
28                 $scope.data = JSON.parse(j.data);
29                 console.log($scope.data);
30                 $scope.systemAlertsTableDatas =JSON.parse($scope.data.systemAlertsTableDatas);
31         },function(error){
32                 console.log("failed");
33                 //reloadPageOnce();
34         });
35
36         DashboardService.getPAPStatusData().then(function(data){
37                 var j = data;
38                 $scope.data = JSON.parse(j.data);
39                 console.log($scope.data);
40                 $scope.papTableMapDatas =JSON.parse($scope.data.papTableDatas);
41         if($scope.papTableMapDatas != null){
42             for(i = 0; i < $scope.papTableMapDatas.length; i++){
43                 $scope.papTableDatas.push($scope.papTableMapDatas[i].map);
44             }
45         }
46         },function(error){
47                 console.log("failed");
48                 //reloadPageOnce();
49         });
50
51         DashboardService.getPDPStatusData().then(function(data){
52                 var j = data;
53                 $scope.data = JSON.parse(j.data);
54                 console.log($scope.data);
55         $scope.pdpTableMapDatas =JSON.parse($scope.data.pdpTableDatas);
56         if($scope.pdpTableMapDatas != null) {
57             for (i = 0; i < $scope.pdpTableMapDatas.length; i++) {
58                 $scope.pdpTableDatas.push($scope.pdpTableMapDatas[i].map);
59             }
60         }
61         },function(error){
62                 console.log("failed");
63                 //reloadPageOnce();
64         });
65
66         DashboardService.getPolicyActivityData().then(function(data){
67                 var j = data;
68                 $scope.data = JSON.parse(j.data);
69                 console.log($scope.data);
70                 $scope.policyActivityTableMapDatas =JSON.parse($scope.data.policyActivityTableDatas);
71         if($scope.policyActivityTableMapDatas != null) {
72             for (i = 0; i < $scope.policyActivityTableMapDatas.length; i++) {
73                 $scope.policyActivityTableDatas.push($scope.policyActivityTableMapDatas[i].map);
74             }
75         }
76         },function(error){
77                 console.log("failed");
78                 //reloadPageOnce();
79         });
80         
81         $scope.availableGridHealthDatas = {
82                         data : 'systemAlertsTableDatas',
83                             enableFiltering: true,
84                             columnDefs: [{ field: 'id'},
85                               { field: 'type'},
86                               { field: 'system'},
87                               {field: 'logtype'},
88                               {field : 'date' ,type: 'date', cellFilter: 'date:\'yyyy-MM-dd\'' },
89                               {field : 'description'}
90                           ],      
91         };
92
93         $scope.papStatusDatas = {
94                 data : 'papTableDatas',
95                 enableFiltering: true,
96                 columnDefs: [{ field: 'system'},
97                         { field: 'status'},
98                         { field: 'noOfPolicy'},
99                         {field: 'noOfConnectedTrap'}
100                 ],
101         };
102
103         $scope.pdpStatusDatas = {
104                 data : 'pdpTableDatas',
105                 enableFiltering: true,
106                 columnDefs: [{ field: 'id'},
107                         { field: 'name'},
108                         { field: 'groupname'},
109                         {field: 'status'},
110                         {field : 'description' },
111                         {field : 'permitCount'},
112                         {field : 'denyCount'},
113                         {field : 'naCount'}
114                 ],
115         };
116
117         $scope.policyActivityDatas = {
118                 data : 'policyActivityTableDatas',
119                 enableFiltering: true,
120                 columnDefs: [{ field: 'policyId'},
121                         { field: 'fireCount'},
122                         { field: 'system'}
123                 ],
124         };
125 });