[Library | Trunk]: Fix some errors on server from numbers component
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60974 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
e6fd2f6655
commit
0e6b1e13ca
|
@ -7,6 +7,7 @@ import {properties} from '../../../../environments/environment';
|
|||
import {NumberSize, NumberUtils} from '../../utils/number-utils.class';
|
||||
import {BehaviorSubject, Observable, Subscription, zip} from 'rxjs';
|
||||
import {RouterHelper} from "../../utils/routerHelper.class";
|
||||
import {HelperFunctions} from "../../utils/HelperFunctions.class";
|
||||
|
||||
export interface Numbers {
|
||||
publicationsSize?: NumberSize;
|
||||
|
@ -38,7 +39,8 @@ interface Link {
|
|||
<a *ngIf="externalLink" [href]="links.get('project').link" target="_blank" class="uk-text-bold number">
|
||||
{{numbers.fundersSize.number|number}}<span class="number-size">{{numbers.fundersSize.size}}</span>
|
||||
</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('project').link" [queryParams]="links.get('project').params" class="uk-text-bold number">
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('project').link"
|
||||
[queryParams]="links.get('project').params" class="uk-text-bold number">
|
||||
{{numbers.fundersSize.number|number}}<span class="number-size">{{numbers.fundersSize.size}}</span>
|
||||
</a>
|
||||
</h3>
|
||||
|
@ -47,10 +49,13 @@ interface Link {
|
|||
<div *ngIf="numbers.datasourcesSize">
|
||||
<h3>
|
||||
<a *ngIf="externalLink" [href]="links.get('datasource').link" target="_blank" class="uk-text-bold number">
|
||||
{{numbers.datasourcesSize.number|number}}<span class="number-size">{{numbers.datasourcesSize.size}}</span>
|
||||
{{numbers.datasourcesSize.number|number}}<span
|
||||
class="number-size">{{numbers.datasourcesSize.size}}</span>
|
||||
</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('datasource').link" [queryParams]="links.get('datasource').params" class="uk-text-bold number">
|
||||
{{numbers.datasourcesSize.number|number}}<span class="number-size">{{numbers.datasourcesSize.size}}</span>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('datasource').link"
|
||||
[queryParams]="links.get('datasource').params" class="uk-text-bold number">
|
||||
{{numbers.datasourcesSize.number|number}}<span
|
||||
class="number-size">{{numbers.datasourcesSize.size}}</span>
|
||||
</a>
|
||||
</h3>
|
||||
<span class="uk-text-uppercase uk-text-large">Content providers</span>
|
||||
|
@ -60,7 +65,8 @@ interface Link {
|
|||
<a *ngIf="externalLink" [href]="links.get('project').link" target="_blank" class="uk-text-bold number">
|
||||
{{numbers.projectsSize.number|number}}<span class="number-size">{{numbers.projectsSize.size}}</span>
|
||||
</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('project').link" [queryParams]="links.get('project').params" class="uk-text-bold number">
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('project').link"
|
||||
[queryParams]="links.get('project').params" class="uk-text-bold number">
|
||||
{{numbers.projectsSize.number|number}}<span class="number-size">{{numbers.projectsSize.size}}</span>
|
||||
</a>
|
||||
</h3>
|
||||
|
@ -75,7 +81,8 @@ interface Link {
|
|||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a *ngIf="externalLink" [href]="links.get('publication').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.publicationsSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('publication').link" [queryParams]="links.get('publication').params"
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('publication').link"
|
||||
[queryParams]="links.get('publication').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.publicationsSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="book" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
|
@ -87,10 +94,12 @@ interface Link {
|
|||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a *ngIf="externalLink" [href]="links.get('dataset').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.datasetsSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('dataset').link" [queryParams]="links.get('dataset').params"
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('dataset').link"
|
||||
[queryParams]="links.get('dataset').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.datasetsSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
<icon name="database" ratio="1.5" [flex]="true" class="uk-margin-right"
|
||||
[customClass]="colorClass"></icon>
|
||||
<span>research data</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -99,7 +108,8 @@ interface Link {
|
|||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a *ngIf="externalLink" [href]="links.get('software').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.softwareSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('software').link" [queryParams]="links.get('software').params"
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('software').link"
|
||||
[queryParams]="links.get('software').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.softwareSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="cog" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
|
@ -111,10 +121,12 @@ interface Link {
|
|||
<div class="number-width uk-flex uk-flex-column">
|
||||
<a *ngIf="externalLink" [href]="links.get('other').link" target="_blank"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.otherSize.count|number}}</a>
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('other').link" [queryParams]="links.get('other').params"
|
||||
<a *ngIf="!externalLink" [routerLink]="links.get('other').link"
|
||||
[queryParams]="links.get('other').params"
|
||||
class="number uk-text-bold uk-margin-bottom uk-text-center uk-text-left@m">{{numbers.otherSize.count|number}}</a>
|
||||
<div class="uk-text-uppercase uk-flex uk-flex-middle uk-flex-center uk-flex-left@m">
|
||||
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right" [customClass]="colorClass"></icon>
|
||||
<icon name="earth" ratio="1.5" [flex]="true" class="uk-margin-right"
|
||||
[customClass]="colorClass"></icon>
|
||||
<span>other research products</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -152,10 +164,13 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
constructor(private searchResearchResultsService: SearchResearchResultsService,
|
||||
private searchDataprovidersService: SearchDataprovidersService,
|
||||
private refineFieldResultsService: RefineFieldResultsService) {
|
||||
this.links = new Map<Entity, Link>();
|
||||
this.params = new Map<Entity, {}>();
|
||||
this.emptySubject = new BehaviorSubject<number>(0);
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
if(this.defaultInit) {
|
||||
if (this.defaultInit) {
|
||||
this.init();
|
||||
}
|
||||
this.setLinks();
|
||||
|
@ -168,7 +183,7 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
this.params.set('other', {type: 'other', qf: 'false'});
|
||||
this.params.set('project', {});
|
||||
this.params.set('datasource', {});
|
||||
if(this.refineValue) {
|
||||
if (this.refineValue) {
|
||||
this.params.forEach((value) => {
|
||||
value['fq'] = this.refineValue;
|
||||
});
|
||||
|
@ -177,43 +192,55 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
|
||||
setLinks() {
|
||||
this.setParams();
|
||||
if(this.externalLink) {
|
||||
this.links.set('publication', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('publication')), Object.values(this.params.get('publication')))});
|
||||
this.links.set('dataset', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('dataset')), Object.values(this.params.get('dataset')))});
|
||||
this.links.set('software', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('software')), Object.values(this.params.get('software')))});
|
||||
this.links.set('other', {link: this.externalLink + properties.searchLinkToResults +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('other')), Object.values(this.params.get('other')))});
|
||||
this.links.set('project', {link: this.externalLink + properties.searchLinkToProjects +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('project')), Object.values(this.params.get('project')))});
|
||||
this.links.set('datasource', {link: this.externalLink + properties.searchLinkToDataProviders +
|
||||
this.routerHelper.createQueryParamsString(Object.keys(this.params.get('datasource')), Object.values(this.params.get('datasource')))});
|
||||
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')))
|
||||
});
|
||||
} else {
|
||||
this.links.set('publication', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('publication')), Object.values(this.params.get('publication')))
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('publication')), HelperFunctions.getValues(this.params.get('publication')))
|
||||
});
|
||||
this.links.set('dataset', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('dataset')), Object.values(this.params.get('dataset')))
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('dataset')), HelperFunctions.getValues(this.params.get('dataset')))
|
||||
});
|
||||
this.links.set('software', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('software')), Object.values(this.params.get('software')))
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('software')), HelperFunctions.getValues(this.params.get('software')))
|
||||
});
|
||||
this.links.set('other', {
|
||||
link: properties.searchLinkToResults,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('other')), Object.values(this.params.get('other')))
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('other')), HelperFunctions.getValues(this.params.get('other')))
|
||||
});
|
||||
this.links.set('project', {
|
||||
link: properties.searchLinkToProjects,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('project')), Object.values(this.params.get('project')))
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('project')), HelperFunctions.getValues(this.params.get('project')))
|
||||
});
|
||||
this.links.set('datasource', {
|
||||
link: properties.searchLinkToDataProviders,
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('datasource')), Object.values(this.params.get('datasource')))
|
||||
params: this.routerHelper.createQueryParams(Object.keys(this.params.get('datasource')), HelperFunctions.getValues(this.params.get('datasource')))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -221,19 +248,19 @@ export class NumbersComponent implements OnInit, OnDestroy {
|
|||
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
|
||||
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true, refineValue: string = null) {
|
||||
this.loading = true;
|
||||
if(refineValue) {
|
||||
if (refineValue) {
|
||||
this.refineValue = refineValue;
|
||||
}
|
||||
let refineParams = (this.refineValue)?('&fq=' + this.refineValue):null;
|
||||
let refineParams = (this.refineValue) ? ('&fq=' + this.refineValue) : null;
|
||||
this.subs.push(zip(
|
||||
(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
|
||||
(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
|
||||
).subscribe((data: any[]) => {
|
||||
if (data[0] && data[0] > 0) {
|
||||
this.numbers.publicationsSize = NumberUtils.roundNumber(data[0]);
|
||||
|
|
|
@ -69,4 +69,8 @@ export class HelperFunctions {
|
|||
});
|
||||
return encoded;
|
||||
}
|
||||
|
||||
public static getValues(value: any): any[] {
|
||||
return Object.keys(value).map(key => value[key]);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue