24 changed files with 248 additions and 224 deletions
@ -1,14 +1,49 @@ |
|||||
export class Race{ |
import { Expose, Type } from 'class-transformer'; |
||||
|
import { RaceEntry } from './raceEntry.model'; |
||||
|
import { Season } from './season.model'; |
||||
|
|
||||
|
export class Race { |
||||
|
@Expose() |
||||
id: string = ""; |
id: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
mapName: string = ""; |
mapName: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
mapURL: string = ""; |
mapURL: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
mapUID: string = ""; |
mapUID: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
mapImgUrl: string = ""; |
mapImgUrl: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
authorTime: number = 0; |
authorTime: number = 0; |
||||
|
|
||||
|
@Expose() |
||||
goldTime: number = 0; |
goldTime: number = 0; |
||||
|
|
||||
|
@Expose() |
||||
silverTime: number = 0; |
silverTime: number = 0; |
||||
|
|
||||
|
@Expose() |
||||
bronzeTime: number = 0; |
bronzeTime: number = 0; |
||||
|
|
||||
|
@Expose() |
||||
startDate: Date = new Date(0); |
startDate: Date = new Date(0); |
||||
|
|
||||
|
@Expose() |
||||
endDate: Date = new Date(0); |
endDate: Date = new Date(0); |
||||
|
|
||||
|
@Expose() |
||||
racers: string[] = []; |
racers: string[] = []; |
||||
|
|
||||
|
@Expose() |
||||
|
@Type(() => RaceEntry) |
||||
|
results: RaceEntry[] = []; |
||||
|
|
||||
|
@Expose() |
||||
|
@Type(() => Season) |
||||
|
season: Season | null = null; |
||||
} |
} |
||||
@ -1,7 +1,22 @@ |
|||||
|
import { Expose, Type } from 'class-transformer'; |
||||
|
import { Race } from './race.model'; |
||||
|
import { Racer } from './racer.model'; |
||||
|
|
||||
export class RaceEntry { |
export class RaceEntry { |
||||
id: string = ""; |
@Expose() |
||||
race_id: string = ""; |
id: number = -1; |
||||
racer_id: string = ""; |
|
||||
|
@Expose() |
||||
|
@Type(() => Race) |
||||
|
race: Race | null = null; |
||||
|
|
||||
|
@Expose() |
||||
|
@Type(() => Racer) |
||||
|
racer: Racer | null = null; |
||||
|
|
||||
|
@Expose() |
||||
replayPath: string = ""; |
replayPath: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
time: number = 0; |
time: number = 0; |
||||
} |
} |
||||
@ -1,5 +1,33 @@ |
|||||
|
import { Expose, Type } from 'class-transformer'; |
||||
|
import { User } from './user.model'; |
||||
|
import { RaceEntry } from './raceEntry.model'; |
||||
|
|
||||
export class Racer { |
export class Racer { |
||||
|
@Expose() |
||||
id: string = ""; |
id: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
name: string = ""; |
name: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
gameHandle: string = ""; |
gameHandle: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
|
results: RaceEntry[] = []; |
||||
|
|
||||
|
@Expose() |
||||
|
@Type(() => User) |
||||
|
user: User | null = null; |
||||
|
|
||||
|
getName(): string { |
||||
|
let name = "" |
||||
|
|
||||
|
name += this.gameHandle |
||||
|
|
||||
|
if(this.user) { |
||||
|
name += " (" + this.user.getUserRealName() + ")"; |
||||
|
} |
||||
|
|
||||
|
return name; |
||||
|
} |
||||
} |
} |
||||
@ -1,6 +1,16 @@ |
|||||
|
import { Expose, Type } from 'class-transformer'; |
||||
import { Racer } from "./racer.model"; |
import { Racer } from "./racer.model"; |
||||
|
import { Season } from './season.model'; |
||||
|
|
||||
export class SeasonStanding { |
export class SeasonStanding { |
||||
racer?: Racer; |
@Expose() |
||||
|
@Type(() => Season) |
||||
|
season: Season | null = null; |
||||
|
|
||||
|
@Expose() |
||||
|
@Type(() => Racer) |
||||
|
racer: Racer | null = null;; |
||||
|
|
||||
|
@Expose() |
||||
points: number = 0; |
points: number = 0; |
||||
} |
} |
||||
@ -1,12 +1,35 @@ |
|||||
|
import { Expose, Type } from 'class-transformer'; |
||||
import { Race } from "./race.model"; |
import { Race } from "./race.model"; |
||||
import { SeasonStanding } from "./season-standing.model"; |
import { SeasonStanding } from "./season-standing.model"; |
||||
|
import { Racer } from './racer.model'; |
||||
|
|
||||
export class Season { |
export class Season { |
||||
|
@Expose() |
||||
id: string = "0"; |
id: string = "0"; |
||||
|
|
||||
|
@Expose() |
||||
title: string = ""; |
title: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
subTitle: string = ""; |
subTitle: string = ""; |
||||
startingDate: Date = new Date(Date.now()); |
|
||||
|
@Expose() |
||||
|
@Type(() => Date) |
||||
|
startingDate: Date = new Date(0); |
||||
|
|
||||
|
@Expose() |
||||
|
@Type(() => Race) |
||||
races: Race[] = []; |
races: Race[] = []; |
||||
racers: string[] = []; |
|
||||
|
@Expose() |
||||
|
@Type(() => Racer) |
||||
|
racers: Racer[] = []; |
||||
|
|
||||
|
@Expose() |
||||
|
@Type(() => SeasonStanding) |
||||
standings: SeasonStanding[] = []; |
standings: SeasonStanding[] = []; |
||||
|
|
||||
|
getStartingDate() { |
||||
|
return this.startingDate.toUTCString(); |
||||
|
} |
||||
} |
} |
||||
@ -0,0 +1,51 @@ |
|||||
|
import { Expose, Type } from 'class-transformer'; |
||||
|
import { Racer } from './racer.model'; |
||||
|
|
||||
|
export class User { |
||||
|
@Expose() |
||||
|
auth0id: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
|
nickname: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
|
email: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
|
picture: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
|
realName: string = ""; |
||||
|
|
||||
|
@Expose() |
||||
|
lastLogin: Date | null = null; |
||||
|
|
||||
|
@Expose({ name: 'racer' }) |
||||
|
@Type(() => Racer) |
||||
|
racer: Racer | null = null; |
||||
|
|
||||
|
getUserName() : string { |
||||
|
return this.nickname; |
||||
|
} |
||||
|
|
||||
|
getUserId() : string { |
||||
|
return this.auth0id.replace("auth0|", "") || ""; |
||||
|
} |
||||
|
|
||||
|
compareId(otherId: string) { |
||||
|
let other = otherId.replace("auth0|", "") |
||||
|
return this.getUserId() == other; |
||||
|
} |
||||
|
|
||||
|
getUserPicture() : string { |
||||
|
return this.picture || ""; |
||||
|
} |
||||
|
|
||||
|
getUserEmail() : string { |
||||
|
return this.email || ""; |
||||
|
} |
||||
|
|
||||
|
getUserRealName() : string { |
||||
|
return this.realName || "??? ???"; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,15 @@ |
|||||
|
import { Injectable } from '@angular/core'; |
||||
|
|
||||
|
@Injectable({ |
||||
|
providedIn: 'root', |
||||
|
}) |
||||
|
export class UtilsService { |
||||
|
formatMilliseconds(milliseconds: number) |
||||
|
{ |
||||
|
const minutes = Math.floor(milliseconds / (1000 * 60)); |
||||
|
const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000); |
||||
|
const remainingMilliseconds = milliseconds % 1000; |
||||
|
|
||||
|
return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}:${String(remainingMilliseconds).padStart(3, '0')}`; |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue