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";
|
2021-04-28 17:03:45 +02:00
|
|
|
import {HelperFunctions} from "../../utils/HelperFunctions.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";
|
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
|
|
|
|
2022-05-13 13:51:53 +02:00
|
|
|
type Entity = 'publication' | 'dataset' | 'software' | 'other' | 'project' | 'datasource' | 'organization';
|
2021-04-18 13:35:57 +02:00
|
|
|
|
|
|
|
interface Link {
|
|
|
|
link: string,
|
|
|
|
params?: any
|
|
|
|
}
|
|
|
|
|
2021-04-15 16:42:12 +02:00
|
|
|
@Component({
|
|
|
|
selector: 'numbers',
|
|
|
|
template: `
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="!loading && numbers">
|
2021-04-16 15:00:02 +02:00
|
|
|
<div class="uk-container uk-section uk-padding-remove-bottom uk-text-center">
|
|
|
|
<div class="uk-grid uk-grid-large uk-child-width-1-3@m" uk-grid>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="numbers.fundersSize">
|
2021-04-18 13:35:57 +02:00
|
|
|
<h3 *ngIf="links.get('project')">
|
2022-09-23 15:33:26 +02:00
|
|
|
<a *ngIf="externalLink" [href]="links.get('project').link" target="_blank" class="uk-text-bold number uk-link-text uk-button-link">
|
2021-04-18 13:35:57 +02:00
|
|
|
{{numbers.fundersSize.number|number}}<span class="number-size">{{numbers.fundersSize.size}}</span>
|
|
|
|
</a>
|
2021-04-28 17:03:45 +02:00
|
|
|
<a *ngIf="!externalLink" [routerLink]="links.get('project').link"
|
2022-09-23 15:33:26 +02:00
|
|
|
[queryParams]="links.get('project').params" class="uk-text-bold number uk-link-text uk-button-link">
|
2021-04-16 20:18:02 +02:00
|
|
|
{{numbers.fundersSize.number|number}}<span class="number-size">{{numbers.fundersSize.size}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</a>
|
|
|
|
</h3>
|
|
|
|
<span class="uk-text-uppercase uk-text-large">Funders</span>
|
|
|
|
</div>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="numbers.datasourcesSize">
|
2021-04-16 15:00:02 +02:00
|
|
|
<h3>
|
2022-09-23 15:33:26 +02:00
|
|
|
<a *ngIf="externalLink" [href]="links.get('datasource').link" target="_blank" class="uk-text-bold number uk-link-text uk-button-link">
|
2021-04-28 17:03:45 +02:00
|
|
|
{{numbers.datasourcesSize.number|number}}<span
|
|
|
|
class="number-size">{{numbers.datasourcesSize.size}}</span>
|
2021-04-18 13:35:57 +02:00
|
|
|
</a>
|
2021-04-28 17:03:45 +02:00
|
|
|
<a *ngIf="!externalLink" [routerLink]="links.get('datasource').link"
|
2022-09-23 15:33:26 +02:00
|
|
|
[queryParams]="links.get('datasource').params" class="uk-text-bold number uk-link-text uk-button-link">
|
2021-04-28 17:03:45 +02:00
|
|
|
{{numbers.datasourcesSize.number|number}}<span
|
|
|
|
class="number-size">{{numbers.datasourcesSize.size}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</a>
|
|
|
|
</h3>
|
[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
|
|
|
<span class="uk-text-uppercase uk-text-large">{{openaireEntities.DATASOURCES}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</div>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="numbers.projectsSize">
|
2021-04-16 15:00:02 +02:00
|
|
|
<h3>
|
2022-09-23 15:33:26 +02:00
|
|
|
<a *ngIf="externalLink" [href]="links.get('project').link" target="_blank" class="uk-text-bold number uk-link-text uk-button-link">
|
2021-04-18 13:35:57 +02:00
|
|
|
{{numbers.projectsSize.number|number}}<span class="number-size">{{numbers.projectsSize.size}}</span>
|
|
|
|
</a>
|
2021-04-28 17:03:45 +02:00
|
|
|
<a *ngIf="!externalLink" [routerLink]="links.get('project').link"
|
2022-09-23 15:33:26 +02:00
|
|
|
[queryParams]="links.get('project').params" class="uk-text-bold number uk-link-text uk-button-link">
|
2021-04-16 20:18:02 +02:00
|
|
|
{{numbers.projectsSize.number|number}}<span class="number-size">{{numbers.projectsSize.size}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</a>
|
|
|
|
</h3>
|
[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
|
|
|
<span class="uk-text-uppercase uk-text-large">{{openaireEntities.PROJECTS}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</div>
|
2021-04-15 16:42:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div class="uk-section uk-margin-top" [ngClass]="backgroundClass">
|
2021-04-16 15:00:02 +02:00
|
|
|
<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>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="numbers.publicationsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
2022-09-23 15:33:26 +02:00
|
|
|
<div class="number-width uk-width-medium uk-flex uk-flex-column">
|
2021-04-18 13:35:57 +02:00
|
|
|
<a *ngIf="externalLink" [href]="links.get('publication').link" target="_blank"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.publicationsSize.count|number}}</a>
|
2021-04-28 17:03:45 +02:00
|
|
|
<a *ngIf="!externalLink" [routerLink]="links.get('publication').link"
|
|
|
|
[queryParams]="links.get('publication').params"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.publicationsSize.count|number}}</a>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
2021-04-16 15:00:02 +02:00
|
|
|
<icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
[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
|
|
|
<span>{{openaireEntities.PUBLICATIONS}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</div>
|
2021-04-15 16:42:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="numbers.datasetsSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
2022-09-23 15:33:26 +02:00
|
|
|
<div class="number-width uk-width-medium uk-flex uk-flex-column">
|
2021-04-18 13:35:57 +02:00
|
|
|
<a *ngIf="externalLink" [href]="links.get('dataset').link" target="_blank"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.datasetsSize.count|number}}</a>
|
2021-04-28 17:03:45 +02:00
|
|
|
<a *ngIf="!externalLink" [routerLink]="links.get('dataset').link"
|
|
|
|
[queryParams]="links.get('dataset').params"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.datasetsSize.count|number}}</a>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
2021-04-28 17:03:45 +02:00
|
|
|
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right"
|
|
|
|
[customClass]="colorClass"></icon>
|
[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
|
|
|
<span>{{openaireEntities.DATASETS}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</div>
|
2021-04-15 16:42:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="numbers.softwareSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
2022-09-23 15:33:26 +02:00
|
|
|
<div class="number-width uk-width-medium uk-flex uk-flex-column">
|
2021-04-18 13:35:57 +02:00
|
|
|
<a *ngIf="externalLink" [href]="links.get('software').link" target="_blank"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.softwareSize.count|number}}</a>
|
2021-04-28 17:03:45 +02:00
|
|
|
<a *ngIf="!externalLink" [routerLink]="links.get('software').link"
|
|
|
|
[queryParams]="links.get('software').params"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.softwareSize.count|number}}</a>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
2021-04-16 15:00:02 +02:00
|
|
|
<icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
[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
|
|
|
<span>{{openaireEntities.SOFTWARE}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</div>
|
2021-04-15 16:42:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div *ngIf="numbers.otherSize" class="uk-width-1-2@m uk-flex uk-flex-center">
|
2022-09-23 15:33:26 +02:00
|
|
|
<div class="number-width uk-width-medium uk-flex uk-flex-column">
|
2021-04-18 13:35:57 +02:00
|
|
|
<a *ngIf="externalLink" [href]="links.get('other').link" target="_blank"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.otherSize.count|number}}</a>
|
2021-04-28 17:03:45 +02:00
|
|
|
<a *ngIf="!externalLink" [routerLink]="links.get('other').link"
|
|
|
|
[queryParams]="links.get('other').params"
|
2022-09-23 15:33:26 +02:00
|
|
|
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m uk-link-text uk-button-link">{{numbers.otherSize.count|number}}</a>
|
2021-04-16 20:18:02 +02:00
|
|
|
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
2021-04-28 17:03:45 +02:00
|
|
|
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right"
|
|
|
|
[customClass]="colorClass"></icon>
|
[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
|
|
|
<span>{{openaireEntities.OTHER}}</span>
|
2021-04-16 15:00:02 +02:00
|
|
|
</div>
|
2021-04-15 16:42:12 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-16 15:14:57 +02:00
|
|
|
</div>
|
|
|
|
<div *ngIf="loading" class="uk-container uk-section uk-text-center" style="min-height: 400px">
|
2021-04-16 15:00:02 +02:00
|
|
|
<loading [color]="colorClass"></loading>
|
|
|
|
</div>
|
|
|
|
`,
|
2021-04-15 16:42:12 +02:00
|
|
|
})
|
|
|
|
export class NumbersComponent implements OnInit, OnDestroy {
|
2022-10-03 19:25:37 +02:00
|
|
|
@Input() colorClass = 'uk-text-primary';
|
2021-04-16 15:00:02 +02:00
|
|
|
@Input() backgroundClass = null;
|
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
|
|
|
/** Add an external link for numbers link */
|
|
|
|
@Input() externalLink;
|
|
|
|
/** When numbers have been initialized this emitter will emitted */
|
2021-04-16 20:18:02 +02:00
|
|
|
@Output() results: EventEmitter<Numbers> = new EventEmitter<Numbers>();
|
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-16 15:00:02 +02:00
|
|
|
public loading: boolean = true;
|
2021-04-18 13:35:57 +02:00
|
|
|
public links: Map<Entity, Link> = new Map<Entity, Link>();
|
|
|
|
private params: Map<Entity, {}> = new Map<Entity, {}>();
|
|
|
|
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,
|
|
|
|
private refineFieldResultsService: RefineFieldResultsService) {
|
2021-04-28 17:03:45 +02:00
|
|
|
this.links = new Map<Entity, Link>();
|
|
|
|
this.params = new Map<Entity, {}>();
|
|
|
|
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();
|
|
|
|
}
|
2021-04-18 13:35:57 +02:00
|
|
|
this.setLinks();
|
|
|
|
}
|
|
|
|
|
|
|
|
setParams() {
|
2021-07-14 13:19:57 +02:00
|
|
|
this.params.set('publication', {type: 'publications'});
|
|
|
|
this.params.set('dataset', {type: 'datasets'});
|
|
|
|
this.params.set('software', {type: 'software'});
|
|
|
|
this.params.set('other', {type: 'other'});
|
2021-04-18 13:35:57 +02:00
|
|
|
this.params.set('project', {});
|
|
|
|
this.params.set('datasource', {});
|
2021-04-28 17:03:45 +02:00
|
|
|
if (this.refineValue) {
|
2021-04-18 13:35:57 +02:00
|
|
|
this.params.forEach((value) => {
|
|
|
|
value['fq'] = this.refineValue;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setLinks() {
|
|
|
|
this.setParams();
|
2021-04-28 17:03:45 +02:00
|
|
|
if (this.externalLink) {
|
|
|
|
this.links.set('publication', {
|
|
|
|
link: this.externalLink + properties.searchLinkToResults +
|
|
|
|
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('publication')), HelperFunctions.getValues(this.params.get('publication')))
|
|
|
|
});
|
|
|
|
this.links.set('dataset', {
|
|
|
|
link: this.externalLink + properties.searchLinkToResults +
|
|
|
|
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('dataset')), HelperFunctions.getValues(this.params.get('dataset')))
|
|
|
|
});
|
|
|
|
this.links.set('software', {
|
|
|
|
link: this.externalLink + properties.searchLinkToResults +
|
|
|
|
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('software')), HelperFunctions.getValues(this.params.get('software')))
|
|
|
|
});
|
|
|
|
this.links.set('other', {
|
|
|
|
link: this.externalLink + properties.searchLinkToResults +
|
|
|
|
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('other')), HelperFunctions.getValues(this.params.get('other')))
|
|
|
|
});
|
|
|
|
this.links.set('project', {
|
|
|
|
link: this.externalLink + properties.searchLinkToProjects +
|
|
|
|
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('project')), HelperFunctions.getValues(this.params.get('project')))
|
|
|
|
});
|
|
|
|
this.links.set('datasource', {
|
|
|
|
link: this.externalLink + properties.searchLinkToDataProviders +
|
|
|
|
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('datasource')), HelperFunctions.getValues(this.params.get('datasource')))
|
|
|
|
});
|
2021-04-18 13:35:57 +02:00
|
|
|
} else {
|
|
|
|
this.links.set('publication', {
|
|
|
|
link: properties.searchLinkToResults,
|
2021-04-28 17:03:45 +02:00
|
|
|
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('publication')), HelperFunctions.getValues(this.params.get('publication')))
|
2021-04-18 13:35:57 +02:00
|
|
|
});
|
|
|
|
this.links.set('dataset', {
|
|
|
|
link: properties.searchLinkToResults,
|
2021-04-28 17:03:45 +02:00
|
|
|
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('dataset')), HelperFunctions.getValues(this.params.get('dataset')))
|
2021-04-18 13:35:57 +02:00
|
|
|
});
|
|
|
|
this.links.set('software', {
|
|
|
|
link: properties.searchLinkToResults,
|
2021-04-28 17:03:45 +02:00
|
|
|
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('software')), HelperFunctions.getValues(this.params.get('software')))
|
2021-04-18 13:35:57 +02:00
|
|
|
});
|
|
|
|
this.links.set('other', {
|
|
|
|
link: properties.searchLinkToResults,
|
2021-04-28 17:03:45 +02:00
|
|
|
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('other')), HelperFunctions.getValues(this.params.get('other')))
|
2021-04-18 13:35:57 +02:00
|
|
|
});
|
|
|
|
this.links.set('project', {
|
|
|
|
link: properties.searchLinkToProjects,
|
2021-04-28 17:03:45 +02:00
|
|
|
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('project')), HelperFunctions.getValues(this.params.get('project')))
|
2021-04-18 13:35:57 +02:00
|
|
|
});
|
|
|
|
this.links.set('datasource', {
|
|
|
|
link: properties.searchLinkToDataProviders,
|
2021-04-28 17:03:45 +02:00
|
|
|
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('datasource')), HelperFunctions.getValues(this.params.get('datasource')))
|
2021-04-18 13:35:57 +02:00
|
|
|
});
|
|
|
|
}
|
2021-04-16 20:18:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
|
2021-04-18 13:57:35 +02:00
|
|
|
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true, refineValue: string = null) {
|
2021-04-16 20:18:02 +02:00
|
|
|
this.loading = true;
|
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,
|
|
|
|
(getDataProviders) ? this.searchDataprovidersService.numOfSearchDataproviders('', 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]);
|
|
|
|
}
|
|
|
|
this.results.emit(this.numbers);
|
2021-04-16 15:00:02 +02:00
|
|
|
this.loading = false;
|
|
|
|
}, err => {
|
|
|
|
this.handleError('Error getting numbers', err);
|
|
|
|
this.loading = false;
|
|
|
|
}));
|
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);
|
2021-04-15 16:42:12 +02:00
|
|
|
}
|
|
|
|
}
|