From 68fc70162b58c868cfd9baf706086036754230b4 Mon Sep 17 00:00:00 2001 From: argirok Date: Thu, 18 Jan 2024 11:48:55 +0200 Subject: [PATCH] add loading in monitor, avoid no monitor yet when not loaded yet, avoid double setView, call fos refine once. --- src/app/shared/monitor/monitor.component.html | 3 +- src/app/shared/monitor/monitor.component.ts | 72 +++++++++---------- src/app/shared/monitor/monitor.module.ts | 3 +- 3 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/app/shared/monitor/monitor.component.html b/src/app/shared/monitor/monitor.component.html index 9e7106c..eecab12 100644 --- a/src/app/shared/monitor/monitor.component.html +++ b/src/app/shared/monitor/monitor.component.html @@ -13,7 +13,8 @@
-
+ +
No {{entities.stakeholder}} yet.
diff --git a/src/app/shared/monitor/monitor.component.ts b/src/app/shared/monitor/monitor.component.ts index 1beb51e..553338e 100644 --- a/src/app/shared/monitor/monitor.component.ts +++ b/src/app/shared/monitor/monitor.component.ts @@ -15,7 +15,6 @@ import {SearchResearchResultsService} from "../../openaireLibrary/services/searc import {CustomFilterService} from "../../openaireLibrary/shared/customFilter.service"; import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; import {Filter, Value} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; -import {RefineResultsUtils} from "../../openaireLibrary/services/servicesUtils/refineResults.class"; import {SearchFields} from "../../openaireLibrary/utils/properties/searchFields"; @Component({ @@ -46,46 +45,39 @@ export class MonitorComponent extends MonitorIndicatorStakeholderBaseComponent { this.requireLogin = false; this.subscriptions.push(this.userManagementService.getUserInfo().subscribe(user => { this.user = user; - this.subscriptions.push(this._route.params.subscribe(params => { - this.loading = true; - this.activeTopic = null; - this.activeCategory = null; - this.activeSubCategory = null; - this.numberResults = new Map(); - this.chartsActiveType = new Map(); - this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { - if (stakeholder) { - this.stakeholder = stakeholder; - - - this.subscriptions.push(this.customFilterService.getCustomFilterAsObservable().subscribe(filters => { - if(filters) { - let customFilterParams = ""; - for (let customFilter of filters) { - if (customFilter.isHiddenFilter) { - customFilterParams += "&fq=" + StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId))); - } - } - this.subscriptions.push(this.searchResearchResultsService.advancedSearchResults("publication", null, 1, 0, null, this.properties, - "&refine=true&fields=fos&type=publications", ["fos"], customFilterParams).subscribe(res => { - this.filters = this.postProcessingFosFilters(res[2]); - this.title = this.stakeholder.name; - this.description = this.stakeholder.name; - this.subscriptions.push(this._route.queryParams.subscribe(queryParams => { - this.handleQueryParams(queryParams, params); - this.setMetadata(); - this.setView(params); - })); - })); - + this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { + if (stakeholder) { + this.loading = true; + this.stakeholder = stakeholder; + this.subscriptions.push(this.customFilterService.getCustomFilterAsObservable().subscribe(filters => { + if (filters) { + let customFilterParams = ""; + for (let customFilter of filters) { + if (customFilter.isHiddenFilter) { + customFilterParams += "&fq=" + StringUtils.URIEncode(customFilter.queryFieldName + " exact " + StringUtils.quote((customFilter.valueId))); } - - - })); - // } else { - // this.navigateToError(); - } - })); + } + this.subscriptions.push(this.searchResearchResultsService.advancedSearchResults("publication", null, 1, 0, null, this.properties, + "&refine=true&fields=fos&type=publications", ["fos"], customFilterParams).subscribe(res => { + this.filters = this.postProcessingFosFilters(res[2]); + this.title = this.stakeholder.name; + this.description = this.stakeholder.name; + this.subscriptions.push(this._route.params.subscribe(params => { + this.loading = true; + this.activeTopic = null; + this.activeCategory = null; + this.activeSubCategory = null; + this.numberResults = new Map(); + this.chartsActiveType = new Map(); + this.subscriptions.push(this._route.queryParams.subscribe(queryParams => { + this.handleQueryParams(queryParams, params); + this.setMetadata(); + })); + })); + })); + } + })); + } })); })); } diff --git a/src/app/shared/monitor/monitor.module.ts b/src/app/shared/monitor/monitor.module.ts index 628c636..3945a1b 100644 --- a/src/app/shared/monitor/monitor.module.ts +++ b/src/app/shared/monitor/monitor.module.ts @@ -12,6 +12,7 @@ import {SearchFilterModule} from "../../openaireLibrary/searchPages/searchUtils/ import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; import {filters} from "../../openaireLibrary/utils/icons/icons"; import {SliderUtilsModule} from "../../openaireLibrary/sharedComponents/slider-utils/slider-utils.module"; +import {LoadingModule} from "../../openaireLibrary/utils/loading/loading.module"; @NgModule({ imports: [CommonModule, RouterModule.forChild([ @@ -19,7 +20,7 @@ import {SliderUtilsModule} from "../../openaireLibrary/sharedComponents/slider-u {path: ':topic/', component: MonitorComponent}, {path: ':topic/:category', component: MonitorComponent}, {path: ':topic/:category/:subCategory', component: MonitorComponent} - ]), PageContentModule, SliderTabsModule, NumberRoundModule, IconsModule, ClickModule, RangeFilterModule, SearchFilterModule, SliderUtilsModule], + ]), PageContentModule, SliderTabsModule, NumberRoundModule, IconsModule, ClickModule, RangeFilterModule, SearchFilterModule, SliderUtilsModule, LoadingModule], declarations: [MonitorComponent], exports: [MonitorComponent] })