aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/account/account-details
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/account/account-details')
-rw-r--r--client/src/app/account/account-details/account-details.component.ts52
-rw-r--r--client/src/app/account/account-details/index.ts2
2 files changed, 27 insertions, 27 deletions
diff --git a/client/src/app/account/account-details/account-details.component.ts b/client/src/app/account/account-details/account-details.component.ts
index 30e5b14ee..d7531cb55 100644
--- a/client/src/app/account/account-details/account-details.component.ts
+++ b/client/src/app/account/account-details/account-details.component.ts
@@ -1,16 +1,16 @@
1import { Component, OnInit, Input } from '@angular/core'; 1import { Component, OnInit, Input } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'; 2import { FormBuilder, FormGroup } from '@angular/forms'
3import { Router } from '@angular/router'; 3import { Router } from '@angular/router'
4 4
5import { NotificationsService } from 'angular2-notifications'; 5import { NotificationsService } from 'angular2-notifications'
6 6
7import { AuthService } from '../../core'; 7import { AuthService } from '../../core'
8import { 8import {
9 FormReactive, 9 FormReactive,
10 User, 10 User,
11 UserService, 11 UserService,
12 USER_PASSWORD 12 USER_PASSWORD
13} from '../../shared'; 13} from '../../shared'
14 14
15@Component({ 15@Component({
16 selector: 'my-account-details', 16 selector: 'my-account-details',
@@ -18,51 +18,51 @@ import {
18}) 18})
19 19
20export class AccountDetailsComponent extends FormReactive implements OnInit { 20export class AccountDetailsComponent extends FormReactive implements OnInit {
21 @Input() user: User = null; 21 @Input() user: User = null
22 22
23 error: string = null; 23 error: string = null
24 24
25 form: FormGroup; 25 form: FormGroup
26 formErrors = {}; 26 formErrors = {}
27 validationMessages = {}; 27 validationMessages = {}
28 28
29 constructor( 29 constructor (
30 private authService: AuthService, 30 private authService: AuthService,
31 private formBuilder: FormBuilder, 31 private formBuilder: FormBuilder,
32 private router: Router, 32 private router: Router,
33 private notificationsService: NotificationsService, 33 private notificationsService: NotificationsService,
34 private userService: UserService 34 private userService: UserService
35 ) { 35 ) {
36 super(); 36 super()
37 } 37 }
38 38
39 buildForm() { 39 buildForm () {
40 this.form = this.formBuilder.group({ 40 this.form = this.formBuilder.group({
41 displayNSFW: [ this.user.displayNSFW ], 41 displayNSFW: [ this.user.displayNSFW ]
42 }); 42 })
43 43
44 this.form.valueChanges.subscribe(data => this.onValueChanged(data)); 44 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
45 } 45 }
46 46
47 ngOnInit() { 47 ngOnInit () {
48 this.buildForm(); 48 this.buildForm()
49 } 49 }
50 50
51 updateDetails() { 51 updateDetails () {
52 const displayNSFW = this.form.value['displayNSFW']; 52 const displayNSFW = this.form.value['displayNSFW']
53 const details = { 53 const details = {
54 displayNSFW 54 displayNSFW
55 }; 55 }
56 56
57 this.error = null; 57 this.error = null
58 this.userService.updateDetails(details).subscribe( 58 this.userService.updateDetails(details).subscribe(
59 () => { 59 () => {
60 this.notificationsService.success('Success', 'Informations updated.'); 60 this.notificationsService.success('Success', 'Informations updated.')
61 61
62 this.authService.refreshUserInformations(); 62 this.authService.refreshUserInformations()
63 }, 63 },
64 64
65 err => this.error = err 65 err => this.error = err
66 ); 66 )
67 } 67 }
68} 68}
diff --git a/client/src/app/account/account-details/index.ts b/client/src/app/account/account-details/index.ts
index 28f644738..4829f608a 100644
--- a/client/src/app/account/account-details/index.ts
+++ b/client/src/app/account/account-details/index.ts
@@ -1 +1 @@
export * from './account-details.component'; export * from './account-details.component'