Project

General

Profile

1
import {Component, 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

    
9
@Component({
10
  selector: 'app',
11
  templateUrl: './app.component.html',
12
})
13

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