diff --git a/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.html b/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.html
index 9c7f779b..cfbce94d 100644
--- a/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.html
+++ b/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.html
@@ -135,7 +135,7 @@
-
Maximum bottom time [min]: |
@@ -162,14 +162,14 @@
{{ diff.highestDensity.valueA | number:'1.0-2' }}
- ({{densityTextOfProfile(profileA)}})
+ ({{diff.densityGasA}})
|
{{ diff.highestDensity.valueB | number:'1.0-2' }}
- ({{densityTextOfProfile(profileB)}})
+ ({{diff.densityGasB}})
|
@@ -206,18 +206,18 @@
| CNS toxicity [%]: |
- {{cnsTextOfProfile(profileA)}}
+ {{diff.cnsA}}
|
- {{cnsTextOfProfile(profileB)}}
+ {{diff.cnsB}}
|
- {{ cnsDifferenceText(diff.cns.difference) | number:'1.0-0' }}
+ {{ diff.cnsDifference | number:'1.0-0' }}
diff --git a/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.ts b/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.ts
index ff79e2bb..d2545d27 100644
--- a/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.ts
+++ b/projects/planner/src/app/diff/diveresults/table/diff-diveresults-table.component.ts
@@ -58,80 +58,115 @@ class ResultDiff {
}
}
-@Component({
- selector: 'app-diff-diveresults-table',
- templateUrl: './diff-diveresults-table.component.html',
- styleUrls: ['./diff-diveresults-table.component.scss', '../../diff.component.scss']
-})
-export class DiveResultsTableDifferenceComponent {
- public diff = {
- totalDuration: new ResultDiff(this.profileA, this.profileB, 1, d => d.totalDuration),
- timeToSurface: new ResultDiff(this.profileA, this.profileB, -1, d => d.timeToSurface),
- averageDepth: new ResultDiff(this.profileA, this.profileB, -1, d => d.averageDepth),
- emergencyAscentStart: new ResultDiff(this.profileA, this.profileB, -1, d => d.emergencyAscentStart),
- noDeco: new ResultDiff(this.profileA, this.profileB, 1, d => d.noDecoTime),
- maxTime: new ResultDiff(this.profileA, this.profileB, 1, d => d.maxTime),
- highestDensity: new ResultDiff(this.profileA, this.profileB, -1, d => d.highestDensity.density),
- otu: new ResultDiff(this.profileA, this.profileB, -1, d => d.otu),
- cns: new ResultDiff(this.profileA, this.profileB, -1, d => d.cns),
- };
-
+class DiveResulsDiff {
+ public totalDuration = new ResultDiff(this.profileA, this.profileB, 1,
+ d => d.totalDuration);
+ public timeToSurface = new ResultDiff(this.profileA, this.profileB, -1,
+ d => d.timeToSurface);
+ public averageDepth = new ResultDiff(this.profileA, this.profileB, -1,
+ d => this.units.fromMeters(d.averageDepth));
+ public emergencyAscentStart = new ResultDiff(this.profileA, this.profileB, -1,
+ d => d.emergencyAscentStart);
+ public noDeco = new ResultDiff(this.profileA, this.profileB, 1,
+ d => d.noDecoTime);
+ public maxTime = new ResultDiff(this.profileA, this.profileB, 1,
+ d => d.maxTime);
+ public highestDensity = new ResultDiff(this.profileA, this.profileB, -1,
+ d => this.density(d));
+ public otu = new ResultDiff(this.profileA, this.profileB, -1,
+ d => d.otu);
+ public cns = new ResultDiff(this.profileA, this.profileB, -1,
+ d => d.cns);
+
+ private readonly maxCns = 1000;
private readonly cnsDifferenceUnderMinusOneThousand = '< -1000';
- constructor(
- public viewSwitch: ViewSwitchService,
- public units: UnitConversion,
- public profilesDiff: ProfileComparatorService) {
+ public constructor(private units: UnitConversion, private profileA: DiveResults, private profileB: DiveResults) {
}
- public get profileA(): DiveResults {
- return this.profilesDiff.profileAResults;
+ public get densityGasA(): string {
+ return this.densityFormatted(this.profileA);
}
- public get profileB(): DiveResults {
- return this.profilesDiff.profileBResults;
+ public get densityGasB(): string {
+ return this.densityFormatted(this.profileA);
}
- public get diveInfosCalculated(): boolean {
- return this.profilesDiff.areDiveInfosCalculated();
+ public get cnsA(): string {
+ return this.cnsFormatted(this.profileA);
}
- public get areProfilesCalculated(): boolean {
- return this.profilesDiff.areProfilesCalculated();
+ public get cnsB(): string {
+ return this.cnsFormatted(this.profileA);
}
- public cnsDifferenceText(diff: number): string {
- if(diff >= 1000) {
+ public get cnsDifference(): string {
+ const diff = this.cns.difference;
+
+ if(diff >= this.maxCns) {
return TextConstants.cnsOverOneThousand;
}
- if(diff <= -1000) {
+ if(diff <= -this.maxCns) {
return this.cnsDifferenceUnderMinusOneThousand;
}
return formatNumber(diff, 'en', '1.0-0');
}
- public showMaxBottomTimeOfProfile(profile: DiveResults): boolean {
- return profile.maxTime > 0;
- }
-
- public highestDensityOfProfile(profile: DiveResults): number {
- const density = profile.highestDensity.density;
- return this.units.fromGramPerLiter(density);
+ public get showMaxBottomTime(): boolean {
+ return this.profileA.maxTime > 0 && this.profileB.maxTime > 0;
}
- public densityTextOfProfile(profile: DiveResults): string {
+ private densityFormatted(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 cnsTextOfProfile(profile: DiveResults): string {
- if(profile.cns >= 1000) {
+ private density(profile: DiveResults): number {
+ const density = profile.highestDensity.density;
+ return this.units.fromGramPerLiter(density);
+ }
+
+ private cnsFormatted(profile: DiveResults): string {
+ if(profile.cns >= this.maxCns) {
return TextConstants.cnsOverOneThousand;
}
return formatNumber(profile.cns, 'en', '1.0-0');
}
}
+
+@Component({
+ selector: 'app-diff-diveresults-table',
+ templateUrl: './diff-diveresults-table.component.html',
+ styleUrls: ['./diff-diveresults-table.component.scss', '../../diff.component.scss']
+})
+export class DiveResultsTableDifferenceComponent {
+ public constructor(
+ public viewSwitch: ViewSwitchService,
+ public units: UnitConversion,
+ public profilesDiff: ProfileComparatorService) {
+ }
+
+ public get diff(): DiveResulsDiff {
+ return new DiveResulsDiff(this.units, this.profileA, this.profileB);
+ }
+
+ public get profileA(): DiveResults {
+ return this.profilesDiff.profileAResults;
+ }
+
+ public get profileB(): DiveResults {
+ return this.profilesDiff.profileBResults;
+ }
+
+ public get diveInfosCalculated(): boolean {
+ return this.profilesDiff.areDiveInfosCalculated();
+ }
+
+ public get areProfilesCalculated(): boolean {
+ return this.profilesDiff.areProfilesCalculated();
+ }
+}
|