import {Component, Input} from '@angular/core'; import {Router, ActivatedRoute} from '@angular/router'; import {DomSanitizer} from '@angular/platform-browser'; //Usage Example import {RouterHelper} from './routerHelper.class'; import {EnvProperties} from './properties/env-properties'; import {properties} from "../../../environments/environment"; @Component({ selector: 'paging', template: ` ` }) export class PagingFormatter { @Input() isDisabled: boolean = false; @Input() currentPage: number = 1; @Input() size: number=10; @Input() totalResults: number = 10; @Input() baseUrl:string=""; @Input() parameterNames:string[]; @Input() parameterValues:string[]; private limit: number; properties:EnvProperties; public routerHelper:RouterHelper = new RouterHelper(); constructor () { } ngOnInit() { this.properties = properties; this.limit = this.properties.pagingLimit; } getTotalPages(){ let total: number = 0; //let limit: number = 20;//OpenaireProperties.getPagingLimit(); var i:number =parseInt(''+(this.totalResults/this.size)); total = (((this.totalResults/this.size) == i )? i :(i+1)) ; if((this.currentPage == this.limit) && (total > this.limit)) { total = this.limit; } else if((this.currentPage > this.limit) && (total > this.limit)) { total = this.currentPage; } return total; } // onPage(pageNum: number){ // return this.sanitizer.bypassSecurityTrustUrl( this.baseUrl+((this.baseUrl.indexOf("?") > -1 )?'&':'?')+ "page=" + (pageNum)); // // } }