2017-12-19 13:53:46 +01:00
|
|
|
import {Component, Input} from '@angular/core';
|
|
|
|
import {SearchResult} from '../../utils/entities/searchResult';
|
2018-02-05 14:14:59 +01:00
|
|
|
import {ErrorCodes} from '../../utils/properties/openaireProperties';
|
2017-12-19 13:53:46 +01:00
|
|
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
2018-02-05 14:14:59 +01:00
|
|
|
import{EnvProperties} from '../../utils/properties/env-properties';
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'search-result',
|
|
|
|
templateUrl:'searchResult.component.html'
|
|
|
|
})
|
|
|
|
|
|
|
|
export class SearchResultComponent {
|
|
|
|
@Input() results: SearchResult[];
|
|
|
|
@Input() status: number;
|
|
|
|
@Input() type: string;
|
|
|
|
@Input() showLoading: boolean = false;
|
|
|
|
@Input() showSubjects: boolean = false;
|
|
|
|
@Input() showOrganizations: boolean = true;
|
|
|
|
@Input() custom_class: string = "search-results";
|
2018-02-05 14:14:59 +01:00
|
|
|
@Input() properties:EnvProperties;
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
public urlParam: string;
|
|
|
|
public linkToAdvancedSearchPage: string;
|
|
|
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
|
|
|
public routerHelper:RouterHelper = new RouterHelper();
|
|
|
|
public errorMessage: string = "No results found";
|
|
|
|
constructor () {}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2018-02-05 14:14:59 +01:00
|
|
|
|
|
|
|
if(this.type == "publication") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedPublications;
|
|
|
|
this.urlParam = "articleId";
|
|
|
|
} else if(this.type == "dataset") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDatasets;
|
|
|
|
this.urlParam = "datasetId";
|
|
|
|
} else if(this.type == "software") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedSoftware;
|
|
|
|
this.urlParam = "softwareId";
|
|
|
|
} else if(this.type == "project") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedProjects;
|
|
|
|
this.urlParam = "projectId";
|
|
|
|
} else if(this.type == "organization") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedOrganizations;
|
|
|
|
this.urlParam = "organizationId";
|
|
|
|
} else if(this.type == "dataprovider") {
|
|
|
|
this.linkToAdvancedSearchPage = this.properties.searchLinkToAdvancedDataProviders;
|
|
|
|
this.urlParam = "datasourceId";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public quote(params: string):string {
|
|
|
|
return '"'+params+'"';
|
|
|
|
}
|
|
|
|
}
|