✔Modifications du model de l'appli et ajout d'un stub 📚, avancement.

Backend/model
mohamed 2 years ago
parent 9433a61ed7
commit 9f0b7c720f

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

@ -1,18 +1,12 @@
export class Geocalisation { export class Geocalisation {
readonly id: number;
private gpsLat: number; private gpsLat: number;
private gpsLong: number; private gpsLong: number;
constructor(id: number, gpsLat: number, gpsLong: number) { constructor(gpsLat: number, gpsLong: number) {
this.id = id;
this.gpsLat = gpsLat; this.gpsLat = gpsLat;
this.gpsLong = gpsLong; this.gpsLong = gpsLong;
} }
getId() {
return this.id;
}
getGpsLat() { getGpsLat() {
return this.gpsLat; return this.gpsLat;
} }

@ -0,0 +1,7 @@
import { Session } from "./Session";
export interface ILoader{
Load() : Session
LoadFromFile(file : File) : Session
}

@ -1,24 +1,27 @@
import { Point } from "./Point"; import { Point } from "./Point";
export class Lap { export class Lap {
readonly id: number; private number : number;
private points: Point[]; private points: Point[];
private time: number; private time: number;
constructor(id: number, points: Point[], time: number) { constructor(number: number,points: Point[], time: number) {
this.id = id; this.number = number;
this.points = points; this.points = points;
this.time = time; this.time = time;
} }
getId() { getNumber(){
return this.id; return this.number;
}
setNumber(){
return this.number;
} }
getPoints() { getPoints() {
return this.points; return this.points;
} }
setPoints(points: Point[]) { setPoints(points: Point[]) {
this.points = points; this.points = points;
} }
@ -26,7 +29,6 @@ export class Lap {
getTime() { getTime() {
return this.time; return this.time;
} }
setTime(time: number) { setTime(time: number) {
this.time = time; this.time = time;
} }

@ -0,0 +1,12 @@
import { ILoader } from "./ILoader";
import { Session } from "./Session";
export class LoadDB implements ILoader{
LoadFromFile(file: File): Session {
throw new Error("file argument is not accepted !."); // GARDER EN NON IMPLEMENTED !
}
Load(): Session {
throw new Error("Method not implemented."); // APPEL API
}
}

@ -0,0 +1,13 @@
import { ILoader } from "./ILoader";
import { Session } from "./Session";
export class LoadXLS implements ILoader{
LoadFromFile(file: File): Session {
throw new Error("Method not implemented."); // APPEL API RETOUR JSON
}
Load(): Session {
throw new Error("Cannot load without a file."); // GARDER EN NON IMPLEMENTED !
}
}

@ -3,7 +3,7 @@ import { Team } from "./Team";
import { User } from "./User"; import { User } from "./User";
export class Member extends User { export class Member extends User {
constructor(id: number, pseudo: string, password: string, email: string, sessions: Session[], team: Team) { constructor(username: string, password: string, email: string, sessions: Session[],image : HTMLImageElement= require('../assets/images/user.jpg')) {
super(id, pseudo, password, email, sessions, team); super(username, password, email, sessions, image);
} }
} }

@ -3,7 +3,11 @@ import { Team } from "./Team";
import { User } from "./User"; import { User } from "./User";
export class Owner extends User { export class Owner extends User {
constructor(id: number, pseudo: string, password: string, email: string, sessions: Session[], team: Team) { constructor( username: string, password: string, email: string, sessions: Session[],image : HTMLImageElement= require('../assets/images/user.jpg')) {
super(id, pseudo, password, email, sessions, team); super(username, password, email, sessions,image);
}
IsOwner(): boolean{
return true;
} }
} }

@ -1,7 +1,6 @@
import { Geocalisation } from "./Geocalisation"; import { Geocalisation } from "./Geocalisation";
export class Point { export class Point {
readonly id: number;
private geo: Geocalisation; private geo: Geocalisation;
private timer: number; private timer: number;
private distance: number; private distance: number;
@ -13,8 +12,7 @@ export class Point {
private gLat: number; private gLat: number;
private vCar: number; private vCar: number;
constructor(id: number, geo: Geocalisation, timer: number, distance: number, nGear: number, pBrakeF: number, aSteer: number, rPedal: number, gLong: number, gLat: number, vCar: number) { constructor( geo: Geocalisation, timer: number, distance: number, nGear: number, pBrakeF: number, aSteer: number, rPedal: number, gLong: number, gLat: number, vCar: number) {
this.id = id;
this.geo = geo; this.geo = geo;
this.timer = timer; this.timer = timer;
this.distance = distance; this.distance = distance;
@ -26,11 +24,6 @@ export class Point {
this.gLat = gLat; this.gLat = gLat;
this.vCar = vCar; this.vCar = vCar;
} }
getId() {
return this.id;
}
getGeo() { getGeo() {
return this.geo; return this.geo;
} }

@ -1,20 +1,23 @@
import { Lap } from "./Lap"; import { Lap } from "./Lap";
export class Session { export class Session {
readonly id: number;
private name: string; private name: string;
private type: SessionType;
private laps: Lap[]; private laps: Lap[];
constructor(id: number, name: string, laps: Lap[]) { constructor( name: string, laps: Lap[], type: SessionType = SessionType.Unknown) {
this.id = id; this.type = type
this.name = name; this.name = name;
this.laps = laps; this.laps = laps;
} }
getType() {
getId() { return this.type;
return this.id;
} }
setType(type: SessionType) {
this.type = type;
}
getName() { getName() {
return this.name; return this.name;
} }

@ -3,11 +3,11 @@ import { SessionBuilder } from "./SessionBuilder";
export class StandartSessionBuilder extends SessionBuilder { export class StandartSessionBuilder extends SessionBuilder {
BuildSession() { BuildSession() {
PointBuilder(); //PointBuilder();
} }
PointBuilder() { PointBuilder() {
new Point(); //new Point();
} }
} }

@ -1,25 +1,19 @@
import { User } from "./User"; import { User } from "./User";
import { WaitingMember } from "./WaitingMember";
export class Team { export class Team {
readonly id: number;
private name: string; private name: string;
private owner: User; private owner: User;
private members: User[]; private users: User[];
private logo: File; private logo: HTMLImageElement;
private waitList: User[];
constructor(id: number, name: string, owner: User,members: User[] = null, logo: File = null, waitList: User[] = null) { constructor(name: string, owner: User,users: User[] = [], logo: HTMLImageElement = require('../assets/images/people.jpg')) {
this.id = id;
this.name = name; this.name = name;
this.owner = owner; this.owner = owner;
this.members = members; this.users = users;
this.logo = logo; this.logo = logo;
this.waitList = waitList;
} }
getId() {
return this.id;
}
getName() { getName() {
return this.name; return this.name;
@ -37,27 +31,37 @@ export class Team {
this.owner = owner; this.owner = owner;
} }
getMembers() { getusers() {
return this.members; return this.users;
} }
setMembers(members: User[]) { setusers(users: User[]) {
this.members = members; this.users = users;
} }
getLogo() { getLogo() {
return this.logo; return this.logo;
} }
setLogo(logo: File) { setLogo(logo: HTMLImageElement) {
this.logo = logo; this.logo = logo;
} }
getWaitList() { getWaitList() {
return this.waitList; var waitList : User[] = [];
this.users.forEach(user => {
if(user as WaitingMember){
waitList.concat(user);
}
});
return waitList;
} }
setWaitList(waitList: User[]) { addToWaitList(user: User) : boolean{
this.waitList = waitList; if(!this.users.includes(user)){
this.users.concat(user);
return true;
}
return false;
} }
} }

@ -1,16 +1,10 @@
export class Track { export class Track {
readonly id: number;
private name: string; private name: string;
constructor(id: number, name: string) { constructor(name: string) {
this.id = id;
this.name = name; this.name = name;
} }
getId() {
return this.id;
}
getName() { getName() {
return this.name; return this.name;
} }

@ -2,31 +2,35 @@ import { Session } from "./Session";
import { Team } from "./Team"; import { Team } from "./Team";
export abstract class User { export abstract class User {
readonly id: number; private username: string;
private pseudo: string;
private password: string; private password: string;
private email: string; private email: string;
private sessions: Session[]; private sessions: Session[];
private team: Team; private image : HTMLImageElement;
constructor(id: number, pseudo: string, password: string, email: string, sessions: Session[] = null, team: Team = null) { constructor(username: string, password: string, email: string, sessions: Session[] = [], image : HTMLImageElement) {
this.pseudo = pseudo; this.username = username;
this.password = password; this.password = password;
this.email = email; this.email = email;
this.sessions = sessions; this.sessions = sessions;
this.team = team; this.image = image;
}
getImage(){
return this.image;
} }
getId() { setImage(image: HTMLImageElement){
return this.id; this.image = image;
} }
getPseudo() { getUsername() {
return this.pseudo; return this.username;
} }
setPseudo(pseudo: string) { setUsername(username: string) {
this.pseudo = pseudo; this.username = username;
} }
getPassword() { getPassword() {
@ -53,12 +57,4 @@ export abstract class User {
this.sessions = sessions; this.sessions = sessions;
} }
getTeam() {
return this.team;
}
setTeam(team: Team) {
this.team = team;
}
} }

@ -3,7 +3,7 @@ import { Team } from "./Team";
import { User } from "./User"; import { User } from "./User";
export class WaitingMember extends User { export class WaitingMember extends User {
constructor(id: number, pseudo: string, password: string, email: string, sessions: Session[], team: Team) { constructor( pseudo: string, password: string, email: string, sessions: Session[],image : HTMLImageElement= require('../assets/images/user.jpg')) {
super(id, pseudo, password, email, sessions, team); super(pseudo, password, email, sessions, image);
} }
} }

@ -0,0 +1,24 @@
import { Member } from "../core/Member";
import { Owner } from "../core/Owner";
import { Team } from "../core/Team";
import { User } from "../core/User";
import { WaitingMember } from "../core/WaitingMember";
const owner1 = new Owner("eric","PASSWORD123","eric@gmail.com",[]);
const owner2 = new Owner("castor","PASSWORD123","castor@gmail.com",[]);
export const USERS1 : User[] = [
new Member("jean","PASSWORD123","jean@gmail.com",[]),
new WaitingMember("anas","PASSWORD123","anas@gmail.com",[]),
]
export const USERS2 : User[] = [
new Member("stickman","PASSWORD123","stickman@gmail.com",[]),
new Member("crapaud","PASSWORD123","crapaud@gmail.com",[]),
new WaitingMember("mcdo","PASSWORD123","mcdo@gmail.com",[]),
new WaitingMember("bucheron","PASSWORD123","bucheron@gmail.com",[]),
]
export const TEAMS : Team[] = [
new Team("La team 1",owner1, USERS1),
new Team("Bat INFO",owner2,USERS2)
]
Loading…
Cancel
Save