arranging proje

This commit is contained in:
insanity
2018-05-27 18:12:20 +09:00
parent 8bc54330a6
commit 0ad9d38d49
37 changed files with 1933 additions and 2415 deletions

View File

@@ -1,2 +1 @@
<of-notification-badge [notificationPage]="notificationPage$ | async"
></of-notification-badge>
<of-notification-badge [notificationPage]="notificationPage$ | async" (select)="onSelect($event)" (viewAll)="onViewAll($event)"></of-notification-badge>

View File

@@ -1,10 +1,10 @@
import { Component, OnInit, Output, EventEmitter, Input } from '@angular/core';
import { AfterContentInit, OnDestroy } from '@angular/core/src/metadata/lifecycle_hooks';
import { AfterContentInit, OnDestroy, OnChanges, SimpleChanges } from '@angular/core/src/metadata/lifecycle_hooks';
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Domain } from '@overflow/commons-typescript/model/domain';
import * as ListStore from '../../store/notification';
import { NotificationSelector } from '../../store';
import * as NotificationEntityStore from '../../store/entity/notification';
import { NotificationEntitySelector } from '../../store/';
import { AuthSelector } from '../../../member/store';
import { Member } from '@overflow/commons-typescript/model/member';
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
@@ -16,20 +16,26 @@ import { ActivatedRoute } from '@angular/router';
selector: 'of-notification-badge-container',
templateUrl: './badge-container.component.html',
})
export class NotificationBadgeContainerComponent implements OnInit {
export class NotificationBadgeContainerComponent implements OnInit, OnChanges {
notificationPage$: Observable<Page<Notification>>;
@Output() viewAll = new EventEmitter();
@Output() select = new EventEmitter<Notification>();
constructor(
private store: Store<ListStore.State>,
private store: Store<NotificationEntityStore.State>,
private route: ActivatedRoute
) {
this.notificationPage$ = store.pipe(select(NotificationSelector.select('page')));
// this.notificationPage$ = store.pipe(select(NotificationEntitySelector.selectAll));
}
ngOnInit() {
this.getNotifications();
}
ngOnChanges(changes: SimpleChanges): void {
this.getNotifications();
}
getNotifications() {
this.store.select(AuthSelector.select('member')).subscribe(
@@ -40,7 +46,7 @@ export class NotificationBadgeContainerComponent implements OnInit {
sortCol: 'id',
sortDirection: 'descending',
};
this.store.dispatch(new ListStore.ReadAllByMember({ member, pageParams }));
this.store.dispatch(new NotificationEntityStore.ReadAllByMember({ member, pageParams }));
},
(error) => {
console.log(error);
@@ -57,7 +63,7 @@ export class NotificationBadgeContainerComponent implements OnInit {
sortCol: 'id',
sortDirection: 'descending'
};
this.store.dispatch(new ListStore.MarkAllAsRead({ member, pageParams }));
this.store.dispatch(new NotificationEntityStore.MarkAllAsRead({ member, pageParams }));
},
(error) => {
console.log(error);
@@ -65,8 +71,12 @@ export class NotificationBadgeContainerComponent implements OnInit {
);
}
notificationSelected(notification: Notification) {
// this.router.navigate([notification.url]);
alert('redirect to ' + notification.url);
onSelect(notification: Notification) {
this.select.emit(notification);
}
onViewAll() {
this.viewAll.emit();
}
}

View File

@@ -3,8 +3,8 @@ import { AfterContentInit, OnDestroy } from '@angular/core/src/metadata/lifecycl
import { Store, select } from '@ngrx/store';
import { Observable } from 'rxjs/Observable';
import { Domain } from '@overflow/commons-typescript/model/domain';
import * as ListStore from '../../store/notification';
import { NotificationSelector } from '../../store';
import * as NotificationEntityStore from '../../store/entity/notification';
import { NotificationEntitySelector } from '../../store/';
import { AuthSelector } from '../../../member/store';
import { Member } from '@overflow/commons-typescript/model/member';
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
@@ -22,10 +22,10 @@ export class NotificationListContainerComponent implements OnInit {
pageNo: number;
constructor(
private store: Store<ListStore.State>,
private store: Store<NotificationEntityStore.State>,
private route: ActivatedRoute
) {
this.notificationPage$ = store.pipe(select(NotificationSelector.select('page')));
// this.notificationPage$ = store.pipe(select(NotificationEntitySelector.selectAll));
}
ngOnInit() {
@@ -48,7 +48,7 @@ export class NotificationListContainerComponent implements OnInit {
sortCol: 'id',
sortDirection: 'descending',
};
this.store.dispatch(new ListStore.ReadAllByMember({ member, pageParams }));
this.store.dispatch(new NotificationEntityStore.ReadAllByMember({ member, pageParams }));
},
(error) => {
console.log(error);
@@ -65,7 +65,7 @@ export class NotificationListContainerComponent implements OnInit {
sortCol: 'id',
sortDirection: 'descending'
};
this.store.dispatch(new ListStore.MarkAllAsRead({ member, pageParams }));
this.store.dispatch(new NotificationEntityStore.MarkAllAsRead({ member, pageParams }));
},
(error) => {
console.log(error);