pagination is modified

This commit is contained in:
병준 박 2019-08-19 16:22:44 +09:00
parent 0c686a458b
commit eab09924ba
4 changed files with 25 additions and 14 deletions

View File

@ -153,9 +153,9 @@
<mat-paginator
#paginator
[length]="'10'"
[length]="dataSource.page.totalElements"
[pageIndex]="0"
[pageSize]="10"
[pageSize]="20"
[pageSizeOptions]="[5, 10, 25, 100]"
>
</mat-paginator>

View File

@ -9,9 +9,11 @@ import { CollectionViewer } from '@angular/cdk/collections';
import { User } from 'src/modules/user/model/user.model';
import { UserService } from 'src/modules/user/service/user.service';
import { Page } from 'src/modules/common/data/model/page';
export class UsersDataSource extends DataSource<User> {
private filterSubject = new BehaviorSubject('');
private pageSubject = new BehaviorSubject<Page<User>>({});
constructor(
private userService: UserService,
@ -30,6 +32,14 @@ export class UsersDataSource extends DataSource<User> {
this.filterSubject.next(filter);
}
get page(): Page<User> {
return this.pageSubject.value;
}
set page(value: Page<User>) {
this.pageSubject.next(value);
}
connect(
collectionViewer: CollectionViewer
): Observable<User[] | readonly User[]> {
@ -49,6 +59,7 @@ export class UsersDataSource extends DataSource<User> {
return this.userService.getUsers().pipe(
map(page => {
this.page = page;
return page.content;
})
);

View File

@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>UCAP APM</title>
<title>Banana Sound Backend</title>
<base href="/" />
<meta charset="utf-8" />

View File

@ -13,15 +13,15 @@ export interface Pageable {
}
export interface Page<T> {
content: T[] | null;
empty: boolean;
first: boolean;
last: boolean;
number: number;
numberOfElements: number;
pageable: Pageable;
size: number;
sort: Sort;
totalElements: number;
totalPages: number;
content?: T[] | null;
empty?: boolean;
first?: boolean;
last?: boolean;
number?: number;
numberOfElements?: number;
pageable?: Pageable;
size?: number;
sort?: Sort;
totalElements?: number;
totalPages?: number;
}