Project

General

Profile

1
import {Component, Input} from '@angular/core';
2
import {SearchResult}     from '../../utils/entities/searchResult';
3
import { ErrorCodes} from '../../utils/properties/openaireProperties';
4
import {RouterHelper} from '../../utils/routerHelper.class';
5

    
6
@Component({
7
    selector: 'search-result',
8
    template: `
9
     <ul class="uk-list uk-list-divider  uk-margin" style="min-height: 1100px;">
10
      <div *ngIf="status == errorCodes.NONE" class="uk-alert uk-alert-primary uk-animation-fade" role="alert">No Results found</div>
11
      <div *ngIf="status == errorCodes.ERROR" class="uk-alert uk-alert-warning uk-animation-fade" role="alert">An Error Occured</div>
12
      <div *ngIf="status == errorCodes.NOT_AVAILABLE" class="uk-alert uk-alert-danger uk-animation-fade" role="alert">Service not available</div>
13
      <div *ngIf="status == errorCodes.LOADING && showLoading" class="uk-alert uk-alert-primary uk-animation-fade" role="alert">Loading...</div>
14

    
15
        <li *ngFor="let result of results" class="uk-animation-fade">
16
            <h4 class = "{{result.title.accessMode}} {{result.title.sc39}}" [title] = result.title.accessMode >
17
                <!--a href="{{result['title'].url}}"-->
18
                <!--a [queryParams]="{articleId: 'od_______908::3a5b2885656a91307156325644e73b92'}" routerLinkActive="router-link-active" routerLink="search/publication"-->
19

    
20
                <a [queryParams]="routerHelper.createQueryParam(urlParam,result.id)" routerLinkActive="router-link-active" routerLink="/search/{{type}}">
21
                <!--a href="/search/{{type}}?{{urlParam}}={{result.id}}"-->
22
                    <p *ngIf="result['title'].name != undefined && result['title'].name != ''"
23
                        [innerHTML]="result['title'].name">
24
                    </p>
25
                    <p *ngIf="result['title'].name == undefined || result['title'].name == ''">
26
                        [no title available]
27
                    </p>
28
                </a>
29
            </h4>
30

    
31
            <div>
32
                <span *ngIf="result['authors'] != undefined">
33
                    <span *ngFor="let author of result['authors'].slice(0,15)">
34
                        <!--a href="{{author['url']}}"-->
35
                        <a [queryParams]="{personId: author.id}" routerLinkActive="router-link-active" routerLink="/search/person">
36
                            {{author['name']}};
37
                        </a>
38
                    </span>
39
                    <span *ngIf="result['authors'].length > 15">...</span>
40
                </span>
41
                <span *ngIf="result.year != undefined && result.year != ''">
42
                    ({{result.year}})
43
                </span>
44
            </div>
45

    
46
            <div *ngIf="result.publisher != undefined && result.publisher != ''">Publisher: {{result.publisher}}</div>
47

    
48
            <div *ngIf="result.country != undefined && result.country != ''">Country: {{result.country}}</div>
49

    
50
            <div *ngIf="result['projects'] != undefined">
51
                <span> Projects: </span>
52
                <span *ngFor="let project of result['projects'].slice(0,15) let i=index">
53
                    <!--a *ngIf="project.url != undefined" href="{{project.url}}"-->
54
                        <a *ngIf="project.id" [queryParams]="{projectId: project.id}" routerLinkActive="router-link-active" routerLink="/search/project">
55
                            {{project['funderShortname']?project['funderShortname']:project['funderName']}}
56
                            | {{ project['acronym']?project['acronym']:project['title']}} ({{project.code}})</a><span
57

    
58
                            *ngIf="!project.id">{{project['funderShortname']?project['funderShortname']:project['funderName']}}<span
59
                                *ngIf="project['acronym'] || project['title']"> | {{ project['acronym']?project['acronym']:project['title']}}</span><span
60
                                *ngIf="project.code">({{project.code}})</span></span><span
61

    
62
                    *ngIf="i < result['projects'].length-1">,</span>
63
                </span>
64
                <span *ngIf="result['projects'].length > 15">...</span>
65
            </div>
66

    
67
            <blockquote *ngIf="result.description != undefined && result.description != ''">
68
                <div class="text-justify">
69
                    {{result.description}}
70
                </div>
71
            </blockquote>
72

    
73
            <mark *ngIf="result.embargoEndDate != undefined && result.embargoEndDate != ''">Embargo End Date: {{result.embargoEndDate}}</mark>
74

    
75

    
76
            <div *ngIf="result['funders'] != undefined">
77
              <span> Funders: </span>
78
              <span *ngFor="let funder of result['funders'] let i=index">
79

    
80
                  <span *ngIf="funder.funderShortname">
81
                    {{funder.funderShortname}}</span><span
82

    
83
                    *ngIf="i < result['funders'].length-1">,</span>
84
              </span>
85
            </div>
86
            <span *ngIf="result.startYear && result.endYear"> ({{result.startYear}} - {{result.endYear}})</span>
87
            <div *ngIf="result['organizations'] != undefined && result['organizations'].length > 0">
88
                <span> Organizations: </span>
89
                <span *ngFor="let organization of result['organizations'] let i=index">
90
                    <!--a *ngIf="organization.url != undefined" href="{{organization.url}}"-->
91
                    <a *ngIf="organization.id" [queryParams]="{organizationId: organization.id}" routerLinkActive="router-link-active" routerLink="/search/organization">
92
                            {{organization.name}}</a><span
93

    
94
                        *ngIf="!organization.id">
95
                            {{organization.name}}</span><span
96

    
97
                        *ngIf="i < result['organizations'].length-1">,</span>
98
                </span>
99
            </div>
100

    
101
            <div *ngIf="result['type'] != undefined && result['type'] != ''">Type: {{result['type']}}</div>
102
            <div *ngIf="result['websiteURL'] != undefined && result['websiteURL'] != ''">
103
                <span>Website URL: </span>
104
                <span>
105
                    <a href="{{result['websiteURL']}}" target="_blank" class="custom-external custom-icon">
106
                        {{result['websiteURL']}}
107
                    </a>
108
                </span>
109
            </div>
110
            <div *ngIf="result['OAIPMHURL'] != undefined && result['OAIPMHURL'] != ''">
111
                <span>OAI-PMH URL: </span>
112
                <span>
113
                    <a href="{{result['OAIPMHURL']}}" target="_blank" class="custom-external custom-icon">
114
                        {{result['OAIPMHURL']}}
115
                    </a>
116
                </span>
117
            </div>
118

    
119
            <div *ngIf="result['compatibility'] != undefined && result['compatibility'] != ''">
120
                Compatibility: {{result.compatibility}}
121
            </div>
122

    
123
            <div *ngIf="result['countries'] && result['countries'].length > 0">
124
                Countries: {{result.countries}}
125
            </div>
126

    
127
        </li>
128
    </ul>
129
    `
130
})
131

    
132
export class SearchResultComponent {
133
    @Input() results: SearchResult[];
134
    @Input() status: number;
135
    @Input() type: string;
136
    @Input() urlParam: string;
137
    @Input() showLoading: boolean = false;
138

    
139
    public errorCodes:ErrorCodes = new ErrorCodes();
140
    public routerHelper:RouterHelper = new RouterHelper();
141
    public errorMessage: string = "No results found";
142

    
143
    constructor () {
144

    
145
    }
146

    
147
    ngOnInit() {}
148
}
(21-21/25)