import { AppComponentBase } from "./app-component-base" ; import { Injector , OnInit } from '@angular/core' ; export class PagedResultDto { items : any [ ] ; totalCount : number ; } export class EntityDto { id : number ; } export class PagedRequestDto { skipCount : number ; maxResultCount : number ; } export abstract class PagedListingComponentBase < EntityDto > extends AppComponentBase implements OnInit { public pageSize : number = 10 ; public pageNumber : number = 1 ; public totalPages : number = 1 ; public totalItems : number ; public isTableLoading = false ; constructor ( injector ) { super ( injector ) ; } ngOnInit ( ) { this . refresh ( ) ; } refresh ( ) { this . getDataPage ( this . pageNumber ) ; } public showPaging ( result , pageNumber ) { this . totalPages = ( ( result . totalCount - ( result . totalCount % this . pageSize ) ) / this . pageSize ) + 1 ; this . totalItems = result . totalCount ; this . pageNumber = pageNumber ; } public getDataPage ( page ) { var req = new PagedRequestDto ( ) ; req . maxResultCount = this . pageSize ; req . skipCount = ( page - 1 ) * this . pageSize ; this . isTableLoading = true ; this . list ( req , page , ( ) => { this . isTableLoading = false ; } ) ; } protected abstract list ( request , pageNumber , finishedCallback ) ; protected abstract delete ( entity ) ; }