From 54ca0ea337de54f7ab57d51b3409b96d04a1f81b Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Mon, 8 Jul 2019 12:19:33 +0000 Subject: [PATCH] [Connect|Trunk]: Use RoutesRecognized event to read query params. git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-connect-portal/trunk@56395 d315682c-612b-4755-9ff5-7f18f6832af3 --- src/app/app.component.ts | 33 ++++++++++---------- src/app/searchPages/find/search.component.ts | 1 - 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/app/app.component.ts b/src/app/app.component.ts index c45b726..b59bf6c 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -1,5 +1,5 @@ import {Component} from '@angular/core'; -import {ActivatedRoute, NavigationStart, Router} from '@angular/router'; +import {ActivatedRoute, NavigationStart, Router, RoutesRecognized} from '@angular/router'; import {EnvProperties} from './openaireLibrary/utils/properties/env-properties'; import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; @@ -64,11 +64,6 @@ export class AppComponent { constructor( private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService, private _communitiesService:CommunitiesService, private _subscribeService: SubscribeService, private router: Router){//, private _layoutService: LayoutService) { - router.events.forEach((event) => { - if (event instanceof NavigationStart) { - HelperFunctions.scroll(); - } - }); } ngOnInit() { @@ -77,17 +72,21 @@ export class AppComponent { this.properties = this.propertiesService.envSpecific; var communityId: string = ""; this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI); - if(this.properties.environment == "development") { - this.route.queryParams.subscribe(data => { - this.showMenu = false; - communityId = data['communityId']; - this.buildMenu(communityId); - }); - } else { - this.showMenu = false; - communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); - this.buildMenu(communityId); - } + this.router.events.forEach((event) => { + if (event instanceof RoutesRecognized) { + HelperFunctions.scroll(); + if (this.properties.environment == "development") { + this.showMenu = false; + communityId = (event.state.root.firstChild.queryParams['communityId']) ? event.state.root.firstChild.queryParams['communityId'] : ''; + console.log(communityId); + this.buildMenu(communityId); + } else { + this.showMenu = false; + communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); + this.buildMenu(communityId); + } + } + }); if (typeof document !== 'undefined') { try{ diff --git a/src/app/searchPages/find/search.component.ts b/src/app/searchPages/find/search.component.ts index 0e8b6da..7585d19 100644 --- a/src/app/searchPages/find/search.component.ts +++ b/src/app/searchPages/find/search.component.ts @@ -30,7 +30,6 @@ export class OpenaireSearchComponent{ this.connectCommunityId = data['communityId']; this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId]; this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); - console.log(this.customFilter); } }); }