Compare commits

..

No commits in common. 'master' and 'redux' have entirely different histories.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 527 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 594 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 419 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 587 B

15864
R-Dash/package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -16,22 +16,18 @@
"@reduxjs/toolkit": "^1.9.3",
"@rneui/base": "^4.0.0-rc.7",
"expo": "~48.0.6",
"expo-document-picker": "~11.2.2",
"expo-document-picker": "~11.2.1",
"expo-status-bar": "~1.4.4",
"jsonwebtoken": "^9.0.0",
"react": "18.2.0",
"react-native": "0.71.4",
"react-native-document-picker": "^8.2.0",
"react-native-fs": "^2.20.0",
"react-native": "0.71.3",
"react-native-document-picker": "^8.1.4",
"react-native-gesture-handler": "^2.9.0",
"react-native-maps": "1.3.2",
"react-native-safe-area-context": "^4.5.0",
"react-redux": "^8.0.5",
"redux": "^4.2.1",
"typescript": "^4.9.4",
"react-native-web": "~0.18.10",
"react-dom": "18.2.0",
"@expo/webpack-config": "^18.0.1"
"typescript": "^4.9.4"
},
"devDependencies": {
"@babel/core": "^7.20.0",

@ -2,6 +2,4 @@ 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";
export const ADD_FILE = 'ADD_FILE';

@ -1,4 +1,4 @@
import { configureStore, getDefaultMiddleware } from '@reduxjs/toolkit'
import { configureStore } from '@reduxjs/toolkit'
import appReducer from './reducers/appReducer';
// Reference here all your application reducers
@ -6,13 +6,9 @@ const reducer = {
appReducer: appReducer,
}
const middleware = getDefaultMiddleware({
serializableCheck: false, // Disable serializableCheck
immutableCheck: false
});
const store = configureStore({
// @ts-ignore
const store = configureStore({
reducer,
middleware,
});
});
export default store;

@ -1,10 +1,9 @@
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";
import { FETCH_SESSIONS } from "../Constants";
export const setSessionsList = (sessionsList: Session[]) => {
return {
@ -13,46 +12,26 @@ export const setSessionsList = (sessionsList: Session[]) => {
};
}
// 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 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 getSessionsList = () => {
return async dispatch => {
try {
const sessionsPromise = await fetch(server_link+'/FullSession');
const sessionsPromise = await fetch('https://r-dash.azurewebsites.net/FullSession');
const sessionsListJson = await sessionsPromise.json();
const sessionsList: Session[] = sessionsListJson.map(elt => {
const laps: Lap[] = elt["tours"].map(lap => {
@ -60,14 +39,13 @@ export const getSessionsList = () => {
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 Lap(lap["temps"], 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)');
console.log('Error---------', error);
//dispatch(fetchDataRejected(error))
}
}

@ -1,5 +1,5 @@
import { Team } from "../../core/Team";
import { FETCH_TEAMS, ADD_TEAM, server_link } from "../Constants";
import { FETCH_TEAMS, ADD_TEAM } from "../Constants";
export const setTeamsList = (teamsList: Team[]) => {
return {
@ -11,7 +11,7 @@ export const setTeamsList = (teamsList: Team[]) => {
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", {
const response = await fetch('https://r-dash.azurewebsites.net/Ecuries?' + "Email=test@gmail.com" + "&password=test123" + "&pseudoPilote=test_PILOTE", {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@ -33,7 +33,7 @@ export const addNewTeam = (newTeam: Team) => {
export const getTeamsList = () => {
return async dispatch => {
try {
const teamsPromise = await fetch(server_link+'/Ecuries');
const teamsPromise = await fetch('https://r-dash.azurewebsites.net/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));

@ -16,7 +16,7 @@ export const setUsersList = (usersList: User[]) => {
export const getUsersList = (team: Team) => {
return async dispatch => {
try {
const usersPromise = await fetch(server_link+'/Pilotes/'+team);
const usersPromise = await fetch('https://codefirst.iut.uca.fr/containers/enzojolys-r-dash_container/Pilotes/'+team);
const usersListJson = await usersPromise.json();
const dto: DtoUserEcurie = usersListJson.map(elt => new DtoUserEcurie(elt["owner"], elt["members"], elt["waitingMember"]));
const usersList: User[] = []

@ -106,12 +106,12 @@ export default function Lap(props: { navigation: any, route : any}) {
<View style={styles.infoContainer}>
<Text style={styles.infoItem}>Average Speed:</Text>
<Text style={styles.infoValue}>{currentLap.getAverageSpeed().toFixed()} km/h</Text>
<Text style={styles.infoValue}>{currentLap.getAverageSpeed()} km/h</Text>
</View>
<View style={styles.infoContainer}>
<Text style={styles.infoItem}>Max Speed:</Text>
<Text style={styles.infoValue}>{currentLap.getMaxSpeed().toFixed()} km/h</Text>
<Text style={styles.infoValue}>{currentLap.getMaxSpeed()} km/h</Text>
</View>
</View>
</BackgroundImage>

@ -1,144 +1,25 @@
import React, { useState } from 'react';
import { Pressable, StyleSheet, Text, View, Image, TouchableOpacity, TextInput } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context';
import TopBar from '../components/TopBar';
import { addXlsFile } from '../redux/actions/sessions';
import { useDispatch } from 'react-redux';
import * as DocumentPicker from 'expo-document-picker';
import { uploadFiles, DocumentDirectoryPath } from 'react-native-fs';
import TopBar from '../components/TopBar';
export default function NewTrack(props: { navigation: any }) {
const { navigation } = props;
const dispatch = useDispatch();
const [pickedDocument, setPickedDocument] = useState<DocumentPicker.DocumentResult | null>(null);
const [trackName, setTrackName] = useState('');
const [sessionName, setSessionName] = useState('');
const handlePickDocument = async () => {
try {
const result = await DocumentPicker.getDocumentAsync({});
const result = await DocumentPicker.getDocumentAsync({ type: 'excel/xls' });
if (result.type === 'success') {
setPickedDocument(result);
}
else if(result.type === 'cancel'){
console.log("AAA");
setPickedDocument(null);
}
} catch (err) {
console.log(err);
}
};
// var files = [
// {
// name: "file",
// filename: "file.jpg",
// filepath: pickedDocument.uri,
// filetype: "image/jpeg",
// },
// ];
// const handleConfirm = async () => {
// if (!pickedDocument || !trackName || !sessionName) {
// return;
// }
// const formData = new FormData();
// formData.append('file', {
// uri: pickedDocument.uri,
// type: pickedDocument.type,
// name: pickedDocument.name,
// });
// try {
// await dispatch(addXlsFile(formData, 'test_PILOTE', 'test@gmail.com', 'test123', sessionName, trackName, 'Training'));
// navigation.goBack();
// } catch (error) {
// console.log('Error - POST FILE', error);
// }
// };
// const handleConfirm = async () => {
// if (!pickedDocument || !trackName || !sessionName) {
// return;
// }
// try {
// const file = new File([await pickedDocument.uri], pickedDocument.name, { type: pickedDocument.type });
// const url = 'https://r-dash.azurewebsites.net/File?pseudoPilote=test_PILOTE&nameSession=weekend&nameCircuit=test_CIRCUIT&typeSession=Training';
// const options = {
// method: 'POST',
// body: file,
// headers: {
// 'Content-Type': 'application/octet-stream',
// },
// };
// await fetch(url, options);
// navigation.goBack();
// } catch (error) {
// console.log('Error - POST FILE', error);
// }
// };
// const handleConfirm = async () => {
// if (!pickedDocument || !trackName || !sessionName) {
// return;
// }
// try {
// const file = new File([await pickedDocument.uri], pickedDocument.name, { type: pickedDocument.type });
// const url = 'https://r-dash.azurewebsites.net/File?pseudoPilote=test_PILOTE&nameSession=weekend&nameCircuit=test_CIRCUIT&typeSession=Training';
// const options = {
// method: 'POST',
// body: file,
// headers: {
// 'Content-Type': 'application/octet-stream',
// },
// };
// const response = await fetch(url, options);
// const responseData = await response.text(); // or response.text() or response.blob() depending on the expected response type
// navigation.goBack();
// console.log(responseData);
// } catch (error) {
// console.log('Error - POST FILE', error);
// }
// };
const handleConfirm = async () => {
if (!pickedDocument || !trackName || !sessionName) {
return;
}
try {
//const file = new File([await pickedDocument.uri], pickedDocument.name, { type: pickedDocument.type });
const url = 'https://r-dash.azurewebsites.net/File?pseudoPilote=test_PILOTE&nameSession=test%20import&nameCircuit=test_CIRCUIT&typeSession=Training';
const formData = new FormData();
console.log(pickedDocument.type);
console.log(pickedDocument.uri);
formData.append('file',
{
name: pickedDocument.name,
type: "application/vnd.ms-excel",
uri : pickedDocument.uri,
});
const response = await fetch(url, {
method: 'POST',
body: formData,
headers: {
'accept':'*/*',
'Content-Type': 'multipart/form-data',
},
});
const data = await response.json();
console.log('API response:', data);
if (!response.ok) {
throw new Error( JSON.stringify(response) + 'Failed to upload file');
}
navigation.goBack();
} catch (error) {
console.log('Error - POST FILE', error);
}
};
return (
<SafeAreaView>
<View style={styles.container}>
@ -152,8 +33,7 @@ export default function NewTrack(props: { navigation: any }) {
<Text style={{ paddingTop: 20 }}>Track name: </Text>
<TextInput
style={styles.textInput}
onChangeText={setTrackName}
value={trackName}
secureTextEntry={true}
placeholder="Track name"
/>
</View>
@ -162,8 +42,7 @@ export default function NewTrack(props: { navigation: any }) {
<Text style={{ paddingTop: 20 }}>Session name: </Text>
<TextInput
style={styles.textInput}
onChangeText={setSessionName}
value={sessionName}
secureTextEntry={true}
placeholder="Session name"
/>
</View>
@ -188,7 +67,7 @@ export default function NewTrack(props: { navigation: any }) {
source={require('../assets/images/return.png')}
/>
</Pressable>
<Pressable style={styles.button} onPress={handleConfirm}>
<Pressable style={styles.button} onPress={() => navigation.goBack()}>
<Image
style={styles.return}
source={require('../assets/images/checked.png')}

@ -1,7 +1,7 @@
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 MapView, { Marker } from 'react-native-maps';
import React from 'react';
import TopBar from '../components/TopBar';
import { Point } from '../core/Point';
@ -20,7 +20,6 @@ export default function Lap(props: { navigation: any, route : any}) {
const goToPreviousPoint = () => {
if (currentPointIndex > 0) {
setCurrentPointIndex(currentPointIndex - 1);
}
};
@ -30,24 +29,11 @@ export default function Lap(props: { navigation: any, route : any}) {
}
};
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");
}
const markers: { id: number; name: string; coordinate: { latitude: number; longitude: number } }[] = points.map((pt, index) => {
return {
id: index,
name: pt.getDistance() + 'm',
coordinate: { latitude: pt.getGeo().getGpsLat(), longitude: pt.getGeo().getGpsLong() },
image: img,
};
});
@ -77,7 +63,7 @@ export default function Lap(props: { navigation: any, route : any}) {
</View>
</TouchableOpacity>
<Text style={styles.text_title}>Point {currentPointIndex + 1 } </Text>
<Text style={styles.text_title}>Point {currentPointIndex + 1 } / { points.length } </Text>
<TouchableOpacity style={[styles.LapBrowserButton, currentPointIndex === points.length - 1 ? styles.disabled : null]} onPress={goToNextPoint}>
<View>
@ -98,8 +84,8 @@ export default function Lap(props: { navigation: any, route : any}) {
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 }} />
{markers.map(({ id, name, coordinate }) => (
<Marker key={id} title={name} coordinate={coordinate} onPress={() => handleMarker(id)} />
))}
@ -130,7 +116,7 @@ export default function Lap(props: { navigation: any, route : any}) {
<View style={styles.infoContainer}>
<Text style={styles.infoItem}>nGear:</Text>
<Text style={styles.infoValue}>{currentPoint.getNGear()} gear</Text>
<Text style={styles.infoValue}>{currentPoint.getVCar()} gear</Text>
</View>
<View style={styles.infoContainer}>
@ -151,7 +137,7 @@ export default function Lap(props: { navigation: any, route : any}) {
</View>
<View style={styles.infoContainer}>
<Text style={styles.infoItem}>gLat:</Text>
<Text style={styles.infoValue}>{currentPoint.getGLat()} g</Text>
<Text style={styles.infoValue}>{currentPoint.getGLong()} g</Text>
</View>
</View>
</BackgroundImage>

@ -6,7 +6,6 @@ import {
Text,
View,
TouchableOpacity,
ActivityIndicator,
} from "react-native";
import { useDispatch, useSelector } from "react-redux";
import SessionListItem from "../components/SessionCmp";
@ -18,7 +17,6 @@ import { SESSIONS } from "../stub/stub";
export default function Session_browser(props: { navigation: any }) {
const { navigation } = props;
const [search, setSearch] = useState("");
const [loading, setLoading] = useState(false);
const handlePress = (item: Session) => {
setSearch("");
@ -30,10 +28,8 @@ export default function Session_browser(props: { navigation: any }) {
const dispatch = useDispatch();
useEffect(() => {
setLoading(true);
const loadTeams = async () => {
await dispatch(getSessionsList());
setLoading(false);
};
loadTeams();
}, [dispatch]);
@ -65,17 +61,13 @@ export default function Session_browser(props: { navigation: any }) {
value={search}
onChangeText={setSearch}
/>
{loading ? (
<ActivityIndicator size="large" color="#BF181F" />
) : (
<FlatList
data={filteredData}
renderItem={({ item }) => (
<SessionListItem session={item} onPress={handlePress} />
)}
keyExtractor={(Item) => Item.getName()}
/>
)}
<FlatList
data={filteredData}
renderItem={({ item }) => (
<SessionListItem session={item} onPress={handlePress} />
)}
keyExtractor={(Item) => Item.getName()}
/>
<TouchableOpacity
style={styles.addContainerButton}

Loading…
Cancel
Save