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

    
48
                                {{item['name']}}
49
                        </a>
50

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

    
70
    })
71

    
72
export class TabTableComponent {
73
    @Input() percentageName: string = "Trust";
74
    @Input() info: { "name": string, "url": string, "date": string, "percentage": number}[];//Map<string, string[]>;
75
    @Input() properties:EnvProperties;
76
    public routerHelper:RouterHelper = new RouterHelper();
77
    public searchLinkToPublication: string;
78
    public searchLinkToDataset: string;
79

    
80
    public page: number = 1;
81
    public pageSize: number = 10;
82

    
83
    constructor () {
84
    }
85

    
86
    ngOnInit() {
87
        this.searchLinkToPublication = this.properties.searchLinkToPublication;
88
        this.searchLinkToDataset = this.properties.searchLinkToDataset;
89
    }
90

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

    
99
    updatePage($event) {
100
      this.page = $event.value;
101
    }
102
}
(17-17/17)