54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
|
import {Component, Input} from '@angular/core';
|
||
|
import {SearchResult} from '../../utils/entities/searchResult';
|
||
|
import {OpenaireProperties, ErrorCodes} from '../../utils/properties/openaireProperties';
|
||
|
import {RouterHelper} from '../../utils/routerHelper.class';
|
||
|
|
||
|
@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";
|
||
|
|
||
|
public urlParam: string;
|
||
|
public linkToAdvancedSearchPage: string;
|
||
|
public errorCodes:ErrorCodes = new ErrorCodes();
|
||
|
public routerHelper:RouterHelper = new RouterHelper();
|
||
|
public errorMessage: string = "No results found";
|
||
|
|
||
|
constructor () {}
|
||
|
|
||
|
ngOnInit() {
|
||
|
if(this.type == "publication") {
|
||
|
this.linkToAdvancedSearchPage = OpenaireProperties.getLinkToAdvancedSearchPublications();
|
||
|
this.urlParam = "articleId";
|
||
|
} else if(this.type == "dataset") {
|
||
|
this.linkToAdvancedSearchPage = OpenaireProperties.getLinkToAdvancedSearchDatasets();
|
||
|
this.urlParam = "datasetId";
|
||
|
} else if(this.type == "software") {
|
||
|
this.linkToAdvancedSearchPage = OpenaireProperties.getLinkToAdvancedSearchSoftware();
|
||
|
this.urlParam = "softwareId";
|
||
|
} else if(this.type == "project") {
|
||
|
this.linkToAdvancedSearchPage = OpenaireProperties.getLinkToAdvancedSearchProjects();
|
||
|
this.urlParam = "projectId";
|
||
|
} else if(this.type == "organization") {
|
||
|
this.linkToAdvancedSearchPage = OpenaireProperties.getLinkToAdvancedSearchOrganizations();
|
||
|
this.urlParam = "organizationId";
|
||
|
} else if(this.type == "dataprovider") {
|
||
|
this.linkToAdvancedSearchPage = OpenaireProperties.getLinkToAdvancedSearchDataProviders();
|
||
|
this.urlParam = "datasourceId";
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public quote(params: string):string {
|
||
|
return '"'+params+'"';
|
||
|
}
|
||
|
}
|