[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 {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 {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu'; import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
@ -64,11 +64,6 @@ export class AppComponent {
constructor( private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService, constructor( private route: ActivatedRoute, private propertiesService:EnvironmentSpecificService,
private _communitiesService:CommunitiesService, private _subscribeService: SubscribeService, private _communitiesService:CommunitiesService, private _subscribeService: SubscribeService,
private router: Router){//, private _layoutService: LayoutService) { private router: Router){//, private _layoutService: LayoutService) {
router.events.forEach((event) => {
if (event instanceof NavigationStart) {
HelperFunctions.scroll();
}
});
} }
ngOnInit() { ngOnInit() {
@ -77,17 +72,21 @@ export class AppComponent {
this.properties = this.propertiesService.envSpecific; this.properties = this.propertiesService.envSpecific;
var communityId: string = ""; var communityId: string = "";
this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI); this._communitiesService.updateCommunities(this.properties, this.properties.communitiesAPI);
if(this.properties.environment == "development") { this.router.events.forEach((event) => {
this.route.queryParams.subscribe(data => { if (event instanceof RoutesRecognized) {
this.showMenu = false; HelperFunctions.scroll();
communityId = data['communityId']; if (this.properties.environment == "development") {
this.buildMenu(communityId); this.showMenu = false;
}); communityId = (event.state.root.firstChild.queryParams['communityId']) ? event.state.root.firstChild.queryParams['communityId'] : '';
} else { console.log(communityId);
this.showMenu = false; this.buildMenu(communityId);
communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain); } else {
this.buildMenu(communityId); this.showMenu = false;
} communityId = ConnectHelper.getCommunityFromDomain(this.properties.domain);
this.buildMenu(communityId);
}
}
});
if (typeof document !== 'undefined') { if (typeof document !== 'undefined') {
try{ try{

View File

@ -30,7 +30,6 @@ export class OpenaireSearchComponent{
this.connectCommunityId = data['communityId']; this.connectCommunityId = data['communityId'];
this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId]; this.piwikSiteId = PiwikHelper.siteIDs[this.connectCommunityId];
this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, ""); this.customFilter = new SearchCustomFilter("Community", "communityId", this.connectCommunityId, "");
console.log(this.customFilter);
} }
}); });
} }