1 |
58118
|
k.triantaf
|
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 |
58144
|
k.triantaf
|
import {AlertModal} from "../modal/alert";
|
6 |
58118
|
k.triantaf
|
|
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 |
58237
|
konstantin
|
@Input() showSubjects: boolean = true;
|
15 |
58118
|
k.triantaf
|
@Input() showOrganizations: boolean = true;
|
16 |
58144
|
k.triantaf
|
@Input() modal: AlertModal = null;
|
17 |
58253
|
argiro.kok
|
@Input() promoteWebsiteURL: boolean = false;
|
18 |
58118
|
k.triantaf
|
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 |
58144
|
k.triantaf
|
public getTypeName(type: string): string {
|
40 |
|
|
if (type === "dataset") {
|
41 |
|
|
return "research data";
|
42 |
|
|
} else if (type === "other") {
|
43 |
58219
|
k.triantaf
|
return "other research product";
|
44 |
58144
|
k.triantaf
|
} else if (type === "dataprovider") {
|
45 |
|
|
return "content provider";
|
46 |
|
|
} else {
|
47 |
|
|
return type;
|
48 |
|
|
}
|
49 |
|
|
}
|
50 |
|
|
|
51 |
58118
|
k.triantaf
|
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 |
58144
|
k.triantaf
|
|
59 |
58118
|
k.triantaf
|
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 |
58275
|
k.triantaf
|
public onClick() {
|
70 |
58144
|
k.triantaf
|
if(this.modal) {
|
71 |
|
|
this.modal.cancel();
|
72 |
|
|
}
|
73 |
|
|
}
|
74 |
58253
|
argiro.kok
|
}
|