openaire-library/searchPages/searchUtils/searchResult.component.ts

58 lines
2.2 KiB
TypeScript

import {Component, Input} from '@angular/core';
import {SearchResult} from '../../utils/entities/searchResult';
import {ErrorCodes} from '../../utils/properties/errorCodes';
import {RouterHelper} from '../../utils/routerHelper.class';
import{EnvProperties} from '../../utils/properties/env-properties';
@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";
@Input() properties:EnvProperties;
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 = 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";
}
}
public quote(params: string):string {
return '"'+params+'"';
}
}