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";
|
2021-01-13 19:30:25 +01:00
|
|
|
import {OrcidService} from "../../orcid/orcid.service";
|
|
|
|
import {Session} from "../../login/utils/helper.class";
|
2021-02-24 21:33:37 +01:00
|
|
|
import {properties} from "../../../../environments/environment";
|
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;
|
2021-03-10 11:41:38 +01:00
|
|
|
@Input() showImage: boolean;
|
2020-05-19 17:59:20 +02:00
|
|
|
|
2021-01-13 19:30:25 +01:00
|
|
|
constructor( private http: HttpClient/*ATHENA CODE*/
|
|
|
|
, private orcidService: OrcidService) {
|
2020-02-07 14:05:07 +01:00
|
|
|
}
|
|
|
|
|
2020-03-12 14:49:10 +01:00
|
|
|
ngOnInit() {}
|
2020-11-11 15:43:13 +01:00
|
|
|
sub;
|
|
|
|
ngOnDestroy() {
|
|
|
|
if(this.sub){
|
|
|
|
this.sub.unsubscribe();
|
|
|
|
}
|
|
|
|
}
|
2020-04-06 16:49:38 +02:00
|
|
|
initialize(){
|
|
|
|
this.previewResults = [];
|
|
|
|
for(let result of this.results){
|
|
|
|
this.previewResults.push(this.getResultPreview(result));
|
|
|
|
}
|
2021-01-13 19:30:25 +01:00
|
|
|
|
[Trunk | Library]:
1. resultLanding.component.html & result-preview.component.html: Show orcid buttons in all environments (production too) | in <orcid-work> added "resultTitle" property.
2. myOrcidLinks.component.ts: Added "getPersonalDetails()" method and link to advanced research outcomes page, filtered by user's name (if personal details from ORCID fails, use name from AAI - getUserInfo).
3. searchMyOrcidResults.module.ts: Removed PagingModule and added NoLoadPaging.
4. searchMyOrcidResults.component.ts: Added method "totalPages()" to calculate pages in paging.
5. searchMyOrcidResults.component.html:
a. Added <no-load-paging> (instead of custom paging with <paging-no-load>).
b. In <orcid-work> added "resultTitle" property.
c. Fix widths of grid inside card for result preview and orcid buttons.
6. orcid-work.component.ts:
a. Added "resultTitle" @Input property, to show it in notifications, instead of pids.
b. Updated messages for errors and for multiple put-codes.
c. Use "danger" notifications instead of "warning" when an error occurs.
d. For search and my orcid links pages, in orcid buttons, use <icon> for icons | For landing page, updated icons in orcid buttons.
e. Added message "The action will affect your real ORCID iD." in tooltips, when environment == 'beta'.
f. Removed property "procedurePaused" and its usage replaced by "currentAction".
g. [Bug fix] For search pages, added "uk-align-right", in order orcid button not to take width for the whole line.
h. [Bug fix] In method "getOrcidWorks()" check "Session.isLoggedIn()" was missing.
7. orcid.component.ts: If personal details from ORCID fails, use name from AAI - getUserInfo.
8. orcid.module.ts: Added IconsModule and registered icons: add, remove, preview, refresh in IconsService.
9. searchResult.component.ts: Call "orcidService.getPutCodes()" in all environments (production too).
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60619 d315682c-612b-4755-9ff5-7f18f6832af3
2021-03-11 02:40:53 +01:00
|
|
|
if(properties.adminToolsPortalType == "explore" && Session.isLoggedIn() && this.results && this.results.length > 0) {
|
2021-01-13 19:30:25 +01:00
|
|
|
this.orcidService.getPutCodes(this.previewResults.map(
|
|
|
|
previewResult => {
|
|
|
|
if(previewResult.identifiers) {
|
|
|
|
let pidsArray: string[] = [];
|
|
|
|
for(let key of Array.from(previewResult.identifiers.keys())) {
|
|
|
|
pidsArray = pidsArray.concat(previewResult.identifiers.get(key));
|
|
|
|
}
|
|
|
|
return pidsArray;//.join();
|
|
|
|
}
|
|
|
|
})).subscribe(
|
|
|
|
putCodes => {
|
|
|
|
for (let i = 0; i < this.previewResults.length; i++) {
|
|
|
|
if(this.previewResults[i].identifiers) {
|
|
|
|
this.previewResults[i].orcidPutCodes = putCodes[i];
|
2021-02-24 21:33:37 +01:00
|
|
|
// console.debug(i, this.previewResults[i].orcidPutCodes);
|
2021-01-13 19:30:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}, error => {
|
|
|
|
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-04-06 16:49:38 +02:00
|
|
|
/////////////////////// ATHENA CODE ///////////////////////
|
|
|
|
// console.log(data[1]);
|
2020-05-25 14:24:48 +02:00
|
|
|
let dois = encodeURIComponent(this.results.map((result) => result.DOIs).join(","));
|
2020-04-06 16:49:38 +02:00
|
|
|
// console.log(dois);
|
2020-12-15 18:08:31 +01:00
|
|
|
if(dois.length > 0 && this.showImpactFactors && (this.properties.impactFactorsAPIURL && this.properties.impactFactorsAPIURL.length > 0) ) {
|
2020-05-07 12:50:15 +02:00
|
|
|
let url = this.properties.impactFactorsAPIURL + dois;
|
2020-11-11 15:43:13 +01:00
|
|
|
this.sub = this.http.get((this.properties.useCache?(this.properties.cacheUrl+(encodeURIComponent(url))):url)).subscribe((data_received:any[]) => {
|
2020-05-25 14:24:48 +02:00
|
|
|
let impact =[];
|
|
|
|
data_received.forEach(function (result) {
|
|
|
|
if(result.doi && result.doi.length > 0 && result.pop_class!=null && result.inf_class!=null)
|
|
|
|
impact[result.doi]=result;
|
|
|
|
});
|
|
|
|
this.previewResults.forEach(function (result) {
|
2021-02-10 10:33:36 +01:00
|
|
|
if(result.identifiers && result.identifiers.get("doi")) {
|
2020-06-02 10:40:56 +02:00
|
|
|
result.identifiers.get("doi").forEach(function (doi) {
|
|
|
|
if (impact[doi]) {
|
|
|
|
result.DOI = doi;
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
2020-05-25 14:24:48 +02:00
|
|
|
}
|
2020-06-02 10:40:56 +02:00
|
|
|
});
|
2020-04-06 16:49:38 +02:00
|
|
|
for (let i = 0; i < this.previewResults.length; i++) {
|
2020-05-25 14:24:48 +02:00
|
|
|
if (this.previewResults[i].DOI) {
|
2020-05-25 11:46:37 +02:00
|
|
|
this.previewResults[i].pop_inf = new Array<string>();
|
2020-05-25 14:24:48 +02:00
|
|
|
this.previewResults[i].pop_inf.push(impact[this.previewResults[i].DOI].pop_class, impact[this.previewResults[i].DOI].inf_class);
|
2020-05-05 18:21:31 +02:00
|
|
|
if(this.previewResults[i].pop_inf[0]=="A"){
|
|
|
|
// this.previewResults[i].pop_inf.push("High");
|
|
|
|
this.previewResults[i].pop_inf.push("Exceptional");
|
|
|
|
}else if(this.previewResults[i].pop_inf[0]=="B"){
|
|
|
|
// this.previewResults[i].pop_inf.push("Average");
|
|
|
|
this.previewResults[i].pop_inf.push("Substantial");
|
|
|
|
}else{
|
|
|
|
// this.previewResults[i].pop_inf.push("low");
|
|
|
|
this.previewResults[i].pop_inf.push("Average");
|
|
|
|
}
|
|
|
|
if(this.previewResults[i].pop_inf[1]=="A"){
|
|
|
|
// this.previewResults[i].pop_inf.push("Strong");
|
|
|
|
this.previewResults[i].pop_inf.push("Exceptional");
|
|
|
|
}else if(this.previewResults[i].pop_inf[1]=="B"){
|
|
|
|
// this.previewResults[i].pop_inf.push("Average");
|
|
|
|
this.previewResults[i].pop_inf.push("Substantial");
|
|
|
|
}else{
|
|
|
|
// this.previewResults[i].pop_inf.push("Weak");
|
|
|
|
this.previewResults[i].pop_inf.push("Average");
|
|
|
|
}
|
2020-04-06 16:49:38 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}, 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
|
|
|
}
|