Commit 98049cbe authored by Anael Lacour's avatar Anael Lacour
Browse files

add color debug WIP

parent 260b1b00
# See https://help.github.com/ignore-files/ for more about ignoring files.
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
......@@ -11,8 +13,11 @@
# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.<br />
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.<br />
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.<br />
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.<br />
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.<br />
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
### Code Splitting
This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting
### Analyzing the Bundle Size
This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size
### Making a Progressive Web App
This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app
### Advanced Configuration
This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration
### Deployment
This section has moved here: https://facebook.github.io/create-react-app/docs/deployment
### `npm run build` fails to minify
This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify
This diff is collapsed.
.App {
text-align: center;
}
.App-logo {
animation: App-logo-spin infinite 20s linear;
height: 80px;
}
.App-header {
background-color: #222;
height: 150px;
padding: 20px;
color: white;
}
.App-intro {
font-size: large;
}
@keyframes App-logo-spin {
from { transform: rotate(0deg); }
to { transform: rotate(360deg); }
}
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useState, useEffect } from 'react';
import './App.css';
import axios from 'axios';
import Header from './components/Header';
import { Inject, ScheduleComponent, Day, Week, ViewsDirective, ViewDirective } from '@syncfusion/ej2-react-schedule';
import { loadByLogin, loadUserUVs, Mapper } from './api/edtutc';
function App() {
const [edt, setUserEDT] = useState([]);
const [uvs, setUserUvs] = useState([]);
const [searchLogins, setSearchLogins] = useState(['lacouran']);
useEffect(() => {
console.log('In use effect');
searchLogins.forEach((login) => {
console.log('treating login : ' + login);
loadByLogin(login).then((data) => setUserEDT(edt.concat(Mapper(data)))).catch(err => console.log(err));
loadUserUVs(login).then((data) => setUserUvs(uvs.concat(data))).catch(err => console.log(err));
})
}, [searchLogins])
function AddSearch(input) {
if (input === '') return;
setSearchLogins([...searchLogins, input]);
}
function removeFromArray(arrOriginal, elementToRemove) {
return arrOriginal.filter((el) => {return el !== elementToRemove})
}
function DeleteSerchedUser(input){
console.log('login to delete : ' + input);
let newArray = removeFromArray(searchLogins, input);
setSearchLogins(newArray);
setUserEDT([]);
setUserUvs([]);
}
return (
<div className="App">
<Header onSearch={AddSearch} onDelete={DeleteSerchedUser} title='Emploi du temps' />
<p style={{ fontWeight: 'bold' }}>Vos UVs : {uvs.join(", ")}</p>
<p style={{ fontWeight: 'bold' }}>Vos Logins : {searchLogins.join(", ")}</p>
<ScheduleComponent
eventSettings={{ dataSource: edt }}
timeScale={{ interval: 60 }}
showWeekNumber={true}
startHour='7:00'
endHour='20:00'
height='1000px'
width='900px'
>
<ViewsDirective>
<ViewDirective option='Day' />
<ViewDirective option='Week' />
</ViewsDirective>
<Inject services={[Day, Week]} />
</ScheduleComponent>
</div>
);
}
export default App;
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
it('renders without crashing', () => {
const div = document.createElement('div');
ReactDOM.render(<App />, div);
});
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';
import './index.css';
ReactDOM.render(
<App />,
document.getElementById('root')
);
This diff is collapsed.
{
"name": "anaelmarie",
"name": "edt",
"version": "0.1.0",
"private": true,
"dependencies": {
"@syncfusion/ej2-react-schedule": "^18.1.55",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.5.0",
"@testing-library/user-event": "^7.2.1",
"axios": "^0.19.2",
"bootstrap": "^4.5.0",
"randomcolor": "^0.5.4",
"react": "^16.13.1",
"react-bootstrap": "^1.0.1",
"react-dom": "^16.13.1",
"react-scripts": "0.9.5"
"react-scripts": "3.4.1"
},
"devDependencies": {},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
<!doctype html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
Notice the use of %PUBLIC_URL% in the tag above.
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
......@@ -13,9 +24,11 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<link href="https://cdn.syncfusion.com/ej2/material.css" rel="stylesheet" type="text/css" />
<title>EDT</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
......@@ -24,8 +37,8 @@
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start`.
To create a production bundle, use `npm run build`.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
.App {
display: flex;
flex-direction: column;
align-items: center;
}
.App-title {
color: white;
}
.SearchBar {
display: flex;
flex-direction: column;
align-items: center;
}
.TimeSlot {
background-color: khaki;
padding: 12px;
}
.TimeSlot-text {
color: black;
font-weight: bold;
}
.TimeTable {
display: flex;
}
.Delete {
margin-right: 10px;
margin-left: 10px;
}
.Logins {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
margin-bottom: 10px;
margin-left: 10px;
padding: 10px;
}
/* eslint-disable array-callback-return */
/* eslint-disable react-hooks/exhaustive-deps */
import React, { useState, useEffect } from 'react';
import './App.css';
import randomColor from 'randomcolor';
import Information from './components/Information';
import SearchBar from './components/SearchBar';
import { Inject, ScheduleComponent, Day, Week, ViewsDirective, ViewDirective } from '@syncfusion/ej2-react-schedule';
import { loadEDTByLogin, loadUserUVs, Mapper } from './api/edtutc';
function App() {
const [EDT, setEDT] = useState([]);
const [uvs, setUvs] = useState([]);
//const [searchLogins, setSearchLogins] = useState([]);
const [student, setStudent] = useState({ login: 'vtchekov', color: randomColor() });
useEffect(() => {
let canceled = false;
loadEDTByLogin(student.login)
.then((edt) => {
if (!canceled || edt.length > 0) {
let list_uvs = loadUserUVs(edt);
let val = {
login: student.login,
uvs: list_uvs,
}
setUvs([...uvs, val]);
let mapped_objects = Mapper(edt, student);
setEDT(EDT.concat(mapped_objects));
}
})
.catch(err => console.log(err));
return () => { canceled = true; } //prevent quick api fetch spamming;
}, [student])
function handleSearch(input) {
if (input === '' || contains(EDT, input) === true) return; //si l'utilisateur rentre une chaîne vide on sort de la fonction
let student = {
login: input,
color: randomColor(),
}
setStudent(student);
}
function contains(arr, elementToCheck) { //Check if element is already searched;
let found = false;
for (let i = 0; i < EDT.length; i++) {
if (EDT[i].Id === elementToCheck) {found = true; break};
}
return found;
}
function handleDelete(input) {
if (input === '') return; //si l'utilisateur rentre une chaîne vide on sort de la fonction
deleteEDT(input);
deleteUVs(input);
}
function deleteEDT(login) {
let newEDT = EDT.filter((element) => {
return element.Id !== login;
})
setEDT(newEDT);
}
function deleteUVs(login) {
let newUvs = uvs.filter((element) => {
return element.login !== login;
})
setUvs(newUvs);
}
function onRenderCell(event) {
let cell = event.data;
event.element.style.backgroundColor = cell.Color;
}
return (
<div className="App">
<SearchBar onSearch={handleSearch} onDelete={handleDelete} title='Emploi du temps' />
<Information onDelete={handleDelete} uvs={uvs} />
<ScheduleComponent
eventSettings={{ dataSource: EDT }}
timeScale={{ interval: 60 }}
showWeekNumber={true}
startHour='7:00'
endHour='21:00'
height='600px'
width='900px'
eventRendered={onRenderCell}
>
<ViewsDirective>
<ViewDirective option='Day' />
<ViewDirective option='Week' />
</ViewsDirective>
<Inject services={[Day, Week]} />
</ScheduleComponent>
</div>
);
}
export default App;
import React from 'react';
import { render } from '@testing-library/react';
import App from './App';
test('renders learn react link', () => {
const { getByText } = render(<App />);
const linkElement = getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment