[Trunk|Admin]: Use RoutesRecognized event to read query params.
git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-admin-portal/trunk@56396 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
parent
63a8efe503
commit
2621817e70
|
@ -1,4 +1,4 @@
|
|||
<navbar *ngIf= "properties" portal="connect-admin" logoPath="assets/imgs/" [onlyTop]=false [userMenu]=true
|
||||
<navbar *ngIf= "properties && showMenu" portal="connect-admin" logoPath="assets/imgs/" [onlyTop]=false [userMenu]=true
|
||||
[homeurl] = false [userMenuItems]=userMenuItems [menuItems]=menuItems [properties]=properties
|
||||
[community]=community class="adminMenu"></navbar>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {MenuItem, RootMenuItem, SideMenuItem} from './openaireLibrary/sharedComponents/menu';
|
||||
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
||||
import {ActivatedRoute, NavigationStart, Router, RoutesRecognized} from '@angular/router';
|
||||
import {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
||||
import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service';
|
||||
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||
|
@ -33,21 +33,12 @@ export class AppComponent implements OnInit{
|
|||
isPortalAdministrator = false;
|
||||
showSidebar: boolean;
|
||||
wellcome = false;
|
||||
showMenu:boolean = false;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private propertiesService: EnvironmentSpecificService,
|
||||
private _communitiesService: CommunitiesService,
|
||||
private router: Router) {
|
||||
router.events.forEach((event) => {
|
||||
if (event instanceof NavigationStart) {
|
||||
HelperFunctions.scroll();
|
||||
if(event.url === '/') {
|
||||
this.wellcome = true;
|
||||
} else {
|
||||
this.wellcome = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
@ -58,6 +49,7 @@ export class AppComponent implements OnInit{
|
|||
this.logInUrl = this.properties.loginUrl;
|
||||
this.logOutUrl = this.properties.logoutUrl;
|
||||
this.showSidebar = false;
|
||||
this.showMenu = false;
|
||||
if (Session.getUser()) {
|
||||
localStorage.setItem('user_id', Session.getUser().id);
|
||||
localStorage.setItem('mining_backend_address', this.properties.miningBackendURL);
|
||||
|
@ -66,15 +58,25 @@ export class AppComponent implements OnInit{
|
|||
this.isPortalAdministrator = Session.isPortalAdministrator();
|
||||
}
|
||||
this._communitiesService.updateCommunities(this.properties, this.properties.communityAPI + 'communities');
|
||||
this.router.events.forEach((event) => {
|
||||
if(event instanceof RoutesRecognized) {
|
||||
HelperFunctions.scroll();
|
||||
if(event.url === '/') {
|
||||
this.wellcome = true;
|
||||
} else {
|
||||
this.wellcome = false;
|
||||
}
|
||||
this.communityId = (event.state.root.firstChild.queryParams['communityId']) ? event.state.root.firstChild.queryParams['communityId'] : '';
|
||||
|
||||
this.route.queryParams.subscribe(data => {
|
||||
this.communityId = ((data['communityId']) ? data['communityId'] : '');
|
||||
this.communityType = null;
|
||||
this.menuItems = [];
|
||||
this.userMenuItems = [];
|
||||
this._communitiesService.getCommunitiesState().subscribe(
|
||||
communities => {
|
||||
// this.community = community;
|
||||
if(!communities || communities.length === 0) {
|
||||
return;
|
||||
}
|
||||
this.userMenuItems = [];
|
||||
let countCommunities = 0;
|
||||
let index_managerOfCommunity = null;
|
||||
|
@ -127,6 +129,7 @@ export class AppComponent implements OnInit{
|
|||
this.userMenuItems.push(new MenuItem('personal', 'Manage Personal Info', '', '/personal', false, [], [], {communityId: this.communityId}));
|
||||
this.userMenuItems.push(new MenuItem("","Support","https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611","",false,[],[],{}))
|
||||
}
|
||||
this.showMenu = true;
|
||||
this.buildSideBar();
|
||||
},
|
||||
error => {
|
||||
|
@ -140,6 +143,7 @@ export class AppComponent implements OnInit{
|
|||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue