now displaying minutes / seconds correctly
This commit is contained in:
parent
084f022280
commit
012bf1c6ef
@ -12,6 +12,8 @@ import {HttpClientModule} from '@angular/common/http';
|
|||||||
import {AppRoutingModule} from './app-routing.module';
|
import {AppRoutingModule} from './app-routing.module';
|
||||||
import { ChampionshipComponent } from './championship/championship.component';
|
import { ChampionshipComponent } from './championship/championship.component';
|
||||||
import { ChampionshipselectordialogComponent } from './championshipselectordialog/championshipselectordialog.component';
|
import { ChampionshipselectordialogComponent } from './championshipselectordialog/championshipselectordialog.component';
|
||||||
|
import { RacetimepipePipe } from './racetimepipe.pipe';
|
||||||
|
import { MinutesPipe } from './minutes.pipe';
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
@ -21,7 +23,9 @@ import { ChampionshipselectordialogComponent } from './championshipselectordialo
|
|||||||
PouleComponent,
|
PouleComponent,
|
||||||
TierComponent,
|
TierComponent,
|
||||||
ChampionshipComponent,
|
ChampionshipComponent,
|
||||||
ChampionshipselectordialogComponent
|
ChampionshipselectordialogComponent,
|
||||||
|
RacetimepipePipe,
|
||||||
|
MinutesPipe
|
||||||
],
|
],
|
||||||
imports: [
|
imports: [
|
||||||
BrowserModule,
|
BrowserModule,
|
||||||
|
|||||||
@ -35,10 +35,13 @@
|
|||||||
|
|
||||||
<!--do a penalty for this race/team combo-->
|
<!--do a penalty for this race/team combo-->
|
||||||
<div class="penaltycell" [ngStyle]="{'grid-column':2, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
<div class="penaltycell" [ngStyle]="{'grid-column':2, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
||||||
<span class="timecell">{{getPenaltySum(raceindex, team.idteam)/1000 | number:'1.2-2'}}</span>
|
<span class="timecell">{{getPenaltySum(raceindex, team.idteam) | number:'1.0-0'}}<span class="timeletter">s</span></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="totalcell" [ngStyle]="{'grid-column':3, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
<div class="totalcell" [ngStyle]="{'grid-column':3, 'grid-row':2+(teamindex*(maxRaces+1))+raceindex+1}">
|
||||||
<span class="timecell">{{getRaceTime(raceindex, team.idteam)/1000 | number:'1.2-2'}}</span>
|
<span class="timecell">{{getRaceTime(raceindex, team.idteam) | minutes}}</span>
|
||||||
|
<span class="timeletter">m</span>
|
||||||
|
<span class="timecell">{{getRaceTimeSeconds(raceindex, team.idteam)}}</span>
|
||||||
|
<span class="timeletter">s</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@ -48,7 +51,10 @@
|
|||||||
<div class="resultcell" [ngStyle]="{'grid-column':4,
|
<div class="resultcell" [ngStyle]="{'grid-column':4,
|
||||||
'grid-row-start':2+(teamindex*(maxRaces+1))+1,
|
'grid-row-start':2+(teamindex*(maxRaces+1))+1,
|
||||||
'grid-row-end': 2+(teamindex*(maxRaces+1))+1+maxRaces}">
|
'grid-row-end': 2+(teamindex*(maxRaces+1))+1+maxRaces}">
|
||||||
<span class="timecell">{{getAvgOfBestTwo(team.idteam)/1000 | number:'1.2-2'}}</span>
|
<span class="timecell">{{getAvgOfBestTwo(team.idteam) | minutes}}</span>
|
||||||
|
<span class="timeletter">m</span>
|
||||||
|
<span class="timecell">{{((getAvgOfBestTwo(team.idteam)/1000)%60).toFixed(2)}}</span>
|
||||||
|
<span class="timeletter">s</span>
|
||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
|
|
||||||
|
|||||||
@ -20,3 +20,7 @@
|
|||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.timeletter {
|
||||||
|
font-size: 60%;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
@ -89,6 +89,10 @@ export class PouleComponent implements OnInit {
|
|||||||
return penaltysum;
|
return penaltysum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get avg of best two in milliseconds.
|
||||||
|
* @param idTeam
|
||||||
|
*/
|
||||||
getAvgOfBestTwo(idTeam: number) {
|
getAvgOfBestTwo(idTeam: number) {
|
||||||
if (!this.timesIndexed) {
|
if (!this.timesIndexed) {
|
||||||
return null;
|
return null;
|
||||||
@ -136,6 +140,15 @@ export class PouleComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRaceTimeMinutes(raceNr: number, idTeam: number): number {
|
||||||
|
return Math.floor(this.getRaceTime(raceNr, idTeam) / 1000 / 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
getRaceTimeSeconds(raceNr: number, idTeam: number): string {
|
||||||
|
const raceTime = this.getRaceTime(raceNr, idTeam);
|
||||||
|
return ((raceTime / 1000) % 60).toFixed(2);
|
||||||
|
}
|
||||||
|
|
||||||
getLapTimes(raceNr: number, idTeam: number): number[] {
|
getLapTimes(raceNr: number, idTeam: number): number[] {
|
||||||
// console.log('lapnr/idteam' + lapNr + ' ' + idTeam);
|
// console.log('lapnr/idteam' + lapNr + ' ' + idTeam);
|
||||||
// console.log(this.timesIndexed);
|
// console.log(this.timesIndexed);
|
||||||
|
|||||||
8
src/app/minutes.pipe.spec.ts
Normal file
8
src/app/minutes.pipe.spec.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { MinutesPipe } from './minutes.pipe';
|
||||||
|
|
||||||
|
describe('MinutesPipe', () => {
|
||||||
|
it('create an instance', () => {
|
||||||
|
const pipe = new MinutesPipe();
|
||||||
|
expect(pipe).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
15
src/app/minutes.pipe.ts
Normal file
15
src/app/minutes.pipe.ts
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import {Pipe, PipeTransform} from '@angular/core';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'minutes'
|
||||||
|
})
|
||||||
|
export class MinutesPipe implements PipeTransform {
|
||||||
|
|
||||||
|
transform(value: any, args?: any): any {
|
||||||
|
if (value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return Math.floor((value / 1000) / 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
8
src/app/racetimepipe.pipe.spec.ts
Normal file
8
src/app/racetimepipe.pipe.spec.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { RacetimepipePipe } from './racetimepipe.pipe';
|
||||||
|
|
||||||
|
describe('RacetimepipePipe', () => {
|
||||||
|
it('create an instance', () => {
|
||||||
|
const pipe = new RacetimepipePipe();
|
||||||
|
expect(pipe).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
24
src/app/racetimepipe.pipe.ts
Normal file
24
src/app/racetimepipe.pipe.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import {Pipe, PipeTransform} from '@angular/core';
|
||||||
|
|
||||||
|
@Pipe({
|
||||||
|
name: 'racetimepipe'
|
||||||
|
})
|
||||||
|
export class RacetimepipePipe implements PipeTransform {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transform an amount of milliseconds to '999m:99s'
|
||||||
|
* @param value
|
||||||
|
* @param args
|
||||||
|
*/
|
||||||
|
transform(value: any, args?: any): any {
|
||||||
|
if (value === null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
// assume a number in milliseconds
|
||||||
|
const ms = <number>value;
|
||||||
|
const m = Math.floor(ms / 60);
|
||||||
|
const s = ms - m * 60;
|
||||||
|
return value + 'ms' + m + 'm:' + s.toFixed(2) + 's';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -5,6 +5,6 @@
|
|||||||
</button>
|
</button>
|
||||||
<button mat-raised-button color="primary" *ngFor="let tier of tiers" routerLink="/championship/20/tier/{{tier}}">
|
<button mat-raised-button color="primary" *ngFor="let tier of tiers" routerLink="/championship/20/tier/{{tier}}">
|
||||||
<mat-icon svgIcon="{{getTierIcon(tier)}}"></mat-icon>
|
<mat-icon svgIcon="{{getTierIcon(tier)}}"></mat-icon>
|
||||||
Tier {{tier}}
|
{{getTierName(tier)}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -67,4 +67,24 @@ export class TopmenuComponent implements OnInit {
|
|||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a tier name. If there's a fixed amount of tiers we can give them a special name.
|
||||||
|
* @param tier
|
||||||
|
*/
|
||||||
|
getTierName(tier: number) {
|
||||||
|
if (tier === this.tiers.length) {
|
||||||
|
return 'Finale';
|
||||||
|
} else if (tier === this.tiers.length - 1) {
|
||||||
|
return 'Halve finale';
|
||||||
|
} else if (tier === this.tiers.length - 2) {
|
||||||
|
return 'Kwart finale';
|
||||||
|
} else if (tier === this.tiers.length - 3) {
|
||||||
|
return 'Achtste finale';
|
||||||
|
} else if (tier === this.tiers.length - 3) {
|
||||||
|
return 'Zestiende finale';
|
||||||
|
} else {
|
||||||
|
return 'tier' + tier;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user