Projekt

Obecné

Profil

Stáhnout (1.54 KB) Statistiky
| Větev: | Tag: | Revize:
1 1b7df50a Hung Hoang
import {Component} from '@angular/core';
2
import {MatDialog} from '@angular/material';
3 3fcf8b67 Hung Hoang
import {LocalizationService} from '../localization/localization.service';
4 696f3358 Václav Jirák
import {UserService} from '../services/api/user.service';
5
import {UserProfile} from '../models/user.model';
6 7479e470 Hung Hoang
import {ProfileSettingsComponent} from '../profile-settings/profile-settings.component';
7 37333849 Václav Jirák
8
@Component({
9
  selector: 'app-header',
10
  templateUrl: './header.component.html',
11
  styleUrls: ['./header.component.sass']
12
})
13
export class HeaderComponent {
14 696f3358 Václav Jirák
  profile: UserProfile;
15 9c7b1b63 Václav Jirák
16
  constructor(
17
    private dialog: MatDialog,
18 696f3358 Václav Jirák
    private localizationService: LocalizationService,
19
    private userService: UserService
20 9c7b1b63 Václav Jirák
    ) {
21 696f3358 Václav Jirák
    userService.getLoggedUserProfile()
22
      .subscribe((data: UserProfile) => this.profile = data);
23 9c7b1b63 Václav Jirák
  }
24 37333849 Václav Jirák
25
  onProfileClick(): void {
26 9cc55d8d Václav Jirák
    this.userService.getLoggedUserProfile()
27
      .subscribe((data: UserProfile) => {
28
        this.profile = data;
29
30
        this.dialog.open(ProfileSettingsComponent, {
31
          data: {
32
            notification: this.profile.notification
33
          }
34
        }).afterClosed().subscribe(dialogData => {
35 7479e470 Hung Hoang
          if (!dialogData.isConfirmed) {
36
            return;
37
          }
38
39 9cc55d8d Václav Jirák
          this.userService.putNotificationSettingsWithLanguage(
40
            {
41
              notification: dialogData.notification
42
            },
43
            this.localizationService.getCurrentLanguage()
44
          ).subscribe(() => {
45
            this.userService.getLoggedUserProfile().subscribe((profile: UserProfile) => this.profile = profile);
46
          });
47
        });
48
      });
49 37333849 Václav Jirák
  }
50
}