Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class E2eDirective {
return;
}

this.elementRef.nativeElement.setAttribute('data-cy', E2eDirective.transformValue(value));
this.elementRef.nativeElement.dataset.cy = E2eDirective.transformValue(value);
}

private static transformValue(value: string | (string | number)[]): string {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,14 @@ export class AuthenticationService implements OnDestroy {
const expiry = this.readAccessTokenExpiryFromLocalStorage();

// Add some clock skew to prevent race condition
return expiry === undefined || expiry * 1000 < new Date().getTime() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000;
return expiry === undefined || expiry * 1000 < Date.now() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000;
}

private isRefreshTokenExpired(): boolean {
const expiry = this.readRefreshTokenExpiryFromLocalStorage();

// Add some clock skew to prevent race condition
return expiry === undefined || expiry * 1000 < new Date().getTime() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000;
return expiry === undefined || expiry * 1000 < Date.now() + AuthenticationService.tokenExpiryCheckClockSkewSeconds * 1000;
}

private decodeAccessToken(token: string): TurnierplanAccessToken {
Expand Down Expand Up @@ -323,7 +323,11 @@ export class AuthenticationService implements OnDestroy {
private logoutAndClearData(navigateTo?: () => void): Observable<void> {
const logout$ = this.turnierplanApi.invoke(logout).pipe(
catchError(() => of(undefined)),
tap(() => AuthenticationService.allLocalStorageKeys.forEach((key) => localStorage.removeItem(key))),
tap(() => {
for (const key of AuthenticationService.allLocalStorageKeys) {
localStorage.removeItem(key);
}
}),
map(() => void 0)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class DocumentConfigReceiptsComponent extends DocumentConfigComponent<Rec
// For now, we simply find the lowest number that is not currently a key in the map.
const existingEntries = this.amountKeys.map((x) => +x);
let newEntry = 2;
while (existingEntries.some((x) => x === newEntry)) {
while (existingEntries.includes(newEntry)) {
newEntry++;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ export class FolderTreeComponent {
treeData.push(root);

// Add all tournaments w/o folder to the root node
tournaments.filter((x) => x.folderId === undefined).forEach((tournament) => root.tournaments.push(tournament));
for (const tournament of tournaments) {
if (tournament.folderId === undefined) {
root.tournaments.push(tournament);
}
}

// Get all distinct folders
const allFolders = FolderTreeComponent.detectFolders(tournaments);
allFolders.sort((a, b) => a.name.localeCompare(b.name));

// Add all tournaments with folder to the corresponding folder node
allFolders.forEach((folder) => {
for (const folder of allFolders) {
const folderTournaments = tournaments.filter((tournament) => tournament.folderId === folder.id);
folderTournaments.sort((a, b) => a.name.localeCompare(b.name));

Expand All @@ -64,7 +68,7 @@ export class FolderTreeComponent {
};

treeData.push(folderEntry);
});
}

return treeData;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class LabelsSelectComponent {
this.labelsSelected = {};

for (const label of this.availableLabels) {
this.labelsSelected[label.id] = selectedLabelIds.some((x) => x === label.id);
this.labelsSelected[label.id] = selectedLabelIds.includes(label.id);
}

this.isInitialized = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export class ManageApplicationsComponent implements OnDestroy {
}

protected isTeamVisible(team: ApplicationTeamDto): boolean {
return this.tournamentClassFilter.length === 0 || this.tournamentClassFilter.some((x) => x === team.tournamentClassId);
return this.tournamentClassFilter.length === 0 || this.tournamentClassFilter.includes(team.tournamentClassId);
}

protected getNumberOfVisibleTeams(application: ApplicationDto): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export class MatchPlanComponent implements OnChanges {
matches: []
};

this.matches.forEach((match) => {
for (const match of this.matches) {
this.matchCount++;
const isCorrectGroup = currentGroup.title.displayName === match.type.displayName;

Expand All @@ -114,7 +114,7 @@ export class MatchPlanComponent implements OnChanges {
if (match.kickoff !== undefined && new Date(match.kickoff).getSeconds() !== 0) {
this.showKickoffWithSeconds = true;
}
});
}

this.showCourtColumn = new Set(this.matches.map((x) => x.court)).size > 1;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ export class MatchTreeComponent implements OnChanges, AfterViewInit {
this.columns.at(-1)!.dependencyIds.push(...dependentMatchIds);
this.columns.push({ index: this.columns.length, matches: [...dependantMatches], dependencyIds: [] });

dependantMatches.forEach((match) => includedMatchIds.push(match.id));
for (const match of dependantMatches) {
includedMatchIds.push(match.id);
}

dependantMatches = [];
dependentMatchIds = [];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ export class MultiSelectFilterComponent {
}

protected isValueSelected(value: unknown): boolean {
return this._selected.some((x) => x === value);
return this._selected.includes(value);
}

protected setValueSelected(value: unknown, isSelected: boolean): void {
let updated = false;

if (isSelected) {
if (!this._selected.some((x) => x === value)) {
if (!this._selected.includes(value)) {
this._selected.push(value);
updated = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,17 +204,14 @@ export class SelectApplicationTeamComponent implements OnInit, OnDestroy {
}

protected isTeamDisabled(id: number): boolean {
return this.usedApplicationTeamIds.some((x) => x === id);
return this.usedApplicationTeamIds.includes(id);
}

private emitSelectedTeams(): void {
this.teamSelected.emit(this.currentSelection);
}

private isTeamVisible(team: ApplicationTeamDto): boolean {
return (
this.applicationsFilter.tournamentClass.length === 0 ||
this.applicationsFilter.tournamentClass.some((x) => x === team.tournamentClassId)
);
return this.applicationsFilter.tournamentClass.length === 0 || this.applicationsFilter.tournamentClass.includes(team.tournamentClassId);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class UpdatesCheckComponent implements OnInit {
try {
const parsed = JSON.parse(localStorageValue) as VersionCache;
const cacheExpiry = parsed.timestamp + cacheMaxAgeMilliseconds;
if (new Date().getTime() < cacheExpiry) {
if (Date.now() < cacheExpiry) {
return of(parsed.version);
}
} catch (e) {
Expand All @@ -64,7 +64,7 @@ export class UpdatesCheckComponent implements OnInit {
localStorageKey,
JSON.stringify({
version: version,
timestamp: new Date().getTime()
timestamp: Date.now()
} as VersionCache)
);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ export class ConfigureTournamentComponent implements OnInit, OnDestroy, DiscardC
}

protected get totalTeamCount(): number {
let count = 0;
this.groups.forEach((x) => (count += x.teams.length));
return count;
return this.groups.reduce((sum, group) => sum + group.teams.length, 0);
}

protected get isGroupPhaseCourtsInvalid(): boolean {
Expand Down Expand Up @@ -387,7 +385,7 @@ export class ConfigureTournamentComponent implements OnInit, OnDestroy, DiscardC
}

protected moveTeam(team: TemporaryTeam, from: TemporaryGroup, to: TemporaryGroup): void {
const index = from.teams.findIndex((x) => x === team);
const index = from.teams.indexOf(team);
from.teams.splice(index, 1);
to.teams.push(team);

Expand Down Expand Up @@ -634,7 +632,7 @@ export class ConfigureTournamentComponent implements OnInit, OnDestroy, DiscardC
return;
}

if (!this.currentFinalRound || this.availableFinalRounds.findIndex((x) => x === this.currentFinalRound) === -1) {
if (!this.currentFinalRound || this.availableFinalRounds.indexOf(this.currentFinalRound) === -1) {
this.currentFinalRound = this.availableFinalRounds[0];
}

Expand Down
2 changes: 1 addition & 1 deletion src/Turnierplan.App/Client/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const routes: Routes = [
children: [
{
matcher: (url: UrlSegment[]) =>
url.length > 0 && ['change-password', 'login', 'user-info'].some((x) => x === url[0].path) ? { consumed: [] } : null,
url.length > 0 && ['change-password', 'login', 'user-info'].includes(url[0].path) ? { consumed: [] } : null,
title: environment.defaultTitle,
loadChildren: () => import('./app/identity/identity.routes').then((m) => m.identityRoutes)
},
Expand Down
Loading