From ebdff9eb44ffd2eef119c08bee0322cfea46c51f Mon Sep 17 00:00:00 2001 From: argirok Date: Tue, 12 Dec 2023 16:41:02 +0200 Subject: [PATCH] [develop | DONE | ADDED] Add filters in dashboards, add fos lvl1 &lvl2 filters --- src/app/shared/monitor/monitor.component.html | 82 +++++++++++++++++++ src/app/shared/monitor/monitor.component.ts | 58 +++++++++++-- src/app/shared/monitor/monitor.module.ts | 10 ++- src/assets/irish-monitor.less | 7 ++ 4 files changed, 149 insertions(+), 8 deletions(-) diff --git a/src/app/shared/monitor/monitor.component.html b/src/app/shared/monitor/monitor.component.html index 0fc12f2..d9387d3 100644 --- a/src/app/shared/monitor/monitor.component.html +++ b/src/app/shared/monitor/monitor.component.html @@ -164,3 +164,85 @@ + + + + {{countSelectedFilters()}} + + +
+
+
+ +
+
+
+

Filters

+ Clear All +
+ +
Sign in to apply filters.
+
    +
  • + +
  • + +
  • + + +
  • +
    +
+ + * If your filter selection cannot be applied to a chart, that chart will appear grayed-out. + +
+
+
+ +
+
+
+
    +
  • + + {{periodFilter.selectedFromAndToValues}} + + +
  • + + + + +
  • + + {{value.name}} + + +
  • +
    +
    +
    +
    +
+
+ + +
+
+
diff --git a/src/app/shared/monitor/monitor.component.ts b/src/app/shared/monitor/monitor.component.ts index 9b34b78..ae7d135 100644 --- a/src/app/shared/monitor/monitor.component.ts +++ b/src/app/shared/monitor/monitor.component.ts @@ -11,6 +11,10 @@ import {IndicatorPath, Visibility} from "../../openaireLibrary/monitor/entities/ import {ActivatedRoute, Router} from "@angular/router"; import {PiwikService} from "../../openaireLibrary/utils/piwik/piwik.service"; import {SEOService} from "../../openaireLibrary/sharedComponents/SEO/SEO.service"; +import {SearchResearchResultsService} from "../../openaireLibrary/services/searchResearchResults.service"; +import {CustomFilterService} from "../customFilter.service"; +import {StringUtils} from "../../openaireLibrary/utils/string-utils.class"; +import {Filter} from "../../openaireLibrary/searchPages/searchUtils/searchHelperClasses.class"; @Component({ selector: 'monitor', @@ -28,6 +32,8 @@ export class MonitorComponent extends MonitorIndicatorStakeholderBaseComponent { protected cdr: ChangeDetectorRef, protected layoutService: LayoutService, protected statisticsService: StatisticsService, + protected searchResearchResultsService: SearchResearchResultsService, + protected customFilterService: CustomFilterService, private userManagementService: UserManagementService, private stakeholderService: StakeholderService) { super(); @@ -47,15 +53,32 @@ export class MonitorComponent extends MonitorIndicatorStakeholderBaseComponent { this.subscriptions.push(this.stakeholderService.getStakeholderAsObservable().subscribe(stakeholder => { if (stakeholder) { this.stakeholder = stakeholder; + this.subscriptions.push(this._route.queryParams.subscribe(queryParams => { this.handleQueryParams(queryParams, params); - this.title = this.stakeholder.name; - this.description = this.stakeholder.name; - this.setMetadata(); - this.setView(params); + 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.setMetadata(); + this.setView(params); + })); + + } + })); + })); - } else { - this.navigateToError(); + // } else { + // this.navigateToError(); } })); })); @@ -65,4 +88,27 @@ export class MonitorComponent extends MonitorIndicatorStakeholderBaseComponent { hasPermission(visibility: Visibility): boolean { return true; } + logIn() { + this.userManagementService.login(); + } + + postProcessingFosFilters(refineFilters:Filter[]){ + let filters:Filter[] = []; + for(let filter of refineFilters){ + if(filter.filterId == "fos"){ + let fos: Filter ={...filter}; + fos.values = []; + for(let value of filter.values){ + let code = value.id.split(" ")[0]; + if(code.length <= 4){ + fos.values.push(value); + } + } + filters.push(fos); + }else{ + filters.push(filter); + } + } + return filters; + } } diff --git a/src/app/shared/monitor/monitor.module.ts b/src/app/shared/monitor/monitor.module.ts index f9e8d52..256f7ac 100644 --- a/src/app/shared/monitor/monitor.module.ts +++ b/src/app/shared/monitor/monitor.module.ts @@ -7,6 +7,10 @@ import {SliderTabsModule} from "../../openaireLibrary/sharedComponents/tabs/slid import {NumberRoundModule} from "../../openaireLibrary/utils/pipes/number-round.module"; import {IconsModule} from "../../openaireLibrary/utils/icons/icons.module"; import {ClickModule} from "../../openaireLibrary/utils/click/click.module"; +import {RangeFilterModule} from "../../openaireLibrary/utils/rangeFilter/rangeFilter.module"; +import {SearchFilterModule} from "../../openaireLibrary/searchPages/searchUtils/searchFilter.module"; +import {IconsService} from "../../openaireLibrary/utils/icons/icons.service"; +import {filters} from "../../openaireLibrary/utils/icons/icons"; @NgModule({ imports: [CommonModule, RouterModule.forChild([ @@ -14,10 +18,12 @@ import {ClickModule} from "../../openaireLibrary/utils/click/click.module"; {path: ':topic/', component: MonitorComponent}, {path: ':topic/:category', component: MonitorComponent}, {path: ':topic/:category/:subCategory', component: MonitorComponent} - ]), PageContentModule, SliderTabsModule, NumberRoundModule, IconsModule, ClickModule], + ]), PageContentModule, SliderTabsModule, NumberRoundModule, IconsModule, ClickModule, RangeFilterModule, SearchFilterModule], declarations: [MonitorComponent], exports: [MonitorComponent] }) export class MonitorModule { - + constructor(private iconsService: IconsService) { + this.iconsService.registerIcons([ filters]); + } } diff --git a/src/assets/irish-monitor.less b/src/assets/irish-monitor.less index 896e9b1..b6f1d2d 100644 --- a/src/assets/irish-monitor.less +++ b/src/assets/irish-monitor.less @@ -65,3 +65,10 @@ svg .a { opacity: 1 !important; } + + +&.semiFiltered { + &, & > * > .highcharts-series-group { + opacity: 0.5; + } +}