add loading in monitor, avoid no monitor yet when not loaded yet, avoid double setView, call fos refine once.

This commit is contained in:
argirok 2024-01-18 11:48:55 +02:00
parent 3811d6a24f
commit 68fc70162b
3 changed files with 36 additions and 42 deletions

View File

@ -13,7 +13,8 @@
</div>
</div>
<div inner>
<div *ngIf="!activeSubCategory" class="message">
<loading *ngIf="loading" class="uk-margin-top"></loading>
<div *ngIf="!activeSubCategory && !loading" class="message">
No {{entities.stakeholder}} yet.
</div>
<div *ngIf="activeSubCategory" class="uk-section">

View File

@ -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<string, number>();
this.chartsActiveType = new Map<string, IndicatorPath>();
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<string, number>();
this.chartsActiveType = new Map<string, IndicatorPath>();
this.subscriptions.push(this._route.queryParams.subscribe(queryParams => {
this.handleQueryParams(queryParams, params);
this.setMetadata();
}));
}));
}));
}
}));
}
}));
}));
}

View File

@ -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]
})