2 * ============LICENSE_START==========================================
4 * ===================================================================
5 * Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
6 * ===================================================================
8 * Unless otherwise specified, all software contained herein is licensed
9 * under the Apache License, Version 2.0 (the "License");
10 * you may not use this software except in compliance with the License.
11 * You may obtain a copy of the License at
13 * http://www.apache.org/licenses/LICENSE-2.0
15 * Unless required by applicable law or agreed to in writing, software
16 * distributed under the License is distributed on an "AS IS" BASIS,
17 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 * See the License for the specific language governing permissions and
19 * limitations under the License.
21 * Unless otherwise specified, all documentation contained herein is licensed
22 * under the Creative Commons License, Attribution 4.0 Intl. (the "License");
23 * you may not use this documentation except in compliance with the License.
24 * You may obtain a copy of the License at
26 * https://creativecommons.org/licenses/by/4.0/
28 * Unless required by applicable law or agreed to in writing, documentation
29 * distributed under the License is distributed on an "AS IS" BASIS,
30 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31 * See the License for the specific language governing permissions and
32 * limitations under the License.
34 * ============LICENSE_END============================================
39 import { Component, OnInit, ViewChild } from '@angular/core';
40 import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
41 import { MatTableDataSource } from '@angular/material';
42 import { MatSort, MatPaginator } from '@angular/material';
43 import { NotificationService } from '../../shared/services/index';
44 import { NewNotificationModalComponent } from './new-notification-modal/new-notification-modal.component';
45 import { ConfirmationModalComponent } from 'src/app/modals/confirmation-modal/confirmation-modal.component';
46 import { InformationModalComponent } from 'src/app/modals/information-modal/information-modal.component';
49 selector: 'app-user-notification-admin',
50 templateUrl: './user-notification-admin.component.html',
51 styleUrls: ['./user-notification-admin.component.scss']
53 export class UserNotificationAdminComponent implements OnInit {
57 tableAdminNotifItems: any = [];
58 displayedColumns: string[] = ['messageSource', 'message', 'startDateLocalTime','endDateLocalTime', 'priority', 'createdBy', 'createdTime', 'allUsersRoles', 'viewOrDelete'];
59 notificationsDataSource = new MatTableDataSource(this.tableAdminNotifItems);
60 @ViewChild(MatSort) sort: MatSort;
61 @ViewChild(MatPaginator) paginator: MatPaginator;
63 constructor(public notificationService: NotificationService, public ngbModal: NgbModal) { }
66 this.getAdminNotifications();
69 getAdminNotifications(){
70 this.notificationService.getAdminNotification()
73 if (this.result == null || this.result == 'undefined') {
74 console.log('NotificationService::getAdminNotifications Failed:::: Result or result.data is null');
76 this.tableAdminNotifItems = this.result;
77 this.populateTableData(this.tableAdminNotifItems);
81 this.openConfirmationModal('Error', error);
86 removeUserNotification(selectedAdminNotification: any){
87 let confirmationMsg = 'You are about to delete this Notification : ' + selectedAdminNotification.msgHeader+ '. Click OK to continue.';
88 this.openInformationModal("Confirmation",confirmationMsg).result.then((result) => {
89 if (result === 'Ok') {
90 selectedAdminNotification.activeYn = 'N';
91 this.notificationService.updateAdminNotification(selectedAdminNotification)
94 this.tableAdminNotifItems = [];
95 this.getAdminNotifications();
98 this.openConfirmationModal('Error', error);
103 this.openConfirmationModal('Error', resut);
109 openAddNewNotificationModal(rowData: any){
110 const modalRef = this.ngbModal.open(NewNotificationModalComponent, { windowClass: 'add-notification-modal'});
111 modalRef.componentInstance.title = 'Add a New Notification';
112 if(rowData != 'undefined' && rowData){
113 modalRef.componentInstance.selectedNotification = rowData;
114 this.isEditMode = true;
116 modalRef.componentInstance.notification = {};
117 this.isEditMode = false;
119 modalRef.componentInstance.passEntry.subscribe((receivedEntry: any) => {
121 this.tableAdminNotifItems = [];
122 this.getAdminNotifications();
127 populateTableData(notificationHistory: Array<Object>){
128 this.notificationsDataSource = new MatTableDataSource(notificationHistory);
129 this.notificationsDataSource.sort = this.sort;
130 this.notificationsDataSource.paginator = this.paginator;
133 applyFilter(filterValue: string) {
134 this.notificationsDataSource.filter = filterValue.trim().toLowerCase();
137 openConfirmationModal(_title: string, _message: string) {
138 const modalInfoRef = this.ngbModal.open(ConfirmationModalComponent);
139 modalInfoRef.componentInstance.title = _title;
140 modalInfoRef.componentInstance.message = _message;
143 openInformationModal(_title: string, _message: string){
144 const modalInfoRef = this.ngbModal.open(InformationModalComponent);
145 modalInfoRef.componentInstance.title = _title;
146 modalInfoRef.componentInstance.message = _message;