Projekt

Obecné

Profil

Stáhnout (1001 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1 2c5da396 hlavja
import {Component, OnDestroy, OnInit} from '@angular/core';
2 464309d9 hlavja
import {AuthService} from '../../../auth/services/auth.service';
3 2c5da396 hlavja
import {User} from '../../../auth/models/user';
4
import {Subscription} from 'rxjs';
5 b6006ff4 hlavja
import {Right} from '../../api/endpoints/models/right';
6 464309d9 hlavja
7
@Component({
8
  selector: 'app-nav-bar',
9
  templateUrl: './nav-bar.component.html',
10
  styleUrls: ['./nav-bar.component.scss']
11
})
12 2c5da396 hlavja
export class NavBarComponent implements OnInit, OnDestroy {
13 464309d9 hlavja
14 2c5da396 hlavja
  loggedUser: User;
15
  subscription: Subscription[] = [];
16 b6006ff4 hlavja
  showAddUserPopup = false;
17
  rights: Right[];
18 464309d9 hlavja
  constructor(
19 2c5da396 hlavja
    private authService: AuthService
20 464309d9 hlavja
  ) {
21
  }
22
23
  ngOnInit(): void {
24 2c5da396 hlavja
    this.setUser();
25
  }
26
27
  setUser(){
28
    this.authService.getUserState().subscribe(res => {
29
      if(res){
30
        this.loggedUser = res;
31
      }
32
    });
33 464309d9 hlavja
  }
34
35
  logOut(): void {
36
    this.authService.doLogout();
37
  }
38 2c5da396 hlavja
39
  ngOnDestroy(): void {
40
    this.subscription.forEach(subs => subs.unsubscribe());
41
  }
42 b6006ff4 hlavja
43
  addUser() {
44
    this.showAddUserPopup = true;
45
  }
46 464309d9 hlavja
}