[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
|
[homeurl] = false [userMenuItems]=userMenuItems [menuItems]=menuItems [properties]=properties
|
||||||
[community]=community class="adminMenu"></navbar>
|
[community]=community class="adminMenu"></navbar>
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
import {Component, OnInit} from '@angular/core';
|
import {Component, OnInit} from '@angular/core';
|
||||||
import {MenuItem, RootMenuItem, SideMenuItem} from './openaireLibrary/sharedComponents/menu';
|
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 {EnvironmentSpecificService} from './openaireLibrary/utils/properties/environment-specific.service';
|
||||||
import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service';
|
import {CommunitiesService} from './openaireLibrary/connect/communities/communities.service';
|
||||||
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
||||||
|
@ -33,21 +33,12 @@ export class AppComponent implements OnInit{
|
||||||
isPortalAdministrator = false;
|
isPortalAdministrator = false;
|
||||||
showSidebar: boolean;
|
showSidebar: boolean;
|
||||||
wellcome = false;
|
wellcome = false;
|
||||||
|
showMenu:boolean = false;
|
||||||
|
|
||||||
constructor(private route: ActivatedRoute,
|
constructor(private route: ActivatedRoute,
|
||||||
private propertiesService: EnvironmentSpecificService,
|
private propertiesService: EnvironmentSpecificService,
|
||||||
private _communitiesService: CommunitiesService,
|
private _communitiesService: CommunitiesService,
|
||||||
private router: Router) {
|
private router: Router) {
|
||||||
router.events.forEach((event) => {
|
|
||||||
if (event instanceof NavigationStart) {
|
|
||||||
HelperFunctions.scroll();
|
|
||||||
if(event.url === '/') {
|
|
||||||
this.wellcome = true;
|
|
||||||
} else {
|
|
||||||
this.wellcome = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
@ -58,6 +49,7 @@ export class AppComponent implements OnInit{
|
||||||
this.logInUrl = this.properties.loginUrl;
|
this.logInUrl = this.properties.loginUrl;
|
||||||
this.logOutUrl = this.properties.logoutUrl;
|
this.logOutUrl = this.properties.logoutUrl;
|
||||||
this.showSidebar = false;
|
this.showSidebar = false;
|
||||||
|
this.showMenu = false;
|
||||||
if (Session.getUser()) {
|
if (Session.getUser()) {
|
||||||
localStorage.setItem('user_id', Session.getUser().id);
|
localStorage.setItem('user_id', Session.getUser().id);
|
||||||
localStorage.setItem('mining_backend_address', this.properties.miningBackendURL);
|
localStorage.setItem('mining_backend_address', this.properties.miningBackendURL);
|
||||||
|
@ -66,80 +58,92 @@ export class AppComponent implements OnInit{
|
||||||
this.isPortalAdministrator = Session.isPortalAdministrator();
|
this.isPortalAdministrator = Session.isPortalAdministrator();
|
||||||
}
|
}
|
||||||
this._communitiesService.updateCommunities(this.properties, this.properties.communityAPI + 'communities');
|
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.communityType = null;
|
||||||
this.communityId = ((data['communityId']) ? data['communityId'] : '');
|
this.menuItems = [];
|
||||||
this.communityType = null;
|
this.userMenuItems = [];
|
||||||
this.menuItems = [];
|
this._communitiesService.getCommunitiesState().subscribe(
|
||||||
this.userMenuItems = [];
|
communities => {
|
||||||
this._communitiesService.getCommunitiesState().subscribe(
|
// this.community = community;
|
||||||
communities => {
|
if(!communities || communities.length === 0) {
|
||||||
// this.community = community;
|
return;
|
||||||
this.userMenuItems = [];
|
}
|
||||||
let countCommunities = 0;
|
this.userMenuItems = [];
|
||||||
let index_managerOfCommunity = null;
|
let countCommunities = 0;
|
||||||
for (let i = 0; i < communities.length; i++) {
|
let index_managerOfCommunity = null;
|
||||||
const com = communities[i];
|
for (let i = 0; i < communities.length; i++) {
|
||||||
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) {
|
const com = communities[i];
|
||||||
this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId}));
|
if (Session.isPortalAdministrator() || Session.isCommunityCurator()) {
|
||||||
} else {
|
this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId}));
|
||||||
for (const manager of com.managers) {
|
} else {
|
||||||
if (manager == Session.getUserEmail()) {
|
for (const manager of com.managers) {
|
||||||
countCommunities++;
|
if (manager == Session.getUserEmail()) {
|
||||||
index_managerOfCommunity = i;
|
countCommunities++;
|
||||||
this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId}));
|
index_managerOfCommunity = i;
|
||||||
break;
|
this.userMenuItems.push(new MenuItem('manage' + com.communityId, 'Manage ' + ((com.shortTitle) ? com.shortTitle : com.title), '', '/dashboard', false, [], [], {communityId: com.communityId}));
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (com.communityId === this.communityId) {
|
||||||
|
this.community = {
|
||||||
|
id: com.communityId,
|
||||||
|
name: (com.shortTitle) ? com.shortTitle : com.title,
|
||||||
|
logoUrl: com.logoUrl
|
||||||
|
};
|
||||||
|
this.communityType = com.type;
|
||||||
|
this.menuItems = [
|
||||||
|
{
|
||||||
|
rootItem: new MenuItem('dashboard', 'Overview', '/dashboard', '/dashboard', false, [], null, {communityId: com.communityId}),
|
||||||
|
items: []
|
||||||
|
}
|
||||||
|
];
|
||||||
|
} else if (countCommunities === 1 && index_managerOfCommunity != null) {
|
||||||
|
this.community = {
|
||||||
|
id: communities[index_managerOfCommunity].communityId,
|
||||||
|
name: (communities[index_managerOfCommunity].shortTitle) ? communities[index_managerOfCommunity].shortTitle : com.title,
|
||||||
|
logoUrl: communities[index_managerOfCommunity].logoUrl
|
||||||
|
};
|
||||||
|
this.menuItems = [
|
||||||
|
{
|
||||||
|
rootItem: new MenuItem('dashboard', 'Overview', '/dashboard', '/dashboard', false, [], null, {communityId: communities[index_managerOfCommunity].communityId}),
|
||||||
|
items: []
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (com.communityId === this.communityId) {
|
if (!this.communityId || this.communityId === '') {
|
||||||
this.community = {
|
this.community = null;
|
||||||
id: com.communityId,
|
}
|
||||||
name: (com.shortTitle) ? com.shortTitle : com.title,
|
if (this.communityId) {
|
||||||
logoUrl: com.logoUrl
|
this.userMenuItems.push(new MenuItem('manage-user-notifications', 'Manage notification settings', '', '/manage-user-notifications', false, [], [], {communityId: this.communityId}));
|
||||||
};
|
this.userMenuItems.push(new MenuItem('personal', 'Manage Personal Info', '', '/personal', false, [], [], {communityId: this.communityId}));
|
||||||
this.communityType = com.type;
|
this.userMenuItems.push(new MenuItem("","Support","https://openaire-connect.d4science.org/group/openaire-connect-gateway/explore?siteId=172366611","",false,[],[],{}))
|
||||||
this.menuItems = [
|
}
|
||||||
{
|
this.showMenu = true;
|
||||||
rootItem: new MenuItem('dashboard', 'Overview', '/dashboard', '/dashboard', false, [], null, {communityId: com.communityId}),
|
this.buildSideBar();
|
||||||
items: []
|
},
|
||||||
}
|
error => {
|
||||||
];
|
if ((this.communityId && this.communityId !== '') || window.location.pathname === '/') {
|
||||||
} else if (countCommunities === 1 && index_managerOfCommunity != null) {
|
UIkit.notification({
|
||||||
this.community = {
|
message: '<strong>System error retrieving communities.<strong>',
|
||||||
id: communities[index_managerOfCommunity].communityId,
|
status: 'warning',
|
||||||
name: (communities[index_managerOfCommunity].shortTitle) ? communities[index_managerOfCommunity].shortTitle : com.title,
|
timeout: 3000,
|
||||||
logoUrl: communities[index_managerOfCommunity].logoUrl
|
pos: 'top-center'
|
||||||
};
|
});
|
||||||
this.menuItems = [
|
|
||||||
{
|
|
||||||
rootItem: new MenuItem('dashboard', 'Overview', '/dashboard', '/dashboard', false, [], null, {communityId: communities[index_managerOfCommunity].communityId}),
|
|
||||||
items: []
|
|
||||||
}
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this.communityId || this.communityId === '') {
|
);
|
||||||
this.community = null;
|
}
|
||||||
}
|
|
||||||
if (this.communityId) {
|
|
||||||
this.userMenuItems.push(new MenuItem('manage-user-notifications', 'Manage notification settings', '', '/manage-user-notifications', false, [], [], {communityId: this.communityId}));
|
|
||||||
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.buildSideBar();
|
|
||||||
},
|
|
||||||
error => {
|
|
||||||
if ((this.communityId && this.communityId !== '') || window.location.pathname === '/') {
|
|
||||||
UIkit.notification({
|
|
||||||
message: '<strong>System error retrieving communities.<strong>',
|
|
||||||
status: 'warning',
|
|
||||||
timeout: 3000,
|
|
||||||
pos: 'top-center'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue