mirror of
https://codeberg.org/beerbrawl/beerbrawl.git
synced 2024-09-23 05:40:51 +02:00
feat(#39): backend-impl
This commit is contained in:
parent
c2b9ef5760
commit
29362116b3
|
@ -5,13 +5,7 @@ import java.util.List;
|
|||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.CreateTournamentDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TeamDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentCreateTeamDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentListDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentQualificationMatchDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentSignupTeamResponseDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.*;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.mapper.TeamMapper;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.exception.BadTournamentSignupTokenException;
|
||||
import org.slf4j.Logger;
|
||||
|
@ -73,6 +67,21 @@ public class TournamentEndpoint {
|
|||
return ResponseEntity.ok(tournamentMapper.tournamentToTournamentListDto(tournaments));
|
||||
}
|
||||
|
||||
@Secured("ROLE_USER")
|
||||
@ResponseStatus(HttpStatus.OK)
|
||||
@GetMapping(value = "/{tournamentId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@Operation(summary = "Get the overview for a specific tournament",
|
||||
security = @SecurityRequirement(name = "apiKey"))
|
||||
public ResponseEntity<TournamentOverviewDto> getTournamentOverview(@PathVariable(value = "tournamentId") long tournamentId, Authentication authentication) {
|
||||
LOG.info("GET-OVERVIEW {}/{}", BASE_ENDPOINT, tournamentId);
|
||||
// check if user is organizer of tournament
|
||||
if (!tournamentService.isOrganizer(authentication.getName(), tournamentId)) {
|
||||
throw new AccessDeniedException("Current user isn't organizer of the tournament.");
|
||||
}
|
||||
var tournamentOverview = tournamentService.getTournamentOverview(tournamentId);
|
||||
return ResponseEntity.ok(tournamentOverview);
|
||||
}
|
||||
|
||||
@Secured("ROLE_USER")
|
||||
@ResponseStatus(HttpStatus.CREATED)
|
||||
@PostMapping
|
||||
|
|
|
@ -1,2 +1,154 @@
|
|||
package at.ac.tuwien.sepr.groupphase.backend.endpoint.dto;public class TournamentOverviewDto {
|
||||
package at.ac.tuwien.sepr.groupphase.backend.endpoint.dto;
|
||||
|
||||
import jakarta.validation.constraints.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class TournamentOverviewDto {
|
||||
|
||||
@NotNull(message = "Name can't be null.")
|
||||
@Size(max = 200, message = "Name can't be more than 200 characters long.")
|
||||
@NotBlank(message = "Name can't be empty.")
|
||||
@Pattern(regexp = "[\\w\\s\\.äÄöÖüÜ\\-,]*", message = "Name contains not allowed characters.")
|
||||
private String name;
|
||||
|
||||
@NotNull(message = "Registration end can't be null.")
|
||||
@Future(message = "Registration end must be in the future.")
|
||||
private LocalDateTime registrationEnd;
|
||||
|
||||
@Min(value = 16, message = "Max participants needs to be a number larger than 16.")
|
||||
private Long maxParticipants;
|
||||
|
||||
private String description;
|
||||
|
||||
// Qualification specific
|
||||
@NotNull
|
||||
private int allQualificationMatches;
|
||||
|
||||
@NotNull
|
||||
private int playedQualificationMatches;
|
||||
|
||||
// KO specific
|
||||
@NotNull
|
||||
private int allKoMatches;
|
||||
|
||||
@NotNull
|
||||
private int playedKoMatches;
|
||||
|
||||
// Teams specific
|
||||
@NotNull
|
||||
private int teams;
|
||||
|
||||
@NotNull
|
||||
private int checkedInTeams;
|
||||
|
||||
// Tables specific
|
||||
@NotNull
|
||||
private int tables;
|
||||
private int tablesInUse;
|
||||
|
||||
// Static Builder class
|
||||
public static final class TournamentOverviewDtoBuilder {
|
||||
private String name;
|
||||
private LocalDateTime registrationEnd;
|
||||
private Long maxParticipants;
|
||||
private String description;
|
||||
private int allQualificationMatches;
|
||||
private int playedQualificationMatches;
|
||||
private int allKoMatches;
|
||||
private int playedKoMatches;
|
||||
private int teams;
|
||||
private int checkedInTeams;
|
||||
private int tables;
|
||||
private int tablesInUse;
|
||||
|
||||
private TournamentOverviewDtoBuilder() {
|
||||
}
|
||||
|
||||
public static TournamentOverviewDtoBuilder aTournamentOverviewDto() {
|
||||
return new TournamentOverviewDtoBuilder();
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withName(String name) {
|
||||
this.name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withRegistrationEnd(LocalDateTime registrationEnd) {
|
||||
this.registrationEnd = registrationEnd;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withMaxParticipants(Long maxParticipants) {
|
||||
this.maxParticipants = maxParticipants;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withDescription(String description) {
|
||||
this.description = description;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withAllQualificationMatches(int allQualificationMatches) {
|
||||
this.allQualificationMatches = allQualificationMatches;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withPlayedQualificationMatches(int playedQualificationMatches) {
|
||||
this.playedQualificationMatches = playedQualificationMatches;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withAllKoMatches(int allKoMatches) {
|
||||
this.allKoMatches = allKoMatches;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withPlayedKoMatches(int playedKoMatches) {
|
||||
this.playedKoMatches = playedKoMatches;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withTeams(int teams) {
|
||||
this.teams = teams;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withCheckedInTeams(int checkedInTeams) {
|
||||
this.checkedInTeams = checkedInTeams;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withTables(int tables) {
|
||||
this.tables = tables;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDtoBuilder withTablesInUse(int tablesInUse) {
|
||||
this.tablesInUse = tablesInUse;
|
||||
return this;
|
||||
}
|
||||
|
||||
public TournamentOverviewDto build() {
|
||||
TournamentOverviewDto tournamentOverviewDto = new TournamentOverviewDto();
|
||||
tournamentOverviewDto.setName(this.name);
|
||||
tournamentOverviewDto.setRegistrationEnd(this.registrationEnd);
|
||||
tournamentOverviewDto.setMaxParticipants(this.maxParticipants);
|
||||
tournamentOverviewDto.setDescription(this.description);
|
||||
tournamentOverviewDto.setAllQualificationMatches(this.allQualificationMatches);
|
||||
tournamentOverviewDto.setPlayedQualificationMatches(this.playedQualificationMatches);
|
||||
tournamentOverviewDto.setAllKoMatches(this.allKoMatches);
|
||||
tournamentOverviewDto.setPlayedKoMatches(this.playedKoMatches);
|
||||
tournamentOverviewDto.setTeams(this.teams);
|
||||
tournamentOverviewDto.setCheckedInTeams(this.checkedInTeams);
|
||||
tournamentOverviewDto.setTables(this.tables);
|
||||
tournamentOverviewDto.setTablesInUse(this.tablesInUse);
|
||||
return tournamentOverviewDto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ import at.ac.tuwien.sepr.groupphase.backend.entity.BeerPongTable;
|
|||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Repository
|
||||
public interface BeerPongTableRepository extends JpaRepository<BeerPongTable, Long> {
|
||||
List<BeerPongTable> findAllByTournamentId(long tournamentId);
|
||||
}
|
||||
|
|
|
@ -12,4 +12,5 @@ public interface KoStandingsRepository extends JpaRepository<KoStanding, Long> {
|
|||
|
||||
List<KoStanding> findByTournament(Tournament tournament);
|
||||
|
||||
List<KoStanding> findAllByTournamentId(long tournamentId);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import java.util.Collection;
|
|||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentOverviewDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.entity.Team;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
||||
|
@ -113,4 +114,12 @@ public interface TournamentService {
|
|||
* @param teamId the id of the team entity
|
||||
*/
|
||||
void markTeamAsReady(long tournamentId, long teamId);
|
||||
|
||||
/**
|
||||
* Extract information about the current state of a tournament.
|
||||
*
|
||||
* @param tournamentId to locate the target tournament
|
||||
* @return OverViewDto containing wanted information about the tournament.
|
||||
*/
|
||||
TournamentOverviewDto getTournamentOverview(long tournamentId);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package at.ac.tuwien.sepr.groupphase.backend.service.impl;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
@ -9,9 +10,11 @@ import java.util.Objects;
|
|||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import at.ac.tuwien.sepr.groupphase.backend.endpoint.dto.TournamentOverviewDto;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.entity.Team;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.exception.TournamentAlreadyStartedException;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.exception.BadTournamentSignupTokenException;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.security.access.AccessDeniedException;
|
||||
|
@ -24,13 +27,7 @@ import at.ac.tuwien.sepr.groupphase.backend.entity.QualificationParticipation;
|
|||
import at.ac.tuwien.sepr.groupphase.backend.entity.Tournament;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.exception.NotFoundException;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.exception.PreconditionFailedException;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.KoStandingsRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.QualificationMatchRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.QualificationParticipationRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.TeamRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.entity.Tournament.SignupTeamResult;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.TournamentRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.repository.UserRepository;
|
||||
import at.ac.tuwien.sepr.groupphase.backend.service.TournamentService;
|
||||
|
||||
@Service
|
||||
|
@ -41,6 +38,7 @@ public class TournamentServiceImpl implements TournamentService {
|
|||
private final UserRepository userRepository;
|
||||
private final QualificationMatchRepository qualificationRepository;
|
||||
private final QualificationParticipationRepository qualificationParticipationRepository;
|
||||
private final BeerPongTableRepository beerPongTableRepository;
|
||||
private List<QualificationMatch> matches;
|
||||
private boolean qualiIncomplete;
|
||||
private KoStandingsRepository koStandingsRepository;
|
||||
|
@ -51,7 +49,8 @@ public class TournamentServiceImpl implements TournamentService {
|
|||
QualificationMatchRepository qualificatonRepository,
|
||||
UserRepository userRepository,
|
||||
QualificationParticipationRepository qualificationParticipationRepository,
|
||||
KoStandingsRepository koStandingsRepository) {
|
||||
KoStandingsRepository koStandingsRepository,
|
||||
BeerPongTableRepository beerpongTableRepository) {
|
||||
super();
|
||||
|
||||
this.teamRepository = teamRepository;
|
||||
|
@ -60,6 +59,7 @@ public class TournamentServiceImpl implements TournamentService {
|
|||
this.userRepository = userRepository;
|
||||
this.qualificationParticipationRepository = qualificationParticipationRepository;
|
||||
this.koStandingsRepository = koStandingsRepository;
|
||||
this.beerPongTableRepository = beerpongTableRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -310,7 +310,6 @@ public class TournamentServiceImpl implements TournamentService {
|
|||
public void markTeamAsReady(long tournamentId, long teamId) {
|
||||
LOGGER.debug("Mark team with id {} as ready for tournament with id {}", teamId, tournamentId);
|
||||
|
||||
LOGGER.debug("Delete team with id {} from tournament with id {}", teamId, tournamentId);
|
||||
var team =
|
||||
teamRepository.findById(teamId).orElseThrow(() -> new NotFoundException("Team not found in tournament"));
|
||||
var tournament = team.getTournament();
|
||||
|
@ -323,4 +322,56 @@ public class TournamentServiceImpl implements TournamentService {
|
|||
teamRepository.saveAndFlush(team);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TournamentOverviewDto getTournamentOverview(long tournamentId) throws NotFoundException {
|
||||
LOGGER.debug("Obtain data for tournament {} overview" , tournamentId);
|
||||
|
||||
var tournament = tournamentRepository.findById(tournamentId);
|
||||
var qualificationMatches = qualificationRepository.findByTournamentId(tournamentId); //todo: Works? All
|
||||
var koMatches = koStandingsRepository.findAllByTournamentId(tournamentId);
|
||||
var teams = teamRepository.findAllByTournamentId(tournamentId);
|
||||
var tables = beerPongTableRepository.findAllByTournamentId(tournamentId);
|
||||
|
||||
if (tournament.isEmpty()) {
|
||||
throw new NotFoundException("Tournament was not found.");
|
||||
}
|
||||
var dto = TournamentOverviewDto.TournamentOverviewDtoBuilder.aTournamentOverviewDto();
|
||||
|
||||
dto.withDescription(tournament.get().getDescription())
|
||||
.withName(tournament.get().getName())
|
||||
.withRegistrationEnd(tournament.get().getRegistrationEnd())
|
||||
.withMaxParticipants(tournament.get().getMaxParticipants());
|
||||
|
||||
if (!qualificationMatches.isEmpty()) {
|
||||
dto.withAllQualificationMatches(qualificationMatches.size())
|
||||
.withPlayedQualificationMatches(
|
||||
Math.toIntExact(
|
||||
qualificationMatches.stream()
|
||||
.filter(q -> q.getEndTime() != null && q.getEndTime().isAfter(LocalDateTime.now())).count()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!koMatches.isEmpty()) {
|
||||
dto.withAllKoMatches(koMatches.size())
|
||||
.withPlayedKoMatches(
|
||||
Math.toIntExact(
|
||||
koMatches.stream()
|
||||
.filter(q -> q.getEndTime() != null && q.getEndTime().isAfter(LocalDateTime.now())).count()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!tables.isEmpty()) {
|
||||
dto.withTables(tables.size());
|
||||
}
|
||||
|
||||
if (!teams.isEmpty()) {
|
||||
dto.withTeams(teams.size())
|
||||
.withCheckedInTeams(Math.toIntExact(teams.stream().filter(Team::getCheckedIn).count()));
|
||||
}
|
||||
|
||||
return dto.build();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ model/teamDto.ts
|
|||
model/tournamentCreateTeamDto.ts
|
||||
model/tournamentDto.ts
|
||||
model/tournamentListDto.ts
|
||||
model/tournamentOverviewDto.ts
|
||||
model/tournamentQualificationMatchDto.ts
|
||||
model/tournamentQualificationMatchParticipantDto.ts
|
||||
model/tournamentSignupTeamResponseDto.ts
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: v0
|
||||
*
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
|
@ -13,7 +13,7 @@
|
|||
|
||||
import { Inject, Injectable, Optional } from '@angular/core';
|
||||
import { HttpClient, HttpHeaders, HttpParams,
|
||||
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
|
||||
HttpResponse, HttpEvent, HttpParameterCodec, HttpContext
|
||||
} from '@angular/common/http';
|
||||
import { CustomHttpParameterCodec } from '../encoder';
|
||||
import { Observable } from 'rxjs';
|
||||
|
@ -29,6 +29,8 @@ import { TournamentDto } from '../model/tournamentDto';
|
|||
// @ts-ignore
|
||||
import { TournamentListDto } from '../model/tournamentListDto';
|
||||
// @ts-ignore
|
||||
import { TournamentOverviewDto } from '../model/tournamentOverviewDto';
|
||||
// @ts-ignore
|
||||
import { TournamentQualificationMatchDto } from '../model/tournamentQualificationMatchDto';
|
||||
// @ts-ignore
|
||||
import { TournamentSignupTeamResponseDto } from '../model/tournamentSignupTeamResponseDto';
|
||||
|
@ -105,7 +107,7 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Create a new tournament
|
||||
* @param createTournamentDto
|
||||
* @param createTournamentDto
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -179,7 +181,7 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Delete a tournament
|
||||
* @param tournamentId
|
||||
* @param tournamentId
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -242,8 +244,8 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Delete team from a tournament
|
||||
* @param tournamentId
|
||||
* @param teamId
|
||||
* @param tournamentId
|
||||
* @param teamId
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -309,7 +311,7 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Create a new tournament
|
||||
* @param id
|
||||
* @param id
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -372,7 +374,7 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Create a new tournament
|
||||
* @param id
|
||||
* @param id
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -436,7 +438,7 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Get public info about tournament
|
||||
* @param tournamentId
|
||||
* @param tournamentId
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -498,9 +500,73 @@ export class TournamentEndpointService {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the overview for a specific tournament
|
||||
* @param tournamentId
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
public getTournamentOverview(tournamentId: number, observe?: 'body', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<TournamentOverviewDto>;
|
||||
public getTournamentOverview(tournamentId: number, observe?: 'response', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpResponse<TournamentOverviewDto>>;
|
||||
public getTournamentOverview(tournamentId: number, observe?: 'events', reportProgress?: boolean, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<HttpEvent<TournamentOverviewDto>>;
|
||||
public getTournamentOverview(tournamentId: number, observe: any = 'body', reportProgress: boolean = false, options?: {httpHeaderAccept?: 'application/json', context?: HttpContext, transferCache?: boolean}): Observable<any> {
|
||||
if (tournamentId === null || tournamentId === undefined) {
|
||||
throw new Error('Required parameter tournamentId was null or undefined when calling getTournamentOverview.');
|
||||
}
|
||||
|
||||
let localVarHeaders = this.defaultHeaders;
|
||||
|
||||
let localVarHttpHeaderAcceptSelected: string | undefined = options && options.httpHeaderAccept;
|
||||
if (localVarHttpHeaderAcceptSelected === undefined) {
|
||||
// to determine the Accept header
|
||||
const httpHeaderAccepts: string[] = [
|
||||
'application/json'
|
||||
];
|
||||
localVarHttpHeaderAcceptSelected = this.configuration.selectHeaderAccept(httpHeaderAccepts);
|
||||
}
|
||||
if (localVarHttpHeaderAcceptSelected !== undefined) {
|
||||
localVarHeaders = localVarHeaders.set('Accept', localVarHttpHeaderAcceptSelected);
|
||||
}
|
||||
|
||||
let localVarHttpContext: HttpContext | undefined = options && options.context;
|
||||
if (localVarHttpContext === undefined) {
|
||||
localVarHttpContext = new HttpContext();
|
||||
}
|
||||
|
||||
let localVarTransferCache: boolean | undefined = options && options.transferCache;
|
||||
if (localVarTransferCache === undefined) {
|
||||
localVarTransferCache = true;
|
||||
}
|
||||
|
||||
|
||||
let responseType_: 'text' | 'json' | 'blob' = 'json';
|
||||
if (localVarHttpHeaderAcceptSelected) {
|
||||
if (localVarHttpHeaderAcceptSelected.startsWith('text')) {
|
||||
responseType_ = 'text';
|
||||
} else if (this.configuration.isJsonMime(localVarHttpHeaderAcceptSelected)) {
|
||||
responseType_ = 'json';
|
||||
} else {
|
||||
responseType_ = 'blob';
|
||||
}
|
||||
}
|
||||
|
||||
let localVarPath = `/api/v1/tournaments/${this.configuration.encodeParam({name: "tournamentId", value: tournamentId, in: "path", style: "simple", explode: false, dataType: "number", dataFormat: "int64"})}`;
|
||||
return this.httpClient.request<TournamentOverviewDto>('get', `${this.configuration.basePath}${localVarPath}`,
|
||||
{
|
||||
context: localVarHttpContext,
|
||||
responseType: <any>responseType_,
|
||||
withCredentials: this.configuration.withCredentials,
|
||||
headers: localVarHeaders,
|
||||
observe: observe,
|
||||
transferCache: localVarTransferCache,
|
||||
reportProgress: reportProgress
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get teams for a tournament
|
||||
* @param id
|
||||
* @param id
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -564,8 +630,8 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Mark a team as ready for a tournament
|
||||
* @param tournamentId
|
||||
* @param teamId
|
||||
* @param tournamentId
|
||||
* @param teamId
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
@ -631,9 +697,9 @@ export class TournamentEndpointService {
|
|||
|
||||
/**
|
||||
* Create a new team
|
||||
* @param tournamentId
|
||||
* @param tournamentCreateTeamDto
|
||||
* @param token
|
||||
* @param tournamentId
|
||||
* @param tournamentCreateTeamDto
|
||||
* @param token
|
||||
* @param observe set whether or not to return the data Observable as the body, response or events. defaults to returning the body.
|
||||
* @param reportProgress flag to report request and response progress.
|
||||
*/
|
||||
|
|
|
@ -8,6 +8,7 @@ export * from './teamDto';
|
|||
export * from './tournamentCreateTeamDto';
|
||||
export * from './tournamentDto';
|
||||
export * from './tournamentListDto';
|
||||
export * from './tournamentOverviewDto';
|
||||
export * from './tournamentQualificationMatchDto';
|
||||
export * from './tournamentQualificationMatchParticipantDto';
|
||||
export * from './tournamentSignupTeamResponseDto';
|
||||
|
|
28
frontend/openapi-generated/model/tournamentOverviewDto.ts
Normal file
28
frontend/openapi-generated/model/tournamentOverviewDto.ts
Normal file
|
@ -0,0 +1,28 @@
|
|||
/**
|
||||
* OpenAPI definition
|
||||
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
||||
*
|
||||
* The version of the OpenAPI document: v0
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface TournamentOverviewDto {
|
||||
name: string;
|
||||
registrationEnd: string;
|
||||
maxParticipants?: number;
|
||||
description?: string;
|
||||
allQualificationMatches: number;
|
||||
playedQualificationMatches: number;
|
||||
allKoMatches: number;
|
||||
playedKoMatches: number;
|
||||
teams: number;
|
||||
checkedInTeams: number;
|
||||
tables: number;
|
||||
tablesInUse?: number;
|
||||
}
|
||||
|
|
@ -1 +1,34 @@
|
|||
<p>tournament-overview works!</p>
|
||||
<div class="dashboard-container">
|
||||
<mat-card class="header-card">
|
||||
<div class="header">
|
||||
<div class="header-row">
|
||||
<div>Tournament Name: {{this.tournamentOverview?.name}}</div>
|
||||
<div>Description: {{this.tournamentOverview?.description}}</div>
|
||||
</div>
|
||||
<div class="header-row">
|
||||
<div>Maximum allowed participants: {{this.tournamentOverview?.maxParticipants}}</div>
|
||||
<div>End of registration: {{this.tournamentOverview?.registrationEnd}}</div>
|
||||
</div>
|
||||
<div class="button-container">
|
||||
<button mat-raised-button color="primary" (click)="navigateToAll()">All Tournaments</button>
|
||||
<button mat-raised-button color="warn" (click)="editTournament()">Edit</button>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
|
||||
<div class="cards">
|
||||
<mat-card class="card">
|
||||
<mat-card-title>Teams</mat-card-title>
|
||||
</mat-card>
|
||||
<mat-card class="card">
|
||||
<mat-card-title>Qualification</mat-card-title>
|
||||
</mat-card>
|
||||
<mat-card class="card">
|
||||
<mat-card-title>Tables</mat-card-title>
|
||||
</mat-card>
|
||||
<mat-card class="card">
|
||||
<mat-card-title>K.O.</mat-card-title>
|
||||
</mat-card>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
.dashboard-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.header-card {
|
||||
width: 98%;
|
||||
padding: 10px;
|
||||
margin: 1%;
|
||||
}
|
||||
|
||||
.header {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.cards {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.card {
|
||||
height: 150px;
|
||||
}
|
||||
|
||||
.button-container {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px; /* Optional: adds space between the buttons */
|
||||
}
|
|
@ -1,10 +1,60 @@
|
|||
import { Component } from '@angular/core';
|
||||
import { HttpErrorResponse } from '@angular/common/http';
|
||||
import { Component, inject, OnInit, input } from '@angular/core';
|
||||
import { MatSnackBar } from '@angular/material/snack-bar';
|
||||
import { ActivatedRoute, Route, Router } from '@angular/router';
|
||||
import { TournamentEndpointService, TournamentOverviewDto } from '@api';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tournament-overview',
|
||||
templateUrl: './tournament-overview.component.html',
|
||||
styleUrl: './tournament-overview.component.scss'
|
||||
})
|
||||
export class TournamentOverviewComponent {
|
||||
export class TournamentOverviewComponent implements OnInit {
|
||||
|
||||
tournamentOverview: TournamentOverviewDto | undefined;
|
||||
tournamentId: number = -1;
|
||||
|
||||
constructor(
|
||||
private tournamentService: TournamentEndpointService,
|
||||
private router: Router,
|
||||
private activeRoute: ActivatedRoute,
|
||||
private snackBar: MatSnackBar,
|
||||
) {
|
||||
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
this.activeRoute.params.subscribe( params => {
|
||||
this.tournamentId = params['tournamentId'];
|
||||
})
|
||||
this.tournamentService.getTournamentOverview(this.tournamentId).subscribe({
|
||||
next: (data: TournamentOverviewDto) => {
|
||||
this.tournamentOverview = data;
|
||||
},
|
||||
error: error => {
|
||||
this.defaultServiceErrorHandling(error);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
editTournament() {
|
||||
|
||||
}
|
||||
|
||||
navigateToAll() {
|
||||
this.router.navigate(['/tournaments']);
|
||||
}
|
||||
|
||||
private defaultServiceErrorHandling(error: HttpErrorResponse) {
|
||||
let errorMessage = '';
|
||||
if (typeof error.error === 'object') {
|
||||
errorMessage = error.error.error;
|
||||
} else {
|
||||
errorMessage = error.error;
|
||||
}
|
||||
this.snackBar.open(errorMessage, 'OK', {
|
||||
duration: 5000,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue