1
|
import {Component, Input} from '@angular/core';
|
2
|
import {SearchResult} from '../utils/entities/searchResult';
|
3
|
import {ErrorCodes} from '../utils/properties/errorCodes';
|
4
|
import {RouterHelper} from '../utils/routerHelper.class';
|
5
|
import {EnvProperties} from '../utils/properties/env-properties';
|
6
|
import {ZenodoInformationClass} from "./utils/zenodoInformation.class";
|
7
|
import {ActivatedRoute} from "@angular/router";
|
8
|
|
9
|
@Component({
|
10
|
selector: 'deposit-result',
|
11
|
templateUrl:'searchResultsInDeposit.component.html'
|
12
|
})
|
13
|
|
14
|
export class SearchResultsInDepositComponent {
|
15
|
@Input() results: SearchResult[];
|
16
|
@Input() status: number;
|
17
|
@Input() type: string;
|
18
|
@Input() properties:EnvProperties;
|
19
|
|
20
|
|
21
|
public urlParam: string;
|
22
|
public linkToAdvancedSearchPage: string;
|
23
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
24
|
public routerHelper:RouterHelper = new RouterHelper();
|
25
|
public errorMessage: string = "No results found";
|
26
|
|
27
|
@Input() public zenodoInformation: ZenodoInformationClass = new ZenodoInformationClass();
|
28
|
|
29
|
constructor (private route: ActivatedRoute) {}
|
30
|
|
31
|
ngOnInit() {
|
32
|
if(this.type == "publication") {
|
33
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
|
34
|
this.urlParam = "articleId";
|
35
|
} else if(this.type == "dataset") {
|
36
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets;
|
37
|
this.urlParam = "datasetId";
|
38
|
} else if(this.type == "software") {
|
39
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware;
|
40
|
this.urlParam = "softwareId";
|
41
|
} else if(this.type == "other") {
|
42
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrps;
|
43
|
this.urlParam = "orpId";
|
44
|
} else if(this.type == "project") {
|
45
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedProjects;
|
46
|
this.urlParam = "projectId";
|
47
|
} else if(this.type == "organization") {
|
48
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrganizations;
|
49
|
this.urlParam = "organizationId";
|
50
|
} else if(this.type == "dataprovider") {
|
51
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDataProviders;
|
52
|
this.urlParam = "datasourceId";
|
53
|
}
|
54
|
|
55
|
this.route.data
|
56
|
.subscribe((data: { envSpecific: EnvProperties }) => {
|
57
|
this.properties = data.envSpecific;
|
58
|
|
59
|
if (!this.zenodoInformation) {
|
60
|
this.zenodoInformation = new ZenodoInformationClass();
|
61
|
}
|
62
|
if (!this.zenodoInformation.shareInZenodoUrl) {
|
63
|
this.zenodoInformation.url = this.properties.zenodo;
|
64
|
}
|
65
|
if (!this.zenodoInformation.name) {
|
66
|
this.zenodoInformation.name = "Zenodo";
|
67
|
}
|
68
|
});
|
69
|
}
|
70
|
|
71
|
public quote(params: string):string {
|
72
|
return '"'+params+'"';
|
73
|
}
|
74
|
}
|