100 lines
4.5 KiB
TypeScript
100 lines
4.5 KiB
TypeScript
import {Component, Input} from '@angular/core';
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
|
//import {PagingModule} from '../utils/paging.module';
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
@Component({
|
|
selector: 'tabTable',
|
|
template: `
|
|
<div *ngIf="info && info.length > pageSize" class="uk-margin">
|
|
<span class="uk-text-bold">{{info.length}} research results, page {{page}} of {{totalPages(info.length)}}</span>
|
|
<paging-no-load class="uk-float-right" [currentPage]="page" [totalResults]="info.length" [size]="pageSize" (pageChange)="updatePage($event)"></paging-no-load>
|
|
</div>
|
|
|
|
<table class="uk-table">
|
|
<!--thead>
|
|
<tr>
|
|
<th>Title</th>
|
|
<th width="20%">Trust</th>
|
|
</tr>
|
|
</thead-->
|
|
<tbody>
|
|
<tr *ngFor="let item of info.slice((page-1)*pageSize, page*pageSize)" class="{{item['class']}}">
|
|
<td *ngIf="item != undefined">
|
|
<!--span *ngIf="item['class'] == 'dataset'" class="glyphicon glyphicon-star" aria-hidden="true"-->
|
|
<img *ngIf="item['class'] == 'publication'" class= "entityIcon" src="assets/publication.png" alt="(Publication)">
|
|
<img *ngIf="item['class'] == 'dataset'" class= "entityIcon" src="assets/dataset.png" alt="(Dataset)">
|
|
<img *ngIf="item['class'] == 'software'" class= "entityIcon" src="assets/dataset.png" alt="(Software)">
|
|
|
|
<!--/span-->
|
|
<!--a *ngIf="item['url'] != '' && item['name'] != ''" href="{{item['url']}}"-->
|
|
<a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'dataset'"
|
|
[queryParams]="{datasetId: item.id}" routerLinkActive="router-link-active" routerLink="/search/dataset">
|
|
{{item['name']}}
|
|
</a>
|
|
|
|
<a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'software'"
|
|
[queryParams]="{softwareId: item.id}" routerLinkActive="router-link-active" routerLink="/search/software">
|
|
{{item['name']}}
|
|
</a>
|
|
|
|
<a *ngIf="item['id'] != '' && item['name'] != '' && item['class'] == 'publication'"
|
|
[queryParams]="{articleId: item.id}" routerLinkActive="router-link-active" routerLink="/search/publication">
|
|
<!--a *ngIf="item['url'] != '' && item['name'] != '' && item['class'] == 'publication'"
|
|
href="http://astero.di.uoa.gr:3000/search/publication?articleId={{item['id']}}"-->
|
|
|
|
{{item['name']}}
|
|
</a>
|
|
|
|
<p *ngIf="item['id'] == '' && item['name'] != ''">{{item['name']}}</p>
|
|
<span *ngIf="item['date'] != ''">
|
|
({{item['date']}})
|
|
</span>
|
|
</td>
|
|
<td>
|
|
<div *ngIf="item['trust'] != ''" title="{{item['trust']}}%" >
|
|
<div class="uk-text-center">{{item['trust']}}%</div>
|
|
<progress class="uk-progress uk-margin-remove" value="{{item['trust']}}" max="100"></progress>
|
|
</div>
|
|
<div *ngIf="item['trust'] == ''">
|
|
<p>No trust available</p>
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
`
|
|
|
|
})
|
|
|
|
export class TabTableComponent {
|
|
@Input() info: { "name": string, "url": string, "date": string, "trust": number}[];//Map<string, string[]>;
|
|
@Input() properties:EnvProperties;
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
public searchLinkToPublication: string;
|
|
public searchLinkToDataset: string;
|
|
|
|
public page: number = 1;
|
|
public pageSize: number = 10;
|
|
|
|
constructor () {
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.searchLinkToPublication = this.properties.searchLinkToPublication;
|
|
this.searchLinkToDataset = this.properties.searchLinkToDataset;
|
|
}
|
|
|
|
totalPages(totalResults: number): number {
|
|
let totalPages:any = totalResults/this.pageSize;
|
|
if(!(Number.isInteger(totalPages))) {
|
|
totalPages = (parseInt(totalPages, this.pageSize) + 1);
|
|
}
|
|
return totalPages;
|
|
}
|
|
|
|
updatePage($event) {
|
|
this.page = $event.value;
|
|
}
|
|
}
|