diff --git a/src/app/components/dashboard-settings/dashboard-settings.component.ts b/src/app/components/dashboard-settings/dashboard-settings.component.ts index 130f0085e0452c560af6e0a1190013fbb8c4302b..768be1a1b19cf814331added007dd39aa215d18b 100644 --- a/src/app/components/dashboard-settings/dashboard-settings.component.ts +++ b/src/app/components/dashboard-settings/dashboard-settings.component.ts @@ -43,20 +43,15 @@ export class DashboardSettingsComponent implements OnInit { ngOnInit() { this.settingsService.settings$.subscribe(settings => { - const protocols = Object.keys(settings.protocols); - this.form = this.settingsFormBuilder.createDefaultForm(protocols); - - if (this.form) { - this.initializeForm(); - } + this.initializeForm(settings); }); } - initializeForm() { - const currentSettings = this.settingsService.getSettings(); - if (this.form) { - this.form.patchValue(currentSettings); - } + initializeForm(settings: Settings) { + const protocols = Object.keys(settings.protocols); + + this.form = this.settingsFormBuilder.createDefaultForm(protocols); + this.form.patchValue(settings); } onSubmit() { diff --git a/src/app/components/dashboard/dashboard.component.ts b/src/app/components/dashboard/dashboard.component.ts index 170da9b5c4e14ef8e9d5df8f69aa477b0d7e6e39..9d0e3807214bf517cf012cb831c731eb362b2063 100644 --- a/src/app/components/dashboard/dashboard.component.ts +++ b/src/app/components/dashboard/dashboard.component.ts @@ -42,9 +42,7 @@ export class DashboardComponent implements OnInit { ngOnInit() { this.configurationApi.fetchAppliedConfiguration().subscribe(config => { - if (config) { - this.settingsService.initSettings(config.protocols); - } + this.settingsService.initSettings(config.protocols); }); } diff --git a/src/app/service/settings.service.ts b/src/app/service/settings.service.ts index 46b34dbc056bc7fa3b7aa394f7a155de54f041fa..8e9ee7ec8b8916ebbf10c42b5253ea6ed8de15ee 100644 --- a/src/app/service/settings.service.ts +++ b/src/app/service/settings.service.ts @@ -39,8 +39,4 @@ export class SettingsService { updateSettings(settings: Settings) { this.settingsSubject.next(settings); } - - getSettings(): Settings { - return this.settingsSubject.value; - } }