@@ -111,10 +121,12 @@ interface Link {
@@ -152,10 +164,13 @@ export class NumbersComponent implements OnInit, OnDestroy {
constructor(private searchResearchResultsService: SearchResearchResultsService,
private searchDataprovidersService: SearchDataprovidersService,
private refineFieldResultsService: RefineFieldResultsService) {
+ this.links = new Map
();
+ this.params = new Map();
+ this.emptySubject = new BehaviorSubject(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]);
diff --git a/utils/HelperFunctions.class.ts b/utils/HelperFunctions.class.ts
index 81725d14..fc2c1cb2 100644
--- a/utils/HelperFunctions.class.ts
+++ b/utils/HelperFunctions.class.ts
@@ -69,4 +69,8 @@ export class HelperFunctions {
});
return encoded;
}
+
+ public static getValues(value: any): any[] {
+ return Object.keys(value).map(key => value[key]);
+ }
}