Project

General

Profile

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