-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Profile comparison - Waypoints Table #3
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
e3de3d7
Add placeholder components
4e02247
Replace placeholders with specific components
0325a7b
Linter fixes
a18d067
Add missing base test
b97c477
Remove ImperialUnits and isComplex
dcf6cc7
Fix Spec names
9c6bcd7
Implement waypoints table with prop drilling
0fa9680
Display data from both profiles
51ba9b2
Add Compare profile link to navbar
0d4b543
Fix formatting of time values
ea284fe
Implement WaypointsTableRow interface
011308c
Join profile waypoints into WaypointsTableRow[]
a057ce3
Switch to displaying WaypointsTableRow[] data
55705ad
Add two tiered table header for profiles
ca1662c
Style waypoints table
5c1f66f
Fix rebase error - TestData.Profile -> Waypoint[]
a0057f9
Extract WaypointsTableRow interface
4c3a4f9
Formatting changes
3e5aca7
Rename to WaypointsComparisonTableRow
0ff336e
Extract table row population into provider
6f1fb10
Remove link to Compare Profiles
e86946f
Add non-null assertions
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,14 @@ | ||
<div class="row mt-5"> | ||
<div class="col mt-3"> | ||
<p>diff works!</p> | ||
<div class="mt-5"> | ||
<div class="row"> | ||
<div class="col-12 col-lg-12 col-xl-6 col-xxl-6 mt-4"> | ||
<app-diff-profilechart></app-diff-profilechart> | ||
</div> | ||
<div class="col-md-6 col-xl-6 mt-4"> | ||
<app-diff-waypoints [data]="testData"></app-diff-waypoints> | ||
</div> | ||
<div class="col-md-6 col-xl-5 col-xxl-3 mt-4"> | ||
<app-diff-diveinfo></app-diff-diveinfo> | ||
</div> | ||
</div> | ||
</div> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<app-diveinfo></app-diveinfo> |
Empty file.
21 changes: 21 additions & 0 deletions
21
projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { DiveInfoDifferenceComponent } from './diff-diveinfo.component'; | ||
|
||
describe('DiveInfoDifferenceComponent', () => { | ||
let component: DiveInfoDifferenceComponent; | ||
let fixture: ComponentFixture<DiveInfoDifferenceComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [DiveInfoDifferenceComponent] | ||
}); | ||
fixture = TestBed.createComponent(DiveInfoDifferenceComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
projects/planner/src/app/diff/diveinfo/diff-diveinfo.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-diff-diveinfo', | ||
templateUrl: './diff-diveinfo.component.html', | ||
styleUrls: ['./diff-diveinfo.component.scss'] | ||
}) | ||
export class DiveInfoDifferenceComponent { | ||
|
||
} |
1 change: 1 addition & 0 deletions
1
projects/planner/src/app/diff/profilechart/diff-profilechart.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<app-profilechart></app-profilechart> |
Empty file.
21 changes: 21 additions & 0 deletions
21
projects/planner/src/app/diff/profilechart/diff-profilechart.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { ProfileDifferenceChartComponent } from './diff-profilechart.component'; | ||
|
||
describe('ProfileDifferenceChartComponent', () => { | ||
let component: ProfileDifferenceChartComponent; | ||
let fixture: ComponentFixture<ProfileDifferenceChartComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [ProfileDifferenceChartComponent] | ||
}); | ||
fixture = TestBed.createComponent(ProfileDifferenceChartComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
10 changes: 10 additions & 0 deletions
10
projects/planner/src/app/diff/profilechart/diff-profilechart.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
@Component({ | ||
selector: 'app-diff-profilechart', | ||
templateUrl: './diff-profilechart.component.html', | ||
styleUrls: ['./diff-profilechart.component.scss'] | ||
}) | ||
export class ProfileDifferenceChartComponent { | ||
|
||
} |
50 changes: 50 additions & 0 deletions
50
projects/planner/src/app/diff/waypoints/diff-waypoints.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<div class="card overflow-y-scroll"> | ||
<div class="card-header"> | ||
<div class="float-start"> | ||
<fa-icon [icon]="tasks" class="me-3"></fa-icon> | ||
<span>Dive way points</span> | ||
</div> | ||
</div> | ||
<div class="card-body card-minheight table-responsive card-max-height-md"> | ||
<table id="waypointsDiffTable" class="table table-sm p-0 text-center table-hover"> | ||
<thead class="table-light sticky-top"> | ||
<tr> | ||
<th colspan="1" ></th> | ||
<th colspan="2" class="fw-bold px-1 active-profile">Profile A</th> | ||
<th colspan="2" class="fw-bold px-1">Profile B</th> | ||
</tr> | ||
<tr> | ||
<th class="fw-bold px-1 ">Run [min]</th> | ||
<th class="fw-bold px-1 active-profile">Depth [{{units.length}}]</th> | ||
<th class="fw-bold px-1 active-profile">Duration [min]</th> | ||
<th class="fw-bold px-1">Depth [{{units.length}}]</th> | ||
<th class="fw-bold px-1">Duration [min]</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr *ngFor="let row of tableRowProvider.getRows()"> | ||
<td class="px-1 vertical-right-border"> | ||
{{ row.runTime * 1000 | date:'mm:ss' }} | ||
</td> | ||
<td *ngIf="row.depthA !== undefined; else emptyRow" class="px-1"> | ||
{{ row.depthA | number: '1.0-0'}} | ||
</td> | ||
<td *ngIf="row.durationA !== undefined else emptyRowWithDivider" class="px-1 vertical-right-border"> | ||
{{ row.durationA * 1000 | date: 'mm:ss'}} | ||
</td> | ||
<td *ngIf="row.depthB !== undefined else emptyRow" class="px-1"> | ||
{{ row.depthB | number:'1.0-0' }} | ||
</td> | ||
<td *ngIf="row.durationB !== undefined else emptyRow" class="px-1"> | ||
{{ row.durationB * 1000 | date: 'mm:ss'}} | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
|
||
<ng-template #emptyRow><td class="px-1"></td></ng-template> | ||
<ng-template #emptyRowWithDivider><td class="px-1 vertical-right-border"></td></ng-template> | ||
|
||
|
24 changes: 24 additions & 0 deletions
24
projects/planner/src/app/diff/waypoints/diff-waypoints.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@import "node_modules/mdb-angular-ui-kit/assets/scss/free/variables"; | ||
#waypointsDiffTable { | ||
.vertical-right-border { | ||
border-right-width: medium; | ||
} | ||
.vertical-left-border { | ||
border-left-width: medium; | ||
} | ||
|
||
.vertical-borders { | ||
border-left-width: medium; | ||
border-right-width: medium; | ||
} | ||
|
||
tr { | ||
border-top: hidden; | ||
border-bottom: hidden; | ||
} | ||
|
||
.active-profile { | ||
background: $primary; | ||
border-color: $primary; | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
projects/planner/src/app/diff/waypoints/diff-waypoints.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {ComponentFixture, TestBed} from '@angular/core/testing'; | ||
import {WaypointsDifferenceComponent} from './diff-waypoints.component'; | ||
import {UnitConversion} from '../../shared/UnitConversion'; | ||
import {TestData} from '../diff.component'; | ||
|
||
describe('WaypointsDifferenceComponent', () => { | ||
let component: WaypointsDifferenceComponent; | ||
let fixture: ComponentFixture<WaypointsDifferenceComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
declarations: [WaypointsDifferenceComponent], | ||
providers: [UnitConversion] | ||
}); | ||
fixture = TestBed.createComponent(WaypointsDifferenceComponent); | ||
component = fixture.componentInstance; | ||
component.data = new TestData(); | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
24 changes: 24 additions & 0 deletions
24
projects/planner/src/app/diff/waypoints/diff-waypoints.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import {Component, Input, OnInit} 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'; | ||
|
||
@Component({ | ||
selector: 'app-diff-waypoints', | ||
templateUrl: './diff-waypoints.component.html', | ||
styleUrls: ['./diff-waypoints.component.scss'], | ||
}) | ||
export class WaypointsDifferenceComponent implements OnInit { | ||
@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); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
projects/planner/src/app/shared/WaypointsComparisonTableRow.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface WaypointsComparisonTableRow { | ||
runTime: number; | ||
depthA: number | undefined; | ||
durationA: number | undefined; | ||
depthB: number | undefined; | ||
durationB: number | undefined; | ||
} |
66 changes: 66 additions & 0 deletions
66
projects/planner/src/app/shared/waypointsComparisonTableRowProvider.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {WayPoint} from './models'; | ||
import {WaypointsComparisonTableRow} from './WaypointsComparisonTableRow'; | ||
|
||
// TODO: Rework into injectable service that gets data from services instead of constructor | ||
export class WaypointsComparisonTableRowProvider { | ||
|
||
private wayPointsA: WayPoint[]; | ||
private wayPointsB: WayPoint[]; | ||
private _waypointRows: WaypointsComparisonTableRow[] = []; | ||
|
||
constructor(wayPointsA: WayPoint[], wayPointsB: WayPoint[]) { | ||
this.wayPointsA = wayPointsA; | ||
this.wayPointsB = wayPointsB; | ||
} | ||
|
||
public getRows(): WaypointsComparisonTableRow[] { | ||
const MAX_SAFETY_LIMIT = 65536; // 2**16 | ||
let waypointA: WayPoint | undefined = this.wayPointsA.pop(); | ||
let waypointB: WayPoint | undefined = this.wayPointsB.pop(); | ||
|
||
for (let i = 0; i < MAX_SAFETY_LIMIT; i++) { | ||
let row: WaypointsComparisonTableRow; | ||
if (waypointA === undefined && waypointB === undefined) { | ||
break; | ||
} | ||
|
||
if ((waypointA?.endTime || -1) > (waypointB?.endTime || -1)) { | ||
row = { | ||
runTime: waypointA!.endTime, | ||
durationA: waypointA?.duration, | ||
depthA: waypointA?.endDepth, | ||
durationB: undefined, | ||
depthB: undefined, | ||
}; | ||
waypointA = this.wayPointsA.pop(); | ||
this._waypointRows.unshift(row); | ||
continue; | ||
} | ||
|
||
if ((waypointA?.endTime || -1) < (waypointB?.endTime || -1)) { | ||
row = { | ||
runTime: waypointB!.endTime, | ||
durationA: undefined, | ||
depthA: undefined, | ||
durationB: waypointB?.duration, | ||
depthB: waypointB?.endDepth, | ||
}; | ||
waypointB = this.wayPointsB.pop(); | ||
this._waypointRows.unshift(row); | ||
continue; | ||
} | ||
|
||
row = { | ||
runTime: waypointA!.endTime, | ||
durationA: waypointA?.duration, | ||
depthA: waypointA?.endDepth, | ||
durationB: waypointB?.duration, | ||
depthB: waypointB?.endDepth, | ||
}; | ||
waypointA = this.wayPointsA.pop(); | ||
waypointB = this.wayPointsB.pop(); | ||
this._waypointRows.unshift(row); | ||
} | ||
return this._waypointRows; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have dynamic duration formatting based on the value, see original component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix once importing profiles into DiveSchedules is implemented