2020-04-06 16:49:38 +02:00
|
|
|
import {Component, Input, OnChanges, OnInit, SimpleChanges} from '@angular/core';
|
2020-02-07 14:05:07 +01:00
|
|
|
import {SearchResult} from '../../utils/entities/searchResult';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
2020-03-12 14:49:10 +01:00
|
|
|
import {ResultPreview} from "../../utils/result-preview/result-preview";
|
2020-04-06 16:49:38 +02:00
|
|
|
import {HttpClient} from "@angular/common/http";
|
2020-02-07 14:05:07 +01:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
@Component({
|
2020-02-07 14:05:07 +01:00
|
|
|
selector: 'search-result',
|
|
|
|
templateUrl: 'searchResult.component.html'
|
2017-12-19 13:53:46 +01:00
|
|
|
})
|
2020-04-06 16:49:38 +02:00
|
|
|
export class SearchResultComponent implements OnInit, OnChanges {
|
2020-02-07 14:05:07 +01:00
|
|
|
@Input() results: SearchResult[];
|
2020-04-06 16:49:38 +02:00
|
|
|
previewResults:ResultPreview[];
|
2020-02-07 14:05:07 +01:00
|
|
|
@Input() status: number;
|
|
|
|
@Input() type: string;
|
|
|
|
@Input() showLoading: boolean = false;
|
2020-03-12 11:44:51 +01:00
|
|
|
@Input() showSubjects: boolean = true;
|
2020-02-07 14:05:07 +01:00
|
|
|
@Input() showOrganizations: boolean = true;
|
|
|
|
@Input() custom_class: string = "search-results";
|
|
|
|
@Input() properties: EnvProperties;
|
2020-04-06 16:49:38 +02:00
|
|
|
@Input() showImpactFactors: boolean = false;
|
2020-02-07 14:05:07 +01:00
|
|
|
|
2020-04-06 16:49:38 +02:00
|
|
|
constructor( private http: HttpClient/*ATHENA CODE*/) {
|
2020-02-07 14:05:07 +01:00
|
|
|
}
|
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
ngOnInit() {}
|
2020-04-06 16:49:38 +02:00
|
|
|
|
|
|
|
initialize(){
|
|
|
|
this.previewResults = [];
|
|
|
|
for(let result of this.results){
|
|
|
|
this.previewResults.push(this.getResultPreview(result));
|
|
|
|
}
|
|
|
|
/////////////////////// ATHENA CODE ///////////////////////
|
|
|
|
// console.log(data[1]);
|
|
|
|
let dois = encodeURIComponent(this.results.map((result) => result.DOI).join(","));
|
|
|
|
// console.log(dois);
|
|
|
|
if(dois.length > 0 && this.showImpactFactors && this.properties.environment == "development") {
|
|
|
|
let url = 'http://bip.imis.athena-innovation.gr:4000/paper/scores/batch/' + dois;
|
|
|
|
this.http.get(url).subscribe((data_received) => {
|
|
|
|
for (let i = 0; i < this.previewResults.length; i++) {
|
|
|
|
this.previewResults[i].pop_inf = new Array<string>();
|
|
|
|
// console.log(data[1][i].DOI,'inf: ',data_received[i].pop_class,'and pop: ',data_received[i].inf_class);
|
|
|
|
// researchResults[1].pop_inf[i].push(data[i].inf_class,data[i].pop_class);
|
|
|
|
console.log(this.previewResults[i].DOI)
|
|
|
|
if (this.previewResults[i].DOI != '' && this.previewResults[i].DOI != null) {
|
|
|
|
this.previewResults[i].pop_inf.push(data_received[i].pop_class, data_received[i].inf_class);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log(this.previewResults)
|
|
|
|
|
|
|
|
}, error1 => {
|
|
|
|
console.error("Failed to get Impact factors for elixir-gr")
|
|
|
|
});
|
|
|
|
// console.log(researchResults[1]);
|
|
|
|
|
|
|
|
}
|
|
|
|
/////////////////////// ATHENA CODE ///////////////////////
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnChanges(changes: SimpleChanges): void {
|
|
|
|
if (changes.results) {
|
|
|
|
this.initialize();
|
|
|
|
}
|
|
|
|
}
|
2020-03-12 14:49:10 +01:00
|
|
|
public getResultPreview(result: SearchResult): ResultPreview {
|
|
|
|
return ResultPreview.searchResultConvert(result, (result.entityType)?result.entityType:this.type);
|
2020-02-07 14:05:07 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public quote(params: string): string {
|
|
|
|
return '"' + params + '"';
|
|
|
|
}
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|