diff --git a/src/packages/notification/component/badge/notification.component.html b/src/packages/notification/component/badge/notification.component.html
index 7b6d00a..ad19c9b 100644
--- a/src/packages/notification/component/badge/notification.component.html
+++ b/src/packages/notification/component/badge/notification.component.html
@@ -1,7 +1,7 @@
diff --git a/src/packages/notification/component/badge/notification.component.ts b/src/packages/notification/component/badge/notification.component.ts
index 9d785f0..72252df 100644
--- a/src/packages/notification/component/badge/notification.component.ts
+++ b/src/packages/notification/component/badge/notification.component.ts
@@ -21,6 +21,7 @@ export class NotificationBadgeComponent implements OnInit, AfterContentInit {
mark$ = this.detailStore.pipe(select(ReadSelector.select('notification')));
isOpen = false;
notifications: Notification[] = null;
+ badgeCount = 0;
constructor(
private router: Router,
@@ -33,6 +34,7 @@ export class NotificationBadgeComponent implements OnInit, AfterContentInit {
(page: Page) => {
if (page !== null) {
this.notifications = page.content;
+ this.getUnconfirmedCount(this.notifications);
}
},
(error: RPCError) => {
@@ -72,6 +74,16 @@ export class NotificationBadgeComponent implements OnInit, AfterContentInit {
);
}
+ getUnconfirmedCount(notifications: Notification[]) {
+ let totalCnt = 0;
+ notifications.map( function(v, i) {
+ if (v.confirmDate === null) {
+ totalCnt += 1;
+ }
+ });
+ this.badgeCount = totalCnt;
+ }
+
mark(notification: Notification, e: Event) {
this.detailStore.dispatch(new DetailStore.MarkAsRead(notification));
diff --git a/src/packages/notification/component/notification/notification.component.ts b/src/packages/notification/component/notification/notification.component.ts
index 423bfcf..8e0d7f5 100644
--- a/src/packages/notification/component/notification/notification.component.ts
+++ b/src/packages/notification/component/notification/notification.component.ts
@@ -4,7 +4,8 @@ import { Router } from '@angular/router';
import { Store, select } from '@ngrx/store';
import { RPCError } from 'packages/core/rpc/error';
import { Notification } from '../../model';
-import * as NotificationStore from '../../store/list';
+import * as DetailStore from '../../store/detail';
+import * as ListStore from '../../store/list';
import { ReadAllByMemberSelector } from '../../store';
import { AuthSelector } from 'packages/member/store';
import { Member } from '../../../member/model';
@@ -17,7 +18,7 @@ import { PageParams, Page } from 'app/commons/model';
})
export class NotificationComponent implements OnInit, AfterContentInit {
- notification$ = this.store.pipe(select(ReadAllByMemberSelector.select('page')));
+ notification$ = this.listStore.pipe(select(ReadAllByMemberSelector.select('page')));
displayedColumns = ['id', 'title', 'message', 'member'];
dataSource: MatTableDataSource;
@@ -26,7 +27,8 @@ export class NotificationComponent implements OnInit, AfterContentInit {
constructor(
private router: Router,
- private store: Store
+ private listStore: Store,
+ private detailStore: Store
) { }
ngOnInit() {
@@ -48,7 +50,7 @@ export class NotificationComponent implements OnInit, AfterContentInit {
}
getNotifications(pageIndex: number) {
- this.store.select(AuthSelector.select('member')).subscribe(
+ this.listStore.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
const pageParams: PageParams = {
pageNo: pageIndex + '',
@@ -56,7 +58,7 @@ export class NotificationComponent implements OnInit, AfterContentInit {
sortCol: 'id',
sortDirection: 'descending'
};
- this.store.dispatch(new NotificationStore.ReadAllByMember({ member, pageParams }));
+ this.listStore.dispatch(new ListStore.ReadAllByMember({ member, pageParams }));
},
(error) => {
console.log(error);
@@ -64,8 +66,9 @@ export class NotificationComponent implements OnInit, AfterContentInit {
);
}
- handleRowClick(n: Notification) {
- alert('Will redirect to ' + n.url);
+ handleRowClick(notification: Notification) {
+ this.detailStore.dispatch(new DetailStore.MarkAsRead(notification));
+ alert('Will redirect to ' + notification.url);
// this.router.navigate([n.url]);
}