From 4ee8ad094cd7936431a5ffaedad569bbc1cf6d7d Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Fri, 16 Apr 2021 13:00:02 +0000 Subject: [PATCH] [Library | Trunk]: Numbers alignment fixed git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60886 d315682c-612b-4755-9ff5-7f18f6832af3 --- sharedComponents/numbers/numbers.component.ts | 249 ++++++++---------- sharedComponents/numbers/numbers.module.ts | 3 +- utils/loading/loading.component.ts | 2 +- 3 files changed, 115 insertions(+), 139 deletions(-) diff --git a/sharedComponents/numbers/numbers.component.ts b/sharedComponents/numbers/numbers.component.ts index e99a1bb8..dc56145c 100644 --- a/sharedComponents/numbers/numbers.component.ts +++ b/sharedComponents/numbers/numbers.component.ts @@ -5,90 +5,96 @@ import {RefineFieldResultsService} from '../../services/refineFieldResults.servi import {EnvProperties} from '../../utils/properties/env-properties'; import {properties} from '../../../../environments/environment'; import {NumberUtils} from '../../utils/number-utils.class'; -import {Subscription} from 'rxjs'; +import {Subscription, zip} from 'rxjs'; @Component({ selector: 'numbers', template: ` -
-
-
-

- - {{fundersSize.number|number}}{{fundersSize.size}} - -

- Funders -
-
-

- - {{datasourcesSize.number|number}}{{datasourcesSize.size}} - -

- Content providers -
-
-

- - {{projectsSize.number|number}}{{projectsSize.size}} - -

- Projects + + +
+
+
+
+
+ {{publicationsSize.count|number}} +
+ + publications +
+
+
+
+
+ {{datasetsSize.count|number}} +
+ + research data +
+
+
+
+
+ {{softwareSize.count|number}} +
+ + software +
+
+
+
+
+ {{otherSize.count|number}} +
+ + other research products +
+
+
+
+
+
+
+
+
-
-
-
-
-
- {{publicationsSize.count|number}} -
- - publications -
-
-
-
-
- {{datasetsSize.count|number}} -
- - research data -
-
-
-
-
- {{softwareSize.count|number}} -
- - software -
-
-
-
-
- {{otherSize.count|number}} -
- - other research products -
-
-
-
-
-
`, + `, }) export class NumbersComponent implements OnInit, OnDestroy { - @Input() colorClass = 'uk-text-secondary'; - @Input() backgroundClass = 'numbers-background'; + @Input() colorClass = 'portal-color'; + @Input() backgroundClass = null; @Input() refineQuery = null; public properties: EnvProperties = properties; public publicationsSize: any = null; @@ -98,6 +104,7 @@ export class NumbersComponent implements OnInit, OnDestroy { public fundersSize: any = null; public projectsSize: any = null; public datasourcesSize: any = null; + public loading: boolean = true; private subs: any[] = []; constructor(private searchResearchResultsService: SearchResearchResultsService, @@ -106,72 +113,40 @@ export class NumbersComponent implements OnInit, OnDestroy { } ngOnInit() { - this.subs.push(this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, this.refineQuery).subscribe( - data => { - if (data && data > 0) { - this.publicationsSize = NumberUtils.roundNumber(data); - } - }, - err => { - this.handleError('Error getting number of publications', err); + this.subs.push(zip( + this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, this.refineQuery), + this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, this.refineQuery), + this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, this.refineQuery), + this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, this.refineQuery), + this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, this.refineQuery), + this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, this.refineQuery) + ).subscribe((data: any[]) => { + if (data[0] && data[0] > 0) { + this.publicationsSize = NumberUtils.roundNumber(data[0]); } - )); - this.subs.push(this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, this.refineQuery).subscribe( - data => { - if (data && data > 0) { - this.datasetsSize = NumberUtils.roundNumber(data); - } - }, - err => { - this.handleError('Error getting number of research data', err); + if (data[1] && data[1] > 0) { + this.datasetsSize = NumberUtils.roundNumber(data[1]); } - )); - this.subs.push(this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, this.refineQuery).subscribe( - data => { - if (data && data > 0) { - this.softwareSize = NumberUtils.roundNumber(data); - } - }, - err => { - this.handleError('Error getting number of software data', err); + if (data[2] && data[2] > 0) { + this.softwareSize = NumberUtils.roundNumber(data[2]); } - )); - this.subs.push(this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, this.refineQuery).subscribe( - data => { - if (data && data > 0) { - this.otherSize = NumberUtils.roundNumber(data); - } - }, - err => { - this.handleError('Error getting number of software data', err); + if (data[3] && data[3] > 0) { + this.otherSize = NumberUtils.roundNumber(data[3]); } - )); - this.subs.push(this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, this.refineQuery).subscribe( - data => { - if (data[0] && data[0] > 0) { - this.projectsSize = NumberUtils.roundNumber(data[0]); - } - if (data[1].length > 0 && data[1][0].filterId == 'funder' && data[1][0].values) { - this.fundersSize = NumberUtils.roundNumber(data[1][0].values.length); - } - - }, - err => { - this.handleError('Error getting \'funder\' field results of projects', err); - }) - ); - - this.subs.push(this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, this.refineQuery).subscribe( - data => { - if (data && data > 0) { - this.datasourcesSize = NumberUtils.roundNumber(data); - } - - }, - err => { - this.handleError('Error getting number of content providers', err); + if (data[4][0] && data[4][0] > 0) { + this.projectsSize = NumberUtils.roundNumber(data[4][0]); } - )); + if (data[4][1] && data[4][1].length > 0 && data[4][1][0].filterId == 'funder' && data[4][1][0].values) { + this.fundersSize = NumberUtils.roundNumber(data[4][1][0].values.length); + } + if (data[5] && data[5] > 0) { + this.datasourcesSize = NumberUtils.roundNumber(data[5]); + } + this.loading = false; + }, err => { + this.handleError('Error getting numbers', err); + this.loading = false; + })); } ngOnDestroy() { @@ -183,6 +158,6 @@ export class NumbersComponent implements OnInit, OnDestroy { } private handleError(message: string, error) { - console.error("Numbers: " + message, error); + console.error('Numbers: ' + message, error); } } diff --git a/sharedComponents/numbers/numbers.module.ts b/sharedComponents/numbers/numbers.module.ts index f684ad7f..e88ec50d 100644 --- a/sharedComponents/numbers/numbers.module.ts +++ b/sharedComponents/numbers/numbers.module.ts @@ -7,9 +7,10 @@ import {book, cog, database, earth} from '../../utils/icons/icons'; import {SearchResearchResultsService} from '../../services/searchResearchResults.service'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; +import {LoadingModule} from '../../utils/loading/loading.module'; @NgModule({ - imports: [CommonModule, IconsModule], + imports: [CommonModule, IconsModule, LoadingModule], declarations: [NumbersComponent], exports: [NumbersComponent], providers: [SearchResearchResultsService, SearchDataprovidersService, RefineFieldResultsService] diff --git a/utils/loading/loading.component.ts b/utils/loading/loading.component.ts index 05f25bbc..8477e095 100644 --- a/utils/loading/loading.component.ts +++ b/utils/loading/loading.component.ts @@ -11,7 +11,7 @@ import {Component, Input, OnInit} from "@angular/core";
-
+