Project

General

Profile

1
import {Component, Input, ViewChild} from '@angular/core';
2

    
3

    
4
@Component({
5
    selector: 'table-view',
6
    template: `
7

    
8

    
9
    <table class="uk-table uk-table-striped">
10
      <tr>
11
        <th>Name</th>
12
        <th>Type</th>
13
        <th>Country</th>
14
        <th>Institution</th>
15
        <th>Compatibility</th>
16
      </tr>
17
      <tr *ngFor="let result of datasources">
18
        <td>
19
            <a href="{{result['title'].url}}">
20
              <p *ngIf="result['title'].name != undefined && result['title'].name != ''">
21
                  {{result['title'].name}}
22
              </p>
23
              <p *ngIf="result['title'].name == undefined || result['title'].name == ''">
24
                  {{result['title'].url}}
25
              </p>
26
            </a>
27
        </td>
28
        <td> {{result['type']}}</td>
29
        <td>....</td>
30
        <td>
31
          <span *ngFor="let organization of result['organizations'] let i=index">
32
              <a *ngIf="organization.url != undefined" href="{{organization.url}}">
33
                      {{organization.name}}
34
              </a>
35
              <span *ngIf="organization.url == undefined">
36
                  {{organization.name}}
37
              </span>
38
              <span *ngIf="i < result['organizations'].length-1"> ,</span>
39
          </span>
40
        </td>
41
        <td>....</td>
42
      </tr>
43

    
44
    </table>
45

    
46

    
47
    `
48

    
49
})
50
export class DatasourceTableViewComponent {
51
  @Input() datasources =[];
52
  // private results:{name:string, type:string, organizations:string, countries:string, compatibility:string}[] = [];
53
  constructor () {
54

    
55
  }
56

    
57
  public ngOnInit() {
58
    // // var results:{name:string, type:string, organizations:string, countries:string, compatibility:string}[] = []
59
    // for(var i =0; i < this.datasources.length; i++){
60
    //   var datasource: {name:string, type:string, organizations:string, countries:string, compatibility:string} = {name:"",type:"",organizations:"", countries:"", compatibility:""};
61
    //   datasource.name = '<a href="'+this.datasources[i]['title'].url+'" >' + (this.datasources[i]['title'].name)?this.datasources[i]['title'].name:this.datasources[i]['title'].url +'</a>';
62
    //   datasource.type = this.datasources[i]['type'];
63
    //   this.results.push(datasource);
64
    // }
65
  }
66

    
67
  public ngOnDestroy() {
68

    
69
  }
70
  sort(){
71
    // objs.sort(function(a,b) {return (a.last_nom > b.last_nom) ? 1 : ((b.last_nom > a.last_nom) ? -1 : 0);} );
72
  }
73

    
74
}
(2-2/3)