[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
This commit is contained in:
k.triantafyllou 2021-04-16 13:00:02 +00:00
parent 34ae3808d0
commit 4ee8ad094c
3 changed files with 115 additions and 139 deletions

View File

@ -5,90 +5,96 @@ import {RefineFieldResultsService} from '../../services/refineFieldResults.servi
import {EnvProperties} from '../../utils/properties/env-properties'; import {EnvProperties} from '../../utils/properties/env-properties';
import {properties} from '../../../../environments/environment'; import {properties} from '../../../../environments/environment';
import {NumberUtils} from '../../utils/number-utils.class'; import {NumberUtils} from '../../utils/number-utils.class';
import {Subscription} from 'rxjs'; import {Subscription, zip} from 'rxjs';
@Component({ @Component({
selector: 'numbers', selector: 'numbers',
template: ` template: `
<div class="uk-margin-large-top uk-container uk-margin-bottom uk-text-center"> <ng-container *ngIf="!loading">
<div class="uk-grid uk-grid-large uk-child-width-1-3@m" uk-grid> <div class="uk-container uk-section uk-padding-remove-bottom uk-text-center">
<div *ngIf="fundersSize"> <div class="uk-grid uk-grid-large uk-child-width-1-3@m" uk-grid>
<h3> <div *ngIf="fundersSize">
<a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number"> <h3>
{{fundersSize.number|number}}<span class="number-size">{{fundersSize.size}}</span> <a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number">
</a> {{fundersSize.number|number}}<span class="number-size">{{fundersSize.size}}</span>
</h3> </a>
<span class="uk-text-uppercase uk-text-large">Funders</span> </h3>
</div> <span class="uk-text-uppercase uk-text-large">Funders</span>
<div *ngIf="datasourcesSize"> </div>
<h3> <div *ngIf="datasourcesSize">
<a href="https://explore.openaire.eu/search/find/dataproviders" target="_blank" <h3>
class="uk-text-bold number"> <a href="https://explore.openaire.eu/search/find/dataproviders" target="_blank"
{{datasourcesSize.number|number}}<span class="number-size">{{datasourcesSize.size}}</span> class="uk-text-bold number">
</a> {{datasourcesSize.number|number}}<span class="number-size">{{datasourcesSize.size}}</span>
</h3> </a>
<span class="uk-text-uppercase uk-text-large">Content providers</span> </h3>
</div> <span class="uk-text-uppercase uk-text-large">Content providers</span>
<div *ngIf="projectsSize"> </div>
<h3> <div *ngIf="projectsSize">
<a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number"> <h3>
{{projectsSize.number|number}}<span class="number-size">{{projectsSize.size}}</span> <a href="https://explore.openaire.eu/search/find/projects" target="_blank" class="uk-text-bold number">
</a> {{projectsSize.number|number}}<span class="number-size">{{projectsSize.size}}</span>
</h3> </a>
<span class="uk-text-uppercase uk-text-large">Projects</span> </h3>
<span class="uk-text-uppercase uk-text-large">Projects</span>
</div>
</div> </div>
</div> </div>
<div class="uk-section" [ngClass]="backgroundClass">
<div class="uk-container">
<div class="uk-grid uk-flex-center uk-margin-auto-left@m uk-margin-auto-right@m uk-grid-large" uk-grid>
<div *ngIf="publicationsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=publications&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{publicationsSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>publications</span>
</div>
</div>
</div>
<div *ngIf="datasetsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=datasets&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{datasetsSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>research data</span>
</div>
</div>
</div>
<div *ngIf="softwareSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=software&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{softwareSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>software</span>
</div>
</div>
</div>
<div *ngIf="otherSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width uk-flex uk-flex-wrap uk-flex-center uk-flex-left@m">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=other&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{otherSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>other research products</span>
</div>
</div>
</div>
</div>
</div>
</div>
</ng-container>
<div *ngIf="loading" class="uk-container uk-section uk-text-center">
<loading [color]="colorClass"></loading>
</div> </div>
<div class="uk-section" [ngClass]="backgroundClass"> `,
<div class="uk-container">
<div class="uk-grid uk-margin-auto-left uk-margin-auto-right uk-grid-large" uk-grid>
<div *ngIf="publicationsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=publications&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{publicationsSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>publications</span>
</div>
</div>
</div>
<div *ngIf="datasetsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=datasets&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{datasetsSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>research data</span>
</div>
</div>
</div>
<div *ngIf="softwareSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=software&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{softwareSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>software</span>
</div>
</div>
</div>
<div *ngIf="otherSize" class="uk-width-1-2@m uk-flex uk-flex-center">
<div class="number-width">
<a href="https://explore.openaire.eu/search/find/research-outcomes?type=other&qf=false"
target="_blank" class="number uk-text-bold uk-margin-bottom">{{otherSize.count|number}} </a>
<div class="uk-text-uppercase uk-flex uk-flex-middle">
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
<span>other research products</span>
</div>
</div>
</div>
</div>
</div>
</div>`,
}) })
export class NumbersComponent implements OnInit, OnDestroy { export class NumbersComponent implements OnInit, OnDestroy {
@Input() colorClass = 'uk-text-secondary'; @Input() colorClass = 'portal-color';
@Input() backgroundClass = 'numbers-background'; @Input() backgroundClass = null;
@Input() refineQuery = null; @Input() refineQuery = null;
public properties: EnvProperties = properties; public properties: EnvProperties = properties;
public publicationsSize: any = null; public publicationsSize: any = null;
@ -98,6 +104,7 @@ export class NumbersComponent implements OnInit, OnDestroy {
public fundersSize: any = null; public fundersSize: any = null;
public projectsSize: any = null; public projectsSize: any = null;
public datasourcesSize: any = null; public datasourcesSize: any = null;
public loading: boolean = true;
private subs: any[] = []; private subs: any[] = [];
constructor(private searchResearchResultsService: SearchResearchResultsService, constructor(private searchResearchResultsService: SearchResearchResultsService,
@ -106,72 +113,40 @@ export class NumbersComponent implements OnInit, OnDestroy {
} }
ngOnInit() { ngOnInit() {
this.subs.push(this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, this.refineQuery).subscribe( this.subs.push(zip(
data => { this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, this.refineQuery),
if (data && data > 0) { this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, this.refineQuery),
this.publicationsSize = NumberUtils.roundNumber(data); 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),
err => { this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, this.refineQuery)
this.handleError('Error getting number of publications', err); ).subscribe((data: any[]) => {
if (data[0] && data[0] > 0) {
this.publicationsSize = NumberUtils.roundNumber(data[0]);
} }
)); if (data[1] && data[1] > 0) {
this.subs.push(this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, this.refineQuery).subscribe( this.datasetsSize = NumberUtils.roundNumber(data[1]);
data => {
if (data && data > 0) {
this.datasetsSize = NumberUtils.roundNumber(data);
}
},
err => {
this.handleError('Error getting number of research data', err);
} }
)); if (data[2] && data[2] > 0) {
this.subs.push(this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, this.refineQuery).subscribe( this.softwareSize = NumberUtils.roundNumber(data[2]);
data => {
if (data && data > 0) {
this.softwareSize = NumberUtils.roundNumber(data);
}
},
err => {
this.handleError('Error getting number of software data', err);
} }
)); if (data[3] && data[3] > 0) {
this.subs.push(this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, this.refineQuery).subscribe( this.otherSize = NumberUtils.roundNumber(data[3]);
data => {
if (data && data > 0) {
this.otherSize = NumberUtils.roundNumber(data);
}
},
err => {
this.handleError('Error getting number of software data', err);
} }
)); if (data[4][0] && data[4][0] > 0) {
this.subs.push(this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, this.refineQuery).subscribe( this.projectsSize = NumberUtils.roundNumber(data[4][0]);
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][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() { ngOnDestroy() {
@ -183,6 +158,6 @@ export class NumbersComponent implements OnInit, OnDestroy {
} }
private handleError(message: string, error) { private handleError(message: string, error) {
console.error("Numbers: " + message, error); console.error('Numbers: ' + message, error);
} }
} }

View File

@ -7,9 +7,10 @@ import {book, cog, database, earth} from '../../utils/icons/icons';
import {SearchResearchResultsService} from '../../services/searchResearchResults.service'; import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
import {SearchDataprovidersService} from '../../services/searchDataproviders.service'; import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
import {RefineFieldResultsService} from '../../services/refineFieldResults.service'; import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
import {LoadingModule} from '../../utils/loading/loading.module';
@NgModule({ @NgModule({
imports: [CommonModule, IconsModule], imports: [CommonModule, IconsModule, LoadingModule],
declarations: [NumbersComponent], declarations: [NumbersComponent],
exports: [NumbersComponent], exports: [NumbersComponent],
providers: [SearchResearchResultsService, SearchDataprovidersService, RefineFieldResultsService] providers: [SearchResearchResultsService, SearchDataprovidersService, RefineFieldResultsService]

View File

@ -11,7 +11,7 @@ import {Component, Input, OnInit} from "@angular/core";
</div> </div>
</ng-template> </ng-template>
<ng-template #loading> <ng-template #loading>
<div [class]="'uk-flex uk-flex-center '+(top_margin ? 'uk-margin-small-top' : '')"> <div class="uk-flex uk-flex-center" [class.uk-margin-small-top]="top_margin">
<div [ngStyle]="style"> <div [ngStyle]="style">
<span class="uk-icon uk-spinner" [ngClass]="color"> <span class="uk-icon uk-spinner" [ngClass]="color">
<svg width="60" height="60" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle <svg width="60" height="60" viewBox="0 0 30 30" xmlns="http://www.w3.org/2000/svg" data-svg="spinner"><circle