1
|
/**
|
2
|
* Created by stefania on 7/5/16.
|
3
|
*/
|
4
|
|
5
|
import {Component, OnInit, ViewEncapsulation} from "@angular/core";
|
6
|
import {AuthenticationService} from '../../services/authentication.service';
|
7
|
|
8
|
@Component({
|
9
|
selector: 'top-menu',
|
10
|
templateUrl: './topmenu.component.html',
|
11
|
encapsulation: ViewEncapsulation.None
|
12
|
})
|
13
|
|
14
|
export class TopMenuComponent implements OnInit {
|
15
|
isLoggedIn: boolean;
|
16
|
|
17
|
constructor(private authService: AuthenticationService) { }
|
18
|
|
19
|
ngOnInit(){
|
20
|
this.isLoggedIn = false;
|
21
|
}
|
22
|
|
23
|
|
24
|
onClick(id: string) {
|
25
|
var el: HTMLElement = document.getElementById(id);
|
26
|
el.classList.remove('uk-open');
|
27
|
}
|
28
|
|
29
|
|
30
|
login(){
|
31
|
if(!this.authService.isLoggedIn){
|
32
|
this.authService.login();
|
33
|
this.isLoggedIn = true;
|
34
|
}
|
35
|
}
|
36
|
|
37
|
logout(){
|
38
|
if(this.authService.isLoggedIn){
|
39
|
this.authService.logout();
|
40
|
this.isLoggedIn = false;
|
41
|
}
|
42
|
}
|
43
|
|
44
|
register(){
|
45
|
this.authService.register();
|
46
|
this.authService.login();
|
47
|
this.isLoggedIn = true;
|
48
|
}
|
49
|
|
50
|
|
51
|
}
|