2022-04-20 16:40:18 +02:00
|
|
|
import {Component, Input} from "@angular/core";
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'results-and-pages',
|
|
|
|
template: `
|
2022-07-05 00:31:56 +02:00
|
|
|
<h6 *ngIf="type && totalResults > 0" [ngClass]="customClasses">
|
2022-04-20 16:40:18 +02:00
|
|
|
<span>{{totalResults | number}}</span>
|
|
|
|
<span class="uk-text-meta uk-text-capitalize"> {{type}}, page </span>
|
2022-06-30 12:40:37 +02:00
|
|
|
<span>{{currentPage}}</span>
|
2022-04-20 16:40:18 +02:00
|
|
|
<span class="uk-text-meta"> of </span>
|
|
|
|
<span>{{getTotalPages() | number}}</span>
|
|
|
|
</h6>
|
|
|
|
`
|
|
|
|
})
|
|
|
|
|
|
|
|
export class ResultsAndPagesNumComponent {
|
|
|
|
@Input() type: string;
|
|
|
|
@Input() page: number = 1;
|
|
|
|
@Input() pageSize: number = 10;
|
2022-06-30 12:40:37 +02:00
|
|
|
@Input() totalResults: number = 0;
|
2022-04-20 16:40:18 +02:00
|
|
|
@Input() customClasses: string = "";
|
|
|
|
|
|
|
|
constructor() {}
|
2022-06-30 12:40:37 +02:00
|
|
|
|
|
|
|
get currentPage() {
|
|
|
|
if(this.page > this.getTotalPages()) {
|
|
|
|
return this.getTotalPages();
|
|
|
|
} else {
|
|
|
|
return this.page;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-20 16:40:18 +02:00
|
|
|
getTotalPages(){
|
|
|
|
let total: number;
|
|
|
|
let i= this.totalResults/this.pageSize;
|
|
|
|
let integerI=parseInt(''+i);
|
|
|
|
total = parseInt(''+((i==integerI)?i:i+1));
|
|
|
|
|
|
|
|
return total;
|
|
|
|
}
|
2022-06-30 12:40:37 +02:00
|
|
|
}
|