From ac8381b004487129b99b2d4d6bf04289c379699a Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Wed, 19 May 2021 09:36:09 +0000 Subject: [PATCH] [Trunk | Library]: 1. src/app/openaireLibrary/orcid/orcid-work.component.ts: [Bug fix] On ngOnInit() method, call getPutCode, only if(!this.givenPutCode && this.isLoggedIn). 2. src/app/openaireLibrary/utils/properties/env-properties.ts: Added field "enermapsAPIURL?: string". 3. src/app/openaireLibrary/utils/tabs/contents/search-tab.component.ts: Added on top of . 4. src/app/openaireLibrary/landingPages/project/project.component.html: Moved alert inside (was before it). 5. src/app/openaireLibrary/landingPages/result/resultLanding.service.ts: Added methods "getEnermapsDetails()" and "parseEnermapsDetails()" (hide "shared_id"). 6. src/app/openaireLibrary/landingPages/result/resultLanding.component.ts: Added fields and methods to get enermpas details (only when properties.enermapsAPIURL is set). 7. src/app/openaireLibrary/landingPages/result/resultLanding.component.html: a. [Bug fix] Capitalize first letter of title in "References" tab (in small tabs). b. When clicking on tab, call (selectedActiveTab)="onSelectActiveTab($event)". c. If available, show uk-list with enermaps details (key-value pairs). git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@61021 d315682c-612b-4755-9ff5-7f18f6832af3 --- landingPages/project/project.component.html | 8 +++--- .../result/resultLanding.component.html | 16 ++++++++--- .../result/resultLanding.component.ts | 28 +++++++++++++++++++ landingPages/result/resultLanding.service.ts | 21 ++++++++++++++ orcid/orcid-work.component.ts | 2 +- utils/properties/env-properties.ts | 1 + utils/tabs/contents/search-tab.component.ts | 2 ++ 7 files changed, 69 insertions(+), 9 deletions(-) diff --git a/landingPages/project/project.component.html b/landingPages/project/project.component.html index 087181b8..4b0d79f9 100644 --- a/landingPages/project/project.component.html +++ b/landingPages/project/project.component.html @@ -571,14 +571,14 @@
-
- No Data Management Plans (DMPs) available. - Link existing DMPs with this project or start a new DMP in Argos. -
+
+ No Data Management Plans (DMPs) available. + Link existing DMPs with this project or start a new DMP in Argos. +
diff --git a/landingPages/result/resultLanding.component.html b/landingPages/result/resultLanding.component.html index 7f7448e9..cb7d6edb 100644 --- a/landingPages/result/resultLanding.component.html +++ b/landingPages/result/resultLanding.component.html @@ -431,11 +431,19 @@ Enermaps tool

+ +
    + +
  • + {{detail[0]}}: + {{detail[1]}} +
  • +
    +
- - + @@ -473,7 +481,7 @@ - + 0) { this.activeTab = 'bioentities'; + } else if(this.enermapsId && this.properties.enermapsURL && this.properties.enermapsAPIURL) { + this.activeTab = "enermaps"; } } @@ -689,4 +694,27 @@ export class ResultLandingComponent { private isKeyword(value:string, words:string[]){ return value?words.filter( word => { return value.toLowerCase() == word}).length > 0:0; } + + public onSelectActiveTab(activeTabId) { + if (this.activeTab != activeTabId) { // tab really changed + this.activeTab = activeTabId; + if (activeTabId == 'enermaps' && this.properties.enermapsAPIURL) { + this.getEnermapsDetails(this.enermapsId); + } + } + } + + private getEnermapsDetails(id: string) { + if (this.reloadEnermapsDetails) { + this.subscriptions.push(this._resultLandingService.getEnermapsDetails(id).subscribe( + data => { + this.enermapsDetails = data; + this.reloadEnermapsDetails = false; + }, + error => { + console.error("Error in fetching enermaps details ",error); + } + )) + } + } } diff --git a/landingPages/result/resultLanding.service.ts b/landingPages/result/resultLanding.service.ts index a428142a..c1b16b14 100644 --- a/landingPages/result/resultLanding.service.ts +++ b/landingPages/result/resultLanding.service.ts @@ -482,4 +482,25 @@ export class ResultLandingService { } return citations; } + + getEnermapsDetails(id: string) { + let url = properties.enermapsAPIURL+id; + return this.http.get((properties.useLongCache)? (properties.cacheUrl+encodeURIComponent(url)): url) + // return this.http.get(url) + .pipe(map(res => this.parseEnermapsDetails(res))); + } + + parseEnermapsDetails(response: any) { + let details = Array.isArray(response) ? response[0] : response; + let metadata = (details && details.metadata) ? details.metadata : null; + + let entries = []; + let keys = metadata ? Object.keys(metadata) : null; + for(let key of keys) { + if(key != "shared_id" && key && metadata[key]) { + entries.push([key, metadata[key]]); + } + } + return entries; + } } diff --git a/orcid/orcid-work.component.ts b/orcid/orcid-work.component.ts index 142106af..d41b87ef 100644 --- a/orcid/orcid-work.component.ts +++ b/orcid/orcid-work.component.ts @@ -373,7 +373,7 @@ export class OrcidWorkComponent { } ngOnInit() { - if(!this.givenPutCode) { + if(!this.givenPutCode && this.isLoggedIn) { this.getPutCode(); } } diff --git a/utils/properties/env-properties.ts b/utils/properties/env-properties.ts index 9ac9bca1..53768d58 100644 --- a/utils/properties/env-properties.ts +++ b/utils/properties/env-properties.ts @@ -24,6 +24,7 @@ export interface EnvProperties { statisticsAPIURL?: string; impactFactorsAPIURL?: string; enermapsURL?: string; + enermapsAPIURL?: string; claimsAPIURL?: string; searchAPIURLLAst?: string; searchResourcesAPIURL?: string; diff --git a/utils/tabs/contents/search-tab.component.ts b/utils/tabs/contents/search-tab.component.ts index efa89ef2..6ab6520e 100644 --- a/utils/tabs/contents/search-tab.component.ts +++ b/utils/tabs/contents/search-tab.component.ts @@ -23,6 +23,8 @@ import {ErrorCodes} from "../../properties/errorCodes"; + +