improvements+fixes

This commit is contained in:
2021-10-04 10:35:57 +02:00
parent a94647d549
commit 91958dc3ff
15 changed files with 72 additions and 72 deletions
+3 -6
View File
@@ -13,6 +13,7 @@ export class PageSettings implements OnInit {
auth: any;
user: any;
working: boolean = false;
success: boolean = false;
form: FormGroup;
@ViewChild('formDirective') private formDirective: NgForm;
@@ -25,7 +26,6 @@ export class PageSettings implements OnInit {
username: [ { disabled: true }, Validators.nullValidator ],
email: [ '', Validators.nullValidator ],
about: [ '', Validators.nullValidator ],
darkTheme: [ '', Validators.nullValidator ],
});
this.form.get('username').disable();
@@ -35,14 +35,9 @@ export class PageSettings implements OnInit {
this.form.get('username').setValue(this.user.username);
this.form.get('email').setValue(this.user.email);
this.form.get('about').setValue(this.user.about);
this.form.get('darkTheme').setValue(this.user.darkTheme);
})
}
darkThemeChange($event) {
this.user.darkTheme = $event.checked;
}
hasError(controlName: string): boolean {
return this.form.controls[ controlName ].errors != null;
}
@@ -53,6 +48,7 @@ export class PageSettings implements OnInit {
}
this.working = true;
this.success = false;
this.user.about = this.form.get('about').value;
this.user.email = this.form.get('email').value;
@@ -60,6 +56,7 @@ export class PageSettings implements OnInit {
this.userService.update(this.user).subscribe((data) => {
this.user = data;
this.working = false;
this.success = true;
}, (error) => {
this.working = false;
if (error.status == 422) {