Project

General

Profile

1 61381 k.triantaf
import {Component, Input} from '@angular/core';
2
import {RouterHelper} from '../../utils/routerHelper.class';
3
import{EnvProperties} from '../../utils/properties/env-properties';
4
5
@Component({
6
    selector: 'tabTable',
7
    template: `
8
        <div *ngIf="info && info.length > pageSize" class="uk-margin">
9
          <span class="uk-text-bold">{{info.length | number}} research results, page {{page | number}} of {{totalPages(info.length) | number}}</span>
10
          <paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="info.length" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
11
        </div>
12
13
        <table class="uk-table">
14
            <!--thead>
15
                <tr>
16
                    <th>Title</th>
17
                    <th width="20%">{{percentageName}}</th>
18
                </tr>
19
            </thead-->
20
            <tbody>
21
                <tr *ngFor="let item of info.slice((page-1)*pageSize, page*pageSize)" class="{{item['class']}}">
22
                    <td *ngIf="item != undefined">
23
                        <!--span *ngIf="item['class'] == 'dataset'" class="glyphicon glyphicon-star" aria-hidden="true"-->
24
<!--                         <span *ngIf="item['class'] == 'publication'" class="uk-icon" title = "Publication"><svg height="20" ratio="1" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><rect fill="none" height="16" stroke="#000" width="12" x="3.5" y="2.5"></rect><polyline fill="none" points="5 0.5 17.5 0.5 17.5 17" stroke="#000"></polyline></svg></span>-->
25
<!--                         <span class="uk-icon"  *ngIf="item['class'] == 'dataset'" title = "Research data" ><svg height="20" ratio="1" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"><ellipse cx="10" cy="4.64" fill="none" rx="7.5" ry="3.14" stroke="#000"></ellipse><path d="M17.5,8.11 C17.5,9.85 14.14,11.25 10,11.25 C5.86,11.25 2.5,9.84 2.5,8.11" fill="none" stroke="#000"></path><path d="M17.5,11.25 C17.5,12.99 14.14,14.39 10,14.39 C5.86,14.39 2.5,12.98 2.5,11.25" fill="none" stroke="#000"></path><path d="M17.49,4.64 L17.5,14.36 C17.5,16.1 14.14,17.5 10,17.5 C5.86,17.5 2.5,16.09 2.5,14.36 L2.5,4.64" fill="none" stroke="#000"></path></svg></span>-->
26
<!--                         <span class="uk-icon" *ngIf="item['class'] == 'software'" title = "Software"  >-->
27
<!--                          <svg height="20" ratio="1" viewBox="0 0 20 20" width="20" xmlns="http://www.w3.org/2000/svg"> <circle cx="9.997" cy="10" fill="none" r="3.31" stroke="#000"></circle> <path d="M18.488,12.285 L16.205,16.237 C15.322,15.496 14.185,15.281 13.303,15.791 C12.428,16.289 12.047,17.373 12.246,18.5 L7.735,18.5 C7.938,17.374 7.553,16.299 6.684,15.791 C5.801,15.27 4.655,15.492 3.773,16.237 L1.5,12.285 C2.573,11.871 3.317,10.999 3.317,9.991 C3.305,8.98 2.573,8.121 1.5,7.716 L3.765,3.784 C4.645,4.516 5.794,4.738 6.687,4.232 C7.555,3.722 7.939,2.637 7.735,1.5 L12.263,1.5 C12.072,2.637 12.441,3.71 13.314,4.22 C14.206,4.73 15.343,4.516 16.225,3.794 L18.487,7.714 C17.404,8.117 16.661,8.988 16.67,10.009 C16.672,11.018 17.415,11.88 18.488,12.285 L18.488,12.285 Z" fill="none" stroke="#000"></path></svg>-->
28
<!--                        </span>-->
29
<!--                        <span class="uk-icon"  *ngIf="item['class'] == 'other'" title = "Other" ><svg width="20" height="20" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" ratio="1"> <rect fill="none" stroke="#000" x="3.5" y="1.5" width="13" height="17"></rect></svg></span>-->
30
                        <!--/span-->
31
                        <!--a *ngIf="item['url'] != '' && item['name'] != ''" href="{{item['url']}}"-->
32
                      <div class="uk-text-muted">
33
                        {{item['class']}}
34
                      </div>
35
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'dataset'"
36
                            [queryParams]="{datasetId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataset">
37
                                {{item['name']}}
38
                        </a>
39
40
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'software'"
41
                            [queryParams]="{softwareId: item.id}" routerLinkActive="router-link-active" routerLink="/search/software">
42
                                {{item['name']}}
43
                        </a>
44
45
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'other'"
46
                            [queryParams]="{orpId: item.id}" routerLinkActive="router-link-active" routerLink="/search/other">
47
                                {{item['name']}}
48
                        </a>
49
50
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'publication'"
51
                            [queryParams]="{articleId: item.id}" routerLinkActive="router-link-active" routerLink="/search/publication">
52
                        <!--a *ngIf="item['url'] != '' && item['name'] != '' && item['class'] == 'publication'"
53
                            href="http://astero.di.uoa.gr:3000/search/publication?articleId={{item['id']}}"-->
54
55
                                {{item['name']}}
56
                        </a>
57
58
                        <p *ngIf="item['id'] == '' && item['name'] != ''">{{item['name']}}</p>
59
                        <span *ngIf="item['date']">
60
                            ({{item['date']}})
61
                        </span>
62
                    </td>
63
                    <td>
64
                        <div *ngIf="item['percentage'] != ''"  title="{{item['percentage']}}%" >
65
                            <div class="uk-text-center uk-text-small">{{item['percentage']}}%</div>
66
                            <progress class="uk-progress uk-margin-remove" value="{{item['percentage']}}" max="100"></progress>
67
                         </div>
68
                        <div *ngIf="item['percentage'] == ''">
69
                            <p>No {{percentageName}} available</p>
70
                        </div>
71
                    </td>
72
                </tr>
73
            </tbody>
74
        </table>
75
    `
76
77
    })
78
79
export class TabTableComponent {
80
    @Input() percentageName: string = "Trust";
81
    @Input() info: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[];//Map<string, string[]>;
82
    @Input() properties:EnvProperties;
83
    public routerHelper:RouterHelper = new RouterHelper();
84
    public searchLinkToPublication: string;
85
    public searchLinkToDataset: string;
86
87
    public page: number = 1;
88
    public pageSize: number = 10;
89
90
    constructor () {
91
    }
92
93
    ngOnInit() {
94
        this.searchLinkToPublication = this.properties.searchLinkToPublication;
95
        this.searchLinkToDataset = this.properties.searchLinkToDataset;
96
    }
97
98
    totalPages(totalResults: number): number {
99
      let totalPages:any = totalResults/this.pageSize;
100
      if(!(Number.isInteger(totalPages))) {
101
          totalPages = (parseInt(totalPages, this.pageSize) + 1);
102
      }
103
      return totalPages;
104
    }
105
106
    updatePage($event) {
107
      this.page = $event.value;
108
    }
109
}