import {Component, Input, Output, EventEmitter} from '@angular/core';
import {Observable} from 'rxjs/Observable';
import {ErrorCodes} from '../../utils/properties/errorCodes';
@Component({
selector: 'search-paging',
template: `
0">
{{searchUtils.totalResults|number}} {{type}}, page {{searchUtils.page | number}} of {{(totalPages(searchUtils.totalResults)|number)}}
0 && searchUtils.status == errorCodes.LOADING">
{{oldTotalResults|number}} {{type}}, page {{searchUtils.page | number}} of {{(totalPages(oldTotalResults)|number)}}
searchUtils.size && searchUtils.status == errorCodes.LOADING">
`
})
export class SearchPagingComponent {
@Input() searchUtils;
@Input() results;
@Input() baseUrl;
@Input() type;
@Input() parameterNames:string[];
@Input() parameterValues:string[];
@Input() loadPaging: boolean = true;
@Input() oldTotalResults: number = 0;
public totalResults: number = 0;
public errorCodes:ErrorCodes = new ErrorCodes();
// @Input() totalResults:number = 0;
constructor () {}
ngOnInit() {
// this.totalResults = this.searchUtils.totalResults;
// if(!this.loadPaging && this.totalResults == 0) {
// this.totalResults = this.oldTotalResults;
// }
}
totalPages(totalResults: number): number {
let totalPages:any = totalResults/(this.searchUtils.size);
if(!(Number.isInteger(totalPages))) {
totalPages = (parseInt(totalPages, 10) + 1);
}
return totalPages;
}
}