1
|
/**
|
2
|
* Created by stefania on 7/5/16.
|
3
|
*/
|
4
|
import { Component, DoCheck, OnInit, ViewEncapsulation} from '@angular/core';
|
5
|
import { AuthenticationService } from '../../services/authentication.service';
|
6
|
import { environment } from '../../../environments/environment';
|
7
|
import {FormGroup} from "@angular/forms";
|
8
|
|
9
|
@Component({
|
10
|
selector: 'side-menu',
|
11
|
templateUrl: './sidemenu.component.html',
|
12
|
// styleUrls: ['./sidemenu.component.css'],
|
13
|
encapsulation: ViewEncapsulation.None
|
14
|
})
|
15
|
|
16
|
export class SideMenuComponent implements OnInit {
|
17
|
userLoggedIn = false;
|
18
|
userName = '';
|
19
|
isUserAdmin = false;
|
20
|
adminHomePage = environment.FAQ_HOMEPAGE;
|
21
|
|
22
|
inBeta: boolean;
|
23
|
|
24
|
constructor(public authService: AuthenticationService) { }
|
25
|
|
26
|
ngOnInit() {
|
27
|
this.getIsUserLoggedIn();
|
28
|
this.getUserName();
|
29
|
this.getIsUserAdmin();
|
30
|
|
31
|
const baseUrl = window.location.origin;
|
32
|
this.inBeta = ( baseUrl.includes('beta') || baseUrl.includes('athenarc') );
|
33
|
}
|
34
|
|
35
|
onClick(id: string) {
|
36
|
const el: HTMLElement = document.getElementById(id);
|
37
|
el.classList.remove('uk-open');
|
38
|
}
|
39
|
|
40
|
|
41
|
login() {
|
42
|
this.authService.loginWithState();
|
43
|
}
|
44
|
|
45
|
logout() {
|
46
|
this.authService.logout();
|
47
|
}
|
48
|
|
49
|
|
50
|
getUserName() {
|
51
|
this.userName = this.authService.getUserName();
|
52
|
return this.userName;
|
53
|
}
|
54
|
|
55
|
getIsUserLoggedIn() {
|
56
|
this.userLoggedIn = this.authService.getIsUserLoggedIn();
|
57
|
return this.userLoggedIn;
|
58
|
}
|
59
|
|
60
|
getIsUserAdmin() {
|
61
|
this.isUserAdmin = (this.authService.getUserRole().includes('ROLE_ADMIN') ||
|
62
|
this.authService.getUserRole().includes('ROLE_PROVIDE_ADMIN'));
|
63
|
return this.isUserAdmin;
|
64
|
}
|
65
|
}
|