Project

General

Profile

1
import { Component, DoCheck, OnInit, ViewEncapsulation } from '@angular/core';
2
import { AuthenticationService } from '../../services/authentication.service';
3
import { environment } from '../../../environments/environment';
4

    
5
@Component({
6
  selector: 'top-menu-dashboard',
7
  templateUrl: './topmenu-dashboard.component.html',
8
  // styleUrls: ['./topmenu-dashboard.component.css'],
9
  encapsulation: ViewEncapsulation.None
10
})
11

    
12
export class TopmenuDashboardComponent implements OnInit {
13
  userLoggedIn = false;
14
  userName = '';
15
  isUserAdmin = false;
16
  adminHomePage = environment.FAQ_HOMEPAGE;
17

    
18
  inBeta: boolean;
19

    
20
  constructor(public authService: AuthenticationService) { }
21

    
22
  ngOnInit() {
23
    this.getIsUserLoggedIn();
24
    this.getUserName();
25
    this.getIsUserAdmin();
26

    
27
    const baseUrl = window.location.origin;
28
    this.inBeta = ( baseUrl.includes('beta') || baseUrl.includes('athenarc') );
29
  }
30

    
31
  onClick(id: string) {
32
    const el: HTMLElement = document.getElementById(id);
33
    el.classList.remove('uk-open');
34
  }
35

    
36

    
37
  login() {
38
    this.authService.loginWithState();
39
  }
40

    
41
  logout() {
42
    this.authService.logout();
43
  }
44

    
45

    
46
  getUserName() {
47
    this.userName = this.authService.getUserName();
48
    return this.userName;
49
  }
50

    
51
  getIsUserLoggedIn() {
52
    this.userLoggedIn = this.authService.getIsUserLoggedIn();
53
    return this.userLoggedIn;
54
  }
55

    
56
  getIsUserAdmin() {
57
    this.isUserAdmin = (this.authService.getUserRole().includes('ROLE_ADMIN') ||
58
      this.authService.getUserRole().includes('ROLE_PROVIDE_ADMIN'));
59
    return this.isUserAdmin;
60
  }
61
}
(2-2/2)