-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added header component, player details page and fixed routing errors
- Loading branch information
Showing
30 changed files
with
2,297 additions
and
1,705 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
4 changes: 2 additions & 2 deletions
4
courtsight/src/app/basket/match-details/match-details.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
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
File renamed without changes.
37 changes: 37 additions & 0 deletions
37
courtsight/src/app/basket/player-details/player-details.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,37 @@ | ||
<div class="grid mt-3 lg:mx-6 m-2 mb-8"> | ||
<div class="flex flex-1 flex-row flex-wrap justify-content-between align-items-baseline"> | ||
<div class="flex"> | ||
<app-details-header | ||
[title]="player?.player" | ||
[subtitle]="team?.team_info!.full_name" | ||
[items]="header_items"></app-details-header> | ||
</div> | ||
<div class="flex"> | ||
<span class="text-6xl font-bold m-3">{{ player?.num }} ({{player?.position}})</span> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
<div class="grid lg:mx-6 mb-5 m-1"> | ||
<div class="flex flex-1 flex-wrap gap-3"> | ||
<ng-container *ngFor="let stat of average_stats"> | ||
<div class="flex-1 border-2 border-round p-4"> | ||
<div class="flex justify-content-center gap-5"> | ||
<div class="flex flex-column align-items-center gap-1"> | ||
<span class="text-primary ">{{ stat.name }}</span> | ||
<span class="font-bold text-lg">{{ stat.value }}</span> | ||
</div> | ||
</div> | ||
</div> | ||
</ng-container> | ||
</div> | ||
</div> | ||
|
||
<div class="grid lg:mx-6 mb-8" *ngIf="playerStats?.all_stats && playerStats?.all_stats!.length > 0"> | ||
<div class="col-12"> | ||
<app-player-stats [rows]="playerStats?.all_stats!" | ||
title="Last {{playerStats?.all_stats!.length}} matches"></app-player-stats> | ||
</div> | ||
</div> | ||
|
||
<app-time-travel (onDateUpdate)="refreshStats()"></app-time-travel> |
23 changes: 23 additions & 0 deletions
23
courtsight/src/app/basket/player-details/player-details.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,23 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
|
||
import { PlayerDetailsComponent } from './player-details.component'; | ||
|
||
describe('PlayerDetailsComponent', () => { | ||
let component: PlayerDetailsComponent; | ||
let fixture: ComponentFixture<PlayerDetailsComponent>; | ||
|
||
beforeEach(async () => { | ||
await TestBed.configureTestingModule({ | ||
imports: [PlayerDetailsComponent] | ||
}) | ||
.compileComponents(); | ||
|
||
fixture = TestBed.createComponent(PlayerDetailsComponent); | ||
component = fixture.componentInstance; | ||
fixture.detectChanges(); | ||
}); | ||
|
||
it('should create', () => { | ||
expect(component).toBeTruthy(); | ||
}); | ||
}); |
101 changes: 101 additions & 0 deletions
101
courtsight/src/app/basket/player-details/player-details.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,101 @@ | ||
import {Component, inject} from '@angular/core'; | ||
import {DetailsHeaderComponent, Item} from "../../shared/details-header/details-header.component"; | ||
import {PlayerStats} from "../stats"; | ||
import {PlayersService} from "../players.service"; | ||
import {ActivatedRoute} from "@angular/router"; | ||
import {TimeTravelService} from "../../shared/time-travel.service"; | ||
import {Player} from "../player"; | ||
import {Team} from "../team"; | ||
import {TeamsService} from "../teams.service"; | ||
import {PlayerStatsComponent} from "./player-stats/player-stats.component"; | ||
import {CommonModule} from "@angular/common"; | ||
import {CardModule} from "primeng/card"; | ||
import {DividerModule} from "primeng/divider"; | ||
import {TimeTravelComponent} from "../../shared/time-travel/time-travel.component"; | ||
|
||
@Component({ | ||
selector: 'app-player-details', | ||
standalone: true, | ||
imports: [ | ||
DetailsHeaderComponent, | ||
PlayerStatsComponent, | ||
CommonModule, | ||
CardModule, | ||
DividerModule, | ||
TimeTravelComponent | ||
], | ||
templateUrl: './player-details.component.html', | ||
styleUrl: './player-details.component.css' | ||
}) | ||
export class PlayerDetailsComponent { | ||
route: ActivatedRoute = inject(ActivatedRoute); | ||
|
||
teamsService = inject(TeamsService); | ||
playerService = inject(PlayersService); | ||
timetravelService = inject(TimeTravelService); | ||
|
||
team: Team | undefined; | ||
player: Player | undefined; | ||
playerStats: PlayerStats | undefined; | ||
header_items: Item[] = []; | ||
|
||
average_stats: any[] = [] | ||
|
||
constructor() { | ||
this.refreshStats() | ||
} | ||
|
||
refreshStats() { | ||
const player_id = this.route.snapshot.params["id"]; | ||
|
||
this.route.parent!.params.subscribe(params => { | ||
const ticker = params['ticker']; | ||
|
||
this.teamsService.getTeamFromTicker(ticker, "2023-24").then((team: Team) => { | ||
this.team = team; | ||
this.player = team.team_players.find((p) => String(p.player_id) === player_id); | ||
|
||
if (this.player) { | ||
this.header_items = [ | ||
{ | ||
icon: 'pi pi-info-circle', value: `${this.player.age} y/0`, | ||
}, | ||
{ | ||
icon: null, value: `${this.player.weight} lb`, | ||
}, | ||
{ | ||
icon: null, value: `${this.player.height} ft`, | ||
}, | ||
] | ||
} | ||
|
||
this.playerService.getPlayerStatsById(player_id, "2023-24", this.timetravelService.getDateString(), "5").then(playerStats => { | ||
this.playerStats = playerStats; | ||
this.average_stats = [ | ||
{ | ||
value: this.player?.exp, | ||
name: "Experience", | ||
}, | ||
{ | ||
value: playerStats.average.pts, | ||
name: "PPG", | ||
}, | ||
{ | ||
value: playerStats.average.reb, | ||
name: "RPG", | ||
}, | ||
{ | ||
value: playerStats.average.ast, | ||
name: "APG", | ||
}, | ||
{ | ||
value: playerStats.average.blk, | ||
name: "BLK", | ||
}, | ||
] | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
} |
Empty file.
68 changes: 68 additions & 0 deletions
68
courtsight/src/app/basket/player-details/player-stats/player-stats.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,68 @@ | ||
<p-table | ||
[value]="rows" | ||
[scrollable]="true" | ||
styleClass="p-datatable-striped" | ||
> | ||
<ng-template pTemplate="caption"> | ||
<div class="flex align-items-center justify-content-between"> | ||
{{ title }} | ||
</div> | ||
</ng-template> | ||
<ng-template pTemplate="header"> | ||
<tr> | ||
<th class="text-center" pFrozenColumn>Date</th> | ||
<th class="text-center" pFrozenColumn>Matchup</th> | ||
<th class="text-center">W/L</th> | ||
<th class="text-center">min</th> | ||
<th class="text-center">pts</th> | ||
<th class="text-center">fgm</th> | ||
<th class="text-center">fga</th> | ||
<th class="text-center">fg %</th> | ||
<th class="text-center">fg3m</th> | ||
<th class="text-center">fg3a</th> | ||
<th class="text-center">fg3 %</th> | ||
<th class="text-center">ftm</th> | ||
<th class="text-center">fta</th> | ||
<th class="text-center">ft %</th> | ||
<th class="text-center">oreb</th> | ||
<th class="text-center">dreb</th> | ||
<th class="text-center">reb</th> | ||
<th class="text-center">ast</th> | ||
<th class="text-center">stl</th> | ||
<th class="text-center">blk</th> | ||
<th class="text-center">tov</th> | ||
<th class="text-center">pf</th> | ||
<th class="text-center">+/-</th> | ||
</tr> | ||
</ng-template> | ||
<ng-template pTemplate="body" let-stats> | ||
<tr> | ||
<td class="text-center" pFrozenColumn><a routerLink="/basketball/match/{{stats.game_id}}/{{stats.game_date | date: 'yyyy-MM-dd' }}" class="text-primary">{{ stats.game_date }}</a></td> | ||
<td class="text-center" pFrozenColumn>{{ stats.matchup }}</td> | ||
<td class="text-center">{{ stats.wl }}</td> | ||
<td class="text-center">{{ stats.min }}</td> | ||
<td class="text-center">{{ stats.pts }}</td> | ||
<td class="text-center">{{ stats.fgm }}</td> | ||
<td class="text-center">{{ stats.fga }}</td> | ||
<td class="text-center">{{ stats.fg_pct }}</td> | ||
<td class="text-center">{{ stats.fg3m }}</td> | ||
<td class="text-center">{{ stats.fg3a }}</td> | ||
<td class="text-center">{{ stats.fg3_pct }}</td> | ||
<td class="text-center">{{ stats.ftm }}</td> | ||
<td class="text-center">{{ stats.fta }}</td> | ||
<td class="text-center">{{ stats.ft_pct }}</td> | ||
<td class="text-center">{{ stats.oreb }}</td> | ||
<td class="text-center">{{ stats.dreb }}</td> | ||
<td class="text-center">{{ stats.reb }}</td> | ||
<td class="text-center">{{ stats.ast }}</td> | ||
<td class="text-center">{{ stats.stl }}</td> | ||
<td class="text-center">{{ stats.blk }}</td> | ||
<td class="text-center">{{ stats.tov }}</td> | ||
<td class="text-center">{{ stats.pf }}</td> | ||
<td class="text-center">{{ stats.plus_minus }}</td> | ||
</tr> | ||
</ng-template> | ||
|
||
|
||
</p-table> | ||
|
Oops, something went wrong.