-
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.
feat(multi): Adding tournament support and increasing max tables (#10)
* tournament loading working * initial challonge working * tournament dashboard updates * swap tables added * players have fargo observable ids * adding tournaments * handling returned errors
- Loading branch information
1 parent
5d128d0
commit c96f02c
Showing
77 changed files
with
2,923 additions
and
156 deletions.
There are no files selected for viewing
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
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
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
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
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
29 changes: 29 additions & 0 deletions
29
apps/dashboard/src/app/tournament/components/tournament-list/tournament-list.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,29 @@ | ||
<div class="flex flex-col flex-grow" *ngIf="vm$ | async as vm"> | ||
<div *ngIf="vm.hasTournaments" class="flex flex-row h-66px bg-sad-input border-sad-active border-b"> | ||
<div class="w-9/12 flex flex-col justify-center items-start px-10"> | ||
<p class="text-white uppercase text-xs">Name</p> | ||
</div> | ||
<div class="w-3/12 flex flex-col px-10"></div> | ||
</div> | ||
<ng-container *ngIf="vm.isLoaded; else loading"> | ||
<div class="flex flex-row h-66px" *ngFor="let tournament of vm.tournaments; even as isEven; odd as isOdd" [ngClass]="{ 'bg-sad-table-even': isEven, 'bg-sad-table-odd': isOdd }"> | ||
<div class="w-9/12 flex flex-col justify-center px-10"> | ||
<p class="text-white uppercase text-xs whitespace-nowrap">{{ tournament?.name }}</p> | ||
</div> | ||
<div class="w-3/12 flex flex-col justify-center items-end px-10"> | ||
<div class="flex flex-row gap-5 whitespace-nowrap"> | ||
<a href="https://challonge.com/{{ tournament.url }}" target="_blank" class="text-white bg-sad-challonge rounded py-2.5 px-5 uppercase text-xs mr-2.5">View on Challonge</a> | ||
<a class="text-white bg-sad-success rounded py-2.5 px-5 uppercase text-xs" routerLink="./{{ tournament?.id }}">Select</a> | ||
</div> | ||
</div> | ||
</div> | ||
<ng-container *ngIf="!vm.hasTournaments"> | ||
<p class="p-4 text-white bg-sad-input border-sad-active border-t">Please create a new tournament on Challonge to continue.</p> | ||
</ng-container> | ||
</ng-container> | ||
<ng-template #loading> | ||
<div class="relative flex flex-row h-66px" *ngFor="let tournament of [1, 2, 3, 4, 5]; even as isEven; odd as isOdd" [ngClass]="{ 'bg-sad-table-even': isEven, 'bg-sad-table-odd': isOdd }"> | ||
<div class="shimmer-overlay"></div> | ||
</div> | ||
</ng-template> | ||
</div> |
25 changes: 25 additions & 0 deletions
25
apps/dashboard/src/app/tournament/components/tournament-list/tournament-list.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,25 @@ | ||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'; | ||
import { Tournament } from '@pool-overlay/models'; | ||
import { TournamentListStore } from './tournament-list.store'; | ||
|
||
@Component({ | ||
selector: 'pool-overlay-tournament-list', | ||
templateUrl: 'tournament-list.component.html', | ||
providers: [TournamentListStore], | ||
}) | ||
export class TournamentListComponent implements OnInit { | ||
readonly vm$ = this.store.vm$; | ||
|
||
@Output() | ||
public selected = new EventEmitter<{ tournamentId: number }>(); | ||
|
||
constructor(private store: TournamentListStore) { } | ||
|
||
public ngOnInit(): void { | ||
this.store.getTournaments(); | ||
} | ||
|
||
public selectTournament(tournamentId: number): void { | ||
this.selected.emit({ tournamentId }); | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
apps/dashboard/src/app/tournament/components/tournament-list/tournament-list.store.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,74 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { ComponentStore, tapResponse } from '@ngrx/component-store'; | ||
import { Tournament } from '@pool-overlay/models'; | ||
import { switchMap, tap } from 'rxjs'; | ||
import { TournamentsService } from '../../services/tournament.service'; | ||
|
||
export enum LoadingState { | ||
INIT, | ||
LOADING, | ||
LOADED, | ||
} | ||
|
||
interface TournamentListState { | ||
callState: LoadingState; | ||
tournaments: Tournament[]; | ||
} | ||
|
||
export const initialState: TournamentListState = { | ||
callState: LoadingState.INIT, | ||
tournaments: [], | ||
} | ||
|
||
@Injectable() | ||
export class TournamentListStore extends ComponentStore<TournamentListState> { | ||
constructor( | ||
private tournamentsService: TournamentsService, | ||
) { | ||
super(initialState); | ||
} | ||
|
||
// updaters | ||
private updateCallState = this.updater<LoadingState>((state, callState) => ({ | ||
...state, | ||
callState, | ||
})); | ||
|
||
private updateTournaments = this.updater<Tournament[]>((state, tournaments) => ({ | ||
...state, | ||
tournaments, | ||
callState: LoadingState.LOADED, | ||
})); | ||
|
||
// selectors | ||
private isLoaded$ = this.select((state) => state.callState === LoadingState.LOADED); | ||
private tournaments$ = this.select((state) => state.tournaments); | ||
private hasTournaments$ = this.select( | ||
this.isLoaded$, | ||
this.tournaments$, | ||
(loaded, tournaments) => loaded && !!tournaments.length | ||
); | ||
readonly vm$ = this.select( | ||
this.isLoaded$, | ||
this.tournaments$, | ||
this.hasTournaments$, | ||
(isLoaded, tournaments, hasTournaments) => ({ | ||
isLoaded, | ||
tournaments, | ||
hasTournaments, | ||
}) | ||
); | ||
|
||
// effects | ||
readonly getTournaments = this.effect((trigger$) => trigger$.pipe( | ||
tap(() => this.updateCallState(LoadingState.LOADING)), | ||
switchMap(() => this.tournamentsService.getList().pipe( | ||
tapResponse( | ||
(tournaments) => this.updateTournaments(tournaments), | ||
(err) => { | ||
console.log(err); | ||
} | ||
) | ||
)), | ||
)); | ||
} |
Oops, something went wrong.