Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {CommunityInfo} from '../../openaireLibrary/connect/community/communityInfo';
3
import {EnvProperties} from "../../openaireLibrary/utils/properties/env-properties";
4
import {SearchResult} from "../../openaireLibrary/utils/entities/searchResult";
5

    
6
@Component({
7
    selector: 'results-comp',
8
    template: `      
9
    <div class="tab-header">Recent {{getEntityName(resultType, true, true)}}</div>
10
    <div *ngIf="!results && total != 0">
11
        <div *ngIf="showLoading" class="uk-animation-fade uk-width-1-1" role="alert"><span class="loading-gif uk-align-center"></span></div>
12
    </div>
13
    <div *ngIf="results != null && results.length > 0 && !showLoading">
14
      <!--<div class="uk-margin-remove-vertical uk-grid-match uk-child-width-1-1 uk-child-width-1-1@m uk-child-width-1-1@l uk-child-width-1-1@xl uk-grid-small uk-grid uk-grid-stack" uk-grid="">
15
        <li *ngFor="let item of results; let i = index">
16
         <div class="uk-first-column">
17
            <div class="el-item uk-panel">
18
              <h6 class="el-title uk-margin uk-h6 uk-text-primary uk-margin-remove-adjacent uk-margin-remove-bottom">
19
                <div *ngIf=" community != null && community.communityId != null">
20
                    <a [queryParams]="getParamId(resultType,item.id)" routerLinkActive="router-link-active" [routerLink]="'/search/'+getresultTypeLink(resultType, false)" >
21
                    {{item.title}} </a>
22
                </div>
23
                 
24
              </h6>
25
                <div *ngIf="item.accessRights" class="el-content"><span class=" uk-label  label-{{item.accessRights}}">{{item.accessRights}}</span><br></div>
26
                <div>
27
                  <span *ngIf="item.authors != null">
28
                    <span class="el-meta uk-margin uk-text-meta" *ngFor='let author of item.authors; let i = index'>
29
                      <span *ngIf="i < 10">
30
                        <span>{{author}}<span *ngIf="i < (item.authors.length-1)">;</span></span>
31
                      </span>
32
                      <span *ngIf="i == 10">...</span>
33
                    </span>
34
                  </span>
35
                  <span *ngIf="item.year !=''" class="el-meta uk-text-meta"> ({{item.year}}) </span>
36
                </div>
37
                <div class="text-justify descriptionText"> {{item.description}} </div>
38
            </div>
39
         </div>
40
        </li>
41
      </div>-->
42
        <search-result  [results]="results"
43
                        [type]="resultType"  [properties] = properties class="communityRecentResults" [showImpactFactors]="(community.communityId == 'elixir-gr')" >
44
        </search-result>
45
    </div>
46
     <div *ngIf="results != null && results.length > 0">
47
       <div class="uk-text-right">
48
         <div>
49
           <a class="el-content uk-link portal-link uk-text-capitalize" [queryParams]="{type:getresultTypeLink(resultType, true), qf:false}" routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToResults">
50
             View all {{getEntityName(resultType, true, true)}} >
51
           </a>
52
         </div>
53
       </div>
54
     </div>
55

    
56
    <div *ngIf="results != null && results.length == 0 || total == 0" class=" uk-alert uk-alert-primary"> No results available </div>
57

    
58
    `
59

    
60
})
61

    
62
export class ResultsComponent {
63

    
64
    @Input() public results : SearchResult[];
65
    @Input() public resultType: string;
66
    @Input() public params: any;
67
    @Input() public community: CommunityInfo;
68
    @Input() public total: any;
69
    @Input() showLoading: boolean = true;
70
    @Input() properties: EnvProperties;
71

    
72
    getresultTypeLink(type:string, plural:boolean){
73
        if((type == "publication" || type == "dataset") && plural){
74
            return type + "s";
75
        }
76
        return type;
77
    }
78

    
79
  public getEntityName(entityType: string, plural: boolean, full: boolean): string {
80
    if (entityType == "publication") {
81
      return "publication" + (plural ? "s" : "");
82
    } else if (entityType == "dataset") {
83
      return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
84
    } else if (entityType == "software") {
85
      return "software";
86
    } else if (entityType == "other") {
87
      return (full ? ("other research product" + (plural ? "s" : "")) : "other");
88
    } else if (entityType == "result") {
89
      return (full ? ("research outcome" + (plural ? "s" : "")) : "result");
90
    }
91
  }
92
 /*   getParamId(type:string){
93
        let param ="";
94
        if(type == "publication"){
95
            param="article";
96
        }else if(type == "other"){
97
            param="other";
98
        }else{
99
            param=type;
100
        }
101
       return param+"Id";
102
    }*/
103
}
    (1-1/1)