2021-04-16 20:18:02 +02:00
|
|
|
import {Component, EventEmitter, Input, OnDestroy, OnInit, Output} from '@angular/core';
|
2021-04-15 16:42:12 +02:00
|
|
|
import {SearchResearchResultsService} from '../../services/searchResearchResults.service';
|
|
|
|
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
|
|
|
|
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
|
|
|
|
import {EnvProperties} from '../../utils/properties/env-properties';
|
|
|
|
import {properties} from '../../../../environments/environment';
|
2021-04-16 20:18:02 +02:00
|
|
|
import {NumberSize, NumberUtils} from '../../utils/number-utils.class';
|
|
|
|
import {BehaviorSubject, Observable, Subscription, zip} from 'rxjs';
|
2021-04-18 13:35:57 +02:00
|
|
|
import {RouterHelper} from "../../utils/routerHelper.class";
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
import {OpenaireEntities} from "../../utils/properties/searchFields";
|
2022-11-08 13:09:03 +01:00
|
|
|
import {SearchOrganizationsService} from '../../services/searchOrganizations.service';
|
2021-04-16 20:18:02 +02:00
|
|
|
|
|
|
|
export interface Numbers {
|
|
|
|
publicationsSize?: NumberSize;
|
|
|
|
datasetsSize?: NumberSize;
|
|
|
|
datasetsLinkedSize?: NumberSize;
|
|
|
|
softwareLinkedSize?: NumberSize;
|
|
|
|
softwareSize?: NumberSize;
|
|
|
|
otherSize?: NumberSize;
|
|
|
|
fundersSize?: NumberSize;
|
|
|
|
projectsSize?: NumberSize;
|
|
|
|
datasourcesSize?: NumberSize;
|
2022-05-13 13:51:53 +02:00
|
|
|
organizationsSize?: NumberSize;
|
2021-04-16 20:18:02 +02:00
|
|
|
}
|
2021-04-15 16:42:12 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'numbers',
|
|
|
|
template: `
|
2022-11-08 13:09:03 +01:00
|
|
|
<div *ngIf="showContentWithNumbers" class="uk-margin-top" style="max-width: 600px;" uk-scrollspy-class>
|
|
|
|
<div>
|
|
|
|
A comprehensive and open dataset of research information covering
|
|
|
|
<span *ngIf="hasPublications" class="uk-text-bold">{{numbers.publicationsSize.number|number}}<span class="uk-text-lowercase">{{numbers.publicationsSize.size}}</span> {{openaireEntities.PUBLICATIONS.toLowerCase()}}</span>
|
|
|
|
<ng-container *ngIf="(hasPublications && (hasDatasets || hasSoftware || (hasDatasources || hasProjects || hasOrganizations)))">, </ng-container>
|
|
|
|
<span *ngIf="hasDatasets" class="uk-text-bold">{{numbers.datasetsSize.number|number}}<span class="uk-text-lowercase">{{numbers.datasetsSize.size}}</span> {{openaireEntities.DATASETS.toLowerCase()}}</span>
|
|
|
|
<ng-container *ngIf="(hasDatasets && (hasSoftware || (hasDatasources || hasProjects || hasOrganizations)))">, </ng-container>
|
|
|
|
<span *ngIf="hasSoftware" class="uk-text-bold">{{numbers.softwareSize.number|number}}<span class="uk-text-lowercase">{{numbers.softwareSize.size}}</span> {{openaireEntities.SOFTWARE.toLowerCase()}} items</span>
|
|
|
|
<ng-container *ngIf="(hasSoftware && (hasDatasources || hasProjects || hasOrganizations))">, </ng-container>
|
|
|
|
<ng-container *ngIf="((hasPublications || hasDatasets || hasSoftware) && (hasDatasources))"> from </ng-container>
|
|
|
|
<span *ngIf="hasDatasources" class="uk-text-bold">{{numbers.datasourcesSize.number|number}}<span class="uk-text-lowercase">{{numbers.datasourcesSize.size}}</span> {{openaireEntities.DATASOURCES.toLowerCase()}}</span>
|
|
|
|
<ng-container *ngIf="(hasDatasources) && ((hasProjects) || hasOrganizations)">, linked to </ng-container>
|
|
|
|
<span *ngIf="hasProjects" class="uk-text-bold">{{numbers.projectsSize.number|number}}<span class="uk-text-lowercase">{{numbers.projectsSize.size}}</span> grants</span>
|
|
|
|
<ng-container *ngIf="hasProjects && hasOrganizations"> and </ng-container>
|
|
|
|
<span *ngIf="hasOrganizations" class="uk-text-bold">{{numbers.organizationsSize.number|number}}<span class="uk-text-lowercase">{{numbers.organizationsSize.size}}</span> {{openaireEntities.ORGANIZATIONS.toLowerCase()}}</span>.
|
|
|
|
</div>
|
|
|
|
<div class="uk-text-primary">All linked together through citations and semantics.</div>
|
|
|
|
</div>
|
2021-04-16 15:00:02 +02:00
|
|
|
`,
|
2021-04-15 16:42:12 +02:00
|
|
|
})
|
|
|
|
export class NumbersComponent implements OnInit, OnDestroy {
|
2021-04-18 13:35:57 +02:00
|
|
|
/** Add a value if you want to apply refine query*/
|
|
|
|
@Input() refineValue = null;
|
|
|
|
/** True: Default initialization
|
|
|
|
* False: Call init method to initialize numbers */
|
2021-04-16 20:18:02 +02:00
|
|
|
@Input() defaultInit = true;
|
2021-04-18 13:35:57 +02:00
|
|
|
/** When numbers have been initialized this emitter will emitted */
|
2022-11-08 13:09:03 +01:00
|
|
|
@Output() results: EventEmitter<Numbers> = new EventEmitter<Numbers>();
|
|
|
|
|
|
|
|
showPublications: boolean = true;
|
|
|
|
showDatasets: boolean = true;
|
|
|
|
showSoftware: boolean = true;
|
|
|
|
showOrp: boolean = true;
|
|
|
|
showOrganizations: boolean = true;
|
|
|
|
showProjects: boolean = true;
|
|
|
|
showDataProviders: boolean = true;
|
|
|
|
numbersLimit: number = 100;
|
2021-04-15 16:42:12 +02:00
|
|
|
public properties: EnvProperties = properties;
|
[Monitor Dashboard & Library | new-theme]: Renaming entity types using OpenaireEntities.
Files updated: develop.component.ts, methodology.component.ts, claimEntitiesSelection.component.ts, directLinking.component.ts, linkingGeneric.component.html, linkingGeneric.component.ts, approved.component.ts, searchDataprovidersToDeposit.component.ts, errorPage.component.ts, dataProvider.component.html, dataProvider.component.ts, dataProvider.service.ts, relatedDatasourcesTab.component.ts, project.component.ts, myOrcidLinks.component.ts, searchMyOrcidResults.component.html, searchMyOrcidResults.component.ts, searchAll.component.html, searchAll.component.ts, advancedSearchForm.component.html, advancedSearchForm.component.ts, searchDataProviders.component.ts, searchResearchResults.service.ts, numbers.component.ts, other-portals.component.html, other-portals.component.ts, fetchDataproviders.class.ts, fetchResearchResults.class.ts, searchFields.ts, result-preview.component.ts
2022-05-09 12:13:44 +02:00
|
|
|
public openaireEntities = OpenaireEntities;
|
2021-04-18 13:35:57 +02:00
|
|
|
public routerHelper: RouterHelper = new RouterHelper();
|
2021-04-16 20:18:02 +02:00
|
|
|
public numbers: Numbers = {};
|
2021-04-18 13:35:57 +02:00
|
|
|
private emptySubject: BehaviorSubject<number> = new BehaviorSubject<number>(0);
|
2021-04-15 16:42:12 +02:00
|
|
|
private subs: any[] = [];
|
|
|
|
|
|
|
|
constructor(private searchResearchResultsService: SearchResearchResultsService,
|
|
|
|
private searchDataprovidersService: SearchDataprovidersService,
|
2022-11-08 13:09:03 +01:00
|
|
|
private refineFieldResultsService: RefineFieldResultsService,
|
|
|
|
private _searchOrganizationsService: SearchOrganizationsService) {
|
2021-04-28 17:03:45 +02:00
|
|
|
this.emptySubject = new BehaviorSubject<number>(0);
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-04-28 17:03:45 +02:00
|
|
|
if (this.defaultInit) {
|
2021-04-16 20:18:02 +02:00
|
|
|
this.init();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
|
2022-11-08 13:09:03 +01:00
|
|
|
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true, getOrganizations = true, refineValue: string = null) {
|
2021-04-28 17:03:45 +02:00
|
|
|
if (refineValue) {
|
2021-04-18 13:57:35 +02:00
|
|
|
this.refineValue = refineValue;
|
|
|
|
}
|
2021-04-28 17:03:45 +02:00
|
|
|
let refineParams = (this.refineValue) ? ('&fq=' + this.refineValue) : null;
|
2021-04-16 15:00:02 +02:00
|
|
|
this.subs.push(zip(
|
2021-04-28 17:03:45 +02:00
|
|
|
(getPublications) ? this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, refineParams) : this.empty,
|
|
|
|
(getDatasets) ? this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, refineParams) : this.empty,
|
|
|
|
(getDatasetsLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("dataset", this.properties) : this.empty,
|
|
|
|
(getSoftware) ? this.searchResearchResultsService.numOfSearchResults('software', '', this.properties, refineParams) : this.empty,
|
|
|
|
(getSoftwareLinked) ? this.searchResearchResultsService.numOfSearchResultsLinkedToPub("software", this.properties) : this.empty,
|
|
|
|
(getOther) ? this.searchResearchResultsService.numOfSearchResults('other', '', this.properties, refineParams) : this.empty,
|
|
|
|
(getProjects) ? this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, refineParams) : this.empty,
|
2022-11-08 13:09:03 +01:00
|
|
|
(getDataProviders) ? this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, refineParams) : this.empty,
|
|
|
|
(getOrganizations) ? this._searchOrganizationsService.numOfSearchOrganizations2('', this.properties, refineParams) : this.empty
|
2021-04-16 15:00:02 +02:00
|
|
|
).subscribe((data: any[]) => {
|
|
|
|
if (data[0] && data[0] > 0) {
|
2021-04-16 20:18:02 +02:00
|
|
|
this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
|
2021-04-16 15:00:02 +02:00
|
|
|
}
|
|
|
|
if (data[1] && data[1] > 0) {
|
2021-04-16 20:18:02 +02:00
|
|
|
this.numbers.datasetsSize = NumberUtils.roundNumber(data[1]);
|
2021-04-16 15:00:02 +02:00
|
|
|
}
|
|
|
|
if (data[2] && data[2] > 0) {
|
2021-04-16 20:18:02 +02:00
|
|
|
this.numbers.datasetsLinkedSize = NumberUtils.roundNumber(data[2]);
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
2021-04-16 15:00:02 +02:00
|
|
|
if (data[3] && data[3] > 0) {
|
2021-04-16 20:18:02 +02:00
|
|
|
this.numbers.softwareSize = NumberUtils.roundNumber(data[3]);
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
2021-04-16 20:18:02 +02:00
|
|
|
if (data[4] && data[4] > 0) {
|
|
|
|
this.numbers.softwareLinkedSize = NumberUtils.roundNumber(data[4]);
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
2021-04-16 15:00:02 +02:00
|
|
|
if (data[5] && data[5] > 0) {
|
2021-04-16 20:18:02 +02:00
|
|
|
this.numbers.otherSize = NumberUtils.roundNumber(data[5]);
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
2021-04-16 20:18:02 +02:00
|
|
|
if (data[6][0] && data[6][0] > 0) {
|
|
|
|
this.numbers.projectsSize = NumberUtils.roundNumber(data[6][0]);
|
|
|
|
}
|
|
|
|
if (data[6][1] && data[6][1].length > 0 && data[6][1][0].filterId == 'funder' && data[6][1][0].values) {
|
|
|
|
this.numbers.fundersSize = NumberUtils.roundNumber(data[6][1][0].values.length);
|
|
|
|
}
|
|
|
|
if (data[7] && data[7] > 0) {
|
|
|
|
this.numbers.datasourcesSize = NumberUtils.roundNumber(data[7]);
|
|
|
|
}
|
2022-11-08 13:09:03 +01:00
|
|
|
if (data[8] && data[8] > 0) {
|
|
|
|
this.numbers.organizationsSize = NumberUtils.roundNumber(data[8]);
|
|
|
|
}
|
|
|
|
this.results.emit(this.numbers);
|
2021-04-16 15:00:02 +02:00
|
|
|
}, err => {
|
|
|
|
this.handleError('Error getting numbers', err);
|
|
|
|
}));
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy() {
|
|
|
|
this.subs.forEach(sub => {
|
|
|
|
if (sub instanceof Subscription) {
|
|
|
|
sub.unsubscribe();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2021-04-16 20:18:02 +02:00
|
|
|
get empty(): Observable<number> {
|
|
|
|
return this.emptySubject.asObservable();
|
|
|
|
}
|
|
|
|
|
2021-04-15 16:42:12 +02:00
|
|
|
private handleError(message: string, error) {
|
2021-04-16 15:00:02 +02:00
|
|
|
console.error('Numbers: ' + message, error);
|
2022-11-08 13:09:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public get showContentWithNumbers() {
|
|
|
|
if (this.numbers && (this.hasPublications || this.hasDatasets || this.hasSoftware || this.hasDatasources || this.hasProjects || this.hasOrganizations)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public get hasPublications() {
|
|
|
|
return this.showPublications && this.numbers.publicationsSize && this.numbers.publicationsSize.count >= this.numbersLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get hasDatasets() {
|
|
|
|
return this.showDatasets && this.numbers.datasetsSize && this.numbers.datasetsSize.count >= this.numbersLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get hasSoftware() {
|
|
|
|
return this.showSoftware && this.numbers.softwareSize && this.numbers.softwareSize.count >= this.numbersLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get hasDatasources() {
|
|
|
|
return this.showDataProviders && this.numbers.datasourcesSize && this.numbers.datasourcesSize.count >= this.numbersLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get hasProjects() {
|
|
|
|
return this.showProjects && this.numbers.projectsSize && this.numbers.projectsSize.count >= this.numbersLimit;
|
|
|
|
}
|
|
|
|
|
|
|
|
public get hasOrganizations() {
|
|
|
|
return this.showOrganizations && this.numbers.organizationsSize && this.numbers.organizationsSize.count >= this.numbersLimit;
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
|
|
|
}
|