Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {RouterHelper} from '../../utils/routerHelper.class';
3
import {OpenaireProperties} from '../../utils/properties/openaireProperties';
4
//import {PagingModule} from '../utils/paging.module';
5

    
6
@Component({
7
    selector: 'tabTable',
8
    template: `
9
        <div *ngIf="info && info.length > pageSize" class="uk-margin">
10
          <span class="uk-text-bold">{{info.length}} research results, page {{page}} of {{totalPages(info.length)}}</span>
11
          <paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="info.length" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
12
        </div>
13

    
14
        <table class="uk-table">
15
            <!--thead>
16
                <tr>
17
                    <th>Title</th>
18
                    <th width="20%">Trust</th>
19
                </tr>
20
            </thead-->
21
            <tbody>
22
                <tr *ngFor="let item of info.slice((page-1)*pageSize, page*pageSize)" class="{{item['class']}}">
23
                    <td *ngIf="item != undefined">
24
                        <!--span *ngIf="item['class'] == 'dataset'" class="glyphicon glyphicon-star" aria-hidden="true"-->
25
                        <img *ngIf="item['class'] == 'publication'" class= "entityIcon" src="assets/publication.png" alt="(Publication)">
26
                        <img *ngIf="item['class'] == 'dataset'" class= "entityIcon" src="assets/dataset.png" alt="(Dataset)">
27
                        <img *ngIf="item['class'] == 'software'" class= "entityIcon" src="assets/dataset.png" alt="(Software)">
28

    
29
                        <!--/span-->
30
                        <!--a *ngIf="item['url'] != '' && item['name'] != ''" href="{{item['url']}}"-->
31
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'dataset'"
32
                            [queryParams]="{datasetId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataset">
33
                                {{item['name']}}
34
                        </a>
35

    
36
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'software'"
37
                            [queryParams]="{softwareId: item.id}" routerLinkActive="router-link-active" routerLink="/search/software">
38
                                {{item['name']}}
39
                        </a>
40

    
41
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'publication'"
42
                            [queryParams]="{articleId: item.id}" routerLinkActive="router-link-active" routerLink="/search/publication">
43
                        <!--a *ngIf="item['url'] != '' && item['name'] != '' && item['class'] == 'publication'"
44
                            href="http://astero.di.uoa.gr:3000/search/publication?articleId={{item['id']}}"-->
45

    
46
                                {{item['name']}}
47
                        </a>
48

    
49
                        <p *ngIf="item['id'] == '' && item['name'] != ''">{{item['name']}}</p>
50
                        <span *ngIf="item['date'] != ''">
51
                            ({{item['date']}})
52
                        </span>
53
                    </td>
54
                    <td>
55
                        <div *ngIf="item['trust'] != ''"  title="{{item['trust']}}%" >
56
                            <div class="uk-text-center">{{item['trust']}}%</div>
57
                            <progress class="uk-progress uk-margin-remove" value="{{item['trust']}}" max="100"></progress>
58
                         </div>
59
                        <div *ngIf="item['trust'] == ''">
60
                            <p>No trust available</p>
61
                        </div>
62
                    </td>
63
                </tr>
64
            </tbody>
65
        </table>
66
    `
67

    
68
    })
69

    
70
export class TabTableComponent {
71
    @Input() info: { "name": string, "url": string, "date": string, "trust": number}[];//Map<string, string[]>;
72

    
73
    public routerHelper:RouterHelper = new RouterHelper();
74
    public searchLinkToPublication: string;
75
    public searchLinkToDataset: string;
76

    
77
    public page: number = 1;
78
    public pageSize: number = 10;
79

    
80
    constructor () {
81
    }
82

    
83
    ngOnInit() {
84
        this.searchLinkToPublication = OpenaireProperties.getsearchLinkToPublication();
85
        this.searchLinkToDataset = OpenaireProperties.getsearchLinkToDataset();
86
    }
87

    
88
    totalPages(totalResults: number): number {
89
      let totalPages:any = totalResults/this.pageSize;
90
      if(!(Number.isInteger(totalPages))) {
91
          totalPages = (parseInt(totalPages, this.pageSize) + 1);
92
      }
93
      return totalPages;
94
    }
95

    
96
    updatePage($event) {
97
      this.page = $event.value;
98
    }
99
}
(17-17/17)