Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.19.5 #188

Merged
merged 13 commits into from
Jun 13, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
<div class="card-body">
<div class="d-flex">
<div class="d-flex flex-grow-1">
<div *ngIf="team.rank" class="fs-20 mr-4">
{{team.rank}}
</div>

<app-avatar *ngIf="team.players.length == 1" [tooltip]="team.captain.sponsor.name"
[imageUrl]="team.captain.sponsor | sponsorToLogoUri" size="small"
class="mr-2"></app-avatar>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class GameCenterPlayersComponent implements OnInit {

private async load() {
this.isLoading = true;
this.results = await this.adminService.getGameCenterTeams(this.gameId!);
this.results = await this.adminService.getGameCenterTeams(this.gameId!, { sort: "rank" });
this.isLoading = false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ <h4>Execution</h4>

</div>

<div *ngIf="game.gameStart > game.gameEnd" class="row form-group">
<div *ngIf="executionRangeInvalid" class="row form-group">
<alert type="warning" class="col-12">The game's open date must be less than its close date.</alert>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export class GameEditorComponent implements AfterViewInit, OnChanges {
viewing = 1;
showCertificateInfo = false;
showExternalGameFields = false;
protected executionRangeInvalid = false;
protected specCount = 0;

// store unique values of each game field with their frequencies for ordered suggestion lists
Expand Down Expand Up @@ -184,8 +185,16 @@ export class GameEditorComponent implements AfterViewInit, OnChanges {
if (game.minTeamSize > game.maxTeamSize)
return false;

if (game.gameStart > game.gameEnd)
this.executionRangeInvalid = false;
const gameStart = game.gameStart ? new Date(game.gameStart) : new Date(0);
const gameEnd = game.gameEnd ? new Date(game.gameEnd) : new Date(0);
if (gameStart.getFullYear() > 1 && gameEnd?.getFullYear() > 1 && game.gameStart > game.gameEnd) {
this.executionRangeInvalid = true;
return false;
}

game.gameStart = gameStart;
game.gameEnd = gameEnd;

if (game.registrationType == GameRegistrationType.open && game.registrationOpen > game.registrationClose)
return false;
Expand Down
4 changes: 4 additions & 0 deletions projects/gameboard-ui/src/app/api/admin.models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ export interface GameCenterContext {
pointsAvailable: number;
}

export interface GameCenterTeamsRequestArgs {
sort: "name" | "rank" | "timeRemaining" | "timeSinceStart";
}

export interface GameCenterTeamsResults {
teams: PagedArray<GameCenterTeamsResultsTeam>;
}
Expand Down
6 changes: 3 additions & 3 deletions projects/gameboard-ui/src/app/api/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable, firstValueFrom, map, tap } from 'rxjs';
import { ApiUrlService } from '@/services/api-url.service';
import { GameCenterContext, GameCenterTeamsResults, GetAppActiveChallengesResponse, GetAppActiveTeamsResponse, GetSiteOverviewStatsResponse, SendAnnouncement } from './admin.models';
import { GameCenterContext, GameCenterTeamsRequestArgs, GameCenterTeamsResults, GetAppActiveChallengesResponse, GetAppActiveTeamsResponse, GetSiteOverviewStatsResponse, SendAnnouncement } from './admin.models';
import { PlayerMode } from './player-models';
import { DateTime } from 'luxon';

Expand Down Expand Up @@ -48,8 +48,8 @@ export class AdminService {
));
}

async getGameCenterTeams(gameId: string): Promise<GameCenterTeamsResults> {
return firstValueFrom(this.http.get<GameCenterTeamsResults>(this.apiUrl.build(`admin/games/${gameId}/game-center/teams`)).pipe(
async getGameCenterTeams(gameId: string, args: GameCenterTeamsRequestArgs): Promise<GameCenterTeamsResults> {
return firstValueFrom(this.http.get<GameCenterTeamsResults>(this.apiUrl.build(`admin/games/${gameId}/game-center/teams`, args)).pipe(
tap(results => {
for (const team of results.teams.items) {
if (team.registeredOn)
Expand Down
1 change: 1 addition & 0 deletions projects/gameboard-ui/src/app/api/support-models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export interface Ticket {
label: string;
selfCreated: boolean;
staffCreated: boolean;
timeTilSessionEndMs?: number;

created: Date;
lastUpdated: Date;
Expand Down
18 changes: 18 additions & 0 deletions projects/gameboard-ui/src/app/home/landing/landing.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,18 @@ <h2>Featured Games</h2>
</ng-container>
</div>

<!-- Ongoing (games with no end date) -->
<div class="row mt-1" *ngIf="ongoing$ | async as ongoing; else loadingOngoing">
<ng-container *ngIf="!!ongoing.length">
<div class="col-12 mx-0 px-0 mb-2">
<h2>Ongoing Games</h2>
</div>
<ng-container *ngFor="let game of ongoing">
<ng-container *ngTemplateOutlet="gameWrapper;context: {game: game}"></ng-container>
</ng-container>
</ng-container>
</div>

<!-- Live -->
<div class="row mt-1" *ngIf="present$ | async as present; else loading">
<ng-container *ngIf="!!present.length">
Expand Down Expand Up @@ -113,6 +125,12 @@ <h2 class="p-0 m-0 font-weight-bold">Open Game</h2>
</div>
</ng-template>

<ng-template #loadingOngoing>
<div class="text-center">
<app-spinner>Loading ongoing games...</app-spinner>
</div>
</ng-template>

<ng-template #loading>
<div class="text-center">
<app-spinner>Loading games...</app-spinner>
Expand Down
19 changes: 12 additions & 7 deletions projects/gameboard-ui/src/app/home/landing/landing.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { GameService } from '../../api/game.service';
export class LandingComponent implements OnInit {
refresh$ = new BehaviorSubject<any>(true);
featured$: Observable<Game[]>;
ongoing$: Observable<Game[]>;
past$: Observable<GameGroup[]>;
present$: Observable<Game[]>;
future$: Observable<GameGroup[]>;
Expand All @@ -38,22 +39,26 @@ export class LandingComponent implements OnInit {
) {
this.featured$ = this.refresh$.pipe(
debounceTime(400),
switchMap(() => api.list({ isFeatured: true, filter: [], term: this.searchText })),
switchMap(() => api.list({ isFeatured: true, term: this.searchText })),
tap(g => { if (g.length > 0) { this.showSearchBar = true; } }),
);
this.past$ = this.refresh$.pipe(
this.ongoing$ = this.refresh$.pipe(
debounceTime(400),
switchMap(() => api.listGrouped({ filter: ['past', "competitive"], term: this.searchText })),
tap(g => { if (g.length > 0) { this.showSearchBar = true; } }),
);
switchMap(() => api.list({ isOngoing: true, term: this.searchText }))
),
this.past$ = this.refresh$.pipe(
debounceTime(400),
switchMap(() => api.listGrouped({ filter: ['past', "competitive"], isOngoing: false, term: this.searchText })),
tap(g => { if (g.length > 0) { this.showSearchBar = true; } }),
);
this.present$ = this.refresh$.pipe(
debounceTime(200),
switchMap(() => api.list({ filter: ["present", "competitive"], term: this.searchText })),
switchMap(() => api.list({ filter: ["present", "competitive"], isOngoing: false, term: this.searchText })),
tap(g => { if (g.length > 0) { this.showSearchBar = true; } })
);
this.future$ = this.refresh$.pipe(
debounceTime(300),
switchMap(() => api.listGrouped({ filter: ['future', "competitive"], term: this.searchText })),
switchMap(() => api.listGrouped({ filter: ['future', "competitive"], isOngoing: false, term: this.searchText })),
tap(g => { if (g.length > 0) { this.showSearchBar = true; } })
);
}
Expand Down
2 changes: 1 addition & 1 deletion projects/gameboard-ui/src/app/services/router.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class RouterService implements OnDestroy {
}

public getObserveChallengeUrl(gameId: string, challengeId: string) {
return `/admin/observer/challenges/${gameId}?search=${challengeId}`;
return `admin/observer/challenges/${gameId}?search=${challengeId}`;
}

public getObserveTeamsUrl(gameId: string, teamId: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface TicketSupportToolsContext {
challenge?: SimpleEntity;
player?: SimpleEntity;
game?: SimpleEntity;
timeTilSessionEndMs?: number;
team: {
id: string,
name: string,
Expand All @@ -20,7 +21,7 @@ export interface TicketSupportToolsContext {
styleUrls: ['./ticket-support-tools.component.scss'],
template: `
<ul *ngIf="hasGameContext; else noGameContext">
<li *ngIf="observeChallengeUrl || observeTeamUrl">
<li *ngIf="isActiveSession && (observeChallengeUrl || observeTeamUrl)">
Observe
<ul>
<li>
Expand Down Expand Up @@ -72,6 +73,7 @@ export class TicketSupportToolsComponent implements OnInit {
protected hasGameContext = false;
protected challengeStateUrl?: string;
protected gameboardUrl?: string;
protected isActiveSession = false;
protected observeChallengeUrl?: string;
protected observeTeamUrl?: string;
protected playerAdminUrl?: string;
Expand Down Expand Up @@ -100,6 +102,7 @@ export class TicketSupportToolsComponent implements OnInit {
}
}

this.isActiveSession = !!this.context?.timeTilSessionEndMs && this.context.timeTilSessionEndMs > 0;
this.hasGameContext = hasGame || !!this.challengeStateUrl || !!this.gameboardUrl || !!this.playerAdminUrl;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export class TicketDetailsComponent implements AfterViewInit, OnDestroy {
challenge: t.challenge ? { id: t.challengeId, name: t.challenge?.name } : undefined,
game: hasGame ? { id: t.player!.gameId, name: t.player!.gameName } : undefined,
player: hasPlayer ? { id: t.playerId, name: t.player!.approvedName } : undefined,
timeTilSessionEndMs: t.timeTilSessionEndMs,
team: {
id: t.teamId,
name: t.teamName,
Expand Down
Loading