Add interfaces & services
This commit is contained in:
parent
224aaf94a6
commit
a6cd64dd5d
14 changed files with 248 additions and 6 deletions
|
|
@ -4,7 +4,7 @@ import { Component } from '@angular/core';
|
||||||
selector: 'app-root',
|
selector: 'app-root',
|
||||||
templateUrl: './app.component.html',
|
templateUrl: './app.component.html',
|
||||||
standalone: false,
|
standalone: false,
|
||||||
styleUrl: './app.component.css'
|
styleUrl: './app.component.css',
|
||||||
})
|
})
|
||||||
export class AppComponent {
|
export class AppComponent {
|
||||||
title = 'FencerJudgeFront';
|
title = 'FencerJudgeFront';
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,6 @@ import { Component } from '@angular/core';
|
||||||
selector: 'app-header',
|
selector: 'app-header',
|
||||||
standalone: false,
|
standalone: false,
|
||||||
templateUrl: './header.component.html',
|
templateUrl: './header.component.html',
|
||||||
styleUrl: './header.component.css'
|
styleUrl: './header.component.css',
|
||||||
})
|
})
|
||||||
export class HeaderComponent {
|
export class HeaderComponent {}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
|
||||||
19
FencerJudgeFront/src/app/interfaces/matches.ts
Normal file
19
FencerJudgeFront/src/app/interfaces/matches.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
export enum MatchState {
|
||||||
|
ONGOING = 1,
|
||||||
|
OVER = 2,
|
||||||
|
NOT_STARTED = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Matches {
|
||||||
|
id: number;
|
||||||
|
refereeID: number;
|
||||||
|
player1ID: number;
|
||||||
|
score1: number;
|
||||||
|
player2ID: number;
|
||||||
|
score2: number;
|
||||||
|
country: String;
|
||||||
|
city: String;
|
||||||
|
weapon: String;
|
||||||
|
date: Date;
|
||||||
|
state: MatchState;
|
||||||
|
}
|
||||||
5
FencerJudgeFront/src/app/interfaces/models/user.model.ts
Normal file
5
FencerJudgeFront/src/app/interfaces/models/user.model.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
export interface UserModel {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
firstName: string;
|
||||||
|
}
|
||||||
5
FencerJudgeFront/src/app/interfaces/player.ts
Normal file
5
FencerJudgeFront/src/app/interfaces/player.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { UserModel } from './models/user.model';
|
||||||
|
|
||||||
|
export interface Player extends UserModel {
|
||||||
|
club: string;
|
||||||
|
}
|
||||||
12
FencerJudgeFront/src/app/interfaces/referee.ts
Normal file
12
FencerJudgeFront/src/app/interfaces/referee.ts
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
import { UserModel } from './models/user.model';
|
||||||
|
|
||||||
|
export enum RefereeLevel {
|
||||||
|
DEPARTMENTAL = 0,
|
||||||
|
REGIONAL = 1,
|
||||||
|
NATIONAL = 2,
|
||||||
|
INTERNATIONAL = 3,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Referee extends UserModel {
|
||||||
|
level: RefereeLevel;
|
||||||
|
}
|
||||||
16
FencerJudgeFront/src/app/services/matches.service.spec.ts
Normal file
16
FencerJudgeFront/src/app/services/matches.service.spec.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { MatchesService } from './matches.service';
|
||||||
|
|
||||||
|
describe('MatchesService', () => {
|
||||||
|
let service: MatchesService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(MatchesService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
71
FencerJudgeFront/src/app/services/matches.service.ts
Normal file
71
FencerJudgeFront/src/app/services/matches.service.ts
Normal file
|
|
@ -0,0 +1,71 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
import { Matches, MatchState } 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,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
console.log('[MatchesService] Initial matches loaded:', this.matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
getMatches(): Observable<Matches[]> {
|
||||||
|
console.log('[MatchesService] Fetching all matches');
|
||||||
|
return of(this.matches);
|
||||||
|
}
|
||||||
|
|
||||||
|
getMatchById(id: number): Observable<Matches | undefined> {
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
}
|
||||||
16
FencerJudgeFront/src/app/services/player.service.spec.ts
Normal file
16
FencerJudgeFront/src/app/services/player.service.spec.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { PlayerService } from './player.service';
|
||||||
|
|
||||||
|
describe('PlayerService', () => {
|
||||||
|
let service: PlayerService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(PlayerService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
30
FencerJudgeFront/src/app/services/player.service.ts
Normal file
30
FencerJudgeFront/src/app/services/player.service.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
import { Player } from '@interfaces/player';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class PlayerService {
|
||||||
|
private players: Player[] = [
|
||||||
|
{ id: 1, name: 'Martin', firstName: 'Alex', club: 'Lille Escrime' },
|
||||||
|
{ id: 2, name: 'Nguyen', firstName: 'Sophie', club: 'Paris Epée' },
|
||||||
|
{ id: 3, name: 'Klein', firstName: 'Thomas', club: 'Strasbourg Sabre' },
|
||||||
|
{ id: 4, name: 'Leclerc', firstName: 'Lucie', club: 'Nice Fleuret' },
|
||||||
|
{ id: 5, name: 'Dubois', firstName: 'Hugo', club: 'Lyon Epée' },
|
||||||
|
{ id: 6, name: 'Girard', firstName: 'Manon', club: 'Marseille Club' },
|
||||||
|
];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
console.log('[PlayerService] Initial players loaded:', this.players);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlayers(): Observable<Player[]> {
|
||||||
|
console.log('[PlayerService] Fetching all players');
|
||||||
|
return of(this.players);
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlayerById(id: number): Observable<Player | undefined> {
|
||||||
|
const player = this.players.find((p) => p.id === id);
|
||||||
|
console.log(`[PlayerService] Fetching player ID: ${id}`, player);
|
||||||
|
return of(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
FencerJudgeFront/src/app/services/referee.service.spec.ts
Normal file
16
FencerJudgeFront/src/app/services/referee.service.spec.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { TestBed } from '@angular/core/testing';
|
||||||
|
|
||||||
|
import { RefereeService } from './referee.service';
|
||||||
|
|
||||||
|
describe('RefereeService', () => {
|
||||||
|
let service: RefereeService;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
TestBed.configureTestingModule({});
|
||||||
|
service = TestBed.inject(RefereeService);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should be created', () => {
|
||||||
|
expect(service).toBeTruthy();
|
||||||
|
});
|
||||||
|
});
|
||||||
42
FencerJudgeFront/src/app/services/referee.service.ts
Normal file
42
FencerJudgeFront/src/app/services/referee.service.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
import { Injectable } from '@angular/core';
|
||||||
|
import { Observable, of } from 'rxjs';
|
||||||
|
import { Referee, RefereeLevel } from '@interfaces/referee';
|
||||||
|
|
||||||
|
@Injectable({ providedIn: 'root' })
|
||||||
|
export class RefereeService {
|
||||||
|
private referees: Referee[] = [
|
||||||
|
{
|
||||||
|
id: 10,
|
||||||
|
name: 'Durand',
|
||||||
|
firstName: 'Pierre',
|
||||||
|
level: RefereeLevel.NATIONAL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 11,
|
||||||
|
name: 'Lemoine',
|
||||||
|
firstName: 'Anna',
|
||||||
|
level: RefereeLevel.REGIONAL,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 12,
|
||||||
|
name: 'Morel',
|
||||||
|
firstName: 'Lucas',
|
||||||
|
level: RefereeLevel.DEPARTMENTAL,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
constructor() {
|
||||||
|
console.log('[RefereeService] Initial referees loaded:', this.referees);
|
||||||
|
}
|
||||||
|
|
||||||
|
getReferees(): Observable<Referee[]> {
|
||||||
|
console.log('[RefereeService] Fetching all referees');
|
||||||
|
return of(this.referees);
|
||||||
|
}
|
||||||
|
|
||||||
|
getRefereeById(id: number): Observable<Referee | undefined> {
|
||||||
|
const ref = this.referees.find((r) => r.id === id);
|
||||||
|
console.log(`[RefereeService] Fetching referee ID: ${id}`, ref);
|
||||||
|
return of(ref);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -16,7 +16,13 @@
|
||||||
"moduleResolution": "bundler",
|
"moduleResolution": "bundler",
|
||||||
"importHelpers": true,
|
"importHelpers": true,
|
||||||
"target": "ES2022",
|
"target": "ES2022",
|
||||||
"module": "ES2022"
|
"module": "ES2022",
|
||||||
|
"baseUrl": "./src",
|
||||||
|
"paths": {
|
||||||
|
"@interfaces/*": ["app/interfaces/*"],
|
||||||
|
"@services/*": ["app/services/*"],
|
||||||
|
"@utils/*": ["app/utils/*"]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"angularCompilerOptions": {
|
"angularCompilerOptions": {
|
||||||
"enableI18nLegacyMessageIdFormat": false,
|
"enableI18nLegacyMessageIdFormat": false,
|
||||||
|
|
|
||||||
6
package-lock.json
generated
Normal file
6
package-lock.json
generated
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
{
|
||||||
|
"name": "jpe-controle",
|
||||||
|
"lockfileVersion": 3,
|
||||||
|
"requires": true,
|
||||||
|
"packages": {}
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue