notification in progress

This commit is contained in:
insanity
2018-05-25 12:31:08 +09:00
parent d8e0420876
commit a958109e2a
32 changed files with 422 additions and 190 deletions

View File

@@ -0,0 +1,5 @@
import { NotificationListContainerComponent } from './list/list-container.component';
export const CONTAINER_COMPONENTS = [
NotificationListContainerComponent,
];

View File

@@ -0,0 +1 @@
<of-notification-list [notifications]="notifications$ | async"></of-notification-list>

View File

@@ -0,0 +1,42 @@
import { Component, OnInit } from '@angular/core';
import { AfterContentInit, OnDestroy } 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 { AuthSelector } from '../../../member/store';
import { Member } from '@overflow/commons-typescript/model/member';
import { PageParams } from '@overflow/commons-typescript/model/commons/PageParams';
@Component({
selector: 'of-notification-container',
templateUrl: './list-container.component.html',
})
export class NotificationListContainerComponent implements OnInit {
notifications$: Observable<Notification[]>;
constructor(
private store: Store<ListStore.State>,
) {
this.notifications$ = store.pipe(select(NotificationSelector.select('notifications')));
}
ngOnInit() {
this.store.select(AuthSelector.select('member')).subscribe(
(member: Member) => {
const pageParams: PageParams = {
pageNo: 0,
countPerPage: 10,
sortCol: 'id',
sortDirection: 'descending',
};
this.store.dispatch(new ListStore.ReadAllByMember({member, pageParams}));
},
(error) => {
console.log(error);
}
);
}
}