-
{{numbers.otherSize.count|number}}
+
{{numbers.otherSize.count|number}}
+
{{numbers.otherSize.count|number}}
other research products
@@ -107,13 +131,22 @@ export interface Numbers {
export class NumbersComponent implements OnInit, OnDestroy {
@Input() colorClass = 'portal-color';
@Input() backgroundClass = null;
- @Input() refineQuery = null;
+ /** Add a value if you want to apply refine query*/
+ @Input() refineValue = null;
+ /** True: Default initialization
+ * False: Call init method to initialize numbers */
@Input() defaultInit = true;
+ /** Add an external link for numbers link */
+ @Input() externalLink;
+ /** When numbers have been initialized this emitter will emitted */
@Output() results: EventEmitter = new EventEmitter();
- private emptySubject: BehaviorSubject = new BehaviorSubject(0);
public properties: EnvProperties = properties;
+ public routerHelper: RouterHelper = new RouterHelper();
public numbers: Numbers = {};
public loading: boolean = true;
+ public links: Map = new Map();
+ private params: Map = new Map();
+ private emptySubject: BehaviorSubject = new BehaviorSubject(0);
private subs: any[] = [];
constructor(private searchResearchResultsService: SearchResearchResultsService,
@@ -125,20 +158,79 @@ export class NumbersComponent implements OnInit, OnDestroy {
if(this.defaultInit) {
this.init();
}
+ this.setLinks();
+ }
+
+ setParams() {
+ this.params.set('publication', {type: 'publications', qf: 'false'});
+ this.params.set('dataset', {type: 'datasets', qf: 'false'});
+ this.params.set('software', {type: 'software', qf: 'false'});
+ this.params.set('other', {type: 'other', qf: 'false'});
+ this.params.set('project', {});
+ this.params.set('datasource', {});
+ if(this.refineValue) {
+ this.params.forEach((value) => {
+ value['fq'] = this.refineValue;
+ });
+ }
+ }
+
+ 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')))});
+ } else {
+ this.links.set('publication', {
+ link: properties.searchLinkToResults,
+ params: this.routerHelper.createQueryParams(Object.keys(this.params.get('publication')), Object.values(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')))
+ });
+ this.links.set('software', {
+ link: properties.searchLinkToResults,
+ params: this.routerHelper.createQueryParams(Object.keys(this.params.get('software')), Object.values(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')))
+ });
+ this.links.set('project', {
+ link: properties.searchLinkToProjects,
+ params: this.routerHelper.createQueryParams(Object.keys(this.params.get('project')), Object.values(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')))
+ });
+ }
}
init(getDatasetsLinked = false, getSoftwareLinked = false, getPublications = true, getDatasets = true,
getSoftware = true, getOther = true, getProjects = true, getDataProviders = true) {
this.loading = true;
+ let refineParams = (this.refineValue)?('&fq=' + this.refineValue):null;
this.subs.push(zip(
- (getPublications)?this.searchResearchResultsService.numOfSearchResults('publication', '', this.properties, this.refineQuery):this.empty,
- (getDatasets)?this.searchResearchResultsService.numOfSearchResults('dataset', '', this.properties, this.refineQuery):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, this.refineQuery):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, this.refineQuery):this.empty,
- (getProjects)?this.refineFieldResultsService.getRefineFieldsResultsByEntityName(['funder'], 'project', this.properties, this.refineQuery):this.empty,
- (getDataProviders)?this.searchDataprovidersService.numOfSearchDataproviders('', this.properties, this.refineQuery):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/sharedComponents/numbers/numbers.module.ts b/sharedComponents/numbers/numbers.module.ts
index e88ec50d..72d30e26 100644
--- a/sharedComponents/numbers/numbers.module.ts
+++ b/sharedComponents/numbers/numbers.module.ts
@@ -8,9 +8,10 @@ import {SearchResearchResultsService} from '../../services/searchResearchResults
import {SearchDataprovidersService} from '../../services/searchDataproviders.service';
import {RefineFieldResultsService} from '../../services/refineFieldResults.service';
import {LoadingModule} from '../../utils/loading/loading.module';
+import {RouterModule} from "@angular/router";
@NgModule({
- imports: [CommonModule, IconsModule, LoadingModule],
+ imports: [CommonModule, IconsModule, LoadingModule, RouterModule],
declarations: [NumbersComponent],
exports: [NumbersComponent],
providers: [SearchResearchResultsService, SearchDataprovidersService, RefineFieldResultsService]