Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
softwaremagico committed Jun 20, 2024
2 parents ae3acef + 0a6ae00 commit 58c9216
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 29 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[![GitHub commit activity](https://img.shields.io/github/commit-activity/y/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![GitHub last commit](https://img.shields.io/github/last-commit/softwaremagico/KendoTournamentManager)](https://github.com/softwaremagico/KendoTournamentManager)
[![CircleCI](https://circleci.com/gh/softwaremagico/KendoTournamentManager.svg?style=shield)](https://circleci.com/gh/softwaremagico/KendoTournamentManager)
[![Time](https://img.shields.io/badge/development-636.5h-blueviolet.svg)]()
[![Time](https://img.shields.io/badge/development-637.5h-blueviolet.svg)]()

[![Powered by](https://img.shields.io/badge/powered%20by%20java-orange.svg?logo=OpenJDK&logoColor=white)]()
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=kendo-tournament-backend&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=kendo-tournament-backend)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public List<DuelDTO> getUntiesFromTournament(@Parameter(description = "Id of the
}


@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN')")
@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN', 'ROLE_PARTICIPANT')")
@Operation(summary = "Gets all untie duel where one participant is involved.", security = @SecurityRequirement(name = "bearerAuth"))
@GetMapping(value = "/participant/{participantId}/unties", produces = MediaType.APPLICATION_JSON_VALUE)
public List<DuelDTO> getUntiesFromParticipant(@Parameter(description = "Id of the participant.", required = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public List<FightDTO> createNext(@Parameter(description = "Id of an existing tou
}


@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN')")
@PreAuthorize("hasAnyRole('ROLE_VIEWER', 'ROLE_EDITOR', 'ROLE_ADMIN', 'ROLE_PARTICIPANT')")
@Operation(summary = "Gets all fights from competitor.", security = @SecurityRequirement(name = "bearerAuth"))
@GetMapping(value = "/competitor/{competitorId}", produces = MediaType.APPLICATION_JSON_VALUE)
public List<FightDTO> getByCompetitor(@Parameter(description = "Id of the competitor.", required = true)
Expand Down
20 changes: 2 additions & 18 deletions frontend/src/app/interceptors/logged-in.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,28 +38,12 @@ export class LoggedInService {
userLoginPageDependingOnRoles(context: string, params: string): boolean {
if (this.loginService.getJwtValue()) {
//Participant users must redirect to their statistcs.
if (localStorage.getItem('account') == 'participant' && !context.startsWith('/participants/statistics')) {
if (localStorage.getItem('account') == 'participant'
&& (!context.startsWith('/participants/statistics') && !context.startsWith('/participants/fights'))) {
this.router.navigate(['/participants/statistics']);
} else if (localStorage.getItem('account') == 'guest' && !context.startsWith('/tournaments/fights')) {
this.router.navigate(['/tournaments/fights']);
}
this.loginService.getUserRoles().subscribe((_roles: String[]): void => {
if (_roles.includes("viewer") || _roles.includes("editor") || _roles.includes("admin")) {
// Do nothing and navigate as usual.
} else if (_roles.includes("guest")) {
//Gets last tournament and redirects to fight list.
this.tournamentService.getLastUnlockedTournament().subscribe((_tournament: Tournament): void => {
//Path '/tournaments/fights' and '/fights/championship' does not call LoggedInService to avoid redirect loops.
if (_tournament) {
this.router.navigate(['/tournaments/fights'], {state: {tournamentId: _tournament.id}});
} else {
this.router.navigate(['/login']);
}
});
} else if (_roles.includes("participant")) {
this.router.navigate(['/participants/statistics']);
}
});
return true;
}
return this.whiteListedPages.includes(context);
Expand Down
2 changes: 2 additions & 0 deletions frontend/src/app/services/login.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ export class LoginService {
next: (authenticatedUser: AuthenticatedUser): void => {
this.setAuthenticatedUser(authenticatedUser, callback);
localStorage.setItem('account', 'guest');
debugger
localStorage.setItem('tournamentId', tournamentId + "");
},
error: (): void => {
this.router.navigate(["/"]);
Expand Down
4 changes: 3 additions & 1 deletion frontend/src/app/services/rbac/activity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export class ActivityService {
RbacActivity.CHECK_TOURNAMENT_BRACKETS,
RbacActivity.READ_TEAMS_RANKINGS,
RbacActivity.READ_COMPETITORS_RANKINGS,
RbacActivity.CAN_LOGOUT
RbacActivity.CAN_LOGOUT,
RbacActivity.VIEW_PARTICIPANT_FIGHTS,
RbacActivity.VIEW_PARTICIPANT_STATISTICS
];
}

Expand Down
1 change: 1 addition & 0 deletions frontend/src/app/services/rbac/rbac.activity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export enum RbacActivity {
UPLOAD_TOURNAMENT_ACCREDITATION = 'UPLOAD_TOURNAMENT_ACCREDITATION',
UPLOAD_TOURNAMENT_PHOTO = 'UPLOAD_TOURNAMENT_PHOTO',
VIEW_TOURNAMENT_STATISTICS = 'VIEW_TOURNAMENT_STATISTICS',
VIEW_PARTICIPANT_STATISTICS = 'VIEW_PARTICIPANT_STATISTICS',
VIEW_PARTICIPANT_FIGHTS = 'VIEW_PARTICIPANT_FIGHTS',

READ_ALL_ROLES = 'READ_ALL_ROLES',
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/app/views/fight-list/fight-list.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export class FightListComponent extends RbacBasedComponent implements OnInit, On
} else {
//Gets tournament from URL parameter (from QR codes).
this.tournamentId = Number(this.activatedRoute.snapshot.queryParamMap.get('tournamentId'));
if (!this.tournamentId) {
this.tournamentId = Number(localStorage.getItem('tournamentId'));
debugger
}
if (!this.tournamentId || isNaN(this.tournamentId)) {
this.goBackToTournament();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<div class="fights-table">
<div class="upper-menu">
<div class="cell">
<button (click)="goBackToUsers()"
*ngIf="(RbacActivity.READ_ALL_TOURNAMENTS | rbac : this.rbacService.getActivities())"
<button (click)="goBackToStatistics()"
*ngIf="(RbacActivity.VIEW_PARTICIPANT_STATISTICS | rbac : this.rbacService.getActivities())"
[matTooltipShowDelay]="500"
mat-button
matTooltip="{{'back' | translate}}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ export class ParticipantFightListComponent extends RbacBasedComponent implements
if (state['participantId'] && !isNaN(Number(state['participantId']))) {
this.participantId = Number(state['participantId']);
} else {
this.goBackToUsers();
this.goBackToStatistics();
}
}
}

goBackToUsers(): void {
goBackToStatistics(): void {
this.router.navigate(['/participants/statistics'], {state: {participantId: this.participantId}});
}

ngOnInit(): void {
if (this.participantId) {
this.initializeData();
} else {
this.goBackToUsers();
this.goBackToStatistics();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<basic-table [basicTableData]="basicTableData" [disableRow]="disableRow"></basic-table>
<div class="bottom-menu">
<button (click)="openStatistics()"
*ngIf="(RbacActivity.VIEW_TOURNAMENT_STATISTICS | rbac : this.rbacService.getActivities())"
*ngIf="(RbacActivity.VIEW_PARTICIPANT_STATISTICS | rbac : this.rbacService.getActivities())"
[disabled]="!basicTableData.selectedElement" [matTooltipShowDelay]="500"
color="primary" mat-button
matTooltip="{{'titleStatistics' | translate}}">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@

app-achievement-wall {
margin-top: 10px;
width: 270px;
width: 275px;
height: 245px;
}

Expand Down

0 comments on commit 58c9216

Please sign in to comment.