Project

General

Profile

1 43959 argiro.kok
import {Component, Input, Output, EventEmitter} from '@angular/core';
2
import {Observable}       from 'rxjs/Observable';
3
4
@Component({
5
    selector: 'search-paging',
6
    template: `
7
    <div class= "searchPaging">
8 44726 argiro.kok
      <div class="text-right" *ngIf="results  && searchUtils.totalResults > searchUtils.size">
9
            <paging [currentPage]="searchUtils.page" [totalResults]="searchUtils.totalResults"  [baseUrl]="baseUrl" [size]="searchUtils.size"> </paging>
10 43959 argiro.kok
      </div>
11 44726 argiro.kok
      <div class="text-left" *ngIf="results  && searchUtils.totalResults > 0">
12
            {{searchUtils.totalResults}} documents, page {{searchUtils.page}} of {{(totalPages())}}
13 43959 argiro.kok
      </div>
14
    </div>
15
    `
16
})
17
18
export class SearchPagingComponent {
19 44726 argiro.kok
    @Input() searchUtils;
20 43959 argiro.kok
    @Input() results;
21 44726 argiro.kok
    @Input() baseUrl;
22
23
    // @Input() totalResults:number = 0;
24 43959 argiro.kok
    constructor () {
25
     }
26
27
    ngOnInit() {
28 43990 konstantin
29 43959 argiro.kok
    }
30
31 44726 argiro.kok
    totalPages(): number {
32
        let totalPages:any = this.searchUtils.totalResults/(this.searchUtils.size);
33
        if(!(Number.isInteger(totalPages))) {
34
            totalPages = (parseInt(totalPages, 10) + 1);
35 43990 konstantin
        }
36 44726 argiro.kok
        return totalPages;
37 43990 konstantin
    }
38 43959 argiro.kok
39 43990 konstantin
40 43959 argiro.kok
}