Deliver centralized role management feature
[portal.git] / ecomp-portal-FE-common / client / app / views / notification-history / notificationhistory.controller.js
1 /*-
2  * ================================================================================
3  * ECOMP Portal
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property
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  * ================================================================================
19  */
20 'use strict';
21
22 (function () {
23
24     class notificationHistoryCtrl {
25         constructor( $scope, $log,notificationService, confirmBoxService, $modal, ngDialog, $state) {
26                 
27                 var priorityItems={"1":"Normal","2":"Important"};
28                 $scope.priorityItems=priorityItems;
29             $scope.externalNotification="External System";
30                 $scope.isLoadingTable = false;
31             $scope.searchString = '';
32             $scope.notificationHistory = [];
33             let getNotificationHistory = () => {
34                 $scope.isLoadingTable = true;
35                 notificationService.getNotificationHistory().then(res => {
36                     $scope.notificationHistory = res.data;
37                     $scope.isLoadingTable = false;
38                 }).catch(err => {
39                     $log.error('notificationHistoryCtlr:notifSvc.getNotifHist failed: ', err);
40                     $scope.isLoadingTable = false;
41                 });
42             }
43
44             getNotificationHistory();           
45                 
46             $scope.showDetailedJsonMessage=function (selectedAdminNotification) {
47                  notificationService.getMessageRecipients(selectedAdminNotification.notificationId).then(res =>{
48                     $scope.messageRecipients = res;
49                                  var messageObject=JSON.parse(selectedAdminNotification.msgDescription);
50                                   var modalInstance = $modal.open({
51                             templateUrl: 'app/views/user-notifications-admin/user.notifications.json.details.modal.page.html',
52                             controller: 'userNotificationCtrl',
53                             sizeClass: 'modal-large', 
54                             resolve: {
55                                                 items: function () {
56                                                         var items = {
57                                                                    title:    '',
58                                                     selectedAdminNotification:selectedAdminNotification,messageObject:messageObject,messageRecipients:$scope.messageRecipients
59                                                         
60                                                         };
61                                                   return items;
62                                                 }
63                                 }
64                         })
65                      
66          
67          }).catch(err => {
68                $log.error('userNotificationsCtrl:getMessageRecipients:: error ', err);
69                $scope.isLoadingTable = false;
70            });
71                          };
72          }
73     }
74     notificationHistoryCtrl.$inject = ['$scope', '$log', 'notificationService', 'confirmBoxService', '$modal', 'ngDialog', '$state'];
75     angular.module('ecompApp').controller('notificationHistoryCtrl', notificationHistoryCtrl);
76 })();