Skip to content

Commit

Permalink
chore: fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthijsSmets committed Jan 12, 2024
1 parent 2cea56a commit 2b649f8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 42 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import {
Component,
ElementRef,
EventEmitter,
OnDestroy,
Output,
ViewChild,
} from '@angular/core';
import { Component, ElementRef, EventEmitter, OnDestroy, Output, ViewChild } from '@angular/core';
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { NgbModal } from '@ng-bootstrap/ng-bootstrap';
import { HttpService } from '../../../shared/services/http.service';
Expand Down Expand Up @@ -48,15 +41,12 @@ export class TableSettingsModalComponent implements OnDestroy {
}

subscribeToSettingsServiceObservables(): void {
this.showMultipleAtATimeSubscription =
this.settingsService.showMultipleAtATimeObservable.subscribe(
(value: boolean) => {
this.showMultipleAtATime = value;
this.settingsForm
.get('showMultipleFilesAtATime')
?.setValue(this.showMultipleAtATime);
}
);
this.showMultipleAtATimeSubscription = this.settingsService.showMultipleAtATimeObservable.subscribe(
(value: boolean) => {
this.showMultipleAtATime = value;
this.settingsForm.get('showMultipleFilesAtATime')?.setValue(this.showMultipleAtATime);
}
);
}

setShowMultipleAtATime() {
Expand All @@ -83,14 +73,9 @@ export class TableSettingsModalComponent implements OnDestroy {
saveSettings(): void {
const form: any = this.settingsForm.value;
this.cookieService.set('generatorEnabled', form.generatorEnabled);
this.cookieService.set(
'transformationEnabled',
form.transformationEnabled.toString()
);
this.cookieService.set('transformationEnabled', form.transformationEnabled.toString());
this.httpService.postTransformation(form.transformation).subscribe();
const generatorEnabled: string = String(
form.generatorEnabled === 'Enabled'
);
const generatorEnabled: string = String(form.generatorEnabled === 'Enabled');
let data: any = {
generatorEnabled: generatorEnabled,
regexFilter: form.regexFilter,
Expand All @@ -111,28 +96,22 @@ export class TableSettingsModalComponent implements OnDestroy {
factoryReset(): void {
this.settingsForm.reset();
this.settingsService.setShowMultipleAtATime();
this.httpService
.resetSettings()
.subscribe((response) => this.saveResponseSetting(response));
this.httpService.resetSettings().subscribe((response) => this.saveResponseSetting(response));
this.httpService.getTransformation(true).subscribe((resp) => {
this.settingsForm.get('transformation')?.setValue(resp.transformation);
});
}

loadSettings(): void {
this.httpService
.getSettings()
.subscribe((response) => this.saveResponseSetting(response));
this.httpService.getSettings().subscribe((response) => this.saveResponseSetting(response));
if (this.cookieService.get('transformationEnabled')) {
this.settingsForm
.get('transformationEnabled')
?.setValue(this.cookieService.get('transformationEnabled') == 'true');
}

this.httpService.getTransformation(false).subscribe((response) => {
this.settingsForm
.get('transformation')
?.setValue(response.transformation);
this.settingsForm.get('transformation')?.setValue(response.transformation);
});
}

Expand Down
12 changes: 3 additions & 9 deletions src/app/shared/services/settings.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,15 @@ export class SettingsService {
private showMultipleAtATimeKey: string = 'showMultipleFilesAtATime';
private showMultipleAtATime: boolean = false;
private showMultipleAtATimeSubject: Subject<boolean> = new ReplaySubject(1);
public showMultipleAtATimeObservable: Observable<boolean> =
this.showMultipleAtATimeSubject.asObservable();
public showMultipleAtATimeObservable: Observable<boolean> = this.showMultipleAtATimeSubject.asObservable();

public setShowMultipleAtATime(value: boolean = false): void {
this.showMultipleAtATime = value;
this.showMultipleAtATimeSubject.next(this.showMultipleAtATime);
localStorage.setItem(
this.showMultipleAtATimeKey,
String(this.showMultipleAtATime)
);
localStorage.setItem(this.showMultipleAtATimeKey, String(this.showMultipleAtATime));
}

private loadSettingsFromLocalStorage(): void {
this.setShowMultipleAtATime(
localStorage.getItem(this.showMultipleAtATimeKey) === 'true'
);
this.setShowMultipleAtATime(localStorage.getItem(this.showMultipleAtATimeKey) === 'true');
}
}

0 comments on commit 2b649f8

Please sign in to comment.