82 lines
2.5 KiB
TypeScript
82 lines
2.5 KiB
TypeScript
import {Component, OnInit} from '@angular/core';
|
|
import {MenuItem, RootMenuItem, SideMenuItem} from './openaireLibrary/sharedComponents/menu';
|
|
import {ActivatedRoute, NavigationStart, Router} from '@angular/router';
|
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
|
import {User} from './openaireLibrary/login/utils/helper.class';
|
|
import {UserManagementService} from './openaireLibrary/services/user-management.service';
|
|
import {properties} from "../environments/environment";
|
|
import {BehaviorSubject} from "rxjs";
|
|
|
|
declare var UIkit: any;
|
|
|
|
@Component({
|
|
selector: 'app',
|
|
templateUrl: './app.component.html',
|
|
})
|
|
|
|
export class AppComponent implements OnInit {
|
|
title = 'Metadata Registry Service';
|
|
userMenuItems: MenuItem[] = [];
|
|
menuItems: RootMenuItem [] = [];
|
|
logInUrl = null;
|
|
logOutUrl = null;
|
|
properties: EnvProperties = properties;
|
|
showMenu: boolean = false;
|
|
user: User;
|
|
isHome: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(true);
|
|
|
|
constructor(private route: ActivatedRoute,
|
|
private router: Router) {
|
|
this.router.events.subscribe(event => {
|
|
if (event instanceof NavigationStart) {
|
|
this.isHome.next(event.url === '/');
|
|
}
|
|
})
|
|
}
|
|
|
|
ngOnInit() {
|
|
this.logInUrl = this.properties.loginUrl;
|
|
this.logOutUrl = this.properties.logoutUrl;
|
|
this.showMenu = true;
|
|
this.isHome.asObservable().subscribe(isHome => {
|
|
this.buildMenu(isHome);
|
|
});
|
|
}
|
|
|
|
buildMenu(isHome) {
|
|
if(!isHome) {
|
|
this.menuItems = [
|
|
{
|
|
rootItem: new MenuItem("home", "Home", "", "", false, [], null, {}),
|
|
items: [
|
|
new MenuItem("intro", "Usage Statistics Intro", "", "/", false, [], null, {}),
|
|
new MenuItem("countries", "Track Countries Usage Activity", "", "/", false, [], null, {slide: 2}),
|
|
/*
|
|
new MenuItem("chart", "Monthly Usage Events", "", "/", false, [], null, {slide: 3})
|
|
*/
|
|
]
|
|
},
|
|
{
|
|
rootItem: new MenuItem("about", "About", "", "/about", false, [], null, {}),
|
|
items: []
|
|
},
|
|
{
|
|
rootItem: new MenuItem("resources", "Resources", "", "/resources", false, [], null, {}),
|
|
items: []
|
|
}
|
|
];
|
|
} else {
|
|
this.menuItems = [
|
|
{
|
|
rootItem: new MenuItem("about", "About", "", "/about", false, [], null, {}),
|
|
items: []
|
|
},
|
|
{
|
|
rootItem: new MenuItem("resources", "Resources", "", "/resources", false, [], null, {}),
|
|
items: []
|
|
}
|
|
];
|
|
}
|
|
}
|
|
}
|