[PORTAL-7] Rebase
[portal.git] / ecomp-portal-FE-common / client / app / views / notification-history / notificationhistory.controller.js
1 /*-\r
2  * ================================================================================\r
3  * ECOMP Portal\r
4  * ================================================================================\r
5  * Copyright (C) 2017 AT&T Intellectual Property\r
6  * ================================================================================\r
7  * Licensed under the Apache License, Version 2.0 (the "License");\r
8  * you may not use this file except in compliance with the License.\r
9  * You may obtain a copy of the License at\r
10  * \r
11  *      http://www.apache.org/licenses/LICENSE-2.0\r
12  * \r
13  * Unless required by applicable law or agreed to in writing, software\r
14  * distributed under the License is distributed on an "AS IS" BASIS,\r
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
16  * See the License for the specific language governing permissions and\r
17  * limitations under the License.\r
18  * ================================================================================\r
19  */\r
20 'use strict';\r
21 \r
22 (function () {\r
23 \r
24     class notificationHistoryCtrl {\r
25         constructor( $scope, $log,notificationService, confirmBoxService, $modal, ngDialog, $state) {\r
26                 \r
27                 var priorityItems={"1":"Normal","2":"Important"};\r
28                 $scope.priorityItems=priorityItems;\r
29             $scope.externalNotification="External System";\r
30                 $scope.isLoadingTable = false;\r
31             $scope.searchString = '';\r
32             $scope.notificationHistory = [];\r
33             let getNotificationHistory = () => {\r
34                 $scope.isLoadingTable = true;\r
35                 notificationService.getNotificationHistory().then(res => {\r
36                     $scope.notificationHistory = res.data;\r
37                     $scope.isLoadingTable = false;\r
38                 }).catch(err => {\r
39                     $log.error('notificationHistoryCtlr:notifSvc.getNotifHist failed: ', err);\r
40                     $scope.isLoadingTable = false;\r
41                 });\r
42             }\r
43 \r
44             getNotificationHistory();           \r
45                 \r
46             $scope.showDetailedJsonMessage=function (selectedAdminNotification) {\r
47                                  var messageObject=JSON.parse(selectedAdminNotification.msgDescription);\r
48                                  var html="";\r
49                                  html+='<p>'+'Message Source'+' : '+selectedAdminNotification.msgSource+'</p>';\r
50                                  html+='<p>'+'Message Title'+' : '+selectedAdminNotification.msgHeader+'</p>';\r
51                                   for(var field in  messageObject){\r
52                                          if(field=='eventDate'||field=='lastModifiedDate'){\r
53                                                  html+='<p>'+field+' : '+new Date(+messageObject[field])+'</p>';\r
54                                                   \r
55                                          }else{\r
56                                          html+='<p>'+field+' : '+messageObject[field]+'</p>';\r
57                                          \r
58                                          }\r
59                                  }\r
60                         \r
61                      var modalInstance = ngDialog.open({\r
62                                     templateUrl: 'app/views/user-notifications-admin/user.notifications.Json.details.modal.page.html',\r
63                                     controller: 'userNotificationCtrl',\r
64                                     resolve: {\r
65                                         message: function () {\r
66                                                 var message = {\r
67                                                            title:    '',\r
68                                                 text:    html\r
69                                                 \r
70                                                 };\r
71                                           return message;\r
72                                         },\r
73                                      \r
74                                       }\r
75                                   }); \r
76                         \r
77                                  \r
78                          };\r
79          }\r
80     }\r
81     notificationHistoryCtrl.$inject = ['$scope', '$log', 'notificationService', 'confirmBoxService', '$modal', 'ngDialog', '$state'];\r
82     angular.module('ecompApp').controller('notificationHistoryCtrl', notificationHistoryCtrl);\r
83 })();\r