Skip to content
Snippets Groups Projects
Commit 4a77ff7c authored by Artem Dychenko's avatar Artem Dychenko
Browse files

mod: review changes

parent 5dfc7e39
Branches
1 merge request!8Resolve "[FE] Implement Dashboard Settings modal"
......@@ -34,10 +34,7 @@ export class ConfigurationApi {
dto => dto.is_applied
);
if (!appliedConfiguration) {
throw new Error('No applied configuration found');
}
return appliedConfiguration.id;
return appliedConfiguration!.id;
}),
mergeMap(appliedConfigId => {
......
@if(form) {
<div class="dialog" [formGroup]="form">
<h2 mat-dialog-title class="dialog__header">Settings</h2>
<mat-dialog-content class="dialog__content">
......@@ -41,3 +42,4 @@
<app-button class="save-button" (click)="onSubmit()">SAVE</app-button>
</mat-dialog-actions>
</div>
}
......@@ -39,26 +39,32 @@ export class DashboardSettingsComponent implements OnInit {
dialogRef = inject(MatDialogRef<DashboardSettingsComponent>);
settingsService = inject(SettingsService);
form!: SettingsForm;
form: SettingsForm | null = null;
ngOnInit() {
this.settingsService.settings$.subscribe(settings => {
const protocols = Object.keys(settings.protocols);
this.form = this.settingsFormBuilder.createDefaultForm(protocols);
this.initializeForm();
if (this.form) {
this.initializeForm();
}
});
}
initializeForm() {
const currentSettings = this.settingsService.getSettings();
this.form.patchValue(currentSettings);
if (this.form) {
this.form.patchValue(currentSettings);
}
}
onSubmit() {
const settings: Settings = this.settingsFormBuilder.toValue(this.form);
this.settingsService.updateSettings(settings);
this.dialogRef.close();
if (this.form) {
const settings: Settings = this.settingsFormBuilder.toValue(this.form);
this.settingsService.updateSettings(settings);
this.dialogRef.close();
}
}
onCancel() {
......
......@@ -44,8 +44,6 @@ export class DashboardComponent implements OnInit {
this.configurationApi.fetchAppliedConfiguration().subscribe(config => {
if (config) {
this.settingsService.initSettings(config.protocols);
} else {
console.error('Failed to fetch configuration');
}
});
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment