From 4a2f578831b16146e923e954da027e8ff99c4050 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sat, 6 Jan 2024 23:59:25 +0100 Subject: [PATCH 01/39] Add dive profile injection to TestData class --- .../planner/src/app/diff/diff.component.ts | 84 ++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/projects/planner/src/app/diff/diff.component.ts b/projects/planner/src/app/diff/diff.component.ts index 9212d9ed..ab9bae76 100644 --- a/projects/planner/src/app/diff/diff.component.ts +++ b/projects/planner/src/app/diff/diff.component.ts @@ -3,6 +3,8 @@ import {WayPointsService} from '../shared/waypoints.service'; import {UnitConversion} from '../shared/UnitConversion'; import {Segments, StandardGases, Tank, Time} from 'scuba-physics'; import {WayPoint} from '../shared/models'; +import {PreferencesStore} from '../shared/preferencesStore'; +import {PlannerService} from '../shared/planner.service'; export class TestData { public readonly wayPointsA: WayPoint[]; @@ -11,7 +13,77 @@ export class TestData { public readonly wayPointsB: WayPoint[]; public readonly tanksB: Tank[]; - constructor() { + private profileOneJson = ` + { + "options": { + "imperialUnits": false, + "isComplex": false, + "language": "en" + }, + "dives": [ + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 15, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 10, + "duration": 36, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 10, + "endDepth": 10, + "duration": 3564, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ] + } + ] + }`; + constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { const units = new UnitConversion(); const waypointService = new WayPointsService(units); @@ -49,6 +121,12 @@ export class TestData { segmentsB.add(15, 0, StandardGases.ean50, Time.oneMinute * 2); this.wayPointsB = waypointService.calculateWayPoints(segmentsB.items); } + + public loadProfile(){ + localStorage.setItem('preferences', this.profileOneJson); + this.preferencesStore.load(); + this.plannerService.calculate(); + } } @Component({ @@ -57,5 +135,7 @@ export class TestData { styleUrls: ['./diff.component.scss'] }) export class DiffComponent { - public testData = new TestData(); + public testData = new TestData(this.preferencesStore, this.plannerService); + constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { + } } From 7b3eff15dc0911bc18dc36592db45f5d6f9f35fa Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 00:01:11 +0100 Subject: [PATCH 02/39] Extract JSON data to TestDataJsonProvider --- .../planner/src/app/diff/diff.component.ts | 78 ++---------------- .../app/diff/testData/TestDataJsonProvider.ts | 80 +++++++++++++++++++ 2 files changed, 86 insertions(+), 72 deletions(-) create mode 100644 projects/planner/src/app/diff/testData/TestDataJsonProvider.ts diff --git a/projects/planner/src/app/diff/diff.component.ts b/projects/planner/src/app/diff/diff.component.ts index ab9bae76..3a1b1802 100644 --- a/projects/planner/src/app/diff/diff.component.ts +++ b/projects/planner/src/app/diff/diff.component.ts @@ -5,6 +5,7 @@ import {Segments, StandardGases, Tank, Time} from 'scuba-physics'; import {WayPoint} from '../shared/models'; import {PreferencesStore} from '../shared/preferencesStore'; import {PlannerService} from '../shared/planner.service'; +import {TestDataJsonProvider} from './testData/TestDataJsonProvider'; export class TestData { public readonly wayPointsA: WayPoint[]; @@ -13,76 +14,7 @@ export class TestData { public readonly wayPointsB: WayPoint[]; public readonly tanksB: Tank[]; - private profileOneJson = ` - { - "options": { - "imperialUnits": false, - "isComplex": false, - "language": "en" - }, - "dives": [ - { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 15, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ], - "plan": [ - { - "startDepth": 0, - "endDepth": 10, - "duration": 36, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 10, - "endDepth": 10, - "duration": 3564, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ] - } - ] - }`; + private testDataProvider = new TestDataJsonProvider(); constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { const units = new UnitConversion(); const waypointService = new WayPointsService(units); @@ -120,10 +52,12 @@ export class TestData { segmentsB.add(15, 15, StandardGases.ean50, Time.oneMinute); segmentsB.add(15, 0, StandardGases.ean50, Time.oneMinute * 2); this.wayPointsB = waypointService.calculateWayPoints(segmentsB.items); + this.loadProfile(1); } - public loadProfile(){ - localStorage.setItem('preferences', this.profileOneJson); + public loadProfile(num: number){ + const preferencesJson: string = this.testDataProvider.get(num); + localStorage.setItem('preferences', preferencesJson); this.preferencesStore.load(); this.plannerService.calculate(); } diff --git a/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts new file mode 100644 index 00000000..4608f885 --- /dev/null +++ b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts @@ -0,0 +1,80 @@ +export class TestDataJsonProvider { + private profileOneJson = ` + { + "options": { + "imperialUnits": false, + "isComplex": false, + "language": "en" + }, + "dives": [ + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 15, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 10, + "duration": 36, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 10, + "endDepth": 10, + "duration": 3564, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ] + } + ] + }`; + public get(num: number): string{ + switch (num) { + case 1: + return this.profileOneJson; + default: + throw new RangeError('Requested profile index is out of range!'); + } + } +} From a001a47e95a7a445bed5fca6232df7ad402a1928 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 00:22:46 +0100 Subject: [PATCH 03/39] Add more testing dives --- .../app/diff/testData/TestDataJsonProvider.ts | 499 ++++++++++++++++++ 1 file changed, 499 insertions(+) diff --git a/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts index 4608f885..1c981378 100644 --- a/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts +++ b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts @@ -1,4 +1,53 @@ export class TestDataJsonProvider { + private defaultProfileJson = ` + { + "options": { + "imperialUnits": false, + "isComplex": false, + "language": "en" + }, + "dives": [ + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 15, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ], + "plan": [] + } + ] + }`; private profileOneJson = ` { "options": { @@ -69,10 +118,460 @@ export class TestDataJsonProvider { } ] }`; + private profileTwoJson = ` + { + "options": { + "imperialUnits": false, + "isComplex": true, + "language": "en" + }, + "dives": [ + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 24, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "id": 2, + "size": 11, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "id": 3, + "size": 11, + "workPressure": 0, + "startPressure": 150, + "gas": { + "fO2": 1, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 40, + "duration": 120, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 600, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 21, + "duration": 120, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 21, + "endDepth": 21, + "duration": 60, + "tankId": 2, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "startDepth": 21, + "endDepth": 3, + "duration": 180, + "tankId": 2, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "startDepth": 3, + "endDepth": 3, + "duration": 360, + "tankId": 3, + "gas": { + "fO2": 1, + "fHe": 0 + } + }, + { + "startDepth": 3, + "endDepth": 0, + "duration": 60, + "tankId": 3, + "gas": { + "fO2": 1, + "fHe": 0 + } + } + ] + } + ] + }`; + + private profileThreeJson = ` + { + "states": { + "lastScreen": "dashboard", + "states": [ + { + "id": "dashboard" + } + ] + }, + "options": { + "imperialUnits": false, + "isComplex": true, + "language": "en" + }, + "dives": [ + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 24, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "id": 2, + "size": 11.1, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 1, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 40, + "duration": 180, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 1020, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ] + } + ] + }`; + + private profileFourJson = ` + { + "options": { + "imperialUnits": false, + "isComplex": true, + "language": "en" + }, + "dives": [ + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 24, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.18, + "fHe": 0.45 + } + }, + { + "id": 2, + "size": 11.1, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 1, + "fHe": 0 + } + }, + { + "id": 3, + "size": 11.1, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 60, + "duration": 180, + "tankId": 1, + "gas": { + "fO2": 0.18, + "fHe": 0.45 + } + }, + { + "startDepth": 60, + "endDepth": 60, + "duration": 900, + "tankId": 1, + "gas": { + "fO2": 0.18, + "fHe": 0.45 + } + } + ] + } + ] + }`; + + private profileFiveJson = ` + { + "states": { + "lastScreen": "dashboard", + "states": [ + { + "id": "dashboard" + } + ] + }, + "options": { + "imperialUnits": false, + "isComplex": true, + "language": "en" + }, + "dives": [ + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 15, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 40, + "duration": 180, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 30, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 30, + "endDepth": 30, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 30, + "endDepth": 40, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ] + } + ] + }`; + public get(num: number): string{ switch (num) { + case 0: + return this.defaultProfileJson; case 1: return this.profileOneJson; + case 2: + return this.profileTwoJson; + case 3: + return this.profileThreeJson; + case 4: + return this.profileFourJson; + case 5: + return this.profileFiveJson; default: throw new RangeError('Requested profile index is out of range!'); } From bc23699f4fe5dd2fd95b8090b3fb982fdc446678 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 00:47:19 +0100 Subject: [PATCH 04/39] Inject 2 dive profiles --- .../planner/src/app/diff/diff.component.ts | 9 +- .../app/diff/testData/TestDataJsonProvider.ts | 640 +++++++++--------- 2 files changed, 313 insertions(+), 336 deletions(-) diff --git a/projects/planner/src/app/diff/diff.component.ts b/projects/planner/src/app/diff/diff.component.ts index 3a1b1802..2b4ae870 100644 --- a/projects/planner/src/app/diff/diff.component.ts +++ b/projects/planner/src/app/diff/diff.component.ts @@ -52,14 +52,17 @@ export class TestData { segmentsB.add(15, 15, StandardGases.ean50, Time.oneMinute); segmentsB.add(15, 0, StandardGases.ean50, Time.oneMinute * 2); this.wayPointsB = waypointService.calculateWayPoints(segmentsB.items); - this.loadProfile(1); + this.injectProfiles(0, 1); } - public loadProfile(num: number){ - const preferencesJson: string = this.testDataProvider.get(num); + // !! ONLY FOR TESTING PURPOSES !! + // Rewrites user defined dive profiles and replaces with 2 pre-defined testing profiles + public injectProfiles(profileAIndex: number, profileBIndex: number){ + const preferencesJson: string = this.testDataProvider.get(profileAIndex, profileBIndex); localStorage.setItem('preferences', preferencesJson); this.preferencesStore.load(); this.plannerService.calculate(); + this.plannerService.calculate(2); } } diff --git a/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts index 1c981378..57e6edb1 100644 --- a/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts +++ b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts @@ -2,259 +2,233 @@ export class TestDataJsonProvider { private defaultProfileJson = ` { "options": { - "imperialUnits": false, - "isComplex": false, - "language": "en" + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 }, - "dives": [ + "diver": { + "rmv": 20 + }, + "tanks": [ { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 15, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ], - "plan": [] + "id": 1, + "size": 15, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } } - ] + ], + "plan": [] }`; private profileOneJson = ` + { + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ { - "options": { - "imperialUnits": false, - "isComplex": false, - "language": "en" - }, - "dives": [ - { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 15, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ], - "plan": [ - { - "startDepth": 0, - "endDepth": 10, - "duration": 36, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 10, - "endDepth": 10, - "duration": 3564, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ] - } - ] - }`; + "id": 1, + "size": 15, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 10, + "duration": 36, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 10, + "endDepth": 10, + "duration": 3564, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ] + }`; + private profileTwoJson = ` { "options": { - "imperialUnits": false, - "isComplex": true, - "language": "en" + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 }, - "dives": [ + "diver": { + "rmv": 20 + }, + "tanks": [ { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 24, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "id": 2, - "size": 11, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.5, - "fHe": 0 - } - }, - { - "id": 3, - "size": 11, - "workPressure": 0, - "startPressure": 150, - "gas": { - "fO2": 1, - "fHe": 0 - } - } - ], - "plan": [ - { - "startDepth": 0, - "endDepth": 40, - "duration": 120, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 40, - "endDepth": 40, - "duration": 600, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 40, - "endDepth": 21, - "duration": 120, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 21, - "endDepth": 21, - "duration": 60, - "tankId": 2, - "gas": { - "fO2": 0.5, - "fHe": 0 - } - }, - { - "startDepth": 21, - "endDepth": 3, - "duration": 180, - "tankId": 2, - "gas": { - "fO2": 0.5, - "fHe": 0 - } - }, - { - "startDepth": 3, - "endDepth": 3, - "duration": 360, - "tankId": 3, - "gas": { - "fO2": 1, - "fHe": 0 - } - }, - { - "startDepth": 3, - "endDepth": 0, - "duration": 60, - "tankId": 3, - "gas": { - "fO2": 1, - "fHe": 0 - } - } - ] + "id": 1, + "size": 24, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "id": 2, + "size": 11, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "id": 3, + "size": 11, + "workPressure": 0, + "startPressure": 150, + "gas": { + "fO2": 1, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 40, + "duration": 120, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 600, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 21, + "duration": 120, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 21, + "endDepth": 21, + "duration": 60, + "tankId": 2, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "startDepth": 21, + "endDepth": 3, + "duration": 180, + "tankId": 2, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "startDepth": 3, + "endDepth": 3, + "duration": 360, + "tankId": 3, + "gas": { + "fO2": 1, + "fHe": 0 + } + }, + { + "startDepth": 3, + "endDepth": 0, + "duration": 60, + "tankId": 3, + "gas": { + "fO2": 1, + "fHe": 0 + } } ] }`; @@ -351,90 +325,81 @@ export class TestDataJsonProvider { private profileFourJson = ` { "options": { - "imperialUnits": false, - "isComplex": true, - "language": "en" + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 }, - "dives": [ + "diver": { + "rmv": 20 + }, + "tanks": [ { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 24, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.18, - "fHe": 0.45 - } - }, - { - "id": 2, - "size": 11.1, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 1, - "fHe": 0 - } - }, - { - "id": 3, - "size": 11.1, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.5, - "fHe": 0 - } - } - ], - "plan": [ - { - "startDepth": 0, - "endDepth": 60, - "duration": 180, - "tankId": 1, - "gas": { - "fO2": 0.18, - "fHe": 0.45 - } - }, - { - "startDepth": 60, - "endDepth": 60, - "duration": 900, - "tankId": 1, - "gas": { - "fO2": 0.18, - "fHe": 0.45 - } - } - ] + "id": 1, + "size": 24, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.18, + "fHe": 0.45 + } + }, + { + "id": 2, + "size": 11.1, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 1, + "fHe": 0 + } + }, + { + "id": 3, + "size": 11.1, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 60, + "duration": 180, + "tankId": 1, + "gas": { + "fO2": 0.18, + "fHe": 0.45 + } + }, + { + "startDepth": 60, + "endDepth": 60, + "duration": 900, + "tankId": 1, + "gas": { + "fO2": 0.18, + "fHe": 0.45 + } } ] }`; @@ -449,12 +414,6 @@ export class TestDataJsonProvider { } ] }, - "options": { - "imperialUnits": false, - "isComplex": true, - "language": "en" - }, - "dives": [ { "options": { "gfLow": 0.4, @@ -555,10 +514,25 @@ export class TestDataJsonProvider { } ] } - ] - }`; +`; + + public get(profileAIndex: number, profileBIndex: number): string { + const preferencesPrefix = ` + { + "options": { + "imperialUnits": false, + "isComplex": true, + "language": "en" + }, + "dives": [`; + const preferencesSuffix = ` + ] + } + `; + return preferencesPrefix + this.getDive(profileAIndex) + ',' + this.getDive(profileBIndex) + preferencesSuffix; + } - public get(num: number): string{ + private getDive(num: number): string { switch (num) { case 0: return this.defaultProfileJson; From acb724e400a5d23bcbc58e1f681b8cf3bb8798e6 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 00:56:34 +0100 Subject: [PATCH 05/39] Extract test data injection into service --- projects/planner/src/app/app.module.ts | 180 +++++++++--------- .../planner/src/app/diff/diff.component.ts | 21 +- .../src/app/diff/testData/testDataInjector.ts | 22 +++ 3 files changed, 118 insertions(+), 105 deletions(-) create mode 100644 projects/planner/src/app/diff/testData/testDataInjector.ts diff --git a/projects/planner/src/app/app.module.ts b/projects/planner/src/app/app.module.ts index 6c23e782..8d218243 100644 --- a/projects/planner/src/app/app.module.ts +++ b/projects/planner/src/app/app.module.ts @@ -1,94 +1,95 @@ -import { BrowserModule } from '@angular/platform-browser'; -import { NgModule } from '@angular/core'; -import { ReactiveFormsModule } from '@angular/forms'; -import { ServiceWorkerModule } from '@angular/service-worker'; -import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; -import { FontAwesomeModule } from '@fortawesome/angular-fontawesome'; -import { DatePipe, DecimalPipe } from '@angular/common'; +import {BrowserModule} from '@angular/platform-browser'; +import {NgModule} from '@angular/core'; +import {ReactiveFormsModule} from '@angular/forms'; +import {ServiceWorkerModule} from '@angular/service-worker'; +import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; +import {FontAwesomeModule} from '@fortawesome/angular-fontawesome'; +import {DatePipe, DecimalPipe} from '@angular/common'; -import { ClipboardModule } from 'ngx-clipboard'; -import { MdbCollapseModule } from 'mdb-angular-ui-kit/collapse'; -import { MdbDropdownModule } from 'mdb-angular-ui-kit/dropdown'; -import { MdbFormsModule } from 'mdb-angular-ui-kit/forms'; -import { MdbTabsModule } from 'mdb-angular-ui-kit/tabs'; -import { MdbAccordionModule } from 'mdb-angular-ui-kit/accordion'; +import {ClipboardModule} from 'ngx-clipboard'; +import {MdbCollapseModule} from 'mdb-angular-ui-kit/collapse'; +import {MdbDropdownModule} from 'mdb-angular-ui-kit/dropdown'; +import {MdbFormsModule} from 'mdb-angular-ui-kit/forms'; +import {MdbTabsModule} from 'mdb-angular-ui-kit/tabs'; +import {MdbAccordionModule} from 'mdb-angular-ui-kit/accordion'; -import { environment } from '../environments/environment'; -import { AppRoutingModule } from './app-routing.module'; -import { AppComponent } from './app.component'; -import { TanksSimpleComponent } from './tanks-simple/tanks-simple.component'; -import { TanksComplexComponent } from './tanks-complex/tanks-complex.component'; -import { DiverComponent } from './diver/diver.component'; -import { DiveOptionsComponent } from './diveoptions/diveoptions.component'; -import { DiveInfoComponent } from './diveinfo/diveinfo.component'; -import { MainMenuComponent } from './mainmenu/mainmenu.component'; -import { DashboardComponent } from './dashboard/dashboard.component'; -import { GaslabelComponent } from './gaslabel/gaslabel.component'; -import { SacComponent } from './sac/sac.component'; -import { NitroxComponent } from './nitrox/nitrox.component'; -import { WayPointsComponent } from './waypoints/waypoints.component'; -import { ProfileChartComponent } from './profilechart/profilechart.component'; -import { AboutComponent } from './about/about.component'; -import { AppFooterComponent } from './footer/footer.component'; -import { DepthsSimpleComponent } from './depths-simple/depths-simple.component'; -import { DepthsComplexComponent } from './depths-complex/depths-complex.component'; -import { TankChartComponent } from './tank-chart/tank-chart.component'; -import { AppSettingsComponent } from './app-settings/app-settings.component'; -import { CalculatingComponent } from './calculating/calculating.component'; -import { NdlLimitsComponent } from './ndl-limits/ndl-limits.component'; -import { SalinityComponent } from './salinity/salinity.component'; -import { AltitudeComponent } from './altitude/altitude.component'; -import { GradientsComponent } from './gradients/gradients.component'; -import { DepthComponent } from './depth/depth.component'; -import { OxygenComponent } from './oxygen/oxygen.component'; +import {environment} from '../environments/environment'; +import {AppRoutingModule} from './app-routing.module'; +import {AppComponent} from './app.component'; +import {TanksSimpleComponent} from './tanks-simple/tanks-simple.component'; +import {TanksComplexComponent} from './tanks-complex/tanks-complex.component'; +import {DiverComponent} from './diver/diver.component'; +import {DiveOptionsComponent} from './diveoptions/diveoptions.component'; +import {DiveInfoComponent} from './diveinfo/diveinfo.component'; +import {MainMenuComponent} from './mainmenu/mainmenu.component'; +import {DashboardComponent} from './dashboard/dashboard.component'; +import {GaslabelComponent} from './gaslabel/gaslabel.component'; +import {SacComponent} from './sac/sac.component'; +import {NitroxComponent} from './nitrox/nitrox.component'; +import {WayPointsComponent} from './waypoints/waypoints.component'; +import {ProfileChartComponent} from './profilechart/profilechart.component'; +import {AboutComponent} from './about/about.component'; +import {AppFooterComponent} from './footer/footer.component'; +import {DepthsSimpleComponent} from './depths-simple/depths-simple.component'; +import {DepthsComplexComponent} from './depths-complex/depths-complex.component'; +import {TankChartComponent} from './tank-chart/tank-chart.component'; +import {AppSettingsComponent} from './app-settings/app-settings.component'; +import {CalculatingComponent} from './calculating/calculating.component'; +import {NdlLimitsComponent} from './ndl-limits/ndl-limits.component'; +import {SalinityComponent} from './salinity/salinity.component'; +import {AltitudeComponent} from './altitude/altitude.component'; +import {GradientsComponent} from './gradients/gradients.component'; +import {DepthComponent} from './depth/depth.component'; +import {OxygenComponent} from './oxygen/oxygen.component'; -import { DurationPipe } from './pipes/duration.pipe'; -import { PlannerService } from './shared/planner.service'; -import { PreferencesStore } from './shared/preferencesStore'; -import { UnitConversion } from './shared/UnitConversion'; -import { SelectedWaypoint } from './shared/selectedwaypointService'; -import { WorkersFactory } from './shared/workers.factory'; -import { WorkersFactoryCommon } from './shared/serial.workers.factory'; -import { NdlService } from './shared/ndl.service'; -import { OptionsService } from './shared/options.service'; -import { PpO2Component } from './pp-o2/pp-o2.component'; -import { DelayedScheduleService } from './shared/delayedSchedule.service'; -import { AppinfoComponent } from './appinfo/appinfo.component'; -import { DiveIssuesComponent } from './dive-issues/dive-issues.component'; -import { InputControls } from './shared/inputcontrols'; -import { ValidatorGroups } from './shared/ValidatorGroups'; -import { DepthsService } from './shared/depths.service'; -import { TanksService } from './shared/tanks.service'; -import { SacCalculatorService } from './shared/sac-calculator.service'; -import { NitroxCalculatorService } from './shared/nitrox-calculator.service'; -import { SettingsNormalizationService } from './shared/settings-normalization.service'; -import { ViewSwitchService } from './shared/viewSwitchService'; -import { OxygenDropDownComponent } from './oxygen-dropdown/oxygen-dropdown.component'; -import { Preferences } from './shared/preferences'; -import { PlanUrlSerialization } from './shared/PlanUrlSerialization'; -import { WayPointsService } from './shared/waypoints.service'; -import { PlanTabsComponent } from './plan.tabs/plan.tabs.component'; -import { TankSizeComponent } from './tank.size/tank.size.component'; -import { StopsFilter } from './shared/stopsFilter.service'; -import { ViewStates } from './shared/viewStates'; -import { Urls } from './shared/navigation.service'; -import { SubViewStorage } from './shared/subViewStorage'; -import { DashboardStartUp } from './shared/startUp'; -import { AltitudeCalcComponent } from './altitude-calc/altitude-calc.component'; -import { WeightCalcComponent } from './weight/weight.component'; -import { GasPropertiesCalcComponent } from './gas.props/gas.props.component'; -import { DiffComponent } from './diff/diff.component'; -import { DiveResults } from './shared/diveresults'; -import { DiveSchedules } from './shared/dive.schedules'; -import { RedundanciesComponent } from './redundancies/redundancies.component'; -import { RedundanciesService } from './shared/redundancies.service'; -import { ReloadDispatcher } from './shared/reloadDispatcher'; -import { ManagedDiveSchedules } from './shared/managedDiveSchedules'; -import { WaypointsDifferenceComponent } from './diff/waypoints/diff-waypoints.component'; -import { DiveInfoDifferenceComponent } from './diff/diveinfo/diff-diveinfo.component'; -import { ProfileDifferenceChartComponent } from './diff/profilechart/diff-profilechart.component'; -import { MaskitoModule } from '@maskito/angular'; -import { SurfaceIntervalComponent } from './surface-interval/surface-interval.component'; +import {DurationPipe} from './pipes/duration.pipe'; +import {PlannerService} from './shared/planner.service'; +import {PreferencesStore} from './shared/preferencesStore'; +import {UnitConversion} from './shared/UnitConversion'; +import {SelectedWaypoint} from './shared/selectedwaypointService'; +import {WorkersFactory} from './shared/workers.factory'; +import {WorkersFactoryCommon} from './shared/serial.workers.factory'; +import {NdlService} from './shared/ndl.service'; +import {OptionsService} from './shared/options.service'; +import {PpO2Component} from './pp-o2/pp-o2.component'; +import {DelayedScheduleService} from './shared/delayedSchedule.service'; +import {AppinfoComponent} from './appinfo/appinfo.component'; +import {DiveIssuesComponent} from './dive-issues/dive-issues.component'; +import {InputControls} from './shared/inputcontrols'; +import {ValidatorGroups} from './shared/ValidatorGroups'; +import {DepthsService} from './shared/depths.service'; +import {TanksService} from './shared/tanks.service'; +import {SacCalculatorService} from './shared/sac-calculator.service'; +import {NitroxCalculatorService} from './shared/nitrox-calculator.service'; +import {SettingsNormalizationService} from './shared/settings-normalization.service'; +import {ViewSwitchService} from './shared/viewSwitchService'; +import {OxygenDropDownComponent} from './oxygen-dropdown/oxygen-dropdown.component'; +import {Preferences} from './shared/preferences'; +import {PlanUrlSerialization} from './shared/PlanUrlSerialization'; +import {WayPointsService} from './shared/waypoints.service'; +import {PlanTabsComponent} from './plan.tabs/plan.tabs.component'; +import {TankSizeComponent} from './tank.size/tank.size.component'; +import {StopsFilter} from './shared/stopsFilter.service'; +import {ViewStates} from './shared/viewStates'; +import {Urls} from './shared/navigation.service'; +import {SubViewStorage} from './shared/subViewStorage'; +import {DashboardStartUp} from './shared/startUp'; +import {AltitudeCalcComponent} from './altitude-calc/altitude-calc.component'; +import {WeightCalcComponent} from './weight/weight.component'; +import {GasPropertiesCalcComponent} from './gas.props/gas.props.component'; +import {DiffComponent} from './diff/diff.component'; +import {DiveResults} from './shared/diveresults'; +import {DiveSchedules} from './shared/dive.schedules'; +import {RedundanciesComponent} from './redundancies/redundancies.component'; +import {RedundanciesService} from './shared/redundancies.service'; +import {ReloadDispatcher} from './shared/reloadDispatcher'; +import {ManagedDiveSchedules} from './shared/managedDiveSchedules'; +import {WaypointsDifferenceComponent} from './diff/waypoints/diff-waypoints.component'; +import {DiveInfoDifferenceComponent} from './diff/diveinfo/diff-diveinfo.component'; +import {ProfileDifferenceChartComponent} from './diff/profilechart/diff-profilechart.component'; +import {MaskitoModule} from '@maskito/angular'; +import {SurfaceIntervalComponent} from './surface-interval/surface-interval.component'; +import {TestDataInjector} from './diff/testData/testDataInjector'; const ANGULAR_MODULES = [ AppRoutingModule, @@ -182,7 +183,8 @@ const SERVICES = [ ValidatorGroups, ViewStates, ViewSwitchService, - WayPointsService + WayPointsService, + TestDataInjector ]; @NgModule({ diff --git a/projects/planner/src/app/diff/diff.component.ts b/projects/planner/src/app/diff/diff.component.ts index 2b4ae870..73e26e4a 100644 --- a/projects/planner/src/app/diff/diff.component.ts +++ b/projects/planner/src/app/diff/diff.component.ts @@ -3,9 +3,8 @@ import {WayPointsService} from '../shared/waypoints.service'; import {UnitConversion} from '../shared/UnitConversion'; import {Segments, StandardGases, Tank, Time} from 'scuba-physics'; import {WayPoint} from '../shared/models'; -import {PreferencesStore} from '../shared/preferencesStore'; -import {PlannerService} from '../shared/planner.service'; import {TestDataJsonProvider} from './testData/TestDataJsonProvider'; +import {TestDataInjector} from './testData/testDataInjector'; export class TestData { public readonly wayPointsA: WayPoint[]; @@ -15,7 +14,7 @@ export class TestData { public readonly tanksB: Tank[]; private testDataProvider = new TestDataJsonProvider(); - constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { + constructor(private testDataInjector: TestDataInjector) { const units = new UnitConversion(); const waypointService = new WayPointsService(units); @@ -52,17 +51,7 @@ export class TestData { segmentsB.add(15, 15, StandardGases.ean50, Time.oneMinute); segmentsB.add(15, 0, StandardGases.ean50, Time.oneMinute * 2); this.wayPointsB = waypointService.calculateWayPoints(segmentsB.items); - this.injectProfiles(0, 1); - } - - // !! ONLY FOR TESTING PURPOSES !! - // Rewrites user defined dive profiles and replaces with 2 pre-defined testing profiles - public injectProfiles(profileAIndex: number, profileBIndex: number){ - const preferencesJson: string = this.testDataProvider.get(profileAIndex, profileBIndex); - localStorage.setItem('preferences', preferencesJson); - this.preferencesStore.load(); - this.plannerService.calculate(); - this.plannerService.calculate(2); + this.testDataInjector.injectProfiles(0, 1); } } @@ -72,7 +61,7 @@ export class TestData { styleUrls: ['./diff.component.scss'] }) export class DiffComponent { - public testData = new TestData(this.preferencesStore, this.plannerService); - constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { + public testData = new TestData(this.testDataInjector); + constructor(private testDataInjector: TestDataInjector) { } } diff --git a/projects/planner/src/app/diff/testData/testDataInjector.ts b/projects/planner/src/app/diff/testData/testDataInjector.ts new file mode 100644 index 00000000..f85ad8fa --- /dev/null +++ b/projects/planner/src/app/diff/testData/testDataInjector.ts @@ -0,0 +1,22 @@ +import {Injectable} from '@angular/core'; +import {PreferencesStore} from '../../shared/preferencesStore'; +import {PlannerService} from '../../shared/planner.service'; +import {TestDataJsonProvider} from './TestDataJsonProvider'; + +@Injectable() +export class TestDataInjector { + + private testDataProvider = new TestDataJsonProvider(); + constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { + } + + // !! ONLY FOR TESTING PURPOSES !! + // Rewrites user defined dive profiles and replaces with 2 pre-defined testing profiles + public injectProfiles(profileAIndex: number, profileBIndex: number){ + const preferencesJson: string = this.testDataProvider.get(profileAIndex, profileBIndex); + localStorage.setItem('preferences', preferencesJson); + this.preferencesStore.load(); + this.plannerService.calculate(); + this.plannerService.calculate(2); + } +} From 4848f6e1b9c275a5817c761ff2bda78db0a6e560 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 01:31:43 +0100 Subject: [PATCH 06/39] Add ProfileComparatorService --- projects/planner/src/app/app.module.ts | 4 ++- .../app/shared/profileComparatorService.ts | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 projects/planner/src/app/shared/profileComparatorService.ts diff --git a/projects/planner/src/app/app.module.ts b/projects/planner/src/app/app.module.ts index 8d218243..01ce1cce 100644 --- a/projects/planner/src/app/app.module.ts +++ b/projects/planner/src/app/app.module.ts @@ -90,6 +90,7 @@ import {ProfileDifferenceChartComponent} from './diff/profilechart/diff-profilec import {MaskitoModule} from '@maskito/angular'; import {SurfaceIntervalComponent} from './surface-interval/surface-interval.component'; import {TestDataInjector} from './diff/testData/testDataInjector'; +import {ProfileComparatorService} from './shared/profileComparatorService'; const ANGULAR_MODULES = [ AppRoutingModule, @@ -184,7 +185,8 @@ const SERVICES = [ ViewStates, ViewSwitchService, WayPointsService, - TestDataInjector + TestDataInjector, + ProfileComparatorService ]; @NgModule({ diff --git a/projects/planner/src/app/shared/profileComparatorService.ts b/projects/planner/src/app/shared/profileComparatorService.ts new file mode 100644 index 00000000..77e15552 --- /dev/null +++ b/projects/planner/src/app/shared/profileComparatorService.ts @@ -0,0 +1,33 @@ +import {Injectable} from '@angular/core'; +import {DiveSchedules} from './dive.schedules'; +import {DiveResults} from './diveresults'; + +@Injectable() +export class ProfileComparatorService { + + private _profileAIndex = 0; + private _profileBIndex = 1; + + constructor(private schedules: DiveSchedules) { + } + + set profileAIndex(value: number) { + this._profileAIndex = value; + } + + set profileBIndex(value: number) { + this._profileBIndex = value; + } + + public profileAResults(): DiveResults { + return this.schedules.dives[this._profileAIndex].diveResult; + } + + public profileBResults(): DiveResults { + return this.schedules.dives[this._profileBIndex].diveResult; + } + + public hasTwoProfiles(): boolean { + return this.schedules.length > 1; + } +} From db8dd451ba2fc8d8e25ee26ce65583e6055cdcd4 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 01:42:56 +0100 Subject: [PATCH 07/39] Add check for at least 2 profiles --- projects/planner/src/app/diff/diff.component.html | 9 ++++++++- projects/planner/src/app/diff/diff.component.ts | 5 +++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/projects/planner/src/app/diff/diff.component.html b/projects/planner/src/app/diff/diff.component.html index f815edde..69a710d4 100644 --- a/projects/planner/src/app/diff/diff.component.html +++ b/projects/planner/src/app/diff/diff.component.html @@ -1,4 +1,4 @@ -
+
@@ -12,3 +12,10 @@
+ +
+
+
Please make at least 2 profiles
+
+
+
diff --git a/projects/planner/src/app/diff/diff.component.ts b/projects/planner/src/app/diff/diff.component.ts index 73e26e4a..50a3d5dd 100644 --- a/projects/planner/src/app/diff/diff.component.ts +++ b/projects/planner/src/app/diff/diff.component.ts @@ -5,6 +5,7 @@ import {Segments, StandardGases, Tank, Time} from 'scuba-physics'; import {WayPoint} from '../shared/models'; import {TestDataJsonProvider} from './testData/TestDataJsonProvider'; import {TestDataInjector} from './testData/testDataInjector'; +import {ProfileComparatorService} from '../shared/profileComparatorService'; export class TestData { public readonly wayPointsA: WayPoint[]; @@ -51,7 +52,7 @@ export class TestData { segmentsB.add(15, 15, StandardGases.ean50, Time.oneMinute); segmentsB.add(15, 0, StandardGases.ean50, Time.oneMinute * 2); this.wayPointsB = waypointService.calculateWayPoints(segmentsB.items); - this.testDataInjector.injectProfiles(0, 1); + // this.testDataInjector.injectProfiles(0, 1); } } @@ -62,6 +63,6 @@ export class TestData { }) export class DiffComponent { public testData = new TestData(this.testDataInjector); - constructor(private testDataInjector: TestDataInjector) { + constructor(private testDataInjector: TestDataInjector, public profileComparatorService: ProfileComparatorService) { } } From 798dc11b0b015dd9f3a308fd1157107ab3e82041 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 03:01:57 +0100 Subject: [PATCH 08/39] Extract test data injection into component --- projects/planner/src/app/app.module.ts | 4 +- .../planner/src/app/diff/diff.component.html | 4 +- .../src/app/diff/diff.component.spec.ts | 16 +- .../planner/src/app/diff/diff.component.ts | 11 +- .../app/diff/testData/TestDataJsonProvider.ts | 619 +++++++++--------- .../loadtestdata/loadtestdata.component.html | 1 + .../loadtestdata/loadtestdata.component.scss | 9 + .../loadtestdata.component.spec.ts | 45 ++ .../loadtestdata/loadtestdata.component.ts | 22 + .../src/app/diff/testData/testDataInjector.ts | 10 + 10 files changed, 401 insertions(+), 340 deletions(-) create mode 100644 projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html create mode 100644 projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss create mode 100644 projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.spec.ts create mode 100644 projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.ts diff --git a/projects/planner/src/app/app.module.ts b/projects/planner/src/app/app.module.ts index 01ce1cce..ba037523 100644 --- a/projects/planner/src/app/app.module.ts +++ b/projects/planner/src/app/app.module.ts @@ -91,6 +91,7 @@ import {MaskitoModule} from '@maskito/angular'; import {SurfaceIntervalComponent} from './surface-interval/surface-interval.component'; import {TestDataInjector} from './diff/testData/testDataInjector'; import {ProfileComparatorService} from './shared/profileComparatorService'; +import {LoadTestDataComponent} from './diff/testData/loadtestdata/loadtestdata.component'; const ANGULAR_MODULES = [ AppRoutingModule, @@ -150,7 +151,8 @@ const COMPONENTS = [ WeightCalcComponent, WaypointsDifferenceComponent, DiveInfoDifferenceComponent, - ProfileDifferenceChartComponent + ProfileDifferenceChartComponent, + LoadTestDataComponent ]; const SERVICES = [ diff --git a/projects/planner/src/app/diff/diff.component.html b/projects/planner/src/app/diff/diff.component.html index 69a710d4..f814c3da 100644 --- a/projects/planner/src/app/diff/diff.component.html +++ b/projects/planner/src/app/diff/diff.component.html @@ -1,3 +1,5 @@ +
+
@@ -15,7 +17,7 @@
-
Please make at least 2 profiles
+
Please make at least 2 profiles
diff --git a/projects/planner/src/app/diff/diff.component.spec.ts b/projects/planner/src/app/diff/diff.component.spec.ts index 62b41587..e05de204 100644 --- a/projects/planner/src/app/diff/diff.component.spec.ts +++ b/projects/planner/src/app/diff/diff.component.spec.ts @@ -1,6 +1,10 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; -import { DiffComponent } from './diff.component'; +import {DiffComponent} from './diff.component'; +import {ProfileComparatorService} from '../shared/profileComparatorService'; +import {DiveSchedules} from '../shared/dive.schedules'; +import {UnitConversion} from '../shared/UnitConversion'; +import {ReloadDispatcher} from '../shared/reloadDispatcher'; describe('DiffComponent', () => { let component: DiffComponent; @@ -8,7 +12,13 @@ describe('DiffComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DiffComponent] + declarations: [DiffComponent], + providers: [ + ProfileComparatorService, + DiveSchedules, + UnitConversion, + ReloadDispatcher + ] }); fixture = TestBed.createComponent(DiffComponent); component = fixture.componentInstance; diff --git a/projects/planner/src/app/diff/diff.component.ts b/projects/planner/src/app/diff/diff.component.ts index 50a3d5dd..40b51269 100644 --- a/projects/planner/src/app/diff/diff.component.ts +++ b/projects/planner/src/app/diff/diff.component.ts @@ -3,8 +3,6 @@ import {WayPointsService} from '../shared/waypoints.service'; import {UnitConversion} from '../shared/UnitConversion'; import {Segments, StandardGases, Tank, Time} from 'scuba-physics'; import {WayPoint} from '../shared/models'; -import {TestDataJsonProvider} from './testData/TestDataJsonProvider'; -import {TestDataInjector} from './testData/testDataInjector'; import {ProfileComparatorService} from '../shared/profileComparatorService'; export class TestData { @@ -13,9 +11,7 @@ export class TestData { public readonly wayPointsB: WayPoint[]; public readonly tanksB: Tank[]; - - private testDataProvider = new TestDataJsonProvider(); - constructor(private testDataInjector: TestDataInjector) { + constructor() { const units = new UnitConversion(); const waypointService = new WayPointsService(units); @@ -52,7 +48,6 @@ export class TestData { segmentsB.add(15, 15, StandardGases.ean50, Time.oneMinute); segmentsB.add(15, 0, StandardGases.ean50, Time.oneMinute * 2); this.wayPointsB = waypointService.calculateWayPoints(segmentsB.items); - // this.testDataInjector.injectProfiles(0, 1); } } @@ -62,7 +57,7 @@ export class TestData { styleUrls: ['./diff.component.scss'] }) export class DiffComponent { - public testData = new TestData(this.testDataInjector); - constructor(private testDataInjector: TestDataInjector, public profileComparatorService: ProfileComparatorService) { + public testData = new TestData(); + constructor(public profileComparatorService: ProfileComparatorService) { } } diff --git a/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts index 57e6edb1..2f6ef24b 100644 --- a/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts +++ b/projects/planner/src/app/diff/testData/TestDataJsonProvider.ts @@ -1,6 +1,6 @@ export class TestDataJsonProvider { - private defaultProfileJson = ` - { + private diveProfiles: string[] = [ + `{ "options": { "gfLow": 0.4, "gfHigh": 0.85, @@ -38,9 +38,8 @@ export class TestDataJsonProvider { } ], "plan": [] - }`; - private profileOneJson = ` - { + }`, + `{ "options": { "gfLow": 0.4, "gfHigh": 0.85, @@ -99,60 +98,178 @@ export class TestDataJsonProvider { } } ] - }`; - - private profileTwoJson = ` - { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 24, - "workPressure": 0, - "startPressure": 200, - "gas": { + }`, + `{ + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 24, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "id": 2, + "size": 11, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "id": 3, + "size": 11, + "workPressure": 0, + "startPressure": 150, + "gas": { + "fO2": 1, + "fHe": 0 + } + } + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 40, + "duration": 120, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 600, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 21, + "duration": 120, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 21, + "endDepth": 21, + "duration": 60, + "tankId": 2, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "startDepth": 21, + "endDepth": 3, + "duration": 180, + "tankId": 2, + "gas": { + "fO2": 0.5, + "fHe": 0 + } + }, + { + "startDepth": 3, + "endDepth": 3, + "duration": 360, + "tankId": 3, + "gas": { + "fO2": 1, + "fHe": 0 + } + }, + { + "startDepth": 3, + "endDepth": 0, + "duration": 60, + "tankId": 3, + "gas": { + "fO2": 1, + "fHe": 0 + } + } + ] + }`, + `{ + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 + }, + "diver": { + "rmv": 20 + }, + "tanks": [ + { + "id": 1, + "size": 24, + "workPressure": 0, + "startPressure": 200, + "gas": { "fO2": 0.209, "fHe": 0 } }, { "id": 2, - "size": 11, + "size": 11.1, "workPressure": 0, "startPressure": 200, - "gas": { - "fO2": 0.5, - "fHe": 0 - } - }, - { - "id": 3, - "size": 11, - "workPressure": 0, - "startPressure": 150, "gas": { "fO2": 1, "fHe": 0 @@ -163,7 +280,7 @@ export class TestDataJsonProvider { { "startDepth": 0, "endDepth": 40, - "duration": 120, + "duration": 180, "tankId": 1, "gas": { "fO2": 0.209, @@ -173,156 +290,16 @@ export class TestDataJsonProvider { { "startDepth": 40, "endDepth": 40, - "duration": 600, + "duration": 1020, "tankId": 1, "gas": { "fO2": 0.209, "fHe": 0 } - }, - { - "startDepth": 40, - "endDepth": 21, - "duration": 120, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 21, - "endDepth": 21, - "duration": 60, - "tankId": 2, - "gas": { - "fO2": 0.5, - "fHe": 0 - } - }, - { - "startDepth": 21, - "endDepth": 3, - "duration": 180, - "tankId": 2, - "gas": { - "fO2": 0.5, - "fHe": 0 - } - }, - { - "startDepth": 3, - "endDepth": 3, - "duration": 360, - "tankId": 3, - "gas": { - "fO2": 1, - "fHe": 0 - } - }, - { - "startDepth": 3, - "endDepth": 0, - "duration": 60, - "tankId": 3, - "gas": { - "fO2": 1, - "fHe": 0 - } - } - ] - }`; - - private profileThreeJson = ` - { - "states": { - "lastScreen": "dashboard", - "states": [ - { - "id": "dashboard" - } - ] - }, - "options": { - "imperialUnits": false, - "isComplex": true, - "language": "en" - }, - "dives": [ - { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 24, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "id": 2, - "size": 11.1, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 1, - "fHe": 0 - } - } - ], - "plan": [ - { - "startDepth": 0, - "endDepth": 40, - "duration": 180, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 40, - "endDepth": 40, - "duration": 1020, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ] } ] - }`; - - private profileFourJson = ` + }`, + ` { "options": { "gfLow": 0.4, @@ -402,122 +379,109 @@ export class TestDataJsonProvider { } } ] - }`; - - private profileFiveJson = ` - { - "states": { - "lastScreen": "dashboard", - "states": [ - { - "id": "dashboard" - } - ] + }`, + `{ + "options": { + "gfLow": 0.4, + "gfHigh": 0.85, + "maxPpO2": 1.4, + "maxDecoPpO2": 1.6, + "salinity": 1, + "altitude": 0, + "roundStopsToMinutes": false, + "gasSwitchDuration": 2, + "safetyStop": 2, + "lastStopDepth": 3, + "decoStopDistance": 3, + "minimumAutoStopDepth": 10, + "maxEND": 30, + "oxygenNarcotic": true, + "ascentSpeed6m": 3, + "ascentSpeed50percTo6m": 6, + "ascentSpeed50perc": 9, + "descentSpeed": 18, + "problemSolvingDuration": 1 }, + "diver": { + "rmv": 20 + }, + "tanks": [ { - "options": { - "gfLow": 0.4, - "gfHigh": 0.85, - "maxPpO2": 1.4, - "maxDecoPpO2": 1.6, - "salinity": 1, - "altitude": 0, - "roundStopsToMinutes": false, - "gasSwitchDuration": 2, - "safetyStop": 2, - "lastStopDepth": 3, - "decoStopDistance": 3, - "minimumAutoStopDepth": 10, - "maxEND": 30, - "oxygenNarcotic": true, - "ascentSpeed6m": 3, - "ascentSpeed50percTo6m": 6, - "ascentSpeed50perc": 9, - "descentSpeed": 18, - "problemSolvingDuration": 1 - }, - "diver": { - "rmv": 20 - }, - "tanks": [ - { - "id": 1, - "size": 15, - "workPressure": 0, - "startPressure": 200, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ], - "plan": [ - { - "startDepth": 0, - "endDepth": 40, - "duration": 180, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 40, - "endDepth": 40, - "duration": 300, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 40, - "endDepth": 30, - "duration": 300, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 30, - "endDepth": 30, - "duration": 300, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 30, - "endDepth": 40, - "duration": 300, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - }, - { - "startDepth": 40, - "endDepth": 40, - "duration": 300, - "tankId": 1, - "gas": { - "fO2": 0.209, - "fHe": 0 - } - } - ] + "id": 1, + "size": 15, + "workPressure": 0, + "startPressure": 200, + "gas": { + "fO2": 0.209, + "fHe": 0 + } } -`; - - public get(profileAIndex: number, profileBIndex: number): string { - const preferencesPrefix = ` + ], + "plan": [ + { + "startDepth": 0, + "endDepth": 40, + "duration": 180, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 30, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 30, + "endDepth": 30, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 30, + "endDepth": 40, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + }, + { + "startDepth": 40, + "endDepth": 40, + "duration": 300, + "tankId": 1, + "gas": { + "fO2": 0.209, + "fHe": 0 + } + } + ] + }` + ]; + private preferencesPrefix = ` { "options": { "imperialUnits": false, @@ -525,29 +489,30 @@ export class TestDataJsonProvider { "language": "en" }, "dives": [`; - const preferencesSuffix = ` + private preferencesSuffix = ` ] } `; - return preferencesPrefix + this.getDive(profileAIndex) + ',' + this.getDive(profileBIndex) + preferencesSuffix; + public get(profileAIndex: number, profileBIndex: number): string { + + return this.preferencesPrefix + + this.diveProfiles[profileAIndex] + + ',' + this.diveProfiles[profileBIndex] + + this.preferencesSuffix; } - private getDive(num: number): string { - switch (num) { - case 0: - return this.defaultProfileJson; - case 1: - return this.profileOneJson; - case 2: - return this.profileTwoJson; - case 3: - return this.profileThreeJson; - case 4: - return this.profileFourJson; - case 5: - return this.profileFiveJson; - default: - throw new RangeError('Requested profile index is out of range!'); - } + public getAll(): string{ + return this.preferencesPrefix + + this.diveProfiles[0] + + ',' + this.diveProfiles[1] + + ',' + this.diveProfiles[2] + + ',' + this.diveProfiles[3] + + ',' + this.diveProfiles[4] + + ',' + this.diveProfiles[5] + + this.preferencesSuffix; + } + + public numberOfProfiles(): number { + return this.diveProfiles.length; } } diff --git a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html new file mode 100644 index 00000000..0dc670ba --- /dev/null +++ b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html @@ -0,0 +1 @@ + diff --git a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss new file mode 100644 index 00000000..e701a0bd --- /dev/null +++ b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss @@ -0,0 +1,9 @@ +@import "node_modules/mdb-angular-ui-kit/assets/scss/free/variables"; + +#loadTestData { + position: absolute; + z-index: $fixed-action-button-zindex; + left: 92vw; + top: 2rem; + width: 5vw; +} diff --git a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.spec.ts b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.spec.ts new file mode 100644 index 00000000..b8b778c5 --- /dev/null +++ b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.spec.ts @@ -0,0 +1,45 @@ +import {ComponentFixture, TestBed} from '@angular/core/testing'; + +import {LoadTestDataComponent} from './loadtestdata.component'; +import {ProfileComparatorService} from '../../../shared/profileComparatorService'; +import {TestDataInjector} from '../testDataInjector'; +import {PreferencesStore} from '../../../shared/preferencesStore'; +import {Preferences} from '../../../shared/preferences'; +import {ViewSwitchService} from '../../../shared/viewSwitchService'; +import {DiveSchedules} from '../../../shared/dive.schedules'; +import {UnitConversion} from '../../../shared/UnitConversion'; +import {ReloadDispatcher} from '../../../shared/reloadDispatcher'; +import {ViewStates} from '../../../shared/viewStates'; +import {PlannerService} from '../../../shared/planner.service'; +import {WorkersFactoryCommon} from '../../../shared/serial.workers.factory'; + +describe('LoadTestDataComponent', () => { + let component: LoadTestDataComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [LoadTestDataComponent], + providers: [ + ProfileComparatorService, + TestDataInjector, + PlannerService, + WorkersFactoryCommon, + PreferencesStore, + Preferences, + ViewSwitchService, + ViewStates, + DiveSchedules, + UnitConversion, + ReloadDispatcher + ] + }); + fixture = TestBed.createComponent(LoadTestDataComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.ts b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.ts new file mode 100644 index 00000000..fadeaa6d --- /dev/null +++ b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.ts @@ -0,0 +1,22 @@ +import {Component} from '@angular/core'; +import {TestDataInjector} from '../testDataInjector'; +import {DiveSchedules} from '../../../shared/dive.schedules'; + +@Component({ + selector: 'app-loadtestdata', + templateUrl: './loadtestdata.component.html', + styleUrls: ['./loadtestdata.component.scss'] +}) +export class LoadTestDataComponent { + + constructor(public testDataInjector: TestDataInjector, private schedules: DiveSchedules) { + } + + public loadData(){ + this.testDataInjector.injectAllProfiles(); + } + + public isLoaded() { + return this.schedules.length === this.testDataInjector.testProfilesCount; + } +} diff --git a/projects/planner/src/app/diff/testData/testDataInjector.ts b/projects/planner/src/app/diff/testData/testDataInjector.ts index f85ad8fa..f80477be 100644 --- a/projects/planner/src/app/diff/testData/testDataInjector.ts +++ b/projects/planner/src/app/diff/testData/testDataInjector.ts @@ -6,6 +6,7 @@ import {TestDataJsonProvider} from './TestDataJsonProvider'; @Injectable() export class TestDataInjector { + public testProfilesCount = TestDataJsonProvider.length; private testDataProvider = new TestDataJsonProvider(); constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { } @@ -19,4 +20,13 @@ export class TestDataInjector { this.plannerService.calculate(); this.plannerService.calculate(2); } + + public injectAllProfiles() { + const preferencesJson: string = this.testDataProvider.getAll(); + localStorage.setItem('preferences', preferencesJson); + this.preferencesStore.load(); + for (let i = 1; i <= this.testDataProvider.numberOfProfiles(); i++){ + this.plannerService.calculate(i); + } + } } From 7e05c01252a72d75e272074bb4985b48b5676910 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 21:24:21 +0100 Subject: [PATCH 09/39] Fix LoadTestDataComponent.isLoaded --- .../diff/testData/loadtestdata/loadtestdata.component.html | 6 +++++- projects/planner/src/app/diff/testData/testDataInjector.ts | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html index 0dc670ba..1c00cd2d 100644 --- a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html +++ b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.html @@ -1 +1,5 @@ - +
+ +
diff --git a/projects/planner/src/app/diff/testData/testDataInjector.ts b/projects/planner/src/app/diff/testData/testDataInjector.ts index f80477be..1be48087 100644 --- a/projects/planner/src/app/diff/testData/testDataInjector.ts +++ b/projects/planner/src/app/diff/testData/testDataInjector.ts @@ -6,11 +6,15 @@ import {TestDataJsonProvider} from './TestDataJsonProvider'; @Injectable() export class TestDataInjector { - public testProfilesCount = TestDataJsonProvider.length; private testDataProvider = new TestDataJsonProvider(); + private _testProfilesCount = this.testDataProvider.numberOfProfiles(); constructor(private preferencesStore: PreferencesStore, private plannerService: PlannerService) { } + get testProfilesCount(): number { + return this._testProfilesCount; + } + // !! ONLY FOR TESTING PURPOSES !! // Rewrites user defined dive profiles and replaces with 2 pre-defined testing profiles public injectProfiles(profileAIndex: number, profileBIndex: number){ From ec6fd467017ad7a2fd777d70ddbca799b2d8870b Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 21:26:06 +0100 Subject: [PATCH 10/39] Lower LoadTestDataComponent vertical position --- projects/planner/src/app/diff/diff.component.html | 2 +- .../app/diff/testData/loadtestdata/loadtestdata.component.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/projects/planner/src/app/diff/diff.component.html b/projects/planner/src/app/diff/diff.component.html index f814c3da..ce80e1a8 100644 --- a/projects/planner/src/app/diff/diff.component.html +++ b/projects/planner/src/app/diff/diff.component.html @@ -1,4 +1,4 @@ -
+
diff --git a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss index e701a0bd..c4e5d4ea 100644 --- a/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss +++ b/projects/planner/src/app/diff/testData/loadtestdata/loadtestdata.component.scss @@ -4,6 +4,6 @@ position: absolute; z-index: $fixed-action-button-zindex; left: 92vw; - top: 2rem; + top: 10vh; width: 5vw; } From 96efd494f70b5723e6074e5c0cb11cb1b082ba76 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 22:52:32 +0100 Subject: [PATCH 11/39] Rework WaypointsComparisonTableRowProvider into injectable service --- projects/planner/src/app/app.module.ts | 4 +- .../diff-waypoints.component.spec.ts | 12 +++++- .../waypoints/diff-waypoints.component.ts | 14 ++---- ...der.ts => waypoints-difference.service.ts} | 43 +++++++++++++------ 4 files changed, 47 insertions(+), 26 deletions(-) rename projects/planner/src/app/shared/{waypointsComparisonTableRowProvider.ts => waypoints-difference.service.ts} (60%) diff --git a/projects/planner/src/app/app.module.ts b/projects/planner/src/app/app.module.ts index ba037523..8a913f5d 100644 --- a/projects/planner/src/app/app.module.ts +++ b/projects/planner/src/app/app.module.ts @@ -92,6 +92,7 @@ import {SurfaceIntervalComponent} from './surface-interval/surface-interval.comp import {TestDataInjector} from './diff/testData/testDataInjector'; import {ProfileComparatorService} from './shared/profileComparatorService'; import {LoadTestDataComponent} from './diff/testData/loadtestdata/loadtestdata.component'; +import {WaypointsDifferenceService} from './shared/waypoints-difference.service'; const ANGULAR_MODULES = [ AppRoutingModule, @@ -188,7 +189,8 @@ const SERVICES = [ ViewSwitchService, WayPointsService, TestDataInjector, - ProfileComparatorService + ProfileComparatorService, + WaypointsDifferenceService ]; @NgModule({ diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts index f859b4b0..5c074ee1 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts @@ -1,7 +1,10 @@ import {ComponentFixture, TestBed} from '@angular/core/testing'; import {WaypointsDifferenceComponent} from './diff-waypoints.component'; import {UnitConversion} from '../../shared/UnitConversion'; -import {TestData} from '../diff.component'; +import {WaypointsDifferenceService} from '../../shared/waypoints-difference.service'; +import {ProfileComparatorService} from '../../shared/profileComparatorService'; +import {DiveSchedules} from '../../shared/dive.schedules'; +import {ReloadDispatcher} from '../../shared/reloadDispatcher'; describe('WaypointsDifferenceComponent', () => { let component: WaypointsDifferenceComponent; @@ -10,7 +13,12 @@ describe('WaypointsDifferenceComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ declarations: [WaypointsDifferenceComponent], - providers: [UnitConversion] + providers: [UnitConversion, + WaypointsDifferenceService, + ProfileComparatorService, + DiveSchedules, + ReloadDispatcher + ] }); fixture = TestBed.createComponent(WaypointsDifferenceComponent); component = fixture.componentInstance; diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts index 0997e25a..6e076044 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts @@ -1,24 +1,18 @@ -import {Component, Input, OnInit} from '@angular/core'; +import {Component, Input} from '@angular/core'; import {TestData} from '../diff.component'; import {faTasks} from '@fortawesome/free-solid-svg-icons'; import {UnitConversion} from '../../shared/UnitConversion'; -import {WaypointsComparisonTableRowProvider} from '../../shared/waypointsComparisonTableRowProvider'; +import {WaypointsDifferenceService} from '../../shared/waypoints-difference.service'; @Component({ selector: 'app-diff-waypoints', templateUrl: './diff-waypoints.component.html', styleUrls: ['./diff-waypoints.component.scss'], }) -export class WaypointsDifferenceComponent implements OnInit { +export class WaypointsDifferenceComponent { @Input({ required: true }) data!: TestData; public tasks = faTasks; - public tableRowProvider: WaypointsComparisonTableRowProvider = - new WaypointsComparisonTableRowProvider([], []); - constructor(public units: UnitConversion) { - } - - ngOnInit() { - this.tableRowProvider = new WaypointsComparisonTableRowProvider(this.data.wayPointsA, this.data.wayPointsB); + constructor(public units: UnitConversion, public tableRowProvider: WaypointsDifferenceService) { } } diff --git a/projects/planner/src/app/shared/waypointsComparisonTableRowProvider.ts b/projects/planner/src/app/shared/waypoints-difference.service.ts similarity index 60% rename from projects/planner/src/app/shared/waypointsComparisonTableRowProvider.ts rename to projects/planner/src/app/shared/waypoints-difference.service.ts index e1af3a10..e36e8f66 100644 --- a/projects/planner/src/app/shared/waypointsComparisonTableRowProvider.ts +++ b/projects/planner/src/app/shared/waypoints-difference.service.ts @@ -1,22 +1,39 @@ import {WayPoint} from './models'; import {WaypointsComparisonTableRow} from './WaypointsComparisonTableRow'; +import {Injectable} from '@angular/core'; +import {ProfileComparatorService} from './profileComparatorService'; -// TODO: Rework into injectable service that gets data from services instead of constructor -export class WaypointsComparisonTableRowProvider { +@Injectable() +export class WaypointsDifferenceService { - private wayPointsA: WayPoint[]; - private wayPointsB: WayPoint[]; private _waypointRows: WaypointsComparisonTableRow[] = []; + constructor(private profileComparatorService: ProfileComparatorService) { + } + + private get wayPointsA(): WayPoint[]{ + return this.profileComparatorService.profileAResults().wayPoints; + } + + private get wayPointsB(): WayPoint[]{ + return this.profileComparatorService.profileBResults().wayPoints; + } - constructor(wayPointsA: WayPoint[], wayPointsB: WayPoint[]) { - this.wayPointsA = wayPointsA; - this.wayPointsB = wayPointsB; + public isCalculated(): boolean { + return this.profileComparatorService.isReady(); } public getRows(): WaypointsComparisonTableRow[] { const MAX_SAFETY_LIMIT = 65536; // 2**16 - let waypointA: WayPoint | undefined = this.wayPointsA.pop(); - let waypointB: WayPoint | undefined = this.wayPointsB.pop(); + this._waypointRows = []; + + if(!this.isCalculated){ + return []; + } + + const wayPointsACopy = [...this.wayPointsA]; + const wayPointsBCopy = [...this.wayPointsB]; + let waypointA: WayPoint | undefined = wayPointsACopy.pop(); + let waypointB: WayPoint | undefined = wayPointsBCopy.pop(); for (let i = 0; i < MAX_SAFETY_LIMIT; i++) { let row: WaypointsComparisonTableRow; @@ -32,7 +49,7 @@ export class WaypointsComparisonTableRowProvider { durationB: undefined, depthB: undefined, }; - waypointA = this.wayPointsA.pop(); + waypointA = wayPointsACopy.pop(); this._waypointRows.unshift(row); continue; } @@ -45,7 +62,7 @@ export class WaypointsComparisonTableRowProvider { durationB: waypointB?.duration, depthB: waypointB?.endDepth, }; - waypointB = this.wayPointsB.pop(); + waypointB = wayPointsBCopy.pop(); this._waypointRows.unshift(row); continue; } @@ -57,8 +74,8 @@ export class WaypointsComparisonTableRowProvider { durationB: waypointB?.duration, depthB: waypointB?.endDepth, }; - waypointA = this.wayPointsA.pop(); - waypointB = this.wayPointsB.pop(); + waypointA = wayPointsACopy.pop(); + waypointB = wayPointsBCopy.pop(); this._waypointRows.unshift(row); } return this._waypointRows; From 970e0283990e9a7392d77849ba34ab75984b2830 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 23:19:46 +0100 Subject: [PATCH 12/39] Change date formatter to 'duration' --- .../app/diff/waypoints/diff-waypoints.component.html | 6 +++--- .../app/diff/waypoints/diff-waypoints.component.ts | 5 ++++- .../src/app/shared/profileComparatorService.ts | 11 +++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html index 8af30b1e..5eefa2da 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html @@ -24,19 +24,19 @@ - {{ row.runTime * 1000 | date:'mm:ss' }} + {{ row.runTime | duration:profileComparatorService.totalDuration }} {{ row.depthA | number: '1.0-0'}} - {{ row.durationA * 1000 | date: 'mm:ss'}} + {{ row.durationA * 1 | duration:profileComparatorService.totalDuration }} {{ row.depthB | number:'1.0-0' }} - {{ row.durationB * 1000 | date: 'mm:ss'}} + {{ row.durationB * 1 | duration:profileComparatorService.totalDuration }} diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts index 6e076044..b28efd88 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts @@ -3,6 +3,7 @@ import {TestData} from '../diff.component'; import {faTasks} from '@fortawesome/free-solid-svg-icons'; import {UnitConversion} from '../../shared/UnitConversion'; import {WaypointsDifferenceService} from '../../shared/waypoints-difference.service'; +import {ProfileComparatorService} from '../../shared/profileComparatorService'; @Component({ selector: 'app-diff-waypoints', @@ -13,6 +14,8 @@ export class WaypointsDifferenceComponent { @Input({ required: true }) data!: TestData; public tasks = faTasks; - constructor(public units: UnitConversion, public tableRowProvider: WaypointsDifferenceService) { + constructor(public units: UnitConversion, + public tableRowProvider: WaypointsDifferenceService, + public profileComparatorService: ProfileComparatorService) { } } diff --git a/projects/planner/src/app/shared/profileComparatorService.ts b/projects/planner/src/app/shared/profileComparatorService.ts index 77e15552..afc2d985 100644 --- a/projects/planner/src/app/shared/profileComparatorService.ts +++ b/projects/planner/src/app/shared/profileComparatorService.ts @@ -11,6 +11,13 @@ export class ProfileComparatorService { constructor(private schedules: DiveSchedules) { } + get totalDuration(): number { + if(this.profileAResults().totalDuration > this.profileBResults().totalDuration){ + return this.profileAResults().totalDuration; + } + return this.profileBResults().totalDuration; + } + set profileAIndex(value: number) { this._profileAIndex = value; } @@ -30,4 +37,8 @@ export class ProfileComparatorService { public hasTwoProfiles(): boolean { return this.schedules.length > 1; } + + public isReady(): boolean { + return this.profileAResults().calculated && this.profileBResults().calculated; + } } From a0615d87eccdbe78cfad33017b45b839e628ecbb Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 23:23:40 +0100 Subject: [PATCH 13/39] Add Calculating component --- .../app/diff/waypoints/diff-waypoints.component.html | 11 ++++++++--- .../src/app/shared/waypoints-difference.service.ts | 6 +++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html index 5eefa2da..42292765 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html @@ -5,8 +5,11 @@ Dive way points
-
- +
+ + +
@@ -21,7 +24,9 @@ - + - + - + - + - +
Duration [min]
{{ row.runTime | duration:profileComparatorService.totalDuration }} diff --git a/projects/planner/src/app/shared/waypoints-difference.service.ts b/projects/planner/src/app/shared/waypoints-difference.service.ts index e36e8f66..966ca9be 100644 --- a/projects/planner/src/app/shared/waypoints-difference.service.ts +++ b/projects/planner/src/app/shared/waypoints-difference.service.ts @@ -9,6 +9,9 @@ export class WaypointsDifferenceService { private _waypointRows: WaypointsComparisonTableRow[] = []; constructor(private profileComparatorService: ProfileComparatorService) { } + get isCalculated(): boolean { + return this.profileComparatorService.isReady(); + } private get wayPointsA(): WayPoint[]{ return this.profileComparatorService.profileAResults().wayPoints; @@ -18,9 +21,6 @@ export class WaypointsDifferenceService { return this.profileComparatorService.profileBResults().wayPoints; } - public isCalculated(): boolean { - return this.profileComparatorService.isReady(); - } public getRows(): WaypointsComparisonTableRow[] { const MAX_SAFETY_LIMIT = 65536; // 2**16 From 26ec52d9835b0e68aaa0cf3ee2605b82806cdfa9 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 7 Jan 2024 23:44:41 +0100 Subject: [PATCH 14/39] Remove TestData --- .../planner/src/app/diff/diff.component.html | 2 +- .../planner/src/app/diff/diff.component.ts | 51 ------------------- .../diff-waypoints.component.spec.ts | 1 - .../waypoints/diff-waypoints.component.ts | 4 +- 4 files changed, 2 insertions(+), 56 deletions(-) diff --git a/projects/planner/src/app/diff/diff.component.html b/projects/planner/src/app/diff/diff.component.html index ce80e1a8..6daa9140 100644 --- a/projects/planner/src/app/diff/diff.component.html +++ b/projects/planner/src/app/diff/diff.component.html @@ -6,7 +6,7 @@
- +
diff --git a/projects/planner/src/app/diff/diff.component.ts b/projects/planner/src/app/diff/diff.component.ts index 40b51269..df2d4f3d 100644 --- a/projects/planner/src/app/diff/diff.component.ts +++ b/projects/planner/src/app/diff/diff.component.ts @@ -1,63 +1,12 @@ import {Component} from '@angular/core'; -import {WayPointsService} from '../shared/waypoints.service'; -import {UnitConversion} from '../shared/UnitConversion'; -import {Segments, StandardGases, Tank, Time} from 'scuba-physics'; -import {WayPoint} from '../shared/models'; import {ProfileComparatorService} from '../shared/profileComparatorService'; -export class TestData { - public readonly wayPointsA: WayPoint[]; - public readonly tanksA: Tank[]; - - public readonly wayPointsB: WayPoint[]; - public readonly tanksB: Tank[]; - constructor() { - const units = new UnitConversion(); - const waypointService = new WayPointsService(units); - - this.tanksA = [ - new Tank(24, 200, 21), - new Tank(11, 200, 50), - new Tank(11, 150, 100), - ]; - this.tanksA[0].consumed = 120; - this.tanksA[1].consumed = 80; - this.tanksA[2].consumed = 60; - - const segmentsA = new Segments(); - segmentsA.add(0, 40, StandardGases.air, Time.oneMinute * 2); - segmentsA.add(40, 40, StandardGases.air, Time.oneMinute * 10); - segmentsA.add(40, 21, StandardGases.air, Time.oneMinute * 2); - segmentsA.add(21, 21, StandardGases.ean50, Time.oneMinute); - segmentsA.add(21, 3, StandardGases.ean50, Time.oneMinute * 3); - segmentsA.add(3, 3, StandardGases.oxygen, Time.oneMinute * 6); - segmentsA.add(3, 0, StandardGases.oxygen, Time.oneMinute); - this.wayPointsA = waypointService.calculateWayPoints(segmentsA.items); - - this.tanksB = [ - new Tank(24, 200, 21), - new Tank(11, 200, 50) - ]; - this.tanksB[0].consumed = 90; - this.tanksB[1].consumed = 40; - - const segmentsB = new Segments(); - segmentsB.add(0, 30, StandardGases.air, Time.oneMinute * 4); - segmentsB.add(30, 30, StandardGases.air, Time.oneMinute * 10); - segmentsB.add(30, 15, StandardGases.air, Time.oneMinute * 3); - segmentsB.add(15, 15, StandardGases.ean50, Time.oneMinute); - segmentsB.add(15, 0, StandardGases.ean50, Time.oneMinute * 2); - this.wayPointsB = waypointService.calculateWayPoints(segmentsB.items); - } -} - @Component({ selector: 'app-diff', templateUrl: './diff.component.html', styleUrls: ['./diff.component.scss'] }) export class DiffComponent { - public testData = new TestData(); constructor(public profileComparatorService: ProfileComparatorService) { } } diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts index 5c074ee1..a54be04a 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts @@ -22,7 +22,6 @@ describe('WaypointsDifferenceComponent', () => { }); fixture = TestBed.createComponent(WaypointsDifferenceComponent); component = fixture.componentInstance; - component.data = new TestData(); fixture.detectChanges(); }); diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts index b28efd88..5c095465 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts @@ -1,5 +1,4 @@ -import {Component, Input} from '@angular/core'; -import {TestData} from '../diff.component'; +import {Component} from '@angular/core'; import {faTasks} from '@fortawesome/free-solid-svg-icons'; import {UnitConversion} from '../../shared/UnitConversion'; import {WaypointsDifferenceService} from '../../shared/waypoints-difference.service'; @@ -11,7 +10,6 @@ import {ProfileComparatorService} from '../../shared/profileComparatorService'; styleUrls: ['./diff-waypoints.component.scss'], }) export class WaypointsDifferenceComponent { - @Input({ required: true }) data!: TestData; public tasks = faTasks; constructor(public units: UnitConversion, From 734c91a3e39ae72b4dd5fbcb844d9bce9899a7cc Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sat, 27 Jan 2024 17:00:47 +0100 Subject: [PATCH 15/39] Fix for changed PlannerService.calculate signature --- projects/planner/src/app/diff/testData/testDataInjector.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/planner/src/app/diff/testData/testDataInjector.ts b/projects/planner/src/app/diff/testData/testDataInjector.ts index 1be48087..ba1a0b81 100644 --- a/projects/planner/src/app/diff/testData/testDataInjector.ts +++ b/projects/planner/src/app/diff/testData/testDataInjector.ts @@ -21,7 +21,7 @@ export class TestDataInjector { const preferencesJson: string = this.testDataProvider.get(profileAIndex, profileBIndex); localStorage.setItem('preferences', preferencesJson); this.preferencesStore.load(); - this.plannerService.calculate(); + this.plannerService.calculate(1); this.plannerService.calculate(2); } From 759b46b2b18cb13dc69dec283bd88c692e6a3850 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sat, 27 Jan 2024 17:09:43 +0100 Subject: [PATCH 16/39] Add placeholder component for Dive Info - Results --- projects/planner/src/app/app.module.ts | 4 +++- .../diff-diveinfo-results.component.html | 1 + .../diff-diveinfo-results.component.scss | 0 .../diff-diveinfo-results.component.spec.ts | 21 +++++++++++++++++++ .../diff-diveinfo-results.component.ts | 10 +++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html create mode 100644 projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss create mode 100644 projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts create mode 100644 projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts diff --git a/projects/planner/src/app/app.module.ts b/projects/planner/src/app/app.module.ts index 8a913f5d..2c83f443 100644 --- a/projects/planner/src/app/app.module.ts +++ b/projects/planner/src/app/app.module.ts @@ -93,6 +93,7 @@ import {TestDataInjector} from './diff/testData/testDataInjector'; import {ProfileComparatorService} from './shared/profileComparatorService'; import {LoadTestDataComponent} from './diff/testData/loadtestdata/loadtestdata.component'; import {WaypointsDifferenceService} from './shared/waypoints-difference.service'; +import {DiveInfoResultsDifferenceComponent} from './diff/diveinfo/results/diff-diveinfo-results.component'; const ANGULAR_MODULES = [ AppRoutingModule, @@ -153,7 +154,8 @@ const COMPONENTS = [ WaypointsDifferenceComponent, DiveInfoDifferenceComponent, ProfileDifferenceChartComponent, - LoadTestDataComponent + LoadTestDataComponent, + DiveInfoResultsDifferenceComponent ]; const SERVICES = [ diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html new file mode 100644 index 00000000..e10fdb3b --- /dev/null +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss new file mode 100644 index 00000000..e69de29b diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts new file mode 100644 index 00000000..8197b5f6 --- /dev/null +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts @@ -0,0 +1,21 @@ +import {ComponentFixture, TestBed} from '@angular/core/testing'; + +import {DiveInfoResultsDifferenceComponent} from './diff-diveinfo-results.component'; + +describe('DiveInfoResultsDifferenceComponent', () => { + let component: DiveInfoResultsDifferenceComponent; + let fixture: ComponentFixture; + + beforeEach(() => { + TestBed.configureTestingModule({ + declarations: [DiveInfoResultsDifferenceComponent] + }); + fixture = TestBed.createComponent(DiveInfoResultsDifferenceComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts new file mode 100644 index 00000000..bd8c8948 --- /dev/null +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -0,0 +1,10 @@ +import {Component} from '@angular/core'; + +@Component({ + selector: 'app-diff-diveinfo-results', + templateUrl: './diff-diveinfo-results.component.html', + styleUrls: ['./diff-diveinfo-results.component.scss'] +}) +export class DiveInfoResultsDifferenceComponent { + +} From b4def78f805e59e556a27704a11a3f7f94318c57 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sat, 27 Jan 2024 17:40:17 +0100 Subject: [PATCH 17/39] Add code from original diveinfo component --- .../diveinfo/diff-diveinfo.component.html | 103 +++++++++++++++++- .../diveinfo/diff-diveinfo.component.spec.ts | 18 ++- .../diff/diveinfo/diff-diveinfo.component.ts | 53 ++++++++- 3 files changed, 169 insertions(+), 5 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html index e10fdb3b..c3eb27d0 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html @@ -1 +1,102 @@ - \ No newline at end of file +
+
+
+ + Dive info +
+
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total dive time [min]: + {{ dive.totalDuration | duration:dive.totalDuration + }} +
Time to surface [min]: + {{ dive.timeToSurface | number:'1.0-0' }} +
Average depth [{{units.length}}]: + {{ averageDepth | number:'1.0-1' }} +
Rock bottom at [min]: + {{ dive.emergencyAscentStart | + duration:dive.emergencyAscentStart }} +
No decompression time [min]: + + {{ noDeco | number:'1.0-0' }} +
Maximum bottom time [min]: + + {{ dive.maxTime | number:'1.0-0' }} +
+ Highest gas density [{{units.density}}]:
+ ({{densityText}}) +
+ {{ highestDensity | number:'1.0-2' }} +
Turn time [min]: + {{ dive.turnTime | number:'1.0-0' }} +
Turn pressure [{{units.pressure}}]: + {{ dive.turnPressure | number:'1.0-0' }} +
OTU toxicity [OTU]: + {{ dive.otu | number:'1.0-0' }} +
CNS toxicity [%]: + {{cnsText}} +
+
+ +
+ + + Consumed ! + + + +
+
+
diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts index 103b1275..c1256780 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts @@ -1,6 +1,11 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import {ComponentFixture, TestBed} from '@angular/core/testing'; -import { DiveInfoDifferenceComponent } from './diff-diveinfo.component'; +import {DiveInfoDifferenceComponent} from './diff-diveinfo.component'; +import {ViewSwitchService} from '../../shared/viewSwitchService'; +import {UnitConversion} from '../../shared/UnitConversion'; +import {ProfileComparatorService} from '../../shared/profileComparatorService'; +import {DiveSchedules} from '../../shared/dive.schedules'; +import {ReloadDispatcher} from '../../shared/reloadDispatcher'; describe('DiveInfoDifferenceComponent', () => { let component: DiveInfoDifferenceComponent; @@ -8,7 +13,14 @@ describe('DiveInfoDifferenceComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DiveInfoDifferenceComponent] + declarations: [DiveInfoDifferenceComponent], + providers: [ + ViewSwitchService, + DiveSchedules, + ReloadDispatcher, + UnitConversion, + ProfileComparatorService + ] }); fixture = TestBed.createComponent(DiveInfoDifferenceComponent); component = fixture.componentInstance; diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts index 06d7e2f7..d0721cf0 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts @@ -1,4 +1,10 @@ -import { Component } from '@angular/core'; +import {Component} from '@angular/core'; +import {DiveResults} from '../../shared/diveresults'; +import {UnitConversion} from '../../shared/UnitConversion'; +import {ProfileComparatorService} from '../../shared/profileComparatorService'; +import {faSlidersH} from '@fortawesome/free-solid-svg-icons'; +import {ViewSwitchService} from '../../shared/viewSwitchService'; +import {formatNumber} from '@angular/common'; @Component({ selector: 'app-diff-diveinfo', @@ -6,5 +12,50 @@ import { Component } from '@angular/core'; styleUrls: ['./diff-diveinfo.component.scss'] }) export class DiveInfoDifferenceComponent { + public icon = faSlidersH; + + constructor( + private viewSwitch: ViewSwitchService, + public units: UnitConversion, + private profileComparatorService: ProfileComparatorService) { + } + public get dive(): DiveResults { + return this.profileComparatorService.profileAResults(); + } + + public get isComplex(): boolean { + return this.viewSwitch.isComplex; + } + + public get showMaxBottomTime(): boolean { + return this.dive.maxTime > 0; + } + + public get noDeco(): number { + return this.dive.noDecoTime; + } + + public get averageDepth(): number { + return this.units.fromMeters(this.dive.averageDepth); + } + + public get highestDensity(): number { + const density = this.dive.highestDensity.density; + return this.units.fromGramPerLiter(density); + } + + public get densityText(): string { + const gas = this.dive.highestDensity.gas.name; + const depth = this.units.fromMeters(this.dive.highestDensity.depth); + return `${gas} at ${depth} ${this.units.length}`; + } + + public get cnsText(): string { + if(this.dive.cns >= 1000) { + return '> 1000'; + } + + return formatNumber(this.dive.cns, 'en', '1.0-0'); + } } From 04829e0e0a9096527a6082435455bf2192fa6ce1 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sat, 27 Jan 2024 17:56:38 +0100 Subject: [PATCH 18/39] Move table to diff-diveinfo-results component --- .../diveinfo/diff-diveinfo.component.html | 84 +------------------ .../diveinfo/diff-diveinfo.component.spec.ts | 14 +--- .../diff/diveinfo/diff-diveinfo.component.ts | 50 ----------- .../diff-diveinfo-results.component.html | 79 ++++++++++++++++- .../diff-diveinfo-results.component.spec.ts | 14 +++- .../diff-diveinfo-results.component.ts | 48 +++++++++++ 6 files changed, 143 insertions(+), 146 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html index c3eb27d0..cbffccec 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html @@ -10,92 +10,14 @@
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Total dive time [min]: - {{ dive.totalDuration | duration:dive.totalDuration - }} -
Time to surface [min]: - {{ dive.timeToSurface | number:'1.0-0' }} -
Average depth [{{units.length}}]: - {{ averageDepth | number:'1.0-1' }} -
Rock bottom at [min]: - {{ dive.emergencyAscentStart | - duration:dive.emergencyAscentStart }} -
No decompression time [min]: - - {{ noDeco | number:'1.0-0' }} -
Maximum bottom time [min]: - - {{ dive.maxTime | number:'1.0-0' }} -
- Highest gas density [{{units.density}}]:
- ({{densityText}}) -
- {{ highestDensity | number:'1.0-2' }} -
Turn time [min]: - {{ dive.turnTime | number:'1.0-0' }} -
Turn pressure [{{units.pressure}}]: - {{ dive.turnPressure | number:'1.0-0' }} -
OTU toxicity [OTU]: - {{ dive.otu | number:'1.0-0' }} -
CNS toxicity [%]: - {{cnsText}} -
+
-
- Consumed ! + Consumed - +
diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts index c1256780..26ef20cc 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts @@ -1,11 +1,6 @@ import {ComponentFixture, TestBed} from '@angular/core/testing'; import {DiveInfoDifferenceComponent} from './diff-diveinfo.component'; -import {ViewSwitchService} from '../../shared/viewSwitchService'; -import {UnitConversion} from '../../shared/UnitConversion'; -import {ProfileComparatorService} from '../../shared/profileComparatorService'; -import {DiveSchedules} from '../../shared/dive.schedules'; -import {ReloadDispatcher} from '../../shared/reloadDispatcher'; describe('DiveInfoDifferenceComponent', () => { let component: DiveInfoDifferenceComponent; @@ -13,14 +8,7 @@ describe('DiveInfoDifferenceComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DiveInfoDifferenceComponent], - providers: [ - ViewSwitchService, - DiveSchedules, - ReloadDispatcher, - UnitConversion, - ProfileComparatorService - ] + declarations: [DiveInfoDifferenceComponent] }); fixture = TestBed.createComponent(DiveInfoDifferenceComponent); component = fixture.componentInstance; diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts index d0721cf0..675e6092 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts @@ -1,10 +1,5 @@ import {Component} from '@angular/core'; -import {DiveResults} from '../../shared/diveresults'; -import {UnitConversion} from '../../shared/UnitConversion'; -import {ProfileComparatorService} from '../../shared/profileComparatorService'; import {faSlidersH} from '@fortawesome/free-solid-svg-icons'; -import {ViewSwitchService} from '../../shared/viewSwitchService'; -import {formatNumber} from '@angular/common'; @Component({ selector: 'app-diff-diveinfo', @@ -13,49 +8,4 @@ import {formatNumber} from '@angular/common'; }) export class DiveInfoDifferenceComponent { public icon = faSlidersH; - - constructor( - private viewSwitch: ViewSwitchService, - public units: UnitConversion, - private profileComparatorService: ProfileComparatorService) { - } - public get dive(): DiveResults { - return this.profileComparatorService.profileAResults(); - } - - public get isComplex(): boolean { - return this.viewSwitch.isComplex; - } - - public get showMaxBottomTime(): boolean { - return this.dive.maxTime > 0; - } - - public get noDeco(): number { - return this.dive.noDecoTime; - } - - public get averageDepth(): number { - return this.units.fromMeters(this.dive.averageDepth); - } - - public get highestDensity(): number { - const density = this.dive.highestDensity.density; - return this.units.fromGramPerLiter(density); - } - - public get densityText(): string { - const gas = this.dive.highestDensity.gas.name; - const depth = this.units.fromMeters(this.dive.highestDensity.depth); - return `${gas} at ${depth} ${this.units.length}`; - } - - public get cnsText(): string { - if(this.dive.cns >= 1000) { - return '> 1000'; - } - - return formatNumber(this.dive.cns, 'en', '1.0-0'); - } - } diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index e10fdb3b..b2e46beb 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -1 +1,78 @@ - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Total dive time [min]: + {{ dive.totalDuration | duration:dive.totalDuration + }} +
Time to surface [min]: + {{ dive.timeToSurface | number:'1.0-0' }} +
Average depth [{{units.length}}]: + {{ averageDepth | number:'1.0-1' }} +
Rock bottom at [min]: + {{ dive.emergencyAscentStart | + duration:dive.emergencyAscentStart }} +
No decompression time [min]: + + {{ noDeco | number:'1.0-0' }} +
Maximum bottom time [min]: + + {{ dive.maxTime | number:'1.0-0' }} +
+ Highest gas density [{{units.density}}]:
+ ({{densityText}}) +
+ {{ highestDensity | number:'1.0-2' }} +
Turn time [min]: + {{ dive.turnTime | number:'1.0-0' }} +
Turn pressure [{{units.pressure}}]: + {{ dive.turnPressure | number:'1.0-0' }} +
OTU toxicity [OTU]: + {{ dive.otu | number:'1.0-0' }} +
CNS toxicity [%]: + {{cnsText}} +
+ diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts index 8197b5f6..3aadf5b7 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.spec.ts @@ -1,6 +1,11 @@ import {ComponentFixture, TestBed} from '@angular/core/testing'; import {DiveInfoResultsDifferenceComponent} from './diff-diveinfo-results.component'; +import {ViewSwitchService} from '../../../shared/viewSwitchService'; +import {DiveSchedules} from '../../../shared/dive.schedules'; +import {ReloadDispatcher} from '../../../shared/reloadDispatcher'; +import {UnitConversion} from '../../../shared/UnitConversion'; +import {ProfileComparatorService} from '../../../shared/profileComparatorService'; describe('DiveInfoResultsDifferenceComponent', () => { let component: DiveInfoResultsDifferenceComponent; @@ -8,7 +13,14 @@ describe('DiveInfoResultsDifferenceComponent', () => { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [DiveInfoResultsDifferenceComponent] + declarations: [DiveInfoResultsDifferenceComponent], + providers: [ + ViewSwitchService, + DiveSchedules, + ReloadDispatcher, + UnitConversion, + ProfileComparatorService + ] }); fixture = TestBed.createComponent(DiveInfoResultsDifferenceComponent); component = fixture.componentInstance; diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index bd8c8948..0d35f145 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -1,4 +1,9 @@ import {Component} from '@angular/core'; +import {ViewSwitchService} from '../../../shared/viewSwitchService'; +import {UnitConversion} from '../../../shared/UnitConversion'; +import {ProfileComparatorService} from '../../../shared/profileComparatorService'; +import {DiveResults} from '../../../shared/diveresults'; +import {formatNumber} from '@angular/common'; @Component({ selector: 'app-diff-diveinfo-results', @@ -7,4 +12,47 @@ import {Component} from '@angular/core'; }) export class DiveInfoResultsDifferenceComponent { + constructor( + private viewSwitch: ViewSwitchService, + public units: UnitConversion, + private profileComparatorService: ProfileComparatorService) { + } + public get dive(): DiveResults { + return this.profileComparatorService.profileAResults(); + } + + public get isComplex(): boolean { + return this.viewSwitch.isComplex; + } + + public get showMaxBottomTime(): boolean { + return this.dive.maxTime > 0; + } + + public get noDeco(): number { + return this.dive.noDecoTime; + } + + public get averageDepth(): number { + return this.units.fromMeters(this.dive.averageDepth); + } + + public get highestDensity(): number { + const density = this.dive.highestDensity.density; + return this.units.fromGramPerLiter(density); + } + + public get densityText(): string { + const gas = this.dive.highestDensity.gas.name; + const depth = this.units.fromMeters(this.dive.highestDensity.depth); + return `${gas} at ${depth} ${this.units.length}`; + } + + public get cnsText(): string { + if(this.dive.cns >= 1000) { + return '> 1000'; + } + + return formatNumber(this.dive.cns, 'en', '1.0-0'); + } } From 4f2d3448ad448a62aefb076b26f9086359dc0c09 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sat, 27 Jan 2024 18:43:20 +0100 Subject: [PATCH 19/39] Support multiple profiles in DiveInfoResultsDifference --- .../diff-diveinfo-results.component.html | 36 +++++++-------- .../diff-diveinfo-results.component.ts | 46 +++++++++++++------ .../app/shared/profileComparatorService.ts | 8 ++++ 3 files changed, 57 insertions(+), 33 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index b2e46beb..8450258f 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -3,76 +3,76 @@
Total dive time [min]: - {{ dive.totalDuration | duration:dive.totalDuration + {{ profileA.totalDuration | duration:profileA.totalDuration }}
Time to surface [min]: - {{ dive.timeToSurface | number:'1.0-0' }} + {{ profileA.timeToSurface | number:'1.0-0' }}
Average depth [{{units.length}}]: - {{ averageDepth | number:'1.0-1' }} + {{ averageDepth(profileA) | number:'1.0-1' }}
Rock bottom at [min]: - {{ dive.emergencyAscentStart | - duration:dive.emergencyAscentStart }} + {{ profileA.emergencyAscentStart | + duration:profileA.emergencyAscentStart }}
No decompression time [min]: - {{ noDeco | number:'1.0-0' }} + {{ noDeco(profileA) | number:'1.0-0' }}
Maximum bottom time [min]: - {{ dive.maxTime | number:'1.0-0' }} + {{ profileA.maxTime | number:'1.0-0' }}
Highest gas density [{{units.density}}]:
- ({{densityText}}) + ({{densityText(profileA)}})
- {{ highestDensity | number:'1.0-2' }} + {{ highestDensity(profileA) | number:'1.0-2' }}
Turn time [min]: - {{ dive.turnTime | number:'1.0-0' }} + {{ profileA.turnTime | number:'1.0-0' }}
Turn pressure [{{units.pressure}}]: - {{ dive.turnPressure | number:'1.0-0' }} + {{ profileA.turnPressure | number:'1.0-0' }}
OTU toxicity [OTU]: - {{ dive.otu | number:'1.0-0' }} + {{ profileA.otu | number:'1.0-0' }}
CNS toxicity [%]: - {{cnsText}} + {{cnsText(profileA)}}
- + diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index 0d35f145..a6df2144 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -17,42 +17,58 @@ export class DiveInfoResultsDifferenceComponent { public units: UnitConversion, private profileComparatorService: ProfileComparatorService) { } - public get dive(): DiveResults { + public get profileA(): DiveResults { return this.profileComparatorService.profileAResults(); } + public get isReady(): boolean { + return this.profileComparatorService.isReady(); + } + + public get isDiveInfoReady(): boolean { + return this.profileComparatorService.isDiveInfoReady(); + } + + public get isProfileReady(): boolean { + return this.profileComparatorService.isProfileReady(); + } + public get isComplex(): boolean { return this.viewSwitch.isComplex; } - public get showMaxBottomTime(): boolean { - return this.dive.maxTime > 0; + public get needsReturn(): boolean { + return this.profileA.needsReturn; + } + + public showMaxBottomTime(profile: DiveResults): boolean { + return profile.maxTime > 0; } - public get noDeco(): number { - return this.dive.noDecoTime; + public noDeco(profile: DiveResults): number { + return profile.noDecoTime; } - public get averageDepth(): number { - return this.units.fromMeters(this.dive.averageDepth); + public averageDepth(profile: DiveResults): number { + return this.units.fromMeters(profile.averageDepth); } - public get highestDensity(): number { - const density = this.dive.highestDensity.density; + public highestDensity(profile: DiveResults): number { + const density = profile.highestDensity.density; return this.units.fromGramPerLiter(density); } - public get densityText(): string { - const gas = this.dive.highestDensity.gas.name; - const depth = this.units.fromMeters(this.dive.highestDensity.depth); + public densityText(profile: DiveResults): string { + const gas = profile.highestDensity.gas.name; + const depth = this.units.fromMeters(profile.highestDensity.depth); return `${gas} at ${depth} ${this.units.length}`; } - public get cnsText(): string { - if(this.dive.cns >= 1000) { + public cnsText(profile: DiveResults): string { + if(profile.cns >= 1000) { return '> 1000'; } - return formatNumber(this.dive.cns, 'en', '1.0-0'); + return formatNumber(profile.cns, 'en', '1.0-0'); } } diff --git a/projects/planner/src/app/shared/profileComparatorService.ts b/projects/planner/src/app/shared/profileComparatorService.ts index afc2d985..818acec9 100644 --- a/projects/planner/src/app/shared/profileComparatorService.ts +++ b/projects/planner/src/app/shared/profileComparatorService.ts @@ -41,4 +41,12 @@ export class ProfileComparatorService { public isReady(): boolean { return this.profileAResults().calculated && this.profileBResults().calculated; } + + public isDiveInfoReady(): boolean { + return this.profileAResults().diveInfoCalculated && this.profileBResults().diveInfoCalculated; + } + + public isProfileReady(): boolean { + return this.profileAResults().profileCalculated && this.profileBResults().profileCalculated; + } } From bc008f75bca50254f0074e34a59aa11e4f567734 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 4 Feb 2024 21:23:24 +0100 Subject: [PATCH 20/39] Rename methods to better reflect usage --- .../results/diff-diveinfo-results.component.html | 12 ++++++------ .../results/diff-diveinfo-results.component.ts | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index 8450258f..5bccbf0d 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -16,7 +16,7 @@ Average depth [{{units.length}}]: - {{ averageDepth(profileA) | number:'1.0-1' }} + {{ averageDepthOfProfile(profileA) | number:'1.0-1' }} @@ -30,10 +30,10 @@ No decompression time [min]: - {{ noDeco(profileA) | number:'1.0-0' }} + {{ noDecoOfProfile(profileA) | number:'1.0-0' }} - + Maximum bottom time [min]: @@ -43,10 +43,10 @@ Highest gas density [{{units.density}}]:
- ({{densityText(profileA)}}) + ({{densityTextOfProfile(profileA)}}) - {{ highestDensity(profileA) | number:'1.0-2' }} + {{ highestDensityOfProfile(profileA) | number:'1.0-2' }} @@ -70,7 +70,7 @@ CNS toxicity [%]: - {{cnsText(profileA)}} + {{cnsTextOfProfile(profileA)}} diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index a6df2144..32238f7d 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -41,30 +41,30 @@ export class DiveInfoResultsDifferenceComponent { return this.profileA.needsReturn; } - public showMaxBottomTime(profile: DiveResults): boolean { + public showMaxBottomTimeOfProfile(profile: DiveResults): boolean { return profile.maxTime > 0; } - public noDeco(profile: DiveResults): number { + public noDecoOfProfile(profile: DiveResults): number { return profile.noDecoTime; } - public averageDepth(profile: DiveResults): number { + public averageDepthOfProfile(profile: DiveResults): number { return this.units.fromMeters(profile.averageDepth); } - public highestDensity(profile: DiveResults): number { + public highestDensityOfProfile(profile: DiveResults): number { const density = profile.highestDensity.density; return this.units.fromGramPerLiter(density); } - public densityText(profile: DiveResults): string { + public densityTextOfProfile(profile: DiveResults): string { const gas = profile.highestDensity.gas.name; const depth = this.units.fromMeters(profile.highestDensity.depth); return `${gas} at ${depth} ${this.units.length}`; } - public cnsText(profile: DiveResults): string { + public cnsTextOfProfile(profile: DiveResults): string { if(profile.cns >= 1000) { return '> 1000'; } From 894c4021f52b868c14e091b3d5d297854fc617f5 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 4 Feb 2024 21:25:22 +0100 Subject: [PATCH 21/39] Rename methods for clarity of returned result --- .../diff-diveinfo-results.component.html | 28 +++++++++---------- .../diff-diveinfo-results.component.ts | 13 +++++---- .../app/shared/profileComparatorService.ts | 6 ++-- .../shared/waypoints-difference.service.ts | 2 +- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index 5bccbf0d..8711bf4b 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -3,26 +3,26 @@ Total dive time [min]: - {{ profileA.totalDuration | duration:profileA.totalDuration + {{ profileA.totalDuration | duration:profileA.totalDuration }} Time to surface [min]: - {{ profileA.timeToSurface | number:'1.0-0' }} + {{ profileA.timeToSurface | number:'1.0-0' }} Average depth [{{units.length}}]: - {{ averageDepthOfProfile(profileA) | number:'1.0-1' }} + {{ averageDepthOfProfile(profileA) | number:'1.0-1' }} Rock bottom at [min]: - {{ profileA.emergencyAscentStart | + {{ profileA.emergencyAscentStart | duration:profileA.emergencyAscentStart }} @@ -30,14 +30,14 @@ No decompression time [min]: - {{ noDecoOfProfile(profileA) | number:'1.0-0' }} + {{ noDecoOfProfile(profileA) | number:'1.0-0' }} Maximum bottom time [min]: - {{ profileA.maxTime | number:'1.0-0' }} + {{ profileA.maxTime | number:'1.0-0' }} @@ -46,33 +46,33 @@ ({{densityTextOfProfile(profileA)}}) - {{ highestDensityOfProfile(profileA) | number:'1.0-2' }} + {{ highestDensityOfProfile(profileA) | number:'1.0-2' }} Turn time [min]: - {{ profileA.turnTime | number:'1.0-0' }} + {{ profileA.turnTime | number:'1.0-0' }} Turn pressure [{{units.pressure}}]: - {{ profileA.turnPressure | number:'1.0-0' }} + {{ profileA.turnPressure | number:'1.0-0' }} - + OTU toxicity [OTU]: - {{ profileA.otu | number:'1.0-0' }} + {{ profileA.otu | number:'1.0-0' }} - + CNS toxicity [%]: - {{cnsTextOfProfile(profileA)}} + {{cnsTextOfProfile(profileA)}} - + diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index 32238f7d..119bbadf 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -17,20 +17,21 @@ export class DiveInfoResultsDifferenceComponent { public units: UnitConversion, private profileComparatorService: ProfileComparatorService) { } + public get profileA(): DiveResults { return this.profileComparatorService.profileAResults(); } - public get isReady(): boolean { - return this.profileComparatorService.isReady(); + public get areResultsCalculated(): boolean { + return this.profileComparatorService.areResultsCalculated(); } - public get isDiveInfoReady(): boolean { - return this.profileComparatorService.isDiveInfoReady(); + public get areDiveInfosCalculated(): boolean { + return this.profileComparatorService.areDiveInfosCalculated(); } - public get isProfileReady(): boolean { - return this.profileComparatorService.isProfileReady(); + public get areProfilesCalculated(): boolean { + return this.profileComparatorService.areProfilesCalculated(); } public get isComplex(): boolean { diff --git a/projects/planner/src/app/shared/profileComparatorService.ts b/projects/planner/src/app/shared/profileComparatorService.ts index 818acec9..442e6ccb 100644 --- a/projects/planner/src/app/shared/profileComparatorService.ts +++ b/projects/planner/src/app/shared/profileComparatorService.ts @@ -38,15 +38,15 @@ export class ProfileComparatorService { return this.schedules.length > 1; } - public isReady(): boolean { + public areResultsCalculated(): boolean { return this.profileAResults().calculated && this.profileBResults().calculated; } - public isDiveInfoReady(): boolean { + public areDiveInfosCalculated(): boolean { return this.profileAResults().diveInfoCalculated && this.profileBResults().diveInfoCalculated; } - public isProfileReady(): boolean { + public areProfilesCalculated(): boolean { return this.profileAResults().profileCalculated && this.profileBResults().profileCalculated; } } diff --git a/projects/planner/src/app/shared/waypoints-difference.service.ts b/projects/planner/src/app/shared/waypoints-difference.service.ts index 966ca9be..73772c8b 100644 --- a/projects/planner/src/app/shared/waypoints-difference.service.ts +++ b/projects/planner/src/app/shared/waypoints-difference.service.ts @@ -10,7 +10,7 @@ export class WaypointsDifferenceService { constructor(private profileComparatorService: ProfileComparatorService) { } get isCalculated(): boolean { - return this.profileComparatorService.isReady(); + return this.profileComparatorService.areResultsCalculated(); } private get wayPointsA(): WayPoint[]{ From 969388a1fdf4e0c98b69b3916a5bd884e6ca73ab Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 4 Feb 2024 21:36:50 +0100 Subject: [PATCH 22/39] Remove commented code --- .../planner/src/app/diff/diveinfo/diff-diveinfo.component.html | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html index cbffccec..c6241707 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html @@ -17,7 +17,6 @@ Consumed -
From 8f60a4b4633afab512b1340fabf58084a022d25c Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 4 Feb 2024 21:58:56 +0100 Subject: [PATCH 23/39] Add profile B results to table --- .../diff-diveinfo-results.component.html | 53 +++++++++++++++++-- .../diff-diveinfo-results.component.ts | 4 ++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index 8711bf4b..bceddb78 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -6,18 +6,28 @@ {{ profileA.totalDuration | duration:profileA.totalDuration }} + + {{ profileB.totalDuration | duration:profileB.totalDuration + }} + Time to surface [min]: {{ profileA.timeToSurface | number:'1.0-0' }} + + {{ profileB.timeToSurface | number:'1.0-0' }} + Average depth [{{units.length}}]: {{ averageDepthOfProfile(profileA) | number:'1.0-1' }} + + {{ averageDepthOfProfile(profileB) | number:'1.0-1' }} + Rock bottom at [min]: @@ -25,6 +35,10 @@ {{ profileA.emergencyAscentStart | duration:profileA.emergencyAscentStart }} + + {{ profileB.emergencyAscentStart | + duration:profileB.emergencyAscentStart }} + No decompression time [min]: @@ -32,6 +46,9 @@ {{ noDecoOfProfile(profileA) | number:'1.0-0' }} + + {{ noDecoOfProfile(profileB) | number:'1.0-0' }} + Maximum bottom time [min]: @@ -39,20 +56,41 @@ {{ profileA.maxTime | number:'1.0-0' }} + + {{ profileB.maxTime | number:'1.0-0' }} + Highest gas density [{{units.density}}]:
- ({{densityTextOfProfile(profileA)}}) - {{ highestDensityOfProfile(profileA) | number:'1.0-2' }} + + {{ highestDensityOfProfile(profileA) | number:'1.0-2' }} +
+ ({{densityTextOfProfile(profileA)}}) +
+ + + + {{ highestDensityOfProfile(profileB) | number:'1.0-2' }} +
+ ({{densityTextOfProfile(profileB)}}) +
+ Turn time [min]: - {{ profileA.turnTime | number:'1.0-0' }} + + {{ profileA.turnTime | number:'1.0-0' }} + + + + + {{ profileB.turnTime | number:'1.0-0' }} + @@ -60,18 +98,27 @@ {{ profileA.turnPressure | number:'1.0-0' }} + + {{ profileB.turnPressure | number:'1.0-0' }} + OTU toxicity [OTU]: {{ profileA.otu | number:'1.0-0' }} + + {{ profileB.otu | number:'1.0-0' }} + CNS toxicity [%]: {{cnsTextOfProfile(profileA)}} + + {{cnsTextOfProfile(profileB)}} + diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index 119bbadf..e61a343f 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -22,6 +22,10 @@ export class DiveInfoResultsDifferenceComponent { return this.profileComparatorService.profileAResults(); } + public get profileB(): DiveResults { + return this.profileComparatorService.profileBResults(); + } + public get areResultsCalculated(): boolean { return this.profileComparatorService.areResultsCalculated(); } From 8bde1c73778ba728abc5cd1ec032081e857b6a6b Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 4 Feb 2024 22:06:56 +0100 Subject: [PATCH 24/39] Unify formatting --- .../diff-diveinfo-results.component.html | 86 ++++++++++++------- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index bceddb78..a0c4a691 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -3,67 +3,83 @@ Total dive time [min]: - {{ profileA.totalDuration | duration:profileA.totalDuration - }} + + {{ profileA.totalDuration | duration:profileA.totalDuration}} + - {{ profileB.totalDuration | duration:profileB.totalDuration - }} + + {{ profileB.totalDuration | duration:profileB.totalDuration}} + Time to surface [min]: - {{ profileA.timeToSurface | number:'1.0-0' }} + + {{ profileA.timeToSurface | number:'1.0-0' }} + - {{ profileB.timeToSurface | number:'1.0-0' }} + + {{ profileB.timeToSurface | number:'1.0-0' }} + Average depth [{{units.length}}]: - {{ averageDepthOfProfile(profileA) | number:'1.0-1' }} + + {{ averageDepthOfProfile(profileA) | number:'1.0-1' }} + - {{ averageDepthOfProfile(profileB) | number:'1.0-1' }} + + {{ averageDepthOfProfile(profileB) | number:'1.0-1' }} + Rock bottom at [min]: - {{ profileA.emergencyAscentStart | - duration:profileA.emergencyAscentStart }} + + {{ profileA.emergencyAscentStart | duration:profileA.emergencyAscentStart }} + - {{ profileB.emergencyAscentStart | - duration:profileB.emergencyAscentStart }} + + {{ profileB.emergencyAscentStart | duration:profileB.emergencyAscentStart }} + - No decompression time [min]: - + No decompression time [min]: - {{ noDecoOfProfile(profileA) | number:'1.0-0' }} + + {{ noDecoOfProfile(profileA) | number:'1.0-0' }} + - {{ noDecoOfProfile(profileB) | number:'1.0-0' }} + + {{ noDecoOfProfile(profileB) | number:'1.0-0' }} + - Maximum bottom time [min]: - + Maximum bottom time [min]: - {{ profileA.maxTime | number:'1.0-0' }} + + {{ profileA.maxTime | number:'1.0-0' }} + - {{ profileB.maxTime | number:'1.0-0' }} + + {{ profileB.maxTime | number:'1.0-0' }} + - - Highest gas density [{{units.density}}]:
- + Highest gas density [{{units.density}}]: {{ highestDensityOfProfile(profileA) | number:'1.0-2' }} @@ -96,28 +112,40 @@ Turn pressure [{{units.pressure}}]: - {{ profileA.turnPressure | number:'1.0-0' }} + + {{ profileA.turnPressure | number:'1.0-0' }} + - {{ profileB.turnPressure | number:'1.0-0' }} + + {{ profileB.turnPressure | number:'1.0-0' }} + OTU toxicity [OTU]: - {{ profileA.otu | number:'1.0-0' }} + + {{ profileA.otu | number:'1.0-0' }} + - {{ profileB.otu | number:'1.0-0' }} + + {{ profileB.otu | number:'1.0-0' }} + CNS toxicity [%]: - {{cnsTextOfProfile(profileA)}} + + {{cnsTextOfProfile(profileA)}} + - {{cnsTextOfProfile(profileB)}} + + {{cnsTextOfProfile(profileB)}} + From 6a375fc7ef05882434bb939fc2f4e25bfbbc9e92 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 4 Feb 2024 22:38:45 +0100 Subject: [PATCH 25/39] Make Dive Info into Dive Results --- .../diff/diveinfo/diff-diveinfo.component.html | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html index c6241707..073a858e 100644 --- a/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html +++ b/projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html @@ -2,22 +2,14 @@
- Dive info + Dive Results
- - -
- -
-
- - - Consumed - - -
+
+ +
+ From 4e5d2a21d325d4f38150162a3a0c9d09c5463cc5 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Mon, 5 Feb 2024 02:35:36 +0100 Subject: [PATCH 26/39] Resize cards into 2x2 grid --- projects/planner/src/app/diff/diff.component.html | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/planner/src/app/diff/diff.component.html b/projects/planner/src/app/diff/diff.component.html index 6daa9140..600bfa89 100644 --- a/projects/planner/src/app/diff/diff.component.html +++ b/projects/planner/src/app/diff/diff.component.html @@ -2,13 +2,13 @@
-
+
-
+
-
+
From 0e439dd7dcfe12482b27baf63935384599c3ec92 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Mon, 5 Feb 2024 02:37:02 +0100 Subject: [PATCH 27/39] Add deltas to Dive Results table --- .../diff-diveinfo-results.component.html | 59 ++++++++++++++++++- .../diff-diveinfo-results.component.scss | 4 ++ .../diff-diveinfo-results.component.ts | 56 ++++++++++++++++++ 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index a0c4a691..600bdaca 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -12,6 +12,12 @@ {{ profileB.totalDuration | duration:profileB.totalDuration}}
+ + + {{ totalDurationDifference | duration:totalDurationDifference}} + + + Time to surface [min]: @@ -25,6 +31,12 @@ {{ profileB.timeToSurface | number:'1.0-0' }}
+ + + {{ timeToSurfaceDifference | number:'1.0-0' }} + + + Average depth [{{units.length}}]: @@ -38,6 +50,12 @@ {{ averageDepthOfProfile(profileB) | number:'1.0-1' }}
+ + + {{ averageDepthDifference | number:'1.0-1' }} + + + Rock bottom at [min]: @@ -51,6 +69,13 @@ {{ profileB.emergencyAscentStart | duration:profileB.emergencyAscentStart }} + + + + {{ emergencyAscentStartDifference | duration:emergencyAscentStartDifference}} + + + No decompression time [min]: @@ -64,6 +89,12 @@ {{ noDecoOfProfile(profileB) | number:'1.0-0' }} + + + {{ noDecoDifference | number:'1.0-0' }} + + + Maximum bottom time [min]: @@ -77,6 +108,12 @@ {{ profileB.maxTime | number:'1.0-0' }} + + + {{ maxTimeDifference | number:'1.0-0' }} + + + Highest gas density [{{units.density}}]: @@ -94,8 +131,16 @@ ({{densityTextOfProfile(profileB)}}) + + + {{ highestDensityDifference | number:'1.0-2' }} + + + - + + + Turn time [min]: @@ -134,6 +179,12 @@ {{ profileB.otu | number:'1.0-0' }} + + + {{ otuDifference | number:'1.0-0' }} + + + CNS toxicity [%]: @@ -147,6 +198,12 @@ {{cnsTextOfProfile(profileB)}} + + + {{ cnsDifferenceText }} + + + diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss index e69de29b..3c7f830f 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss @@ -0,0 +1,4 @@ +fa-icon { + margin-left: 0.5rem !important; + padding-left: 0.4rem; +} diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index e61a343f..72d7d063 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -4,6 +4,7 @@ import {UnitConversion} from '../../../shared/UnitConversion'; import {ProfileComparatorService} from '../../../shared/profileComparatorService'; import {DiveResults} from '../../../shared/diveresults'; import {formatNumber} from '@angular/common'; +import {faArrowDown, faArrowUp, IconDefinition} from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'app-diff-diveinfo-results', @@ -11,6 +12,8 @@ import {formatNumber} from '@angular/common'; styleUrls: ['./diff-diveinfo-results.component.scss'] }) export class DiveInfoResultsDifferenceComponent { + private arrowUp: IconDefinition = faArrowUp; + private arrowDown: IconDefinition = faArrowDown; constructor( private viewSwitch: ViewSwitchService, @@ -43,9 +46,58 @@ export class DiveInfoResultsDifferenceComponent { } public get needsReturn(): boolean { + // TODO: Add Profile B return this.profileA.needsReturn; } + public get totalDurationDifference(): number { + return this.profileB.totalDuration - this.profileA.totalDuration; + } + + public get timeToSurfaceDifference(): number { + return this.profileB.timeToSurface - this.profileA.timeToSurface; + } + + public get averageDepthDifference(): number { + return this.averageDepthOfProfile(this.profileB) - this.averageDepthOfProfile(this.profileA); + } + + public get emergencyAscentStartDifference(): number { + return this.profileB.emergencyAscentStart - this.profileA.emergencyAscentStart; + } + + public get noDecoDifference(): number { + return this.noDecoOfProfile(this.profileB) - this.noDecoOfProfile(this.profileA); + } + + public get maxTimeDifference(): number { + return this.profileB.maxTime - this.profileA.maxTime; + } + + public get highestDensityDifference(): number { + return this.highestDensityOfProfile(this.profileB) - this.highestDensityOfProfile(this.profileA); + } + + public get otuDifference(): number { + return this.profileB.otu - this.profileA.otu; + } + + public get cnsDifference(): number { + return this.profileB.cns - this.profileA.cns; + } + public get cnsDifferenceText(): string { + const diff = this.cnsDifference; + if(diff >= 1000) { + return '> 1000'; + } + + if(diff <= -1000) { + return '< -1000'; + } + + return formatNumber(diff, 'en', '1.0-0'); + } + public showMaxBottomTimeOfProfile(profile: DiveResults): boolean { return profile.maxTime > 0; } @@ -76,4 +128,8 @@ export class DiveInfoResultsDifferenceComponent { return formatNumber(profile.cns, 'en', '1.0-0'); } + + public getArrow(difference: number): IconDefinition { + return difference > 0 ? this.arrowUp : this.arrowDown; + } } From 1e764b8ccf6f46235b6fed7dd53378f28dbd7442 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Fri, 9 Feb 2024 02:55:11 +0100 Subject: [PATCH 28/39] Add dynamic background coloring to delta column --- .../diff-diveinfo-results.component.html | 197 ++++++++++-------- .../diff-diveinfo-results.component.ts | 29 +++ 2 files changed, 136 insertions(+), 90 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index 600bdaca..e0286bbc 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -2,207 +2,224 @@ Total dive time [min]: - + {{ profileA.totalDuration | duration:profileA.totalDuration}} - + {{ profileB.totalDuration | duration:profileB.totalDuration}} - - - {{ totalDurationDifference | duration:totalDurationDifference}} - - + +
+ + {{ totalDurationDifference | duration:totalDurationDifference}} + + +
Time to surface [min]: - + {{ profileA.timeToSurface | number:'1.0-0' }} - + {{ profileB.timeToSurface | number:'1.0-0' }} - - - {{ timeToSurfaceDifference | number:'1.0-0' }} - - + +
+ + {{ timeToSurfaceDifference | number:'1.0-0' }} + + +
Average depth [{{units.length}}]: - + {{ averageDepthOfProfile(profileA) | number:'1.0-1' }} - + {{ averageDepthOfProfile(profileB) | number:'1.0-1' }} - - - {{ averageDepthDifference | number:'1.0-1' }} - - + +
+ + {{ averageDepthDifference | number:'1.0-1' }} + + +
Rock bottom at [min]: - + {{ profileA.emergencyAscentStart | duration:profileA.emergencyAscentStart }} - + {{ profileB.emergencyAscentStart | duration:profileB.emergencyAscentStart }} - - + +
+ {{ emergencyAscentStartDifference | duration:emergencyAscentStartDifference}} - - + + +
No decompression time [min]: - + {{ noDecoOfProfile(profileA) | number:'1.0-0' }} - + {{ noDecoOfProfile(profileB) | number:'1.0-0' }} - - - {{ noDecoDifference | number:'1.0-0' }} - - + +
+ + {{ noDecoDifference | number:'1.0-0' }} + + +
Maximum bottom time [min]: - + {{ profileA.maxTime | number:'1.0-0' }} - + {{ profileB.maxTime | number:'1.0-0' }} - - - {{ maxTimeDifference | number:'1.0-0' }} - - + +
+ + {{ maxTimeDifference | number:'1.0-0' }} + + +
Highest gas density [{{units.density}}]: - + {{ highestDensityOfProfile(profileA) | number:'1.0-2' }}
({{densityTextOfProfile(profileA)}})
- + {{ highestDensityOfProfile(profileB) | number:'1.0-2' }}
({{densityTextOfProfile(profileB)}})
- - - {{ highestDensityDifference | number:'1.0-2' }} - - + +
+ + {{ highestDensityDifference | number:'1.0-2' }} + + +
- - + - - Turn time [min]: - - - {{ profileA.turnTime | number:'1.0-0' }} - - - - - {{ profileB.turnTime | number:'1.0-0' }} - - - - - Turn pressure [{{units.pressure}}]: - - - {{ profileA.turnPressure | number:'1.0-0' }} - - - - - {{ profileB.turnPressure | number:'1.0-0' }} - - - + + + + + + + + + + + + + + + + + + + + + + + + + + OTU toxicity [OTU]: - + {{ profileA.otu | number:'1.0-0' }} - + {{ profileB.otu | number:'1.0-0' }} - - - {{ otuDifference | number:'1.0-0' }} - - + +
+ + {{ otuDifference | number:'1.0-0' }} + + +
CNS toxicity [%]: - + {{cnsTextOfProfile(profileA)}} - + {{cnsTextOfProfile(profileB)}} - - - {{ cnsDifferenceText }} - - + +
+ + {{ cnsDifferenceText }} + + +
diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index 72d7d063..62949e19 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -14,6 +14,17 @@ import {faArrowDown, faArrowUp, IconDefinition} from '@fortawesome/free-solid-sv export class DiveInfoResultsDifferenceComponent { private arrowUp: IconDefinition = faArrowUp; private arrowDown: IconDefinition = faArrowDown; + private rowColorVectorMap: Map = new Map([ + ['totalDuration', 1], + ['timeToSurface', -1], + ['averageDepth', -1], + ['emergencyAscentStart', -1], + ['noDeco', 1], + ['maxTime', 1], + ['highestDensity', -1], + ['otu', -1], + ['cns', -1] + ]); constructor( private viewSwitch: ViewSwitchService, @@ -132,4 +143,22 @@ export class DiveInfoResultsDifferenceComponent { public getArrow(difference: number): IconDefinition { return difference > 0 ? this.arrowUp : this.arrowDown; } + + public getBgColor(rowKey: string, value: number): string { + if(!this.rowColorVectorMap.has(rowKey)){ + console.error('Could not find vector for key: ' + rowKey); + } + + const isPositive = (this.rowColorVectorMap.get(rowKey) ?? 0) * value > 0; + + if (isPositive){ + return 'table-success'; + } + + if (!isPositive){ + return 'table-danger'; + } + + return 'table-active'; + } } From 4d3a3016e629e229a6d49ddba17e48ec42a02b83 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Fri, 9 Feb 2024 03:40:34 +0100 Subject: [PATCH 29/39] Add header and CSS style --- .../diff-diveinfo-results.component.html | 81 ++++++++++--------- .../diff-diveinfo-results.component.scss | 32 ++++++++ 2 files changed, 77 insertions(+), 36 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index e0286bbc..e5caffd0 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -1,16 +1,25 @@ + + + + + + - @@ -21,9 +21,9 @@ {{ profileB.totalDuration | duration:profileB.totalDuration}} - - - - - - - - - - diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index 62949e19..6cba11a7 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -4,7 +4,7 @@ import {UnitConversion} from '../../../shared/UnitConversion'; import {ProfileComparatorService} from '../../../shared/profileComparatorService'; import {DiveResults} from '../../../shared/diveresults'; import {formatNumber} from '@angular/common'; -import {faArrowDown, faArrowUp, IconDefinition} from '@fortawesome/free-solid-svg-icons'; +import {faArrowDown, faArrowUp, faMinus, IconDefinition} from '@fortawesome/free-solid-svg-icons'; @Component({ selector: 'app-diff-diveinfo-results', @@ -14,6 +14,7 @@ import {faArrowDown, faArrowUp, IconDefinition} from '@fortawesome/free-solid-sv export class DiveInfoResultsDifferenceComponent { private arrowUp: IconDefinition = faArrowUp; private arrowDown: IconDefinition = faArrowDown; + private dash: IconDefinition = faMinus; private rowColorVectorMap: Map = new Map([ ['totalDuration', 1], ['timeToSurface', -1], @@ -141,7 +142,16 @@ export class DiveInfoResultsDifferenceComponent { } public getArrow(difference: number): IconDefinition { - return difference > 0 ? this.arrowUp : this.arrowDown; + if(difference > 0) { + return this.arrowUp; + } + + if (difference < 0) { + return this.arrowDown; + } + + + return this.dash; } public getBgColor(rowKey: string, value: number): string { @@ -149,13 +159,13 @@ export class DiveInfoResultsDifferenceComponent { console.error('Could not find vector for key: ' + rowKey); } - const isPositive = (this.rowColorVectorMap.get(rowKey) ?? 0) * value > 0; + const projectedValue = (this.rowColorVectorMap.get(rowKey) ?? 0) * value; - if (isPositive){ + if (projectedValue > 0){ return 'table-success'; } - if (!isPositive){ + if (projectedValue < 0){ return 'table-danger'; } From 5bbb534dcb07c0437a85bb2328756bf5d18cf7dc Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Fri, 9 Feb 2024 23:19:23 +0100 Subject: [PATCH 34/39] Fix waypoints table styling --- .../app/diff/waypoints/diff-waypoints.component.html | 10 +++++----- .../app/diff/waypoints/diff-waypoints.component.scss | 5 +++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html index 42292765..2fbc8158 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.html @@ -1,11 +1,11 @@ -
+
Dive way points
-
+
@@ -17,9 +17,9 @@
- - - + + + diff --git a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.scss b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.scss index e1e07e89..5734b207 100644 --- a/projects/planner/src/app/diff/waypoints/diff-waypoints.component.scss +++ b/projects/planner/src/app/diff/waypoints/diff-waypoints.component.scss @@ -1,4 +1,9 @@ @import "node_modules/mdb-angular-ui-kit/assets/scss/free/variables"; +#body { + margin: 24px; + flex: 1 1 auto; + +} #waypointsDiffTable { .vertical-right-border { border-right-width: medium; From c23c6fa80f3fa8bd18a94ed0ab3969a8ba62faf6 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 11 Feb 2024 22:33:41 +0100 Subject: [PATCH 35/39] Replace console.error with Logger --- .../diff/diveinfo/results/diff-diveinfo-results.component.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index 6cba11a7..be4bee3d 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -5,6 +5,7 @@ import {ProfileComparatorService} from '../../../shared/profileComparatorService import {DiveResults} from '../../../shared/diveresults'; import {formatNumber} from '@angular/common'; import {faArrowDown, faArrowUp, faMinus, IconDefinition} from '@fortawesome/free-solid-svg-icons'; +import {Logger} from '../../../shared/Logger'; @Component({ selector: 'app-diff-diveinfo-results', @@ -156,7 +157,7 @@ export class DiveInfoResultsDifferenceComponent { public getBgColor(rowKey: string, value: number): string { if(!this.rowColorVectorMap.has(rowKey)){ - console.error('Could not find vector for key: ' + rowKey); + Logger.warn('Could not find vector for key: ' + rowKey); } const projectedValue = (this.rowColorVectorMap.get(rowKey) ?? 0) * value; From c5458d80aaeaf88de3058f695ba2110f72eb14db Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 11 Feb 2024 22:57:45 +0100 Subject: [PATCH 36/39] Introduce constants instead of hidden strings --- .../diff-diveinfo-results.component.ts | 19 +++++++++++++------ .../src/app/diveinfo/diveinfo.component.ts | 3 ++- .../planner/src/app/shared/TextConstants.ts | 1 + 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts index be4bee3d..05827173 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.ts @@ -6,6 +6,7 @@ import {DiveResults} from '../../../shared/diveresults'; import {formatNumber} from '@angular/common'; import {faArrowDown, faArrowUp, faMinus, IconDefinition} from '@fortawesome/free-solid-svg-icons'; import {Logger} from '../../../shared/Logger'; +import {TextConstants} from '../../../shared/TextConstants'; @Component({ selector: 'app-diff-diveinfo-results', @@ -13,6 +14,8 @@ import {Logger} from '../../../shared/Logger'; styleUrls: ['./diff-diveinfo-results.component.scss'] }) export class DiveInfoResultsDifferenceComponent { + private readonly cnsDifferenceUnderMinusOneThousand = '< -1000'; + private arrowUp: IconDefinition = faArrowUp; private arrowDown: IconDefinition = faArrowDown; private dash: IconDefinition = faMinus; @@ -101,11 +104,11 @@ export class DiveInfoResultsDifferenceComponent { public get cnsDifferenceText(): string { const diff = this.cnsDifference; if(diff >= 1000) { - return '> 1000'; + return TextConstants.cnsOverOneThousand; } if(diff <= -1000) { - return '< -1000'; + return this.cnsDifferenceUnderMinusOneThousand; } return formatNumber(diff, 'en', '1.0-0'); @@ -136,7 +139,7 @@ export class DiveInfoResultsDifferenceComponent { public cnsTextOfProfile(profile: DiveResults): string { if(profile.cns >= 1000) { - return '> 1000'; + return TextConstants.cnsOverOneThousand; } return formatNumber(profile.cns, 'en', '1.0-0'); @@ -156,6 +159,10 @@ export class DiveInfoResultsDifferenceComponent { } public getBgColor(rowKey: string, value: number): string { + const cssClassOnImprovement = 'table-success'; + const cssClassOnDeterioration = 'table-danger'; + const cssClassOnNoChange = 'table-active'; + if(!this.rowColorVectorMap.has(rowKey)){ Logger.warn('Could not find vector for key: ' + rowKey); } @@ -163,13 +170,13 @@ export class DiveInfoResultsDifferenceComponent { const projectedValue = (this.rowColorVectorMap.get(rowKey) ?? 0) * value; if (projectedValue > 0){ - return 'table-success'; + return cssClassOnImprovement; } if (projectedValue < 0){ - return 'table-danger'; + return cssClassOnDeterioration; } - return 'table-active'; + return cssClassOnNoChange; } } diff --git a/projects/planner/src/app/diveinfo/diveinfo.component.ts b/projects/planner/src/app/diveinfo/diveinfo.component.ts index 72044b83..834010a9 100644 --- a/projects/planner/src/app/diveinfo/diveinfo.component.ts +++ b/projects/planner/src/app/diveinfo/diveinfo.component.ts @@ -13,6 +13,7 @@ import { Streamed } from '../shared/streamed'; import { DepthsService } from '../shared/depths.service'; import { ViewSwitchService } from '../shared/viewSwitchService'; import { DiveSchedules } from '../shared/dive.schedules'; +import {TextConstants} from '../shared/TextConstants'; @Component({ selector: 'app-diveinfo', @@ -80,7 +81,7 @@ export class DiveInfoComponent extends Streamed { public get cnsText(): string { if(this.dive.cns >= 1000) { - return '> 1000'; + return TextConstants.cnsOverOneThousand; } return formatNumber(this.dive.cns, 'en', '1.0-0'); diff --git a/projects/planner/src/app/shared/TextConstants.ts b/projects/planner/src/app/shared/TextConstants.ts index 69d9ff90..730bdc9b 100644 --- a/projects/planner/src/app/shared/TextConstants.ts +++ b/projects/planner/src/app/shared/TextConstants.ts @@ -1,4 +1,5 @@ export class TextConstants { public static readonly depthConverterWarning = 'This calculator uses simple depth conversion (where 1 ATM = 1 bar), so the' + 'values shown here are less precise, than in rest of the application.'; + public static readonly cnsOverOneThousand = '> 1000'; } From 120063ac4051d798bcae5d7aea1e91c99f06c289 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 11 Feb 2024 23:00:00 +0100 Subject: [PATCH 37/39] Set default profile as initial indexes for diff --- projects/planner/src/app/shared/profileComparatorService.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/planner/src/app/shared/profileComparatorService.ts b/projects/planner/src/app/shared/profileComparatorService.ts index 442e6ccb..900a94dd 100644 --- a/projects/planner/src/app/shared/profileComparatorService.ts +++ b/projects/planner/src/app/shared/profileComparatorService.ts @@ -6,7 +6,7 @@ import {DiveResults} from './diveresults'; export class ProfileComparatorService { private _profileAIndex = 0; - private _profileBIndex = 1; + private _profileBIndex = 0; constructor(private schedules: DiveSchedules) { } From d91d2aec4275db6b0cd1ea48ca8d2120376e9236 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 11 Feb 2024 23:02:15 +0100 Subject: [PATCH 38/39] Remove requirement of 2+ profiles to initiate diff --- projects/planner/src/app/diff/diff.component.html | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/projects/planner/src/app/diff/diff.component.html b/projects/planner/src/app/diff/diff.component.html index 3b0525b6..16177a4d 100644 --- a/projects/planner/src/app/diff/diff.component.html +++ b/projects/planner/src/app/diff/diff.component.html @@ -1,6 +1,6 @@ -
+
@@ -13,11 +13,3 @@
- - -
-
-
Please make at least 2 profiles
-
-
-
From bbbf2f91de48ba348c49f35e00f6ee45cb2d41e6 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Sun, 11 Feb 2024 23:49:54 +0100 Subject: [PATCH 39/39] Add stretch TODO --- .../diff/diveinfo/results/diff-diveinfo-results.component.html | 1 + 1 file changed, 1 insertion(+) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index 3fb30751..c86aace8 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -9,6 +9,7 @@
+
Profile A
Profile B
+ Difference +
Total dive time [min]: - +
{{ profileA.totalDuration | duration:profileA.totalDuration}} - +
- +
{{ profileB.totalDuration | duration:profileB.totalDuration}} - +
@@ -24,14 +33,14 @@
Time to surface [min]: - +
{{ profileA.timeToSurface | number:'1.0-0' }} - +
- +
{{ profileB.timeToSurface | number:'1.0-0' }} - +
@@ -45,14 +54,14 @@
Average depth [{{units.length}}]: - +
{{ averageDepthOfProfile(profileA) | number:'1.0-1' }} - +
- +
{{ averageDepthOfProfile(profileB) | number:'1.0-1' }} - +
@@ -66,14 +75,14 @@
Rock bottom at [min]: - +
{{ profileA.emergencyAscentStart | duration:profileA.emergencyAscentStart }} - +
- +
{{ profileB.emergencyAscentStart | duration:profileB.emergencyAscentStart }} - +
@@ -88,14 +97,14 @@
No decompression time [min]: - +
{{ noDecoOfProfile(profileA) | number:'1.0-0' }} - +
- +
{{ noDecoOfProfile(profileB) | number:'1.0-0' }} - +
@@ -109,14 +118,14 @@
Maximum bottom time [min]: - +
{{ profileA.maxTime | number:'1.0-0' }} - +
- +
{{ profileB.maxTime | number:'1.0-0' }} - +
@@ -130,18 +139,18 @@
Highest gas density [{{units.density}}]: - +
{{ highestDensityOfProfile(profileA) | number:'1.0-2' }}
({{densityTextOfProfile(profileA)}}) -
+
- +
{{ highestDensityOfProfile(profileB) | number:'1.0-2' }}
({{densityTextOfProfile(profileB)}}) -
+
@@ -183,14 +192,14 @@
OTU toxicity [OTU]: - +
{{ profileA.otu | number:'1.0-0' }} - +
- +
{{ profileB.otu | number:'1.0-0' }} - +
@@ -204,14 +213,14 @@
CNS toxicity [%]: - +
{{cnsTextOfProfile(profileA)}} - +
- +
{{cnsTextOfProfile(profileB)}} - +
diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss index 3c7f830f..e61ba970 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss @@ -1,4 +1,36 @@ +@import "node_modules/mdb-angular-ui-kit/assets/scss/free/variables"; + fa-icon { margin-left: 0.5rem !important; padding-left: 0.4rem; } + +.delta { + max-width: 4.3rem; +} + +#table-header { + color:$black; + td:nth-child(2){ + background-color: $primary; + } + td:nth-child(3){ + background-color: $blue-gray-50; + } +} + +// Second collumn (Profile A) +tr:not(#table-header) { + td:nth-child(n+2){ + border-left-width: medium !important; + } +} + + +//tr { +// td:nth-child(n+2){ +// color:$black +// } +//} +// + From 416e0a0c73717dc4ca89f2eda06aeb7994f84f6e Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Fri, 9 Feb 2024 03:51:42 +0100 Subject: [PATCH 30/39] Load diff column only when data is loaded --- .../diff-diveinfo-results.component.html | 39 ++++++++++--------- 1 file changed, 20 insertions(+), 19 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index e5caffd0..a5c6c429 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -4,7 +4,7 @@
Profile A
Profile B
Difference +
- + {{ totalDurationDifference | duration:totalDurationDifference}} @@ -42,9 +42,9 @@ {{ profileB.timeToSurface | number:'1.0-0' }}
+
- + {{ timeToSurfaceDifference | number:'1.0-0' }} @@ -63,9 +63,9 @@ {{ averageDepthOfProfile(profileB) | number:'1.0-1' }}
+
- + {{ averageDepthDifference | number:'1.0-1' }} @@ -85,9 +85,10 @@
+
- + {{ emergencyAscentStartDifference | duration:emergencyAscentStartDifference}} @@ -106,9 +107,9 @@ {{ noDecoOfProfile(profileB) | number:'1.0-0' }}
+
- + {{ noDecoDifference | number:'1.0-0' }} @@ -127,9 +128,9 @@ {{ profileB.maxTime | number:'1.0-0' }}
+
- + {{ maxTimeDifference | number:'1.0-0' }} @@ -152,9 +153,9 @@ ({{densityTextOfProfile(profileB)}})
+
- + {{ highestDensityDifference | number:'1.0-2' }} @@ -201,9 +202,9 @@ {{ profileB.otu | number:'1.0-0' }}
+
- + {{ otuDifference | number:'1.0-0' }} @@ -222,9 +223,9 @@ {{cnsTextOfProfile(profileB)}}
+
- + {{ cnsDifferenceText }} From dfcccc38c2f2dea108e06813d6c3edd2c6a37499 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Fri, 9 Feb 2024 03:53:54 +0100 Subject: [PATCH 31/39] Remove commented code --- .../results/diff-diveinfo-results.component.scss | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss index e61ba970..accf3a1e 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.scss @@ -19,18 +19,8 @@ fa-icon { } } -// Second collumn (Profile A) tr:not(#table-header) { td:nth-child(n+2){ border-left-width: medium !important; } } - - -//tr { -// td:nth-child(n+2){ -// color:$black -// } -//} -// - From d84dc6c2a7b88e247941d6e73c84cc43fccbe1d5 Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Fri, 9 Feb 2024 12:33:02 +0100 Subject: [PATCH 32/39] Comment out test data injection --- projects/planner/src/app/diff/diff.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/projects/planner/src/app/diff/diff.component.html b/projects/planner/src/app/diff/diff.component.html index 600bfa89..3b0525b6 100644 --- a/projects/planner/src/app/diff/diff.component.html +++ b/projects/planner/src/app/diff/diff.component.html @@ -1,4 +1,4 @@ - +
From b2816219a93af68a8c7739af9da6afb5bca7a0fe Mon Sep 17 00:00:00 2001 From: Denis Lebo Date: Fri, 9 Feb 2024 22:30:17 +0100 Subject: [PATCH 33/39] Fix incorrect coloring if difference is 0 --- .../diff-diveinfo-results.component.html | 3 +-- .../diff-diveinfo-results.component.ts | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html index a5c6c429..3fb30751 100644 --- a/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html +++ b/projects/planner/src/app/diff/diveinfo/results/diff-diveinfo-results.component.html @@ -4,8 +4,7 @@
Profile A
Profile B
+ Difference
Profile B
Run [min]Depth [{{units.length}}]Duration [min]Run [min]Depth [{{units.length}}]Duration [min] Depth [{{units.length}}] Duration [min]
Total dive time [min]: