-
Notifications
You must be signed in to change notification settings - Fork 1
Add lap timer UI controls page #554
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
Draft
bracyw
wants to merge
10
commits into
develop
Choose a base branch
from
547-lap-timer-ui-controls
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
21452c8
#547 - add lap timer UI controls page
bracyw 0ac6a13
Merge branch 'develop' of github.com:Northeastern-Electric-Racing/Arg…
bracyw 5ba5ebe
#547 migrate DataTypeEnum to topic.utils
bracyw 06d4210
#547 remove unused code and dead declarations
bracyw 8593aa1
#547 apply prettier formatting
bracyw 6f565a3
#547 add OnPush change detection and remove explicit standalone
bracyw 8ea5492
Merge remote-tracking branch 'origin/develop' into 547-lap-timer-ui-c…
TheJeffreyKuo 53296ab
lap timer ui cleanup and local persistence
TheJeffreyKuo a94c131
Merge branch 'develop' into 547-lap-timer-ui-controls
TheJeffreyKuo 7781263
clean up
TheJeffreyKuo 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 hidden or 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,17 @@ | ||
| import { urls } from './urls'; | ||
|
|
||
| export const startLap = (): Promise<Response> => { | ||
| return fetch(urls.startLap(), { method: 'POST' }); | ||
| }; | ||
|
|
||
| export const pauseLap = (): Promise<Response> => { | ||
| return fetch(urls.pauseLap(), { method: 'POST' }); | ||
| }; | ||
|
|
||
| export const stopLap = (): Promise<Response> => { | ||
| return fetch(urls.stopLap(), { method: 'POST' }); | ||
| }; | ||
|
|
||
| export const getLaps = (): Promise<Response> => { | ||
| return fetch(urls.getLaps()); | ||
| }; |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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
31 changes: 31 additions & 0 deletions
31
angular-client/src/pages/lap-timer-page/lap-timer-page.component.css
This file contains hidden or 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,31 @@ | ||
| .page-grid { | ||
| margin: 0 16px; | ||
| } | ||
|
|
||
| .gauge-wrap { | ||
| display: flex; | ||
| justify-content: center; | ||
| align-items: center; | ||
| height: 100%; | ||
| width: 100%; | ||
| overflow: hidden; | ||
| } | ||
|
|
||
| .gauge-stat { | ||
| display: flex; | ||
| align-items: baseline; | ||
| justify-content: center; | ||
| gap: 4px; | ||
| padding: 8px 0; | ||
| } | ||
| .gauge-value { | ||
| font-family: var(--font-family); | ||
| font-variant-numeric: tabular-nums; | ||
| font-size: var(--font-size-xxl); | ||
| font-weight: 700; | ||
| color: var(--color-text-primary); | ||
| } | ||
| .gauge-unit { | ||
| font-size: var(--font-size-sm); | ||
| color: var(--color-text-secondary); | ||
| } |
48 changes: 48 additions & 0 deletions
48
angular-client/src/pages/lap-timer-page/lap-timer-page.component.html
This file contains hidden or 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,48 @@ | ||
| <div class="page-grid"> | ||
| <p-toast position="top-right" /> | ||
| <p-confirmDialog /> | ||
|
|
||
| <mat-grid-list cols="6" gutterSize="15px" rowHeight="1.5rem"> | ||
| <mat-grid-tile [colspan]="6" [rowspan]="8"> | ||
| <sessions-panel /> | ||
| </mat-grid-tile> | ||
|
|
||
| <mat-grid-tile [colspan]="3" [rowspan]="9"> | ||
| <timer-hero /> | ||
| </mat-grid-tile> | ||
|
|
||
| <mat-grid-tile [colspan]="1" [rowspan]="9"> | ||
| <session-summary /> | ||
| </mat-grid-tile> | ||
|
|
||
| <mat-grid-tile [colspan]="2" [rowspan]="5"> | ||
| <info-background svgIcon="speed" title="Speed" style="width: 100%; height: 100%"> | ||
| <div class="gauge-wrap"> | ||
| <half-gauge [current]="liveSpeed()" [max]="100" [min]="0" unit="mph" [color]="speedGaugeColor()" [size]="320" /> | ||
| </div> | ||
| </info-background> | ||
| </mat-grid-tile> | ||
|
|
||
| <mat-grid-tile [colspan]="1" [rowspan]="4"> | ||
| <info-background title="Battery" style="width: 100%; height: 100%"> | ||
| <div class="gauge-stat"> | ||
| <span class="gauge-value" [style.color]="socColor()">{{ liveSoc() | number: '1.0-0' }}</span> | ||
| <span class="gauge-unit">%</span> | ||
| </div> | ||
| </info-background> | ||
| </mat-grid-tile> | ||
|
|
||
| <mat-grid-tile [colspan]="1" [rowspan]="4"> | ||
| <info-background title="Motor" style="width: 100%; height: 100%"> | ||
| <div class="gauge-stat"> | ||
| <span class="gauge-value" [style.color]="motorTempColor()">{{ liveMotorTemp() | number: '1.0-0' }}</span> | ||
| <span class="gauge-unit">°C</span> | ||
| </div> | ||
| </info-background> | ||
| </mat-grid-tile> | ||
|
|
||
| <mat-grid-tile [colspan]="6" [rowspan]="22"> | ||
| <laps-table /> | ||
| </mat-grid-tile> | ||
| </mat-grid-list> | ||
| </div> | ||
77 changes: 77 additions & 0 deletions
77
angular-client/src/pages/lap-timer-page/lap-timer-page.component.ts
This file contains hidden or 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,77 @@ | ||
| import { ChangeDetectionStrategy, Component, computed, inject, OnDestroy, OnInit, signal } from '@angular/core'; | ||
| import { DecimalPipe } from '@angular/common'; | ||
| import { Subscription } from 'rxjs'; | ||
| import { MatGridList, MatGridTile } from '@angular/material/grid-list'; | ||
| import { ConfirmationService, MessageService } from 'primeng/api'; | ||
| import { ConfirmDialog } from 'primeng/confirmdialog'; | ||
| import { Toast } from 'primeng/toast'; | ||
| import HalfGaugeComponent from 'src/components/half-gauge/half-gauge.component'; | ||
| import { InfoBackgroundComponent } from 'src/components/info-background/info-background.component'; | ||
| import Storage from 'src/services/storage.service'; | ||
| import { topics } from 'src/utils/topic.utils'; | ||
| import SessionsPanelComponent from './sessions-panel/sessions-panel.component'; | ||
| import TimerHeroComponent from './timer-hero/timer-hero.component'; | ||
| import SessionSummaryComponent from './session-summary/session-summary.component'; | ||
| import LapsTableComponent from './laps-table/laps-table.component'; | ||
|
|
||
| @Component({ | ||
| selector: 'lap-timer-page', | ||
| templateUrl: './lap-timer-page.component.html', | ||
| styleUrl: './lap-timer-page.component.css', | ||
| changeDetection: ChangeDetectionStrategy.OnPush, | ||
| providers: [ConfirmationService, MessageService], | ||
| imports: [ | ||
| MatGridList, | ||
| MatGridTile, | ||
| DecimalPipe, | ||
| ConfirmDialog, | ||
| Toast, | ||
| HalfGaugeComponent, | ||
| InfoBackgroundComponent, | ||
| SessionsPanelComponent, | ||
| TimerHeroComponent, | ||
| SessionSummaryComponent, | ||
| LapsTableComponent | ||
| ] | ||
| }) | ||
| export default class LapTimerPageComponent implements OnInit, OnDestroy { | ||
| private storage = inject(Storage); | ||
|
|
||
| readonly liveSpeed = signal(0); | ||
| readonly liveMotorTemp = signal(0); | ||
| readonly liveSoc = signal(0); | ||
|
|
||
| readonly speedGaugeColor = signal('#1ae824'); | ||
|
|
||
| readonly socColor = computed(() => { | ||
| const soc = this.liveSoc(); | ||
| if (soc >= 60) return 'var(--color-battery-high)'; | ||
| if (soc >= 30) return 'var(--color-battery-med)'; | ||
| return 'var(--color-battery-low)'; | ||
| }); | ||
|
|
||
| readonly motorTempColor = computed(() => { | ||
| const t = this.liveMotorTemp(); | ||
| if (t < 60) return 'var(--color-text-primary)'; | ||
| if (t < 80) return 'var(--color-battery-med)'; | ||
| return 'var(--color-battery-low)'; | ||
| }); | ||
|
|
||
| private subs: Subscription[] = []; | ||
|
|
||
| ngOnInit(): void { | ||
| const styles = getComputedStyle(document.documentElement); | ||
| const high = styles.getPropertyValue('--color-battery-high').trim(); | ||
| if (high) this.speedGaugeColor.set(high); | ||
|
|
||
| this.subs.push( | ||
| this.storage.get(topics.speed()).subscribe((v) => this.liveSpeed.set(parseFloat(v.values[0]) || 0)), | ||
| this.storage.get(topics.motorTemp()).subscribe((v) => this.liveMotorTemp.set(parseFloat(v.values[0]) || 0)), | ||
| this.storage.get(topics.stateOfCharge()).subscribe((v) => this.liveSoc.set(parseFloat(v.values[0]) || 0)) | ||
| ); | ||
| } | ||
|
|
||
| ngOnDestroy(): void { | ||
| this.subs.forEach((s) => s.unsubscribe()); | ||
| } | ||
| } |
Oops, something went wrong.
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.
abstraction ticket needed