Angular Web App
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 
 

41 wiersze
1.3 KiB

  1. import { Component, OnDestroy, OnInit } from '@angular/core';
  2. import { Subscription } from 'rxjs';
  3. import { LoginService } from 'src/app/services/login.service';
  4. import { NotificationService } from 'src/app/services/notification.service';
  5. @Component({
  6. selector: 'app-navbar',
  7. templateUrl: './navbar.component.html',
  8. styleUrls: ['./navbar.component.scss']
  9. })
  10. export class NavbarComponent implements OnInit, OnDestroy {
  11. isShowingNotifications = false;
  12. showLogout: boolean = false;
  13. isShowingNotificationsSubscription: Subscription;
  14. loginName: string = '';
  15. notificationsCount: number = 0;
  16. constructor(loginService: LoginService, private notificationService: NotificationService) {
  17. this.loginName = loginService.getLoginName();
  18. this.notificationsCount = notificationService.getAllowedNotifications().length;
  19. this.isShowingNotificationsSubscription = this.notificationService.getIsShowingNotificationsObservable().subscribe(isShowingNotifications => this.isShowingNotifications = isShowingNotifications);
  20. }
  21. showNotifications() {
  22. this.notificationService.setIsShowingNotifications(true);
  23. }
  24. ngOnInit(): void {
  25. }
  26. ngOnDestroy(): void {
  27. if (this.isShowingNotificationsSubscription) {
  28. this.isShowingNotificationsSubscription.unsubscribe();
  29. }
  30. }
  31. }