Projekt

Obecné

Profil

Stáhnout (1001 Bajtů) Statistiky
| Větev: | Tag: | Revize:
1
import {Component, OnDestroy, OnInit} from '@angular/core';
2
import {AuthService} from '../../../auth/services/auth.service';
3
import {User} from '../../../auth/models/user';
4
import {Subscription} from 'rxjs';
5
import {Right} from '../../api/endpoints/models/right';
6

    
7
@Component({
8
  selector: 'app-nav-bar',
9
  templateUrl: './nav-bar.component.html',
10
  styleUrls: ['./nav-bar.component.scss']
11
})
12
export class NavBarComponent implements OnInit, OnDestroy {
13

    
14
  loggedUser: User;
15
  subscription: Subscription[] = [];
16
  showAddUserPopup = false;
17
  rights: Right[];
18
  constructor(
19
    private authService: AuthService
20
  ) {
21
  }
22

    
23
  ngOnInit(): void {
24
    this.setUser();
25
  }
26

    
27
  setUser(){
28
    this.authService.getUserState().subscribe(res => {
29
      if(res){
30
        this.loggedUser = res;
31
      }
32
    });
33
  }
34

    
35
  logOut(): void {
36
    this.authService.doLogout();
37
  }
38

    
39
  ngOnDestroy(): void {
40
    this.subscription.forEach(subs => subs.unsubscribe());
41
  }
42

    
43
  addUser() {
44
    this.showAddUserPopup = true;
45
  }
46
}
(3-3/3)