diff --git a/.idea/gradle.xml b/.idea/gradle.xml new file mode 100644 index 0000000..cac49ff --- /dev/null +++ b/.idea/gradle.xml @@ -0,0 +1,15 @@ + + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..eeec968 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,9 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml index a7e1300..cb90649 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -4,7 +4,7 @@ - + \ No newline at end of file diff --git a/FencerJudgeFront/src/app/components/essentials/footer/footer.component.html b/FencerJudgeFront/src/app/components/essentials/footer/footer.component.html index 01eca56..bd1e916 100644 --- a/FencerJudgeFront/src/app/components/essentials/footer/footer.component.html +++ b/FencerJudgeFront/src/app/components/essentials/footer/footer.component.html @@ -48,11 +48,6 @@
© FencerJudge - Tous droits réservés - Mentions légales - Cookies - Accessibilité - Nous contacter - Presse
diff --git a/FencerJudgeFront/src/app/services/matches/matches.service.ts b/FencerJudgeFront/src/app/services/matches/matches.service.ts index fef45dd..68cd948 100644 --- a/FencerJudgeFront/src/app/services/matches/matches.service.ts +++ b/FencerJudgeFront/src/app/services/matches/matches.service.ts @@ -1,81 +1,70 @@ import { Injectable } from '@angular/core'; -import { Observable, of } from 'rxjs'; -import { Matches, MatchState } from '@interfaces/matches'; +import { Observable, Subject, BehaviorSubject } from 'rxjs'; +import { Matches } from '@interfaces/matches'; @Injectable({ providedIn: 'root' }) export class MatchesService { - private matches: Matches[] = [ - { - id: 1, - refereeID: 10, - player1ID: 1, - score1: 15, - player2ID: 2, - score2: 13, - country: 'France', - city: 'Paris', - weapon: 'Fleuret', - date: new Date('2025-06-10T14:00:00'), - state: MatchState.OVER, - }, - { - id: 2, - refereeID: 11, - player1ID: 3, - score1: 5, - player2ID: 4, - score2: 7, - country: 'France', - city: 'Lyon', - weapon: 'Épée', - date: new Date('2025-06-15T10:00:00'), - state: MatchState.ONGOING, - }, - { - id: 3, - refereeID: 12, - player1ID: 5, - score1: 0, - player2ID: 6, - score2: 0, - country: 'Belgique', - city: 'Bruxelles', - weapon: 'Sabre', - date: new Date('2025-06-20T16:30:00'), - state: MatchState.NOT_STARTED, - }, - ]; + private socket?: WebSocket; + private matchUpdates$ = new Subject(); + private allMatches: Matches[] = []; constructor() { - console.log('[MatchesService] Initial matches loaded:', this.matches); + this.connectToMatchUpdatesWebSocket(); + } + + private connectToMatchUpdatesWebSocket(): void { + const wsUrl = 'ws://localhost:8080/ws/matches'; + this.socket = new WebSocket(wsUrl); + + this.socket.onopen = () => { + console.log('[WebSocket] ✅ Connecté à', wsUrl); + }; + + this.socket.onmessage = (event) => { + try { + const data = JSON.parse(event.data) as Matches[]; + console.log('[WebSocket] 📥 Données reçues :', data); + this.matchUpdates$.next(data); + } catch (e) { + console.error('[WebSocket] ❌ Erreur de parsing JSON', e); + } + }; + + this.socket.onerror = (err) => { + console.error('[WebSocket] ❌ Erreur :', err); + }; + + this.socket.onclose = () => { + console.warn('[WebSocket] 🔌 Fermeture de la connexion'); + }; } getMatches(): Observable { - console.log('[MatchesService] Fetching all matches'); - return of(this.matches); + return this.matchUpdates$.asObservable(); } getMatchById(id: number): Observable { - const match = this.matches.find((m) => m.id === id); - console.log(`[MatchesService] Fetching match ID: ${id}`, match); - return of(match); - } - - // Préparation future pour WebSocket - connectToMatchUpdatesWebSocket(): void { - console.log( - '[MatchesService] WebSocket connection placeholder initialized' - ); - // ici tu pourrais plus tard faire : this.socket = new WebSocket('ws://...') etc. + const match = this.allMatches.find((m) => m.id === id); + console.log(`[MatchesService] Match ID ${id} récupéré :`, match); + return new BehaviorSubject(match).asObservable(); } updateMatch(id: number, updatedData: Partial): void { - const match = this.matches.find((m) => m.id === id); - if (match) { - Object.assign(match, updatedData); - console.log(`[MatchesService] Match ${id} mis à jour :`, match); + const matchIndex = this.allMatches.findIndex((m) => m.id === id); + if (matchIndex !== -1) { + const updatedMatch = { ...this.allMatches[matchIndex], ...updatedData }; + this.allMatches[matchIndex] = updatedMatch; + this.matchUpdates$.next([...this.allMatches]); // émettre un nouveau tableau + console.log( + `[MatchesService] Match ${id} mis à jour localement :`, + updatedMatch + ); } else { - console.warn(`[MatchesService] Match ${id} introuvable`); + console.warn(`[MatchesService] Match ${id} non trouvé pour mise à jour`); } } + + ngOnDestroy(): void { + this.socket?.close(); + } } diff --git a/db.lock.db b/db.lock.db new file mode 100644 index 0000000..9c75c64 --- /dev/null +++ b/db.lock.db @@ -0,0 +1,6 @@ +#FileLock +#Mon Jun 02 17:12:33 CEST 2025 +hostName=ExostFlash +id=197313393c88a931fa21bf5ce1281b7253870b00683 +method=file +server=192.167.2.100\:54366 diff --git a/db.mv.db b/db.mv.db new file mode 100644 index 0000000..b765537 Binary files /dev/null and b/db.mv.db differ diff --git a/jpe-controle.iml b/jpe-controle.iml index 9a5cfce..b081e58 100644 --- a/jpe-controle.iml +++ b/jpe-controle.iml @@ -4,5 +4,6 @@ +
\ No newline at end of file