From 317b7a19e1a9b0234e176a06b854da346bb20587 Mon Sep 17 00:00:00 2001 From: Alex Martzios Date: Fri, 3 Dec 2021 18:04:39 +0200 Subject: [PATCH] Add funders cards in homepage --- src/app/home/home.component.html | 23 +++++++++++++++++++++ src/app/home/home.component.ts | 35 +++++++++++++++++++++++++++++++- src/app/openaireLibrary | 2 +- 3 files changed, 58 insertions(+), 2 deletions(-) diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html index 28c28c4..c987363 100644 --- a/src/app/home/home.component.html +++ b/src/app/home/home.component.html @@ -151,6 +151,29 @@

Our growing Community

+ +
+

Our Canadian Funders

+ +
+
+
+
+
+

{{funder.name}}

+
+
+ research outcomes found +
+
+ Open Access +
+
+
+
+
+
+ diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts index b555167..1294204 100644 --- a/src/app/home/home.component.ts +++ b/src/app/home/home.component.ts @@ -1,5 +1,5 @@ import {Component, ViewChild} from '@angular/core'; -import {Subscription} from 'rxjs'; +import {Subscription, zip} from 'rxjs'; import {ActivatedRoute, Router} from '@angular/router'; import {Location} from '@angular/common'; import {Meta, Title} from '@angular/platform-browser'; @@ -46,6 +46,9 @@ export class HomeComponent { properties: EnvProperties = properties; public readMore: boolean = false; + private noOfFunders = 3; + public funders = []; + subs: Subscription[] = []; resultsQuickFilter: { filter: Filter, selected: boolean, filterId: string, value: string } = { @@ -140,6 +143,7 @@ export class HomeComponent { this.numbersComponent.init(false, false, this.showPublications, this.showDatasets, this.showSoftware, this.showOrp, this.showProjects, this.showDataProviders, StringUtils.URIEncode(this.customFilter.queryFieldName + " exact " + StringUtils.quote((this.customFilter.valueId )))); + this.getTopFunders(); } }, error => { @@ -220,4 +224,33 @@ export class HomeComponent { } return params; } + + getTopFunders() { + let refineParams1 = '&fq=country%20exact%20%22CA%22'; + let refineParams2 = '&fq=resultbestaccessright%20exact%20%22Open%20Access%22&fq=country%20exact%20%22CA%22%20'; + this.subs.push(zip( + this._refineFieldResultsService.getRefineFieldsResultsByEntityName(['relfunder'], 'result', this.properties, refineParams1), + this._refineFieldResultsService.getRefineFieldsResultsByEntityName(['relfunder'], 'result', this.properties, refineParams2) + ).subscribe((data: any[]) => { + for(let i = 0; i < this.noOfFunders; i++) { + this.funders.push({ + "id": data[0][1][0].values[i].id, + "name": data[0][1][0].values[i].name, + "publications": data[0][1][0].values[i].number, + "openAccessPublications": null, + "params": { + relfunder: '"'+encodeURIComponent(data[0][1][0].values[i].id)+'"' + } + }); + } + let allFunders = data[1][1][0].values; + allFunders.forEach(funder => { + for(let topFunder of this.funders) { + if(funder.id == topFunder.id) { + topFunder.openAccessPublications = funder.number; + } + } + }); + })) + } } diff --git a/src/app/openaireLibrary b/src/app/openaireLibrary index 2f65202..ca430fd 160000 --- a/src/app/openaireLibrary +++ b/src/app/openaireLibrary @@ -1 +1 @@ -Subproject commit 2f65202142d48bfd51508e20f9ac0d8cb4368990 +Subproject commit ca430fd89f7654bb71f52383bd52bf58e4c70e5f