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 = 'Metadata Registry Service';
|
17
|
userMenuItems: MenuItem[] = [];
|
18
|
menuItems: RootMenuItem [] = [];
|
19
|
logInUrl = null;
|
20
|
logOutUrl = null;
|
21
|
properties: EnvProperties = properties;
|
22
|
showMenu: boolean = false;
|
23
|
user: User;
|
24
|
isHome: boolean;
|
25
|
header: Header;
|
26
|
logoPath: string = 'assets/common-assets/';
|
27
|
|
28
|
constructor(private layoutService: LayoutService,
|
29
|
private smoothScroll: SmoothScroll) {}
|
30
|
|
31
|
ngOnInit() {
|
32
|
this.logInUrl = this.properties.loginUrl;
|
33
|
this.logOutUrl = this.properties.logoutUrl;
|
34
|
this.showMenu = true;
|
35
|
this.layoutService.isHome.subscribe(isHome => {
|
36
|
this.isHome = isHome
|
37
|
this.header = {
|
38
|
route: "/",
|
39
|
url: null,
|
40
|
title: 'usage-counts',
|
41
|
logoUrl: this.logoPath + 'logo-large-usage-counts.png',
|
42
|
logoSmallUrl:this.logoPath + 'logo-small-usage-counts.png',
|
43
|
position:'left',
|
44
|
badge:true
|
45
|
};
|
46
|
this.buildMenu(isHome);
|
47
|
});
|
48
|
}
|
49
|
|
50
|
buildMenu(isHome) {
|
51
|
this.menuItems = [
|
52
|
{
|
53
|
rootItem: new MenuItem("resources", "Resources", "", "/resources", false, [], null, {}),
|
54
|
items: [
|
55
|
new MenuItem("provide", "OpenAIRE Provide", "", "/resources", false, [], null, {}),
|
56
|
new MenuItem("apis", "APIs and Reports", "", "/resources", false, [], null, {}, null, 'apis')
|
57
|
]
|
58
|
},
|
59
|
{
|
60
|
rootItem: new MenuItem("analytics", "Analytics", "", "/analytics", false, [], null, {}),
|
61
|
items: []
|
62
|
},
|
63
|
{
|
64
|
rootItem: new MenuItem("contact", "Contact", "", "/contact", false, [], null, {}),
|
65
|
items: []
|
66
|
},
|
67
|
{
|
68
|
rootItem: new MenuItem("about", "About", "", "/about", false, [], null, {}),
|
69
|
items: [
|
70
|
new MenuItem("architecture", "Architecture", "", "/about", false, [], null, {}, null, 'architecture'),
|
71
|
/*
|
72
|
new MenuItem("faqs", "FAQs", "", "/about", false, [], null, {}, null, 'faqs')
|
73
|
*/
|
74
|
]
|
75
|
}
|
76
|
];
|
77
|
if(!isHome) {
|
78
|
this.menuItems = [{
|
79
|
rootItem: new MenuItem("home", "Home", "", "/", false, [], null, {}),
|
80
|
items: []
|
81
|
}].concat(this.menuItems);
|
82
|
}
|
83
|
}
|
84
|
|
85
|
ngOnDestroy() {
|
86
|
this.smoothScroll.clearSubscriptions();
|
87
|
}
|
88
|
}
|