Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {RouterHelper} from '../../utils/routerHelper.class';
3
//import {PagingModule} from '../utils/paging.module';
4
import{EnvProperties} from '../../utils/properties/env-properties';
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 | number}} research results, page {{page | number}} of {{totalPages(info.length) | number}}</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%">{{percentageName}}</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
                         <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>
26
                         <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>
27
                         <span class="uk-icon" *ngIf="item['class'] == 'software'" title = "Software"  >
28
                          <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>
29
                        </span>
30
                        <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>
31
                        <!--/span-->
32
                        <!--a *ngIf="item['url'] != '' && item['name'] != ''" href="{{item['url']}}"-->
33
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'dataset'"
34
                            [queryParams]="{datasetId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataset">
35
                                {{item['name']}}
36
                        </a>
37

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

    
43
                        <a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'other'"
44
                            [queryParams]="{orpId: item.id}" routerLinkActive="router-link-active" routerLink="/search/other">
45
                                {{item['name']}}
46
                        </a>
47

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

    
53
                                {{item['name']}}
54
                        </a>
55

    
56
                        <p *ngIf="item['id'] == '' && item['name'] != ''">{{item['name']}}</p>
57
                        <span *ngIf="item['date']">
58
                            ({{item['date']}})
59
                        </span>
60
                    </td>
61
                    <td>
62
                        <div *ngIf="item['percentage'] != ''"  title="{{item['percentage']}}%" >
63
                            <div class="uk-text-center uk-text-small">{{item['percentage']}}%</div>
64
                            <progress class="uk-progress uk-margin-remove" value="{{item['percentage']}}" max="100"></progress>
65
                         </div>
66
                        <div *ngIf="item['percentage'] == ''">
67
                            <p>No {{percentageName}} available</p>
68
                        </div>
69
                    </td>
70
                </tr>
71
            </tbody>
72
        </table>
73
    `
74

    
75
    })
76

    
77
export class TabTableComponent {
78
    @Input() percentageName: string = "Trust";
79
    @Input() info: { "name": string, "id": string, "date": string, "percentage": number, "class": string}[];//Map<string, string[]>;
80
    @Input() properties:EnvProperties;
81
    public routerHelper:RouterHelper = new RouterHelper();
82
    public searchLinkToPublication: string;
83
    public searchLinkToDataset: string;
84

    
85
    public page: number = 1;
86
    public pageSize: number = 10;
87

    
88
    constructor () {
89
    }
90

    
91
    ngOnInit() {
92
        this.searchLinkToPublication = this.properties.searchLinkToPublication;
93
        this.searchLinkToDataset = this.properties.searchLinkToDataset;
94
    }
95

    
96
    totalPages(totalResults: number): number {
97
      let totalPages:any = totalResults/this.pageSize;
98
      if(!(Number.isInteger(totalPages))) {
99
          totalPages = (parseInt(totalPages, this.pageSize) + 1);
100
      }
101
      return totalPages;
102
    }
103

    
104
    updatePage($event) {
105
      this.page = $event.value;
106
    }
107
}
(18-18/18)