[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
This commit is contained in:
k.triantafyllou 2019-07-08 12:19:33 +00:00
parent b29d3eac05
commit 54ca0ea337
2 changed files with 16 additions and 18 deletions

View File

@ -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{

View File

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