Skip to content

Commit dd45271

Browse files
authored
Merge pull request #168 from LeadOn/develop
Everything is cleaner now
2 parents 0a4cecf + 07efb59 commit dd45271

34 files changed

Lines changed: 370 additions & 480 deletions

package-lock.json

Lines changed: 150 additions & 150 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "gameon-front",
3-
"version": "4.3.0",
3+
"version": "4.4.0",
44
"scripts": {
55
"ng": "ng",
66
"start": "ng serve",
@@ -10,15 +10,15 @@
1010
},
1111
"private": true,
1212
"dependencies": {
13-
"@angular/animations": "^19.0.5",
14-
"@angular/cdk": "^19.0.4",
15-
"@angular/common": "^19.0.5",
16-
"@angular/compiler": "^19.0.5",
17-
"@angular/core": "^19.0.5",
18-
"@angular/forms": "^19.0.5",
19-
"@angular/platform-browser": "^19.0.5",
20-
"@angular/platform-browser-dynamic": "^19.0.5",
21-
"@angular/router": "^19.0.5",
13+
"@angular/animations": "^19.0.6",
14+
"@angular/cdk": "^19.0.5",
15+
"@angular/common": "^19.0.6",
16+
"@angular/compiler": "^19.0.6",
17+
"@angular/core": "^19.0.6",
18+
"@angular/forms": "^19.0.6",
19+
"@angular/platform-browser": "^19.0.6",
20+
"@angular/platform-browser-dynamic": "^19.0.6",
21+
"@angular/router": "^19.0.6",
2222
"@fortawesome/angular-fontawesome": "^1.0.0",
2323
"@fortawesome/free-solid-svg-icons": "^6.7.2",
2424
"@ngrx/store": "^19.0.0",
@@ -32,9 +32,9 @@
3232
"zone.js": "~0.15.0"
3333
},
3434
"devDependencies": {
35-
"@angular-devkit/build-angular": "^19.0.6",
36-
"@angular/cli": "^19.0.6",
37-
"@angular/compiler-cli": "^19.0.5",
35+
"@angular-devkit/build-angular": "^19.0.7",
36+
"@angular/cli": "^19.0.7",
37+
"@angular/compiler-cli": "^19.0.6",
3838
"@types/jasmine": "~5.1.0",
3939
"autoprefixer": "^10.4.20",
4040
"jasmine-core": "~5.1.0",

src/app/admin/admin-routing.module.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { NgModule } from '@angular/core';
22
import { RouterModule, Routes } from '@angular/router';
33
import { AdminHomeComponent } from './home/admin-home.component';
4-
import { AuthGuard } from '../shared/guards/auth.guard';
54
import { AdminLayoutComponent } from './admin-layout.component';
65
import { AdminPlatformsComponent } from './platforms/admin-platforms.component';
76
import { AdminPlatformEditComponent } from './platforms/edit/admin-platform-edit.component';
@@ -14,13 +13,14 @@ import { AdminSeasonsComponent } from './seasons/admin-seasons.component';
1413
import { AdminEditTournamentComponent } from './tournaments/edit/admin-edit-tournament.component';
1514
import { AdminCreateTournamentComponent } from './tournaments/create/admin-create-tournament.component';
1615
import { AdminTournamentsComponent } from './tournaments/admin-tournaments.component';
16+
import { canActivateAuthRole } from '../shared/guards/auth.guard';
1717

1818
const routes: Routes = [
1919
{
2020
path: '',
2121
component: AdminLayoutComponent,
22-
canActivate: [AuthGuard],
23-
data: { roles: ['gameon_admin'] },
22+
canActivate: [canActivateAuthRole],
23+
data: { role: 'gameon_admin' },
2424
children: [
2525
{
2626
path: '',

src/app/app-routing.module.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { CommonLayoutComponent } from './shared/layouts/common-layout.component'
44
import { NotFoundComponent } from './shared/components/not-found/not-found.component';
55
import { HomeComponent } from './home/home.component';
66
import { ProfilePageComponent } from './players/me/profile.component';
7-
import { AuthGuard } from './shared/guards/auth.guard';
7+
import { canActivateAuthRole } from './shared/guards/auth.guard';
88
import { PlayerDetailsComponent } from './players/details/player-details.component';
99
import { ChangelogComponent } from './changelog/changelog.component';
1010
import { DonateComponent } from './donate/donate.component';
@@ -15,7 +15,7 @@ import { LolHomeComponent } from './lol/lol-home.component';
1515
import { LolPlayerDetailsComponent } from './lol/player/lol-player-details.component';
1616
import { LolGameDetailsComponent } from './lol/games/details/lol-game-details.component';
1717

18-
const routes: Routes = [
18+
export const routes: Routes = [
1919
{
2020
path: '',
2121
component: CommonLayoutComponent,
@@ -51,7 +51,8 @@ const routes: Routes = [
5151
{
5252
path: 'player/me',
5353
component: ProfilePageComponent,
54-
canActivate: [AuthGuard],
54+
canActivate: [canActivateAuthRole],
55+
data: { role: 'default-roles-gameon' },
5556
},
5657
{
5758
path: 'player/:id',

src/app/app.component.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Component, OnInit } from '@angular/core';
1+
import { Component, inject, OnInit } from '@angular/core';
22
import { initFlowbite } from 'flowbite';
3-
import { KeycloakService } from 'keycloak-angular';
43
import { Store } from '@ngrx/store';
54
import { setPlayer, setPlayerStats } from './store/actions/player.actions';
65
import { Player } from './shared/classes/common/Player';
76
import { GameOnPlayerService } from './shared/services/common/gameon-player.service';
7+
import Keycloak from 'keycloak-js';
88

99
@Component({
1010
selector: 'app-root',
@@ -13,16 +13,24 @@ import { GameOnPlayerService } from './shared/services/common/gameon-player.serv
1313
standalone: false,
1414
})
1515
export class AppComponent implements OnInit {
16+
private readonly keycloak = inject(Keycloak);
17+
18+
isLoggedIn = false;
19+
1620
constructor(
17-
private keycloak: KeycloakService,
1821
private playerService: GameOnPlayerService,
1922
private store: Store<{ player: Player }>
2023
) {}
2124

2225
ngOnInit(): void {
2326
initFlowbite();
2427

25-
if (this.keycloak.isLoggedIn()) {
28+
this.isLoggedIn =
29+
this.keycloak.authenticated != null && this.keycloak.authenticated
30+
? true
31+
: false;
32+
33+
if (this.isLoggedIn) {
2634
// Getting its account, and setting it into store
2735
this.playerService.getCurrent().subscribe(
2836
(data) => {

src/app/app.module.ts

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
1-
import { APP_INITIALIZER, NgModule } from '@angular/core';
1+
import { NgModule } from '@angular/core';
22
import { BrowserModule } from '@angular/platform-browser';
3-
import { KeycloakAngularModule, KeycloakService } from 'keycloak-angular';
3+
import {
4+
createInterceptorCondition,
5+
INCLUDE_BEARER_TOKEN_INTERCEPTOR_CONFIG,
6+
IncludeBearerTokenCondition,
7+
includeBearerTokenInterceptor,
8+
provideKeycloak,
9+
} from 'keycloak-angular';
410
import { AppRoutingModule } from './app-routing.module';
511
import { AppComponent } from './app.component';
612
import { environment } from '../environments/environment';
713
import { SharedModule } from './shared/modules/shared.module';
814
import { CommonLayoutComponent } from './shared/layouts/common-layout.component';
9-
import { HttpClientModule } from '@angular/common/http';
15+
import { provideHttpClient, withInterceptors } from '@angular/common/http';
1016
import { HomeComponent } from './home/home.component';
1117
import { FontAwesomeModule } from '@fortawesome/angular-fontawesome';
1218
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@@ -34,21 +40,15 @@ import { HomeChangelogComponent } from './home/components/changelog/home-changel
3440
import { HomeFifaComponent } from './home/components/fifa/home-fifa.component';
3541
import { HomeLolComponent } from './home/components/lol/home-lol.component';
3642

37-
function initializeKeycloak(keycloak: KeycloakService) {
38-
return () =>
39-
keycloak.init({
40-
config: {
41-
url: environment.keycloak.url,
42-
realm: environment.keycloak.realm,
43-
clientId: environment.keycloak.clientId,
44-
},
45-
initOptions: {
46-
onLoad: 'check-sso',
47-
silentCheckSsoRedirectUri:
48-
window.location.origin + '/assets/silent-check-sso.html',
49-
},
50-
});
51-
}
43+
const devCondition = createInterceptorCondition<IncludeBearerTokenCondition>({
44+
urlPattern: /^(http:\/\/localhost:5184)(\/.*)?$/i,
45+
bearerPrefix: 'Bearer',
46+
});
47+
48+
const prodCondition = createInterceptorCondition<IncludeBearerTokenCondition>({
49+
urlPattern: /^(https:\/\/gameon-api.valentinvirot.fr)(\/.*)?$/i,
50+
bearerPrefix: 'Bearer',
51+
});
5252

5353
@NgModule({
5454
declarations: [
@@ -75,25 +75,33 @@ function initializeKeycloak(keycloak: KeycloakService) {
7575
imports: [
7676
BrowserModule,
7777
AppRoutingModule,
78-
KeycloakAngularModule,
7978
SharedModule,
8079
FontAwesomeModule,
8180
BrowserAnimationsModule,
8281
StoreModule.forRoot({
8382
player: playerReducer,
8483
globalStats: playerStatsReducer,
8584
}),
86-
HttpClientModule,
8785
ClipboardModule,
8886
AdminModule,
8987
],
9088
providers: [
89+
provideKeycloak({
90+
config: {
91+
url: environment.keycloak.url,
92+
realm: environment.keycloak.realm,
93+
clientId: environment.keycloak.clientId,
94+
},
95+
initOptions: {
96+
onLoad: 'check-sso',
97+
silentCheckSsoRedirectUri: `${window.location.origin}/assets/silent-check-sso.html`,
98+
},
99+
}),
91100
{
92-
provide: APP_INITIALIZER,
93-
useFactory: initializeKeycloak,
94-
multi: true,
95-
deps: [KeycloakService],
101+
provide: INCLUDE_BEARER_TOKEN_INTERCEPTOR_CONFIG,
102+
useValue: [devCondition, prodCondition],
96103
},
104+
provideHttpClient(withInterceptors([includeBearerTokenInterceptor])),
97105
],
98106
bootstrap: [AppComponent],
99107
})

src/app/donate/donate.component.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<section id="top-card" class="px-4 pt-4">
2-
<div [@inOutAnimation]>
2+
<div>
33
<app-common-page-header
44
[icon]="btcIcon"
55
[title]="'Me soutenir'"

src/app/fifa/components/fifa-game-history-card/fifa-game-history-card.component.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import { Component, Input } from '@angular/core';
1+
import { Component, inject, Input } from '@angular/core';
22
import {
33
faEdit,
44
faExternalLinkAlt,
55
faTrash,
66
} from '@fortawesome/free-solid-svg-icons';
7-
import { KeycloakService } from 'keycloak-angular';
87
import { GameOnAdminService } from '../../../admin/shared/services/gameon-admin.service';
98
import { FifaGamePlayed } from '../../../shared/classes/fifa/FifaGamePlayed';
9+
import Keycloak from 'keycloak-js';
1010

1111
@Component({
1212
selector: 'app-fifa-game-history-card',
@@ -15,6 +15,8 @@ import { FifaGamePlayed } from '../../../shared/classes/fifa/FifaGamePlayed';
1515
standalone: false,
1616
})
1717
export class FifaGameHistoryCardComponent {
18+
private readonly keycloak = inject(Keycloak);
19+
1820
@Input()
1921
game: FifaGamePlayed = new FifaGamePlayed();
2022

@@ -27,18 +29,15 @@ export class FifaGameHistoryCardComponent {
2729

2830
isAdmin = false;
2931

30-
constructor(
31-
private adminService: GameOnAdminService,
32-
private keycloakService: KeycloakService
33-
) {
34-
if (keycloakService.isUserInRole('gameon_admin')) {
32+
constructor(private adminService: GameOnAdminService) {
33+
if (this.keycloak.hasRealmRole('gameon_admin')) {
3534
this.isAdmin = true;
3635
}
3736
}
3837

3938
deleteGame(game: FifaGamePlayed) {
4039
if (
41-
this.keycloakService.isUserInRole('gameon_admin') &&
40+
this.isAdmin &&
4241
confirm(
4342
'Voulez-vous vraiment supprimer le match ' +
4443
game.id +

src/app/fifa/create/fifa-create-game.component.html

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
1-
<section id="fifa-header" class="px-4 pt-4" [@inOutAnimation]>
1+
<section id="fifa-header" class="px-4 pt-4">
22
<app-common-page-header
33
[icon]="footballIcon"
44
[title]="'Création match'"
55
></app-common-page-header>
66
</section>
77

88
<section id="top-card" class="px-4 mt-4">
9-
<app-loading-spinner
10-
*ngIf="isLoading == true"
11-
[@inOutAnimation]
12-
></app-loading-spinner>
9+
<app-loading-spinner *ngIf="isLoading == true"></app-loading-spinner>
1310
</section>
1411

1512
<form
1613
[formGroup]="createGameForm"
1714
class="flex flex-col"
18-
[@inOutAnimation]
1915
*ngIf="isLoading == false"
2016
>
21-
<div class="px-4 mt-4 flex" [@inOutAnimation]>
17+
<div class="px-4 mt-4 flex">
2218
<span class="text-lg font-semibold text-primary dark:text-primaryDark"
2319
>Équipe #1</span
2420
>
@@ -94,7 +90,7 @@
9490
</div>
9591
</div>
9692

97-
<div class="px-4 mt-4 flex" [@inOutAnimation]>
93+
<div class="px-4 mt-4 flex">
9894
<span class="text-lg font-semibold text-primary dark:text-primaryDark"
9995
>Équipe #2</span
10096
>
@@ -170,7 +166,7 @@
170166
</div>
171167
</div>
172168

173-
<div class="px-4 mt-4 flex" [@inOutAnimation]>
169+
<div class="px-4 mt-4 flex">
174170
<span class="text-lg font-semibold text-primary dark:text-primaryDark"
175171
>Plateforme</span
176172
>
@@ -191,7 +187,7 @@
191187
</div>
192188
</form>
193189

194-
<div class="px-4 mt-4 flex" [@inOutAnimation] *ngIf="isLoading == false">
190+
<div class="px-4 mt-4 flex" *ngIf="isLoading == false">
195191
<button
196192
(click)="createGame()"
197193
class="drop-shadow-lg text-white bg-customGreen hover:bg-green-800 focus:ring-4 focus:outline-none focus:ring-customGreen font-medium rounded-lg text-sm w-full px-5 py-2.5 text-center"

src/app/fifa/create/fifa-create-game.component.ts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { formatDate } from '@angular/common';
22
import { Component, OnInit } from '@angular/core';
33
import { FormControl, FormGroup, Validators } from '@angular/forms';
44
import { Router } from '@angular/router';
5-
import { trigger, style, animate, transition } from '@angular/animations';
65
import { faSoccerBall } from '@fortawesome/free-solid-svg-icons';
76
import { GameOnPlayerService } from '../../shared/services/common/gameon-player.service';
87
import { Player } from '../../shared/classes/common/Player';
@@ -16,18 +15,6 @@ import { GameOnFifaTeamService } from '../../shared/services/fifa/gameon-fifatea
1615
selector: 'app-fifa-create-game',
1716
templateUrl: './fifa-create-game.component.html',
1817
styleUrls: ['./fifa-create-game.component.scss'],
19-
animations: [
20-
trigger('inOutAnimation', [
21-
transition(':enter', [
22-
style({ opacity: 0 }),
23-
animate(200, style({ opacity: 1 })),
24-
]),
25-
transition(':leave', [
26-
style({ opacity: 1 }),
27-
animate(200, style({ opacity: 0 })),
28-
]),
29-
]),
30-
],
3118
standalone: false,
3219
})
3320
export class FifaCreateGameComponent implements OnInit {

0 commit comments

Comments
 (0)