1
|
import {Component} from '@angular/core';
|
2
|
import {MatDialog} from '@angular/material';
|
3
|
import {LocalizationService} from '../localization/localization.service';
|
4
|
import {UserService} from '../services/api/user.service';
|
5
|
import {UserProfile} from '../models/user.model';
|
6
|
import {ProfileSettingsComponent} from "../profile-settings/profile-settings.component";
|
7
|
|
8
|
@Component({
|
9
|
selector: 'app-header',
|
10
|
templateUrl: './header.component.html',
|
11
|
styleUrls: ['./header.component.sass']
|
12
|
})
|
13
|
export class HeaderComponent {
|
14
|
profile: UserProfile;
|
15
|
|
16
|
constructor(
|
17
|
private dialog: MatDialog,
|
18
|
private localizationService: LocalizationService,
|
19
|
private userService: UserService
|
20
|
) {
|
21
|
userService.getLoggedUserProfile()
|
22
|
.subscribe((data: UserProfile) => this.profile = data);
|
23
|
}
|
24
|
|
25
|
onProfileClick(): void {
|
26
|
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
|
this.userService.putNotificationSettingsWithLanguage(
|
36
|
{
|
37
|
notification: dialogData.notification
|
38
|
},
|
39
|
this.localizationService.getCurrentLanguage()
|
40
|
).subscribe(() => {
|
41
|
this.userService.getLoggedUserProfile().subscribe((profile: UserProfile) => this.profile = profile);
|
42
|
});
|
43
|
});
|
44
|
});
|
45
|
}
|
46
|
}
|