Newer
Older
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
63
64
65
66
67
68
69
70
71
72
73
74
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { JhiLanguageService } from 'ng-jhipster';
import { SessionStorageService } from 'ngx-webstorage';
import { VERSION } from 'app/app.constants';
import { LANGUAGES } from 'app/core/language/language.constants';
import { AccountService } from 'app/core/auth/account.service';
import { LoginModalService } from 'app/core/login/login-modal.service';
import { LoginService } from 'app/core/login/login.service';
import { ProfileService } from 'app/layouts/profiles/profile.service';
@Component({
selector: 'jhi-navbar',
templateUrl: './navbar.component.html',
styleUrls: ['navbar.scss'],
})
export class NavbarComponent implements OnInit {
inProduction?: boolean;
isNavbarCollapsed = true;
languages = LANGUAGES;
swaggerEnabled?: boolean;
version: string;
constructor(
private loginService: LoginService,
private languageService: JhiLanguageService,
private sessionStorage: SessionStorageService,
private accountService: AccountService,
private loginModalService: LoginModalService,
private profileService: ProfileService,
private router: Router
) {
this.version = VERSION ? (VERSION.toLowerCase().startsWith('v') ? VERSION : 'v' + VERSION) : '';
}
ngOnInit(): void {
this.profileService.getProfileInfo().subscribe(profileInfo => {
this.inProduction = profileInfo.inProduction;
this.swaggerEnabled = profileInfo.swaggerEnabled;
});
}
changeLanguage(languageKey: string): void {
this.sessionStorage.store('locale', languageKey);
this.languageService.changeLanguage(languageKey);
}
collapseNavbar(): void {
this.isNavbarCollapsed = true;
}
isAuthenticated(): boolean {
return this.accountService.isAuthenticated();
}
login(): void {
this.loginModalService.open();
}
logout(): void {
this.collapseNavbar();
this.loginService.logout();
this.router.navigate(['']);
}
toggleNavbar(): void {
this.isNavbarCollapsed = !this.isNavbarCollapsed;
}
getImageUrl(): string {
return this.isAuthenticated() ? this.accountService.getImageUrl() : '';
}
}