Skip to content

Commit

Permalink
Add faster/slower indicator to lap details.
Browse files Browse the repository at this point in the history
  • Loading branch information
tkem committed Mar 25, 2024
1 parent 81e2b7e commit ff78fb8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/app/rms/leaderboard/leaderboard-head.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="position cell" *ngIf="fields.length > 5">
<div class="position cell" *ngIf="pos">
<span class="title">POS</span>
</div>
<div *ngFor="let field of fields" [ngSwitch]="field" [ngClass]="[field, 'cell']">
Expand Down
1 change: 1 addition & 0 deletions src/app/rms/leaderboard/leaderboard-head.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
})
export class LeaderboardHeadComponent {
@Input() fields: string[];
@Input() pos: boolean; // FIXME: move to fields?
}
12 changes: 12 additions & 0 deletions src/app/rms/leaderboard/leaderboard-lap.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,17 @@
{{times[0] - times[3] | time:'s.sss'}}
</span>
</ng-template>
<!--
<ng-template ngSwitchCase="lastlap">
<span [ngClass]="{best: last[0] - last[1] == item.best[0], allbest: last[0] - last[1] == best[0]}">
{{last[0] - last[1] | time:'s.sss'}}
</span>
</ng-template>
-->
<ng-template ngSwitchCase="status">
<span *ngIf="last" [ngClass]="(last[0] - last[1]) > (times[0] - times[1]) ? 'pos-up' : 'pos-dn'">
</span>
</ng-template>

</div>

1 change: 1 addition & 0 deletions src/app/rms/leaderboard/leaderboard-lap.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export class LeaderboardLapComponent {
@Input() item: LeaderboardItem;
@Input() times: number[];
@Input() best: number[];
@Input() last: number[];
@Input() intlap: number;
@Input() fields: string[];
}
10 changes: 8 additions & 2 deletions src/app/rms/leaderboard/leaderboard.component.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<leaderboard-head class="row" [fields]="fields"></leaderboard-head>
<leaderboard-head class="row" [fields]="fields" [pos]="true"></leaderboard-head>
<leaderboard-item class="row" *ngFor="let item of items; odd as isOddRow;"
(click)="showDetails(item)"
[ngClass]="isOddRow ? 'odd' : 'even'"
Expand Down Expand Up @@ -26,7 +26,13 @@
<leaderboard-head class="row" [fields]="detailFields"></leaderboard-head>
<leaderboard-lap class="row" *ngFor="let times of detail?.laptimes; odd as isOddRow; index as i; count as n"
[ngClass]="isOddRow ? 'odd' : 'even'"
[lap]="n - i" [item]="detail" [times]="times" [best]="best" [intlap]="intlaps[detail?.id]" [fields]="detailFields">
[lap]="n - i"
[item]="detail"
[times]="times"
[best]="best"
[last]="detail?.laptimes[i + 1]"
[intlap]="intlaps[detail?.id]"
[fields]="detailFields">
</leaderboard-lap>
</ion-content>
</ng-template>
Expand Down
4 changes: 2 additions & 2 deletions src/app/rms/leaderboard/leaderboard.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ const FIELDS = [{
}];

const DETAIL_FIELDS = [
'lap laptime gap int',
'lap laptime sector1 sector2 sector3'
'lap laptime gap int status',
'lap laptime sector1 sector2 sector3 status'
];

export class LeaderboardItem {
Expand Down

0 comments on commit ff78fb8

Please sign in to comment.