1 import { Component, OnInit, Input } from '@angular/core';
2 import { FormBuilder, FormGroup } from '@angular/forms';
3 import { Router } from '@angular/router';
5 import { NotificationsService } from 'angular2-notifications';
7 import { AuthService } from '../../core';
13 } from '../../shared';
16 selector: 'my-account-details',
17 templateUrl: './account-details.component.html'
20 export class AccountDetailsComponent extends FormReactive implements OnInit {
21 @Input() user: User = null;
27 validationMessages = {};
30 private authService: AuthService,
31 private formBuilder: FormBuilder,
32 private router: Router,
33 private notificationsService: NotificationsService,
34 private userService: UserService
40 this.form = this.formBuilder.group({
41 displayNSFW: [ this.user.displayNSFW ],
44 this.form.valueChanges.subscribe(data => this.onValueChanged(data));
52 const displayNSFW = this.form.value['displayNSFW'];
58 this.userService.updateDetails(details).subscribe(
60 this.notificationsService.success('Success', 'Informations updated.');
62 this.authService.refreshUserInformations();
65 err => this.error = err