1
|
import {Component, Input, OnInit} from "@angular/core";
|
2
|
import {ResultPreview} from "./result-preview";
|
3
|
import {EnvProperties} from "../properties/env-properties";
|
4
|
import {RouterHelper} from "../routerHelper.class";
|
5
|
import {AlertModal} from "../modal/alert";
|
6
|
|
7
|
@Component({
|
8
|
selector: 'result-preview',
|
9
|
templateUrl: 'result-preview.component.html'
|
10
|
})
|
11
|
export class ResultPreviewComponent implements OnInit{
|
12
|
@Input() result: ResultPreview;
|
13
|
@Input() properties: EnvProperties;
|
14
|
@Input() showSubjects: boolean = true;
|
15
|
@Input() showOrganizations: boolean = true;
|
16
|
@Input() modal: AlertModal = null;
|
17
|
@Input() promoteWebsiteURL: boolean = false;
|
18
|
public routerHelper: RouterHelper = new RouterHelper();
|
19
|
public urlParam: string;
|
20
|
|
21
|
ngOnInit(): void {
|
22
|
if (this.result.resultType === "publication") {
|
23
|
this.urlParam = "articleId";
|
24
|
} else if (this.result.resultType === "dataset") {
|
25
|
this.urlParam = "datasetId";
|
26
|
} else if (this.result.resultType === "software") {
|
27
|
this.urlParam = "softwareId";
|
28
|
} else if (this.result.resultType === "other") {
|
29
|
this.urlParam = "orpId";
|
30
|
} else if (this.result.resultType == "project") {
|
31
|
this.urlParam = "projectId";
|
32
|
} else if (this.result.resultType == "organization") {
|
33
|
this.urlParam = "organizationId";
|
34
|
} else if (this.result.resultType == "dataprovider") {
|
35
|
this.urlParam = "datasourceId";
|
36
|
}
|
37
|
}
|
38
|
|
39
|
public getTypeName(type: string): string {
|
40
|
if (type === "dataset") {
|
41
|
return "research data";
|
42
|
} else if (type === "other") {
|
43
|
return "other research product";
|
44
|
} else if (type === "dataprovider") {
|
45
|
return "content provider";
|
46
|
} else {
|
47
|
return type;
|
48
|
}
|
49
|
}
|
50
|
|
51
|
public removeUnknown(array: string[]): string[] {
|
52
|
return array.filter(value => value.toLowerCase() !== 'unknown');
|
53
|
}
|
54
|
|
55
|
public removeDuplicates(array: string[]): string[] {
|
56
|
return array.filter(value => value.toLowerCase() !== this.result.resultType);
|
57
|
}
|
58
|
|
59
|
public accessClass(accessMode: string): string {
|
60
|
if(accessMode.toLowerCase().indexOf('open') !== -1) {
|
61
|
return 'open';
|
62
|
} else if(accessMode.toLowerCase() === 'not available') {
|
63
|
return 'unknown';
|
64
|
} else {
|
65
|
return 'closed';
|
66
|
}
|
67
|
}
|
68
|
|
69
|
public onClick() {
|
70
|
if(this.modal) {
|
71
|
this.modal.cancel();
|
72
|
}
|
73
|
}
|
74
|
}
|