1
|
import {Component, OnDestroy, OnInit} from '@angular/core';
|
2
|
import {MenuItem, RootMenuItem} from './openaireLibrary/sharedComponents/menu';
|
3
|
import {EnvProperties} from './openaireLibrary/utils/properties/env-properties';
|
4
|
import {User} from './openaireLibrary/login/utils/helper.class';
|
5
|
import {properties} from '../environments/environment';
|
6
|
import {LayoutService} from './services/layout.service';
|
7
|
import {Header} from './openaireLibrary/sharedComponents/navigationBar.component';
|
8
|
import {SmoothScroll} from './openaireLibrary/utils/smooth-scroll';
|
9
|
|
10
|
@Component({
|
11
|
selector: 'app',
|
12
|
templateUrl: './app.component.html',
|
13
|
})
|
14
|
|
15
|
export class AppComponent implements OnInit, OnDestroy {
|
16
|
title = 'OpenAIRE - Research Graph';
|
17
|
userMenuItems: MenuItem[] = [];
|
18
|
menuItems: RootMenuItem [] = [];
|
19
|
logInUrl = null;
|
20
|
logOutUrl = null;
|
21
|
properties: EnvProperties = properties;
|
22
|
showMenu: boolean = false;
|
23
|
user: User;
|
24
|
header: Header;
|
25
|
logoPath: string = 'assets/common-assets/';
|
26
|
|
27
|
constructor(private layoutService: LayoutService,
|
28
|
private smoothScroll: SmoothScroll) {}
|
29
|
|
30
|
ngOnInit() {
|
31
|
this.logInUrl = this.properties.loginUrl;
|
32
|
this.logOutUrl = this.properties.logoutUrl;
|
33
|
this.showMenu = true;
|
34
|
this.header = {
|
35
|
route: "/",
|
36
|
url: null,
|
37
|
title: 'graph',
|
38
|
logoUrl: this.logoPath + 'logo-large-graph.png',
|
39
|
logoSmallUrl:this.logoPath + 'logo-small-graph.png',
|
40
|
position:'left',
|
41
|
badge:true
|
42
|
};
|
43
|
this.layoutService.isHome.subscribe(isHome => {
|
44
|
this.buildMenu(isHome);
|
45
|
});
|
46
|
}
|
47
|
|
48
|
ngOnDestroy() {
|
49
|
this.smoothScroll.clearSubscriptions();
|
50
|
}
|
51
|
|
52
|
buildMenu(isHome) {
|
53
|
this.menuItems = [
|
54
|
{
|
55
|
rootItem: new MenuItem("about", "About", "", "/about", false, [], null, {}),
|
56
|
items: [
|
57
|
new MenuItem("overview", "Overview", "", "/about", false, [], null, {}),
|
58
|
new MenuItem("architecture", "Architecture", "", "/about", false, [], null, {}, null, 'architecture'),
|
59
|
new MenuItem("metrics", "Data and Metrics", "", "/about", false, [], null, {}, null, 'metrics'),
|
60
|
new MenuItem("infrastructure", "Infrastructure", "", "/about", false, [], null, {}, null, 'infrastructure'),
|
61
|
new MenuItem("team", "Team", "", "/about", false, [], null, {}, null, 'team')
|
62
|
]
|
63
|
},
|
64
|
{
|
65
|
rootItem: new MenuItem("resources", "Resources", "", "/resources", false, [], null, {}),
|
66
|
items: [
|
67
|
new MenuItem("api", "API", "", "/resources", false, [], null, {}),
|
68
|
new MenuItem("references", "References", "", "/resources/references", false, [], null, {})
|
69
|
]
|
70
|
},
|
71
|
{
|
72
|
rootItem: new MenuItem("contact", "Support", "", "/support", false, [], null, {}),
|
73
|
items: []
|
74
|
}
|
75
|
];
|
76
|
if(!isHome) {
|
77
|
this.menuItems = [{
|
78
|
rootItem: new MenuItem("home", "Home", "", "/", false, [], null, {}),
|
79
|
items: []
|
80
|
}].concat(this.menuItems);
|
81
|
}
|
82
|
}
|
83
|
}
|