diff options
Diffstat (limited to 'cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/packages-dashboard/package-pagination/package-pagination.component.ts')
-rw-r--r-- | cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/packages-dashboard/package-pagination/package-pagination.component.ts | 51 |
1 files changed, 31 insertions, 20 deletions
diff --git a/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/packages-dashboard/package-pagination/package-pagination.component.ts b/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/packages-dashboard/package-pagination/package-pagination.component.ts index 49a88c6c2..49f91316b 100644 --- a/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/packages-dashboard/package-pagination/package-pagination.component.ts +++ b/cds-ui/client-frankfurt/src/app/modules/feature-modules/packages/packages-dashboard/package-pagination/package-pagination.component.ts @@ -1,30 +1,41 @@ -import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core'; -import { PackagesStore } from '../../packages.store'; +import {Component, OnInit, ChangeDetectionStrategy} from '@angular/core'; +import {PackagesStore} from '../../packages.store'; +import {map} from 'rxjs/operators'; @Component({ - selector: 'app-package-pagination', - templateUrl: './package-pagination.component.html', - styleUrls: ['./package-pagination.component.css'], + selector: 'app-package-pagination', + templateUrl: './package-pagination.component.html', + styleUrls: ['./package-pagination.component.css'], }) export class PackagePaginationComponent implements OnInit { - pageNumber = 0; - totalCount = 4; - pageSize: number; + pageNumber: number; + totalCount: number; + pageSize: number; + previousPage: number; - constructor(private packagesStore: PackagesStore) { - this.pageSize = packagesStore.pageSize; - } + constructor(private packagesStore: PackagesStore) { + this.pageSize = packagesStore.pageSize; - ngOnInit() { - } + this.packagesStore.state$ + .subscribe(state => { + this.pageNumber = state.currentPage; + this.totalCount = state.totalPackages; + }); + } + + ngOnInit() { + } - public getPageFromService(page) { - console.log('getPageFromService', page); - if (isNaN(page)) { - page = 1; - console.log('page change to first...', page); + public getPageFromService(page) { + console.log('getPageFromService', page); + if (isNaN(page)) { + page = 1; + console.log('page change to first...', page); + } + if (this.previousPage !== page) { + this.packagesStore.getPage(page - 1, this.packagesStore.pageSize); + this.previousPage = page; + } } - this.packagesStore.getPagedPackages(page - 1, this.packagesStore.pageSize); - } } |