-
Notifications
You must be signed in to change notification settings - Fork 219
/
__bootstrap._header.component.ts
62 lines (49 loc) · 1.47 KB
/
__bootstrap._header.component.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import { Component, OnInit } from '@angular/core';
<% if (props.auth) { -%>
import { Router } from '@angular/router';
import { I18nService } from '@app/core';
import { AuthenticationService, CredentialsService } from '@app/auth';
<% } else { -%>
import { I18nService } from '@app/core';
<% } -%>
@Component({
selector: 'app-header',
templateUrl: './header.component.html',
styleUrls: ['./header.component.scss']
})
export class HeaderComponent implements OnInit {
menuHidden = true;
<% if (props.auth) { -%>
constructor(private router: Router,
private authenticationService: AuthenticationService,
private credentialsService: CredentialsService,
private i18nService: I18nService) { }
<% } else { -%>
constructor(private i18nService: I18nService) { }
<% } -%>
ngOnInit() { }
toggleMenu() {
this.menuHidden = !this.menuHidden;
}
setLanguage(language: string) {
this.i18nService.language = language;
}
<% if (props.auth) { -%>
logout() {
this.authenticationService.logout()
.subscribe(() => this.router.navigate(['/login'], { replaceUrl: true }));
}
<% } -%>
get currentLanguage(): string {
return this.i18nService.language;
}
get languages(): string[] {
return this.i18nService.supportedLanguages;
}
<% if (props.auth) { -%>
get username(): string | null {
const credentials = this.credentialsService.credentials;
return credentials ? credentials.username : null;
}
<% } -%>
}