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">
14
      <div class="uk-text-right">
15
        <div>
16
          <a class="el-content uk-button uk-button-text" [queryParams]="{type:getresultTypeLink(resultType, true), qf:false}" routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToResults">
17
            View all {{getEntityName(resultType, true, true)}}
18
          </a>
19
        </div>
20
      </div>
21
    </div>
22
    <div *ngIf="results != null && results.length > 0 && !showLoading">
23
      <!--<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="">
24
        <li *ngFor="let item of results; let i = index">
25
         <div class="uk-first-column">
26
            <div class="el-item uk-panel">
27
              <h6 class="el-title uk-margin uk-h6 uk-text-primary uk-margin-remove-adjacent uk-margin-remove-bottom">
28
                <div *ngIf=" community != null && community.communityId != null">
29
                    <a [queryParams]="getParamId(resultType,item.id)" routerLinkActive="router-link-active" [routerLink]="'/search/'+getresultTypeLink(resultType, false)" >
30
                    {{item.title}} </a>
31
                </div>
32
                 
33
              </h6>
34
                <div *ngIf="item.accessRights" class="el-content"><span class=" uk-label  label-{{item.accessRights}}">{{item.accessRights}}</span><br></div>
35
                <div>
36
                  <span *ngIf="item.authors != null">
37
                    <span class="el-meta uk-margin uk-text-meta" *ngFor='let author of item.authors; let i = index'>
38
                      <span *ngIf="i < 10">
39
                        <span>{{author}}<span *ngIf="i < (item.authors.length-1)">;</span></span>
40
                      </span>
41
                      <span *ngIf="i == 10">...</span>
42
                    </span>
43
                  </span>
44
                  <span *ngIf="item.year !=''" class="el-meta uk-text-meta"> ({{item.year}}) </span>
45
                </div>
46
                <div class="text-justify descriptionText"> {{item.description}} </div>
47
            </div>
48
         </div>
49
        </li>
50
      </div>-->
51
        <search-result  [results]="results"
52
                        [type]="resultType"  [properties] = properties class="communityRecentResults" [showImpactFactors]="(community.communityId == 'elixir-gr')" >
53
        </search-result>
54
    </div>
55
     <div *ngIf="results != null && results.length > 0">
56
       <div class="uk-text-right">
57
         <div>
58
           <a class="el-content uk-button uk-button-text" [queryParams]="{type:getresultTypeLink(resultType, true), qf:false}" routerLinkActive="router-link-active" [routerLink]="properties.searchLinkToResults">
59
             View all {{getEntityName(resultType, true, true)}}
60
           </a>
61
         </div>
62
       </div>
63
     </div>
64

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

    
67
    `
68

    
69
})
70

    
71
export class ResultsComponent {
72

    
73
    @Input() public results : SearchResult[];
74
    @Input() public resultType: string;
75
    @Input() public params: any;
76
    @Input() public community: CommunityInfo;
77
    @Input() public total: any;
78
    @Input() showLoading: boolean = true;
79
    @Input() properties: EnvProperties;
80

    
81
    getresultTypeLink(type:string, plural:boolean){
82
        if((type == "publication" || type == "dataset") && plural){
83
            return type + "s";
84
        }
85
        return type;
86
    }
87

    
88
  public getEntityName(entityType: string, plural: boolean, full: boolean): string {
89
    if (entityType == "publication") {
90
      return "publication" + (plural ? "s" : "");
91
    } else if (entityType == "dataset") {
92
      return (full ? "research data" : ("dataset" + (plural ? "s" : "")));
93
    } else if (entityType == "software") {
94
      return "software";
95
    } else if (entityType == "other") {
96
      return (full ? ("other research product" + (plural ? "s" : "")) : "other");
97
    } else if (entityType == "result") {
98
      return (full ? ("research outcome" + (plural ? "s" : "")) : "result");
99
    }
100
  }
101
 /*   getParamId(type:string){
102
        let param ="";
103
        if(type == "publication"){
104
            param="article";
105
        }else if(type == "other"){
106
            param="other";
107
        }else{
108
            param=type;
109
        }
110
       return param+"Id";
111
    }*/
112
}
    (1-1/1)