diff --git a/projects/account/src/app/modules/device/device-add/device-add.component.ts b/projects/account/src/app/modules/device/device-add/device-add.component.ts index 5c6a80e..f3dae56 100644 --- a/projects/account/src/app/modules/device/device-add/device-add.component.ts +++ b/projects/account/src/app/modules/device/device-add/device-add.component.ts @@ -108,7 +108,7 @@ export class DeviceAddComponent implements OnInit { } onPreferencesSubmit() { - this.deviceService.addAccountPreferences(this.preferencesForm); + this.deviceService.addAccountPreferences(this.preferencesForm).subscribe(); } onDefaultsSubmit() { diff --git a/projects/account/src/app/modules/device/device.component.ts b/projects/account/src/app/modules/device/device.component.ts index c5002c2..bede745 100644 --- a/projects/account/src/app/modules/device/device.component.ts +++ b/projects/account/src/app/modules/device/device.component.ts @@ -41,9 +41,18 @@ export class DeviceComponent implements OnInit { ); this.preferencesForm = this.formBuilder.group( { - dateFormat: [null, Validators.required], - measurementSystem: [null, Validators.required], - timeFormat: [null, Validators.required], + dateFormat: [ + this.preferences ? this.preferences.dateFormat : null, + Validators.required + ], + measurementSystem: [ + this.preferences ? this.preferences.measurementSystem : null, + Validators.required + ], + timeFormat: [ + this.preferences ? this.preferences.timeFormat : null, + Validators.required + ], } ); diff --git a/projects/account/src/app/modules/device/preferences/preferences.component.html b/projects/account/src/app/modules/device/preferences/preferences.component.html index fbf9eb8..0f1f023 100644 --- a/projects/account/src/app/modules/device/preferences/preferences.component.html +++ b/projects/account/src/app/modules/device/preferences/preferences.component.html @@ -1,4 +1,4 @@ - + Setup your device preferences Manage your device preferences @@ -26,7 +26,7 @@ - + diff --git a/projects/account/src/app/modules/device/preferences/preferences.component.ts b/projects/account/src/app/modules/device/preferences/preferences.component.ts index 88d68c5..dda8c84 100644 --- a/projects/account/src/app/modules/device/preferences/preferences.component.ts +++ b/projects/account/src/app/modules/device/preferences/preferences.component.ts @@ -71,6 +71,14 @@ export class PreferencesComponent implements OnInit { } onSave() { - this.deviceService.updateAccountPreferences(this.preferencesForm); + if (this.preferences) { + this.deviceService.updateAccountPreferences(this.preferencesForm).subscribe( + () => { this.preferences = this.preferencesForm.value; } + ); + } else { + this.deviceService.addAccountPreferences(this.preferencesForm).subscribe( + () => { this.preferences = this.preferencesForm.value; } + ); + } } }