Skip to content

Commit

Permalink
Added AppSettings service to settings component
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Aug 8, 2024
1 parent 3767f25 commit 8eac42d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { PreferencesStore } from '../shared/preferencesStore';
import { ViewSwitchService } from '../shared/viewSwitchService';
import { ReloadDispatcher } from '../shared/reloadDispatcher';
import { DiveSchedules } from '../shared/dive.schedules';
import { ApplicationSettingsService } from '../shared/ApplicationSettings';

export class AppSettingsPage {
constructor(private fixture: ComponentFixture<AppSettingsComponent>) { }
Expand Down Expand Up @@ -44,6 +45,7 @@ describe('App settings component', () => {
PreferencesStore, Preferences,
PlannerService, WorkersFactoryCommon,
ViewSwitchService, ReloadDispatcher,
ApplicationSettingsService
]
}).compileComponents();
});
Expand All @@ -65,6 +67,10 @@ describe('App settings component', () => {
options = schedules.selected.optionsService;
});

it('Converts Gas density', () => {
expect(component.appSettings.maxGasDensity).toBeCloseTo(0.35584, 4);
});

it('Rounds END', () => {
expect(options.maxEND).toBeCloseTo(98, 4);
});
Expand Down
14 changes: 5 additions & 9 deletions projects/planner/src/app/app-settings/app-settings.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { OptionsService } from '../shared/options.service';
import { SettingsNormalizationService } from '../shared/settings-normalization.service';
import { UnitConversion } from '../shared/UnitConversion';
import { SubViewStorage } from '../shared/subViewStorage';
import { DiverOptions } from '../shared/models';
import {DiveSchedules} from '../shared/dive.schedules';
import { DiveSchedules } from '../shared/dive.schedules';
import { ApplicationSettingsService } from '../shared/ApplicationSettings';

@Component({
selector: 'app-app-settings',
Expand All @@ -28,18 +28,14 @@ export class AppSettingsComponent implements OnInit {
constructor(
public units: UnitConversion,
private settingsNormalization: SettingsNormalizationService,
private formBuilder: NonNullableFormBuilder,
private cd: ChangeDetectorRef,
private schedules: DiveSchedules,
private views: SubViewStorage,
public appSettings: ApplicationSettingsService,
private formBuilder: NonNullableFormBuilder,
private cd: ChangeDetectorRef,
public location: Location) {
}

// consider use to all dives not only to currently selected
private get selectedOptions(): OptionsService {
return this.schedules.selected.optionsService;
}

public ngOnInit(): void {
this.settingsForm = this.formBuilder.group({
imperialUnits: [this.units.imperialUnits, [Validators.required]]
Expand Down

0 comments on commit 8eac42d

Please sign in to comment.