Compare commits

..

No commits in common. 'master' and 'Backend/add_session' have entirely different histories.

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

@ -2,6 +2,4 @@ export const FETCH_USERS = 'FETCH_USERS';
export const FETCH_TEAMS = 'FETCH_TEAMS'; export const FETCH_TEAMS = 'FETCH_TEAMS';
export const FETCH_SESSIONS = 'FETCH_SESSIONS'; export const FETCH_SESSIONS = 'FETCH_SESSIONS';
export const ADD_TEAM = 'ADD_TEAM'; export const ADD_TEAM = 'ADD_TEAM';
export const ADD_FILE = 'ADD_FILE'; 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,10 +1,9 @@
import { Alert } from "react-native";
import { Geocalisation } from "../../core/Geocalisation"; import { Geocalisation } from "../../core/Geocalisation";
import { Lap } from "../../core/Lap"; import { Lap } from "../../core/Lap";
import { Point } from "../../core/Point"; import { Point } from "../../core/Point";
import { Session } from "../../core/Session"; import { Session } from "../../core/Session";
import { User } from "../../core/User"; import { User } from "../../core/User";
import { FETCH_SESSIONS, server_link } from "../Constants"; import { FETCH_SESSIONS } from "../Constants";
export const setSessionsList = (sessionsList: Session[]) => { export const setSessionsList = (sessionsList: Session[]) => {
return { return {
@ -35,7 +34,7 @@ export const addXlsFile = (file: File, pseudoPilote: string, email: string, pass
const formData = new FormData(); const formData = new FormData();
formData.append('file', file); formData.append('file', file);
const response = await fetch( const response = await fetch(
server_link+`/File?pseudoPilote=${pseudoPilote}&Email=${email}&password=${password}&nameSession=${nameSession}&nameCircuit=${nameCircuit}&typeSession=${typeSession}`, `https://r-dash.azurewebsites.net/File?pseudoPilote=${pseudoPilote}&Email=${email}&password=${password}&nameSession=${nameSession}&nameCircuit=${nameCircuit}&typeSession=${typeSession}`,
{ {
method: 'POST', method: 'POST',
body: formData body: formData
@ -45,14 +44,14 @@ export const addXlsFile = (file: File, pseudoPilote: string, email: string, pass
return data; return data;
} catch (error) { } catch (error) {
console.log('Error - POST FILE', error); console.log('Error - POST FILE', error);
Alert.alert('Error', 'An error occured while adding a session. (server might be down)');
} }
} }
}; };
export const getSessionsList = () => { export const getSessionsList = () => {
return async dispatch => { return async dispatch => {
try { try {
const sessionsPromise = await fetch(server_link+'/FullSession'); const sessionsPromise = await fetch('https://r-dash.azurewebsites.net/FullSession');
const sessionsListJson = await sessionsPromise.json(); const sessionsListJson = await sessionsPromise.json();
const sessionsList: Session[] = sessionsListJson.map(elt => { const sessionsList: Session[] = sessionsListJson.map(elt => {
const laps: Lap[] = elt["tours"].map(lap => { const laps: Lap[] = elt["tours"].map(lap => {
@ -67,7 +66,6 @@ export const getSessionsList = () => {
dispatch(setSessionsList(sessionsList)); dispatch(setSessionsList(sessionsList));
} catch (error) { } catch (error) {
console.log('Error -- GET SESSIONS', error); console.log('Error -- GET SESSIONS', error);
Alert.alert('Error', 'An error occured while getting sessions. (server might be down)');
//dispatch(fetchDataRejected(error)) //dispatch(fetchDataRejected(error))
} }
} }

@ -1,5 +1,5 @@
import { Team } from "../../core/Team"; 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[]) => { export const setTeamsList = (teamsList: Team[]) => {
return { return {
@ -11,7 +11,7 @@ export const setTeamsList = (teamsList: Team[]) => {
export const addNewTeam = (newTeam: Team) => { export const addNewTeam = (newTeam: Team) => {
return async dispatch => { return async dispatch => {
try { 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', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
@ -33,7 +33,7 @@ export const addNewTeam = (newTeam: Team) => {
export const getTeamsList = () => { export const getTeamsList = () => {
return async dispatch => { return async dispatch => {
try { try {
const teamsPromise = await fetch(server_link+'/Ecuries'); const teamsPromise = await fetch('https://r-dash.azurewebsites.net/Ecuries');
const teamsListJson = await teamsPromise.json(); const teamsListJson = await teamsPromise.json();
const teamsList: Team[] = teamsListJson.map(elt => new Team(elt["name"], elt["owner"], elt["users"], elt["logo"])); const teamsList: Team[] = teamsListJson.map(elt => new Team(elt["name"], elt["owner"], elt["users"], elt["logo"]));
dispatch(setTeamsList(teamsList)); dispatch(setTeamsList(teamsList));

@ -16,7 +16,7 @@ export const setUsersList = (usersList: User[]) => {
export const getUsersList = (team: Team) => { export const getUsersList = (team: Team) => {
return async dispatch => { return async dispatch => {
try { 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 usersListJson = await usersPromise.json();
const dto: DtoUserEcurie = usersListJson.map(elt => new DtoUserEcurie(elt["owner"], elt["members"], elt["waitingMember"])); const dto: DtoUserEcurie = usersListJson.map(elt => new DtoUserEcurie(elt["owner"], elt["members"], elt["waitingMember"]));
const usersList: User[] = [] const usersList: User[] = []

@ -1,11 +1,10 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { Pressable, StyleSheet, Text, View, Image, TouchableOpacity, TextInput } from 'react-native'; import { Pressable, StyleSheet, Text, View, Image, TouchableOpacity, TextInput } from 'react-native';
import { SafeAreaView } from 'react-native-safe-area-context'; import { SafeAreaView } from 'react-native-safe-area-context';
import * as DocumentPicker from 'expo-document-picker';
import TopBar from '../components/TopBar'; import TopBar from '../components/TopBar';
import { addXlsFile } from '../redux/actions/sessions'; import { addXlsFile } from '../redux/actions/sessions';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';
import * as DocumentPicker from 'expo-document-picker';
import { uploadFiles, DocumentDirectoryPath } from 'react-native-fs';
export default function NewTrack(props: { navigation: any }) { export default function NewTrack(props: { navigation: any }) {
const { navigation } = props; const { navigation } = props;
@ -30,115 +29,19 @@ export default function NewTrack(props: { navigation: any }) {
} }
}; };
// 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 () => { const handleConfirm = async () => {
if (!pickedDocument || !trackName || !sessionName) { if (!pickedDocument || !trackName || !sessionName) {
return; 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');
}
try {
await dispatch(addXlsFile(pickedDocument.uri, 'test_PILOTE', 'test@gmail.com', 'test123', sessionName, trackName, 'Training'));
navigation.goBack(); navigation.goBack();
} catch (error) { } catch (error) {
console.log('Error - POST FILE', error); console.log('Error - POST FILE', error);
} }
}; };
return ( return (
<SafeAreaView> <SafeAreaView>
<View style={styles.container}> <View style={styles.container}>

Loading…
Cancel
Save