Compare commits
No commits in common. 'master' and 'Backend/Page/Team_Browser' have entirely different histories.
master
...
Backend/Pa
Before Width: | Height: | Size: 527 B |
Before Width: | Height: | Size: 594 B |
Before Width: | Height: | Size: 419 B |
Before Width: | Height: | Size: 587 B |
@ -1,55 +0,0 @@
|
||||
import React from "react";
|
||||
import { View,Image,Text, StyleSheet, Touchable } from "react-native";
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import { Session } from "../core/Session";
|
||||
|
||||
type SessionListItemProps = {
|
||||
session: Session;
|
||||
onPress: (team: Session) => void;
|
||||
}
|
||||
|
||||
export default function SessionListItem(props: SessionListItemProps) {
|
||||
|
||||
const timeInSeconds = props.session.getLaps()[props.session.getLaps().length - 1].getTime();
|
||||
return (
|
||||
<TouchableOpacity style={styles.container}
|
||||
onPress={()=> props.onPress(props.session)}>
|
||||
<Text style={styles.text_style}> {props.session.getName()}</Text>
|
||||
<View style={styles.container_low}>
|
||||
<Text style={styles.text_under}> {props.session.getType().toString() }</Text>
|
||||
<Text style={styles.text_under}> { timeInSeconds }</Text>
|
||||
</View>
|
||||
|
||||
</TouchableOpacity>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
borderRadius:30,
|
||||
alignItems:'center',
|
||||
backgroundColor:'#e1e8ee',
|
||||
padding:1,
|
||||
flex: 1,
|
||||
margin:10,
|
||||
},
|
||||
container_low: {
|
||||
borderRadius:30,
|
||||
alignItems:'center',
|
||||
backgroundColor:'#e1e8ee',
|
||||
padding:10,
|
||||
flex: 1,
|
||||
flexDirection: "row",
|
||||
marginBottom:10,
|
||||
},
|
||||
text_style:{
|
||||
textAlign:'center',
|
||||
fontSize:25,
|
||||
},
|
||||
text_under:{
|
||||
marginLeft:15,
|
||||
textAlign:'center',
|
||||
fontSize:20,
|
||||
}
|
||||
});
|
||||
|
@ -1,8 +1,8 @@
|
||||
export enum SessionType {
|
||||
Test = "Test",
|
||||
PrivateTest = "Private Test",
|
||||
Qualification = "Qualification",
|
||||
ShortStroke = "Short Stroke",
|
||||
LongStroke = "Long Stroke",
|
||||
Unknown = "Unknown",
|
||||
}
|
||||
enum SessionType {
|
||||
Test,
|
||||
PrivateTest,
|
||||
Qualification,
|
||||
ShortStroke,
|
||||
LongStroke,
|
||||
Unknown,
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
||||
export const FETCH_USERS = 'FETCH_USERS';
|
||||
export const FETCH_TEAMS = 'FETCH_TEAMS';
|
||||
export const FETCH_SESSIONS = 'FETCH_SESSIONS';
|
||||
export const ADD_TEAM = 'ADD_TEAM';
|
||||
export const ADD_FILE = 'ADD_FILE';
|
||||
//export const server_link = "https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container";
|
||||
export const server_link = "https://r-dash.azurewebsites.net";
|
@ -1,18 +0,0 @@
|
||||
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
|
||||
import appReducer from './reducers/appReducer';
|
||||
|
||||
// Reference here all your application reducers
|
||||
const reducer = {
|
||||
appReducer: appReducer,
|
||||
}
|
||||
|
||||
const middleware = getDefaultMiddleware({
|
||||
serializableCheck: false, // Disable serializableCheck
|
||||
immutableCheck: false
|
||||
});
|
||||
|
||||
const store = configureStore({
|
||||
reducer,
|
||||
middleware,
|
||||
});
|
||||
export default store;
|
@ -1,74 +0,0 @@
|
||||
import { Alert } from "react-native";
|
||||
import { Geocalisation } from "../../core/Geocalisation";
|
||||
import { Lap } from "../../core/Lap";
|
||||
import { Point } from "../../core/Point";
|
||||
import { Session } from "../../core/Session";
|
||||
import { User } from "../../core/User";
|
||||
import { FETCH_SESSIONS, server_link } from "../Constants";
|
||||
|
||||
export const setSessionsList = (sessionsList: Session[]) => {
|
||||
return {
|
||||
type: FETCH_SESSIONS,
|
||||
payload: sessionsList,
|
||||
};
|
||||
}
|
||||
|
||||
// export const addXlsFile = async (file: File) => {
|
||||
// try {
|
||||
// const formData = new FormData();
|
||||
// formData.append('file', file);
|
||||
// const response = await fetch(
|
||||
// 'https://r-dash.azurewebsites.net/File?' + "pseudoPilote=test_PILOTE" + "&Email=test@gmail.com" + "&password=test123" + "&nameSession=test_SESSION" + "&nameCircuit=test_CIRCUIT" + "&typeSession=Unknown", {
|
||||
// method: 'POST',
|
||||
// body: formData
|
||||
// });
|
||||
// const data = await response.json();
|
||||
// return data;
|
||||
// } catch (error) {
|
||||
// console.log('Error---------', error);
|
||||
// }
|
||||
// };
|
||||
|
||||
export const addXlsFile = (file: File, pseudoPilote: string, email: string, password: string, nameSession: string, nameCircuit: string, typeSession: string) => {
|
||||
return async dispatch => {
|
||||
try {
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
const response = await fetch(
|
||||
server_link+`/File?pseudoPilote=${pseudoPilote}&Email=${email}&password=${password}&nameSession=${nameSession}&nameCircuit=${nameCircuit}&typeSession=${typeSession}`,
|
||||
{
|
||||
method: 'POST',
|
||||
body: formData
|
||||
}
|
||||
);
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.log('Error - POST FILE', error);
|
||||
Alert.alert('Error', 'An error occured while adding a session. (server might be down)');
|
||||
}
|
||||
}
|
||||
};
|
||||
export const getSessionsList = () => {
|
||||
return async dispatch => {
|
||||
try {
|
||||
const sessionsPromise = await fetch(server_link+'/FullSession');
|
||||
const sessionsListJson = await sessionsPromise.json();
|
||||
const sessionsList: Session[] = sessionsListJson.map(elt => {
|
||||
const laps: Lap[] = elt["tours"].map(lap => {
|
||||
const points: Point[] = lap["points"].map(point => {
|
||||
const geo = new Geocalisation(point["longitude"], point["latitude"]);
|
||||
return new Point(geo, point["timer"] , point["distance"], point["nGear"], point["pBrakeF"], point["aSteer"], point["rPedal"], point["gLong"], point["gLat"], point["vCar"]);
|
||||
});
|
||||
return new Lap(lap["numero"], points, lap["temps"]);
|
||||
});
|
||||
return new Session(elt["name"], laps, elt["type"]);
|
||||
});
|
||||
dispatch(setSessionsList(sessionsList));
|
||||
} catch (error) {
|
||||
console.log('Error -- GET SESSIONS', error);
|
||||
Alert.alert('Error', 'An error occured while getting sessions. (server might be down)');
|
||||
//dispatch(fetchDataRejected(error))
|
||||
}
|
||||
}
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
import { Team } from "../../core/Team";
|
||||
import { FETCH_TEAMS, ADD_TEAM, server_link } from "../Constants";
|
||||
|
||||
export const setTeamsList = (teamsList: Team[]) => {
|
||||
return {
|
||||
type: FETCH_TEAMS,
|
||||
payload: teamsList,
|
||||
};
|
||||
}
|
||||
|
||||
export const addNewTeam = (newTeam: Team) => {
|
||||
return async dispatch => {
|
||||
try {
|
||||
const response = await fetch(server_link + '/Ecuries?' + "Email=test@gmail.com" + "&password=test123" + "&pseudoPilote=test_PILOTE", {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify(newTeam)
|
||||
});
|
||||
const team = await response.json();
|
||||
dispatch({
|
||||
type: ADD_TEAM,
|
||||
payload: team
|
||||
});
|
||||
} catch (error) {
|
||||
console.log('Error---------', error);
|
||||
//dispatch(fetchDataRejected(error))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const getTeamsList = () => {
|
||||
return async dispatch => {
|
||||
try {
|
||||
const teamsPromise = await fetch(server_link+'/Ecuries');
|
||||
const teamsListJson = await teamsPromise.json();
|
||||
const teamsList: Team[] = teamsListJson.map(elt => new Team(elt["name"], elt["owner"], elt["users"], elt["logo"]));
|
||||
dispatch(setTeamsList(teamsList));
|
||||
} catch (error) {
|
||||
console.log('Error---------', error);
|
||||
//dispatch(fetchDataRejected(error))
|
||||
}
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
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";
|
||||
import { FETCH_USERS } from "../Constants";
|
||||
import { DtoUserEcurie } from "../dto/dtoUserEcurie";
|
||||
|
||||
export const setUsersList = (usersList: User[]) => {
|
||||
return {
|
||||
type: FETCH_USERS,
|
||||
payload: usersList,
|
||||
};
|
||||
}
|
||||
|
||||
export const getUsersList = (team: Team) => {
|
||||
return async dispatch => {
|
||||
try {
|
||||
const usersPromise = await fetch(server_link+'/Pilotes/'+team);
|
||||
const usersListJson = await usersPromise.json();
|
||||
const dto: DtoUserEcurie = usersListJson.map(elt => new DtoUserEcurie(elt["owner"], elt["members"], elt["waitingMember"]));
|
||||
const usersList: User[] = []
|
||||
usersList.push(dto.getOwner())
|
||||
dto.getMembers().forEach(element => {
|
||||
usersList.push(element);
|
||||
});
|
||||
dto.getWaitingMember().forEach(element => {
|
||||
usersList.push(element)
|
||||
});
|
||||
dispatch(setUsersList(usersList));
|
||||
} catch (error) {
|
||||
console.log('Error---------', error);
|
||||
//dispatch(fetchDataRejected(error))
|
||||
}
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
import { Member } from "../../core/Member";
|
||||
import { Owner } from "../../core/Owner";
|
||||
import { WaitingMember } from "../../core/WaitingMember";
|
||||
|
||||
export class DtoUserEcurie {
|
||||
private owner: Owner;
|
||||
private members: Member[];
|
||||
private waitingMember: WaitingMember[];
|
||||
|
||||
constructor(owner: Owner, members: Member[], waitingMember: WaitingMember[]) {
|
||||
this.owner = owner;
|
||||
this.members = members;
|
||||
this.waitingMember = waitingMember;
|
||||
}
|
||||
|
||||
getOwner() {
|
||||
return this.owner;
|
||||
}
|
||||
setOwner(owner: Owner) {
|
||||
this.owner = owner;
|
||||
}
|
||||
|
||||
getMembers() {
|
||||
return this.members;
|
||||
}
|
||||
setMembers(members: Member[]) {
|
||||
this.members = members;
|
||||
}
|
||||
|
||||
getWaitingMember() {
|
||||
return this.waitingMember;
|
||||
}
|
||||
setWaitingMember(waitingMember: WaitingMember[]) {
|
||||
this.waitingMember = waitingMember;
|
||||
}
|
||||
|
||||
}
|
@ -1,28 +0,0 @@
|
||||
import { addXlsFile } from "../actions/sessions";
|
||||
import { addNewTeam } from "../actions/teams";
|
||||
import { FETCH_SESSIONS, FETCH_TEAMS, FETCH_USERS, ADD_TEAM, ADD_FILE } from "../Constants";
|
||||
|
||||
const initialState = {
|
||||
teams: [],
|
||||
users: [],
|
||||
sessions: [],
|
||||
};
|
||||
|
||||
const appReducer = (state = initialState, action: { type: any; payload: any; }) => {
|
||||
switch (action.type) {
|
||||
case ADD_TEAM:
|
||||
return { ...state, teams: [...state.teams, addNewTeam] };
|
||||
case ADD_FILE:
|
||||
return { ...state, sessions: [...state.sessions, addXlsFile] };
|
||||
case FETCH_TEAMS:
|
||||
return { ...state, teams: action.payload };
|
||||
case FETCH_USERS:
|
||||
return { ...state, users: action.payload };
|
||||
case FETCH_SESSIONS:
|
||||
return { ...state, sessions: action.payload };
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default appReducer;
|
@ -1,256 +0,0 @@
|
||||
import { BackgroundImage } from '@rneui/base';
|
||||
import { StyleSheet, Text, View, TouchableOpacity, ScrollView } from 'react-native';
|
||||
import { SafeAreaView } from 'react-native-safe-area-context';
|
||||
import MapView, { MapCallout, Marker } from 'react-native-maps';
|
||||
import React from 'react';
|
||||
import TopBar from '../components/TopBar';
|
||||
import { Point } from '../core/Point';
|
||||
|
||||
export default function Lap(props: { navigation: any, route : any}) {
|
||||
const { currentLap } = props.route.params;
|
||||
const { navigation } = props;
|
||||
|
||||
const points: Point[] = currentLap.getPoints();
|
||||
points.sort((pt1, pt2) => pt1.getTimer() - pt2.getTimer());
|
||||
|
||||
|
||||
const [currentPointIndex, setCurrentPointIndex] = React.useState(0);
|
||||
const currentPoint: Point | undefined = points[currentPointIndex];
|
||||
|
||||
const goToPreviousPoint = () => {
|
||||
if (currentPointIndex > 0) {
|
||||
setCurrentPointIndex(currentPointIndex - 1);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
const goToNextPoint = () => {
|
||||
if (currentPointIndex < points.length - 1) {
|
||||
setCurrentPointIndex(currentPointIndex + 1);
|
||||
}
|
||||
};
|
||||
|
||||
const markers: { id: number; name: string; coordinate: { latitude: number; longitude: number }, image: HTMLImageElement }[] = points.map((pt, index) => {
|
||||
var img;
|
||||
const brake = pt.getPBreakF();
|
||||
if(brake <= 0)
|
||||
{
|
||||
img = require("../assets/images/noBrake.png");
|
||||
}else if(brake > 0 && brake <= 30){
|
||||
img = require("../assets/images/startBrake.png");
|
||||
}else if(brake > 0 && brake <= 100){
|
||||
img = require("../assets/images/midBrake.png");
|
||||
}else{
|
||||
img = require("../assets/images/fullBrake.png");
|
||||
}
|
||||
return {
|
||||
id: index,
|
||||
name: pt.getDistance() + 'm',
|
||||
coordinate: { latitude: pt.getGeo().getGpsLat(), longitude: pt.getGeo().getGpsLong() },
|
||||
image: img,
|
||||
};
|
||||
});
|
||||
|
||||
const handleMarker = (index : number) => {
|
||||
setCurrentPointIndex(index);
|
||||
}
|
||||
|
||||
// currentLap.getPoints().forEach(pt => {
|
||||
// points.push({ latitude: pt.getGeo().getGpsLat(), longitude: pt.getGeo().getGpsLong() });
|
||||
|
||||
// });
|
||||
|
||||
//var currentLap : undefined; // Penser à vérifier si la session ne possède pas de tour !! si c'est le cas afficher une popup d'erreur
|
||||
return (
|
||||
<SafeAreaView style={styles.container}>
|
||||
<View style={styles.container}>
|
||||
{/* Header */}
|
||||
<TopBar navigation={navigation} />
|
||||
|
||||
{/* Body */}
|
||||
<View style={styles.container}>
|
||||
|
||||
<View style={styles.top_lap}>
|
||||
<TouchableOpacity style={[styles.LapBrowserButton, currentPointIndex === 0 ? styles.disabled : null]} onPress={goToPreviousPoint}>
|
||||
<View>
|
||||
<Text style={styles.button_text} >Previous Point</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
<Text style={styles.text_title}>Point {currentPointIndex + 1 } </Text>
|
||||
|
||||
<TouchableOpacity style={[styles.LapBrowserButton, currentPointIndex === points.length - 1 ? styles.disabled : null]} onPress={goToNextPoint}>
|
||||
<View>
|
||||
<Text style={styles.button_text} >Next Point</Text>
|
||||
</View>
|
||||
</TouchableOpacity>
|
||||
|
||||
</View>
|
||||
|
||||
<View style={styles.containerBody}>
|
||||
<MapView
|
||||
style={styles.map}
|
||||
mapType="satellite"
|
||||
region={{
|
||||
latitude: currentLap.getLocationLat(),
|
||||
longitude: currentLap.getLocationLong(),
|
||||
latitudeDelta: 0.001,
|
||||
longitudeDelta: 0.015,
|
||||
}}
|
||||
>
|
||||
{markers.map(({ id, name, coordinate,image }) => (
|
||||
<Marker key={id} title={name} coordinate={coordinate} onPress={() => handleMarker(id)} icon={image} style={{ width: 1, height: 1 }} />
|
||||
))}
|
||||
|
||||
|
||||
</MapView>
|
||||
<ScrollView style={ styles.scrollView}>
|
||||
<BackgroundImage source={require('../assets/images/rdash.png')} resizeMode="contain" >
|
||||
|
||||
<View style={styles.container2}>
|
||||
|
||||
<Text style={styles.header}>Point { currentPointIndex + 1} / { points.length} of Lap {currentLap.getNumber()}</Text>
|
||||
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>Time:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getFormattedTime()}</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>Distance:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getDistance()} m</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>Speed (vCar):</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getVCar()} km/h</Text>
|
||||
</View>
|
||||
|
||||
|
||||
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>nGear:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getNGear()} gear</Text>
|
||||
</View>
|
||||
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>pBreakF:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getPBreakF()} bar</Text>
|
||||
</View>
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>aSteer:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getASteer()} deg</Text>
|
||||
</View>
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>rPedal:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getRPedal()} %</Text>
|
||||
</View>
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>gLong:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getGLong()} g</Text>
|
||||
</View>
|
||||
<View style={styles.infoContainer}>
|
||||
<Text style={styles.infoItem}>gLat:</Text>
|
||||
<Text style={styles.infoValue}>{currentPoint.getGLat()} g</Text>
|
||||
</View>
|
||||
</View>
|
||||
</BackgroundImage>
|
||||
</ScrollView>
|
||||
</View>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
scrollView: {
|
||||
flex:1,
|
||||
},
|
||||
disabled: {
|
||||
opacity: 0.5,
|
||||
},
|
||||
addContainerButton: {
|
||||
margin:5,
|
||||
alignItems: "center",
|
||||
justifyContent: "center",
|
||||
height: "8%",
|
||||
borderRadius: 10,
|
||||
elevation: 3,
|
||||
backgroundColor: "#BF181F",
|
||||
},
|
||||
containerBody:{
|
||||
flex: 1,
|
||||
justifyContent: 'space-between',
|
||||
alignItems: 'stretch',
|
||||
},
|
||||
container2: {
|
||||
backgroundColor: 'rgba(255, 255, 255, 0.9)',
|
||||
borderColor:'black',
|
||||
borderWidth:2,
|
||||
padding: 10,
|
||||
borderRadius: 10,
|
||||
marginBottom: 20,
|
||||
shadowColor: '#000',
|
||||
shadowOffset: {
|
||||
width: 0,
|
||||
height: 2,
|
||||
},
|
||||
shadowOpacity: 0.25,
|
||||
shadowRadius: 3.84,
|
||||
elevation: 5,
|
||||
},
|
||||
header: {
|
||||
fontSize: 24,
|
||||
fontWeight: 'bold',
|
||||
marginBottom: 10,
|
||||
},
|
||||
infoContainer: {
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
marginBottom: 5,
|
||||
},
|
||||
infoItem: {
|
||||
fontSize: 18,
|
||||
fontWeight: 'bold',
|
||||
},
|
||||
infoValue: {
|
||||
fontSize: 18,
|
||||
},
|
||||
map: {
|
||||
flex:1,
|
||||
},
|
||||
top_lap: {
|
||||
height: "8%",
|
||||
flexDirection: 'row',
|
||||
justifyContent: 'space-between',
|
||||
},
|
||||
backgroundImage: {
|
||||
flex: 1,
|
||||
width: '100%',
|
||||
},
|
||||
container: {
|
||||
flex: 1,
|
||||
},
|
||||
LapBrowserButton: {
|
||||
width: "30%",
|
||||
marginTop:5,
|
||||
marginBottom:5,
|
||||
alignContent: 'center',
|
||||
justifyContent: 'center',
|
||||
borderRadius: 10,
|
||||
backgroundColor: '#BF181F',
|
||||
},
|
||||
button_text: {
|
||||
textAlign: 'center',
|
||||
color: '#fff',
|
||||
fontSize: 20,
|
||||
},
|
||||
text_title: {
|
||||
fontSize: 30,
|
||||
textAlign: 'center',
|
||||
},
|
||||
|
||||
});
|
Loading…
Reference in new issue