diff --git a/.gitignore b/.gitignore index 57e50fb427f0ced31be8ba4d27507f839aa10c26..1e7cd564844a1f6418b743aa031d7dfce55234d9 100644 --- a/.gitignore +++ b/.gitignore @@ -24,3 +24,4 @@ yarn-error.log* ./front/node_modules ./back/node_modules */node_modules +/node_modules diff --git a/back/Dockerfile b/back/Dockerfile index a73f4a384dd6359d246ce03d2bb99f8db8783d5e..d2013483dbe4b8765e44646eec7132fe18c1c894 100644 --- a/back/Dockerfile +++ b/back/Dockerfile @@ -5,8 +5,9 @@ WORKDIR /app COPY package.json /app COPY yarn.lock /app -COPY . /app RUN yarn install +COPY . /app + CMD ["yarn", "start"] diff --git a/back/controller.js b/back/controller.js new file mode 100644 index 0000000000000000000000000000000000000000..081eb244dce801bd367ea2b500f3a47e2da009de --- /dev/null +++ b/back/controller.js @@ -0,0 +1,7 @@ +scores = require('./controllers/scores.controller'); +equipe = require('./controllers/equipe.controller'); +participant = require('./controllers/participant.controller'); +objectifs = require('./controllers/objectifs.controller'); + + +module.exports = {equipe,participant,objectifs,scores} diff --git a/back/controllers/equipe.controller.js b/back/controllers/equipe.controller.js new file mode 100644 index 0000000000000000000000000000000000000000..38498fbd6a0048d5a3a6b5e1c8ef5c4b4c2320ea --- /dev/null +++ b/back/controllers/equipe.controller.js @@ -0,0 +1,82 @@ +const axios = require('axios'); +const mysql = require('mysql'); +var [dbhost, dbpassword, dbuser] = require('../secrets.js'); + +const dbConfig = { + host: process.env.MYSQL_HOST_IP, + user: process.env.MYSQL_USER, + password: process.env.MYSQL_PASSWORD, + database: process.env.MYSQL_DATABASE, +}; + +function getClassementEquipe(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "SELECT Equipe.name,SUM(score) AS score,COUNT(participantId) AS nbParticipant,COUNT(score) AS nbScores FROM Score JOIN Equipe ON Equipe.id=Score.equipeId GROUP BY equipeId ORDER BY score DESC;" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function getEquipes(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "SELECT id,name FROM Equipe;" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function addNewEquipe(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "INSERT INTO `Equipe` (`name`) VALUES ('"+req.body.name+"');" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateEquipe(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Equipe SET name = '"+req.body.name+"' WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function deleteEquipe(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "DELETE FROM Equipe WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +module.exports = {getClassementEquipe,getEquipes,addNewEquipe,updateEquipe,deleteEquipe} diff --git a/back/controllers/objectifs.controller.js b/back/controllers/objectifs.controller.js new file mode 100644 index 0000000000000000000000000000000000000000..5c161833dba65264ac5dfbf33fe9e0bf268500f2 --- /dev/null +++ b/back/controllers/objectifs.controller.js @@ -0,0 +1,124 @@ +const axios = require('axios'); +const mysql = require('mysql'); +var [dbhost, dbpassword, dbuser] = require('../secrets.js'); + +const dbConfig = { + host: process.env.MYSQL_HOST_IP, + user: process.env.MYSQL_USER, + password: process.env.MYSQL_PASSWORD, + database: process.env.MYSQL_DATABASE, +}; + +function getClassementObjectifs(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "SELECT name,description,value,coef,realise FROM Objectif CROSS JOIN (SELECT SUM(score) as realise FROM Score) AS Realise ORDER BY value DESC;" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function getAdminObjectifs(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "SELECT id,name,description,value,coef FROM Objectif ORDER BY name;" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function addNewObjectif(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "INSERT INTO `Objectif` (`name`, `description`, `value`, `coef`) VALUES ('"+req.body.name+"', '"+req.body.description+"', '"+req.body.value+"', '"+req.body.coef+"');" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateObjectifName(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Objectif SET name = '"+req.body.name+"' WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateObjectifDescription(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Objectif SET description = '"+req.body.description+"' WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateObjectifValue(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Objectif SET value = "+req.body.value+" WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateObjectifCoef(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Objectif SET coef = "+req.body.coef+" WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function deleteObjectif(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "DELETE FROM Objectif WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +module.exports = {getClassementObjectifs,getAdminObjectifs,addNewObjectif,updateObjectifName,updateObjectifDescription,updateObjectifValue,updateObjectifCoef,deleteObjectif} diff --git a/back/controllers/participant.controller.js b/back/controllers/participant.controller.js new file mode 100644 index 0000000000000000000000000000000000000000..0abe73ad718989abe47bcd84b4d3e7e6e4fe91f5 --- /dev/null +++ b/back/controllers/participant.controller.js @@ -0,0 +1,82 @@ +const axios = require('axios'); +const mysql = require('mysql'); +var [dbhost, dbpassword, dbuser] = require('../secrets.js'); + +const dbConfig = { + host: process.env.MYSQL_HOST_IP, + user: process.env.MYSQL_USER, + password: process.env.MYSQL_PASSWORD, + database: process.env.MYSQL_DATABASE, +}; + +function getClassementIndividuel(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "SELECT Participant.name,SUM(score) AS score,COUNT(equipeId) AS nbEquipes,COUNT(score) AS nbScores FROM Score JOIN Participant ON Participant.id=Score.participantId GROUP BY participantId ORDER BY score DESC;" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function getParticipants(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "SELECT id,name FROM Participant;" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function addNewParticipant(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "INSERT INTO `Participant` (`name`) VALUES ('"+req.body.name+"');" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function updateParticipant(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Participant SET name = '"+req.body.name+"' WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function deleteParticipant(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "DELETE FROM Participant WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +module.exports = {getClassementIndividuel,getParticipants,addNewParticipant,updateParticipant,deleteParticipant} diff --git a/back/controllers/scores.controller.js b/back/controllers/scores.controller.js new file mode 100644 index 0000000000000000000000000000000000000000..87ff131c294c6f9829f7606d471121b80e19a110 --- /dev/null +++ b/back/controllers/scores.controller.js @@ -0,0 +1,110 @@ +const axios = require('axios'); +const mysql = require('mysql'); +var [dbhost, dbpassword, dbuser] = require('../secrets.js'); + +const dbConfig = { + host: process.env.MYSQL_HOST_IP, + user: process.env.MYSQL_USER, + password: process.env.MYSQL_PASSWORD, + database: process.env.MYSQL_DATABASE, +}; + +function getAdminScores(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "SELECT Score.id,score,Participant.name AS participant,Equipe.name AS equipe,createdAt as date,Participant.id as partid,Equipe.id as equid FROM Score LEFT JOIN Participant ON Participant.id=Score.ParticipantId LEFT JOIN Equipe ON Score.equipeId=Equipe.id ORDER BY date DESC;" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +}; + +function addNewScore(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "INSERT INTO `Score` (`participantId`, `equipeId`, `score`) VALUES ('"+req.body.participant+"', '"+req.body.equipe+"', '"+req.body.score+"');" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateScore(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Score SET participantId = "+req.body.participant+", equipeId = "+req.body.equipe+", score = "+req.body.score+" WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateScoreScore(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Score SET score = "+req.body.score+" WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateScoreEquipe(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Score SET equipeId = "+req.body.equipe+" WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function updateScoreParticipant(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "UPDATE Score SET participantId = "+req.body.participant+" WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +function deleteScore(req, res){ + var con = mysql.createConnection(dbConfig); + var query = "DELETE FROM Score WHERE id="+req.body.id+";" + con.connect(); + con.query(query, (err, result) => { + if(err){ + console.log(err) + return res.send({success: false}) + } + return res.send(result) + }); + con.end(); +} + +module.exports = {getAdminScores,addNewScore,updateScore,updateScoreScore,updateScoreEquipe,updateScoreParticipant,deleteScore} diff --git a/back/index.js b/back/index.js index 9377cb83b35be3c3f7fc09181e564b8c405e2125..04b6244b664531cc5b798ce31e72d0c89fdc84fa 100644 --- a/back/index.js +++ b/back/index.js @@ -1,53 +1,19 @@ -const cors = require('cors'); -const express = require('express'); -const mysql = require('mysql'); +var express = require('express'); -const app = express(); +var [dbhost, dbpassword, dbuser] = require('./secrets.js'); +var db_port = process.env.DB_PORT || '3036'; -//Connect to the database -const pool = mysql.createPool({ - host: process.env.MYSQL_HOST_IP, - user: process.env.MYSQL_USER, - password: process.env.MYSQL_PASSWORD, - database: process.env.MYSQL_DATABASE, -}); +var apiRouter = require('./routes/api'); -app.use(cors()); +var app = express(); -//Listen to frontend -app.listen(process.env.REACT_APP_SERVER_PORT, () => { - console.log(`App server now listening on port ${process.env.REACT_APP_SERVER_PORT}`); -}); +app.use(express.json()); +app.use(express.urlencoded({ extended: false })); -//Get data for team ranking -app.get('/classement_par_equipes', (req, res) => { - pool.query(`SELECT Equipe.name,SUM(score) AS score,COUNT(participantId) AS nbParticipant,COUNT(score) AS nbScores FROM Score JOIN Equipe ON Equipe.id=Score.equipeId GROUP BY equipeId ORDER BY score DESC;`, (err, results) => { - if (err) { - return res.send(err); - } else { - return res.send(results); - } - }); -}); +app.use('/api', apiRouter); -//Get data for individual ranking -app.get('/classement_individuel', (req, res) => { - pool.query(`SELECT Participant.name,SUM(score) AS score,COUNT(equipeId) AS nbEquipes,COUNT(score) AS nbScores FROM Score JOIN Participant ON Participant.id=Score.participantId GROUP BY participantId ORDER BY score DESC;`, (err, results) => { - if (err) { - return res.send(err); - } else { - return res.send(results); - } - }); +app.listen(process.env.REACT_APP_SERVER_PORT, () => { + console.log(`App server now listening on port ${process.env.REACT_APP_SERVER_PORT}`); }); -//Get data about goals -app.get('/objectifs', (req, res) => { - pool.query(`SELECT name,description,value,coef,realise FROM Objectif CROSS JOIN (SELECT SUM(score) as realise FROM Score) AS Realise ORDER BY value DESC;`, (err, results) => { - if (err) { - return res.send(err); - } else { - return res.send(results); - } - }); -}); +module.exports = app; diff --git a/back/node_modules/.yarn-integrity b/back/node_modules/.yarn-integrity index 0ab417e1bed6b5ea704cdb80b0670155e58f780f..c50a54be1ff3c8195000eda2f4a05ef656ac2f57 100644 --- a/back/node_modules/.yarn-integrity +++ b/back/node_modules/.yarn-integrity @@ -6,6 +6,7 @@ "flags": [], "linkedModules": [], "topLevelPatterns": [ + "axios@^0.19.2", "cors@^2.8.5", "express@^4.17.1", "mysql@^2.18.1", @@ -19,6 +20,7 @@ "ansi-styles@^3.2.1": "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d", "anymatch@~3.1.1": "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.1.tgz#c55ecf02185e2469259399310c173ce31233b142", "array-flatten@1.1.1": "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2", + "axios@^0.19.2": "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27", "balanced-match@^1.0.0": "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767", "bignumber.js@9.0.0": "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.0.0.tgz#805880f84a329b5eac6e7cb6f8274b6d82bdf075", "binary-extensions@^2.0.0": "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c", @@ -47,6 +49,7 @@ "cross-spawn@^5.0.1": "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449", "crypto-random-string@^1.0.0": "https://registry.yarnpkg.com/crypto-random-string/-/crypto-random-string-1.0.0.tgz#a230f64f568310e1498009940790ec99545bca7e", "debug@2.6.9": "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f", + "debug@=3.1.0": "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261", "debug@^2.2.0": "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f", "debug@^3.2.6": "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b", "deep-extend@^0.6.0": "https://registry.yarnpkg.com/deep-extend/-/deep-extend-0.6.0.tgz#c4fa7c95404a17a9c3e8ca7e1537312b736330ac", @@ -63,11 +66,12 @@ "express@^4.17.1": "https://registry.yarnpkg.com/express/-/express-4.17.1.tgz#4491fc38605cf51f8629d39c2b5d026f98a4c134", "fill-range@^7.0.1": "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40", "finalhandler@~1.1.2": "https://registry.yarnpkg.com/finalhandler/-/finalhandler-1.1.2.tgz#b7e7d000ffd11938d0fdb053506f6ebabe9f587d", + "follow-redirects@1.5.10": "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a", "forwarded@~0.1.2": "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84", "fresh@0.5.2": "https://registry.yarnpkg.com/fresh/-/fresh-0.5.2.tgz#3d8cadd90d976569fa835ab1f8e4b23a105605a7", "fsevents@~2.1.2": "https://registry.yarnpkg.com/fsevents/-/fsevents-2.1.2.tgz#4c0a1fb34bc68e543b4b82a9ec392bfbda840805", "get-stream@^3.0.0": "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14", - "glob-parent@~5.1.0": "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2", + "glob-parent@~5.1.0": "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229", "global-dirs@^0.1.0": "https://registry.yarnpkg.com/global-dirs/-/global-dirs-0.1.1.tgz#b319c0dd4607f353f3be9cca4c72fc148c49f445", "got@^6.7.1": "https://registry.yarnpkg.com/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0", "graceful-fs@^4.1.11": "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.3.tgz#4a12ff1b60376ef09862c2093edd908328be8423", @@ -132,8 +136,8 @@ "path-is-inside@^1.0.1": "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53", "path-key@^2.0.0": "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40", "path-to-regexp@0.1.7": "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c", - "picomatch@^2.0.4": "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a", - "picomatch@^2.0.7": "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a", + "picomatch@^2.0.4": "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad", + "picomatch@^2.0.7": "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad", "pify@^3.0.0": "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176", "prepend-http@^1.0.1": "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc", "process-nextick-args@~2.0.0": "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2", diff --git a/back/node_modules/body-parser/package.json b/back/node_modules/body-parser/package.json index 0ed1c3c3db0e145336d041242eaeb273fa92a5be..e815e5b8a6b3cb5bd8462612705c95e1bf060748 100644 --- a/back/node_modules/body-parser/package.json +++ b/back/node_modules/body-parser/package.json @@ -4,7 +4,9 @@ "_inBundle": false, "_integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", "_location": "/body-parser", - "_phantomChildren": {}, + "_phantomChildren": { + "ms": "2.0.0" + }, "_requested": { "type": "version", "registry": true, diff --git a/back/node_modules/debug/.eslintrc b/back/node_modules/debug/.eslintrc index 8a37ae2c2e5a35db74b4607b4c74e0f4fe39a3e4..146371edbe325121c7666716c0fe238310b5e6ca 100644 --- a/back/node_modules/debug/.eslintrc +++ b/back/node_modules/debug/.eslintrc @@ -3,6 +3,9 @@ "browser": true, "node": true }, + "globals": { + "chrome": true + }, "rules": { "no-console": 0, "no-empty": [1, { "allowEmptyCatch": true }] diff --git a/back/node_modules/debug/.travis.yml b/back/node_modules/debug/.travis.yml index 6c6090c3b09f2e45d8c0a1dc77ff5f4a81e78a3c..a764300377fa424ed6b2651e72aaa3d68cd2075f 100644 --- a/back/node_modules/debug/.travis.yml +++ b/back/node_modules/debug/.travis.yml @@ -1,14 +1,20 @@ +sudo: false language: node_js + node_js: - - "6" - - "5" - "4" + - "6" + - "8" install: - - make node_modules + - make install script: - make lint - make test - - make coveralls + +matrix: + include: + - node_js: '8' + env: BROWSER=1 diff --git a/back/node_modules/debug/CHANGELOG.md b/back/node_modules/debug/CHANGELOG.md index eadaa189517bbcfb2a6784a48ac8d05d2edafe7c..820d21e3322b9d2778786ea743dd5e818991d595 100644 --- a/back/node_modules/debug/CHANGELOG.md +++ b/back/node_modules/debug/CHANGELOG.md @@ -1,4 +1,37 @@ +3.1.0 / 2017-09-26 +================== + + * Add `DEBUG_HIDE_DATE` env var (#486) + * Remove ReDoS regexp in %o formatter (#504) + * Remove "component" from package.json + * Remove `component.json` + * Ignore package-lock.json + * Examples: fix colors printout + * Fix: browser detection + * Fix: spelling mistake (#496, @EdwardBetts) + +3.0.1 / 2017-08-24 +================== + + * Fix: Disable colors in Edge and Internet Explorer (#489) + +3.0.0 / 2017-08-08 +================== + + * Breaking: Remove DEBUG_FD (#406) + * Breaking: Use `Date#toISOString()` instead to `Date#toUTCString()` when output is not a TTY (#418) + * Breaking: Make millisecond timer namespace specific and allow 'always enabled' output (#408) + * Addition: document `enabled` flag (#465) + * Addition: add 256 colors mode (#481) + * Addition: `enabled()` updates existing debug instances, add `destroy()` function (#440) + * Update: component: update "ms" to v2.0.0 + * Update: separate the Node and Browser tests in Travis-CI + * Update: refactor Readme, fixed documentation, added "Namespace Colors" section, redid screenshots + * Update: separate Node.js and web browser examples for organization + * Update: update "browserify" to v14.4.0 + * Fix: fix Readme typo (#473) + 2.6.9 / 2017-09-22 ================== @@ -27,7 +60,7 @@ 2.6.4 / 2017-04-20 ================== - * Fix: bug that would occure if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) + * Fix: bug that would occur if process.env.DEBUG is a non-string value. (#444, @LucianBuzzo) * Chore: ignore bower.json in npm installations. (#437, @joaovieira) * Misc: update "ms" to v0.7.3 (@tootallnate) diff --git a/back/node_modules/debug/Makefile b/back/node_modules/debug/Makefile index 584da8bf938e639ece3ba2bd4105c215c2b1ff51..3ddd1360e6a95e6d7161f2d4d4f8cb9a0816f577 100644 --- a/back/node_modules/debug/Makefile +++ b/back/node_modules/debug/Makefile @@ -15,36 +15,44 @@ YARN ?= $(shell which yarn) PKG ?= $(if $(YARN),$(YARN),$(NODE) $(shell which npm)) BROWSERIFY ?= $(NODE) $(BIN)/browserify -.FORCE: - install: node_modules +browser: dist/debug.js + node_modules: package.json @NODE_ENV= $(PKG) install @touch node_modules -lint: .FORCE - eslint browser.js debug.js index.js node.js - -test-node: .FORCE - istanbul cover node_modules/mocha/bin/_mocha -- test/**.js - -test-browser: .FORCE - mkdir -p dist - +dist/debug.js: src/*.js node_modules + @mkdir -p dist @$(BROWSERIFY) \ --standalone debug \ . > dist/debug.js - karma start --single-run - rimraf dist +lint: + @eslint *.js src/*.js + +test-node: + @istanbul cover node_modules/mocha/bin/_mocha -- test/**.js + @cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js -test: .FORCE - concurrently \ +test-browser: + @$(MAKE) browser + @karma start --single-run + +test-all: + @concurrently \ "make test-node" \ "make test-browser" -coveralls: - cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js +test: + @if [ "x$(BROWSER)" = "x" ]; then \ + $(MAKE) test-node; \ + else \ + $(MAKE) test-browser; \ + fi + +clean: + rimraf dist coverage -.PHONY: all install clean distclean +.PHONY: browser install clean lint test test-all test-node test-browser diff --git a/back/node_modules/debug/README.md b/back/node_modules/debug/README.md index f67be6b317c19952bb506a9e15e797615eea4533..8e754d17b164ad9c15b82e26426afa71298a34d1 100644 --- a/back/node_modules/debug/README.md +++ b/back/node_modules/debug/README.md @@ -1,12 +1,11 @@ # debug -[](https://travis-ci.org/visionmedia/debug) [](https://coveralls.io/github/visionmedia/debug?branch=master) [](https://visionmedia-community-slackin.now.sh/) [](#backers) +[](https://travis-ci.org/visionmedia/debug) [](https://coveralls.io/github/visionmedia/debug?branch=master) [](https://visionmedia-community-slackin.now.sh/) [](#backers) [](#sponsors) +<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png"> - -A tiny node.js debugging utility modelled after node core's debugging technique. - -**Discussion around the V3 API is under way [here](https://github.com/visionmedia/debug/issues/370)** +A tiny JavaScript debugging utility modelled after Node.js core's debugging +technique. Works in Node.js and web browsers. ## Installation @@ -18,7 +17,7 @@ $ npm install debug `debug` exposes a function; simply pass this function the name of your module, and it will return a decorated version of `console.error` for you to pass debug statements to. This will allow you to toggle the debug output for different parts of your module as well as the module as a whole. -Example _app.js_: +Example [_app.js_](./examples/node/app.js): ```js var debug = require('debug')('http') @@ -27,7 +26,7 @@ var debug = require('debug')('http') // fake app -debug('booting %s', name); +debug('booting %o', name); http.createServer(function(req, res){ debug(req.method + ' ' + req.url); @@ -41,81 +40,128 @@ http.createServer(function(req, res){ require('./worker'); ``` -Example _worker.js_: +Example [_worker.js_](./examples/node/worker.js): ```js -var debug = require('debug')('worker'); +var a = require('debug')('worker:a') + , b = require('debug')('worker:b'); -setInterval(function(){ - debug('doing some work'); -}, 1000); +function work() { + a('doing lots of uninteresting work'); + setTimeout(work, Math.random() * 1000); +} + +work(); + +function workb() { + b('doing some work'); + setTimeout(workb, Math.random() * 2000); +} + +workb(); ``` - The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples: +The `DEBUG` environment variable is then used to enable these based on space or +comma-delimited names. -  +Here are some examples: -  +<img width="647" alt="screen shot 2017-08-08 at 12 53 04 pm" src="https://user-images.githubusercontent.com/71256/29091703-a6302cdc-7c38-11e7-8304-7c0b3bc600cd.png"> +<img width="647" alt="screen shot 2017-08-08 at 12 53 38 pm" src="https://user-images.githubusercontent.com/71256/29091700-a62a6888-7c38-11e7-800b-db911291ca2b.png"> +<img width="647" alt="screen shot 2017-08-08 at 12 53 25 pm" src="https://user-images.githubusercontent.com/71256/29091701-a62ea114-7c38-11e7-826a-2692bedca740.png"> #### Windows note - On Windows the environment variable is set using the `set` command. +On Windows the environment variable is set using the `set` command. - ```cmd - set DEBUG=*,-not_this - ``` +```cmd +set DEBUG=*,-not_this +``` - Note that PowerShell uses different syntax to set environment variables. +Note that PowerShell uses different syntax to set environment variables. - ```cmd - $env:DEBUG = "*,-not_this" - ``` +```cmd +$env:DEBUG = "*,-not_this" +``` Then, run the program to be debugged as usual. + +## Namespace Colors + +Every debug instance has a color generated for it based on its namespace name. +This helps when visually parsing the debug output to identify which debug instance +a debug line belongs to. + +#### Node.js + +In Node.js, colors are enabled when stderr is a TTY. You also _should_ install +the [`supports-color`](https://npmjs.org/supports-color) module alongside debug, +otherwise debug will only use a small handful of basic colors. + +<img width="521" src="https://user-images.githubusercontent.com/71256/29092181-47f6a9e6-7c3a-11e7-9a14-1928d8a711cd.png"> + +#### Web Browser + +Colors are also enabled on "Web Inspectors" that understand the `%c` formatting +option. These are WebKit web inspectors, Firefox ([since version +31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) +and the Firebug plugin for Firefox (any version). + +<img width="524" src="https://user-images.githubusercontent.com/71256/29092033-b65f9f2e-7c39-11e7-8e32-f6f0d8e865c1.png"> + + ## Millisecond diff - When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. +When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls. + +<img width="647" src="https://user-images.githubusercontent.com/71256/29091486-fa38524c-7c37-11e7-895f-e7ec8e1039b6.png"> -  +When stdout is not a TTY, `Date#toISOString()` is used, making it more useful for logging the debug information as shown below: - When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below: +<img width="647" src="https://user-images.githubusercontent.com/71256/29091956-6bd78372-7c39-11e7-8c55-c948396d6edd.png"> -  ## Conventions - If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". +If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser". If you append a "*" to the end of your name, it will always be enabled regardless of the setting of the DEBUG environment variable. You can then use it for normal output as well as debug output. ## Wildcards - The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. +The `*` character may be used as a wildcard. Suppose for example your library has +debuggers named "connect:bodyParser", "connect:compress", "connect:session", +instead of listing all three with +`DEBUG=connect:bodyParser,connect:compress,connect:session`, you may simply do +`DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`. - You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:". +You can also exclude specific debuggers by prefixing them with a "-" character. +For example, `DEBUG=*,-connect:*` would include all debuggers except those +starting with "connect:". ## Environment Variables - When running through Node.js, you can set a few environment variables that will - change the behavior of the debug logging: +When running through Node.js, you can set a few environment variables that will +change the behavior of the debug logging: | Name | Purpose | |-----------|-------------------------------------------------| | `DEBUG` | Enables/disables specific debugging namespaces. | +| `DEBUG_HIDE_DATE` | Hide date from debug output (non-TTY). | | `DEBUG_COLORS`| Whether or not to use colors in the debug output. | -| `DEBUG_DEPTH` | Object inspection depth. | +| `DEBUG_DEPTH` | Object inspection depth. | | `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. | - __Note:__ The environment variables beginning with `DEBUG_` end up being - converted into an Options object that gets used with `%o`/`%O` formatters. - See the Node.js documentation for - [`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) - for the complete list. +__Note:__ The environment variables beginning with `DEBUG_` end up being +converted into an Options object that gets used with `%o`/`%O` formatters. +See the Node.js documentation for +[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options) +for the complete list. ## Formatters - - Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. Below are the officially supported formatters: +Debug uses [printf-style](https://wikipedia.org/wiki/Printf_format_string) formatting. +Below are the officially supported formatters: | Formatter | Representation | |-----------|----------------| @@ -126,9 +172,12 @@ Then, run the program to be debugged as usual. | `%j` | JSON. Replaced with the string '[Circular]' if the argument contains circular references. | | `%%` | Single percent sign ('%'). This does not consume an argument. | + ### Custom formatters - You can add custom formatters by extending the `debug.formatters` object. For example, if you wanted to add support for rendering a Buffer as hex with `%h`, you could do something like: +You can add custom formatters by extending the `debug.formatters` object. +For example, if you wanted to add support for rendering a Buffer as hex with +`%h`, you could do something like: ```js const createDebug = require('debug') @@ -142,14 +191,16 @@ debug('this is hex: %h', new Buffer('hello world')) // foo this is hex: 68656c6c6f20776f726c6421 +0ms ``` -## Browser support - You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), - or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), - if you don't want to build it yourself. - Debug's enable state is currently persisted by `localStorage`. - Consider the situation shown below where you have `worker:a` and `worker:b`, - and wish to debug both. You can enable this using `localStorage.debug`: +## Browser Support + +You can build a browser-ready script using [browserify](https://github.com/substack/node-browserify), +or just use the [browserify-as-a-service](https://wzrd.in/) [build](https://wzrd.in/standalone/debug@latest), +if you don't want to build it yourself. + +Debug's enable state is currently persisted by `localStorage`. +Consider the situation shown below where you have `worker:a` and `worker:b`, +and wish to debug both. You can enable this using `localStorage.debug`: ```js localStorage.debug = 'worker:*' @@ -170,23 +221,12 @@ setInterval(function(){ }, 1200); ``` -#### Web Inspector Colors - - Colors are also enabled on "Web Inspectors" that understand the `%c` formatting - option. These are WebKit web inspectors, Firefox ([since version - 31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/)) - and the Firebug plugin for Firefox (any version). - - Colored output looks something like: - -  - ## Output streams By default `debug` will log to stderr, however this can be configured per-namespace by overriding the `log` method: -Example _stdout.js_: +Example [_stdout.js_](./examples/node/stdout.js): ```js var debug = require('debug'); @@ -208,13 +248,29 @@ error('now goes to stdout via console.info'); log('still goes to stdout, but via console.info now'); ``` +## Checking whether a debug target is enabled + +After you've created a debug instance, you can determine whether or not it is +enabled by checking the `enabled` property: + +```javascript +const debug = require('debug')('http'); + +if (debug.enabled) { + // do stuff... +} +``` + +You can also manually toggle this property to force the debug instance to be +enabled or disabled. + ## Authors - TJ Holowaychuk - Nathan Rajlich - Andrew Rhyne - + ## Backers Support us with a monthly donation and help us continue our activities. [[Become a backer](https://opencollective.com/debug#backer)] @@ -290,7 +346,7 @@ Become a sponsor and get your logo on our README on Github with a link to your s (The MIT License) -Copyright (c) 2014-2016 TJ Holowaychuk <tj@vision-media.ca> +Copyright (c) 2014-2017 TJ Holowaychuk <tj@vision-media.ca> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the diff --git a/back/node_modules/debug/component.json b/back/node_modules/debug/component.json deleted file mode 100644 index 9de26410f0d0bba2e48a07f094407d602eb5dd89..0000000000000000000000000000000000000000 --- a/back/node_modules/debug/component.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "debug", - "repo": "visionmedia/debug", - "description": "small debugging utility", - "version": "2.6.9", - "keywords": [ - "debug", - "log", - "debugger" - ], - "main": "src/browser.js", - "scripts": [ - "src/browser.js", - "src/debug.js" - ], - "dependencies": { - "rauchg/ms.js": "0.7.1" - } -} diff --git a/back/node_modules/debug/package.json b/back/node_modules/debug/package.json index ec1b097d8a866c3c11e81a23c56d42a68924d93e..3dd5474b7e6418853f7dd68fe9f7f65329b5364b 100644 --- a/back/node_modules/debug/package.json +++ b/back/node_modules/debug/package.json @@ -1,31 +1,27 @@ { - "_from": "debug@2.6.9", - "_id": "debug@2.6.9", + "_from": "debug@=3.1.0", + "_id": "debug@3.1.0", "_inBundle": false, - "_integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "_integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "_location": "/debug", "_phantomChildren": {}, "_requested": { "type": "version", "registry": true, - "raw": "debug@2.6.9", + "raw": "debug@=3.1.0", "name": "debug", "escapedName": "debug", - "rawSpec": "2.6.9", + "rawSpec": "=3.1.0", "saveSpec": null, - "fetchSpec": "2.6.9" + "fetchSpec": "=3.1.0" }, "_requiredBy": [ - "/body-parser", - "/express", - "/finalhandler", - "/send", - "/undefsafe" + "/follow-redirects" ], - "_resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "_shasum": "5d128515df134ff327e90a4c93f4e077a536341f", - "_spec": "debug@2.6.9", - "_where": "/home/coshyperbolix/Projets_git/leaderboard/back/node_modules/express", + "_resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "_shasum": "5bb5a0672628b64149566ba16819e61518c67261", + "_spec": "debug@=3.1.0", + "_where": "/home/coshyperbolix/Projets_git/leaderboard/back/node_modules/follow-redirects", "author": { "name": "TJ Holowaychuk", "email": "tj@vision-media.ca" @@ -35,12 +31,6 @@ "url": "https://github.com/visionmedia/debug/issues" }, "bundleDependencies": false, - "component": { - "scripts": { - "debug/index.js": "browser.js", - "debug/debug.js": "debug.js" - } - }, "contributors": [ { "name": "Nathan Rajlich", @@ -58,7 +48,7 @@ "deprecated": false, "description": "small debugging utility", "devDependencies": { - "browserify": "9.0.3", + "browserify": "14.4.0", "chai": "^3.5.0", "concurrently": "^3.1.0", "coveralls": "^2.11.15", @@ -88,5 +78,5 @@ "type": "git", "url": "git://github.com/visionmedia/debug.git" }, - "version": "2.6.9" + "version": "3.1.0" } diff --git a/back/node_modules/debug/src/browser.js b/back/node_modules/debug/src/browser.js index 7106924934501fd4035efe78678281020328acc5..f5149ff5296aa11442834d29fdc8565bb159d0be 100644 --- a/back/node_modules/debug/src/browser.js +++ b/back/node_modules/debug/src/browser.js @@ -20,12 +20,17 @@ exports.storage = 'undefined' != typeof chrome */ exports.colors = [ - 'lightseagreen', - 'forestgreen', - 'goldenrod', - 'dodgerblue', - 'darkorchid', - 'crimson' + '#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', + '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', + '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', + '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', + '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', + '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', + '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', + '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', + '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', + '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', + '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33' ]; /** @@ -44,6 +49,11 @@ function useColors() { return true; } + // Internet Explorer and Edge do not support colors. + if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { + return false; + } + // is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) || diff --git a/back/node_modules/debug/src/debug.js b/back/node_modules/debug/src/debug.js index 6a5e3fc94c3ab80e123c3056b6c5dbe056d21658..77e6384a3397605624a1706eb864455f8e7f38ba 100644 --- a/back/node_modules/debug/src/debug.js +++ b/back/node_modules/debug/src/debug.js @@ -13,6 +13,11 @@ exports.enable = enable; exports.enabled = enabled; exports.humanize = require('ms'); +/** + * Active `debug` instances. + */ +exports.instances = []; + /** * The currently active debug mode names, and names to skip. */ @@ -28,12 +33,6 @@ exports.skips = []; exports.formatters = {}; -/** - * Previous log timestamp. - */ - -var prevTime; - /** * Select a color. * @param {String} namespace @@ -62,6 +61,8 @@ function selectColor(namespace) { function createDebug(namespace) { + var prevTime; + function debug() { // disabled? if (!debug.enabled) return; @@ -118,15 +119,28 @@ function createDebug(namespace) { debug.enabled = exports.enabled(namespace); debug.useColors = exports.useColors(); debug.color = selectColor(namespace); + debug.destroy = destroy; // env-specific initialization logic for debug instances if ('function' === typeof exports.init) { exports.init(debug); } + exports.instances.push(debug); + return debug; } +function destroy () { + var index = exports.instances.indexOf(this); + if (index !== -1) { + exports.instances.splice(index, 1); + return true; + } else { + return false; + } +} + /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. @@ -141,10 +155,11 @@ function enable(namespaces) { exports.names = []; exports.skips = []; + var i; var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); var len = split.length; - for (var i = 0; i < len; i++) { + for (i = 0; i < len; i++) { if (!split[i]) continue; // ignore empty strings namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { @@ -153,6 +168,11 @@ function enable(namespaces) { exports.names.push(new RegExp('^' + namespaces + '$')); } } + + for (i = 0; i < exports.instances.length; i++) { + var instance = exports.instances[i]; + instance.enabled = exports.enabled(instance.namespace); + } } /** @@ -174,6 +194,9 @@ function disable() { */ function enabled(name) { + if (name[name.length - 1] === '*') { + return true; + } var i, len; for (i = 0, len = exports.skips.length; i < len; i++) { if (exports.skips[i].test(name)) { diff --git a/back/node_modules/debug/src/index.js b/back/node_modules/debug/src/index.js index e12cf4d58c9f2d6d2d2e656f9cbb0f703cb5fa29..cabcbcda135e862c4780a270a8df97784e65ebb3 100644 --- a/back/node_modules/debug/src/index.js +++ b/back/node_modules/debug/src/index.js @@ -3,7 +3,7 @@ * treat as a browser. */ -if (typeof process !== 'undefined' && process.type === 'renderer') { +if (typeof process === 'undefined' || process.type === 'renderer') { module.exports = require('./browser.js'); } else { module.exports = require('./node.js'); diff --git a/back/node_modules/debug/src/inspector-log.js b/back/node_modules/debug/src/inspector-log.js deleted file mode 100644 index 60ea6c04aafd41d0ea3bcd78f58312ecf0eda436..0000000000000000000000000000000000000000 --- a/back/node_modules/debug/src/inspector-log.js +++ /dev/null @@ -1,15 +0,0 @@ -module.exports = inspectorLog; - -// black hole -const nullStream = new (require('stream').Writable)(); -nullStream._write = () => {}; - -/** - * Outputs a `console.log()` to the Node.js Inspector console *only*. - */ -function inspectorLog() { - const stdout = console._stdout; - console._stdout = nullStream; - console.log.apply(console, arguments); - console._stdout = stdout; -} diff --git a/back/node_modules/debug/src/node.js b/back/node_modules/debug/src/node.js index b15109c905a45bcb5db701cf37cf4e19385c3167..d666fb9c00919bf71317101ebe1096df0e43b215 100644 --- a/back/node_modules/debug/src/node.js +++ b/back/node_modules/debug/src/node.js @@ -23,7 +23,22 @@ exports.useColors = useColors; * Colors. */ -exports.colors = [6, 2, 3, 4, 5, 1]; +exports.colors = [ 6, 2, 3, 4, 5, 1 ]; + +try { + var supportsColor = require('supports-color'); + if (supportsColor && supportsColor.level >= 2) { + exports.colors = [ + 20, 21, 26, 27, 32, 33, 38, 39, 40, 41, 42, 43, 44, 45, 56, 57, 62, 63, 68, + 69, 74, 75, 76, 77, 78, 79, 80, 81, 92, 93, 98, 99, 112, 113, 128, 129, 134, + 135, 148, 149, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, + 172, 173, 178, 179, 184, 185, 196, 197, 198, 199, 200, 201, 202, 203, 204, + 205, 206, 207, 208, 209, 214, 215, 220, 221 + ]; + } +} catch (err) { + // swallow - we only care if `supports-color` is available; it doesn't have to be. +} /** * Build up the default `inspectOpts` object from the environment variables. @@ -51,23 +66,6 @@ exports.inspectOpts = Object.keys(process.env).filter(function (key) { return obj; }, {}); -/** - * The file descriptor to write the `debug()` calls to. - * Set the `DEBUG_FD` env variable to override with another value. i.e.: - * - * $ DEBUG_FD=3 node script.js 3>debug.log - */ - -var fd = parseInt(process.env.DEBUG_FD, 10) || 2; - -if (1 !== fd && 2 !== fd) { - util.deprecate(function(){}, 'except for stderr(2) and stdout(1), any other usage of DEBUG_FD is deprecated. Override debug.log if you want to use a different log function (https://git.io/debug_fd)')() -} - -var stream = 1 === fd ? process.stdout : - 2 === fd ? process.stderr : - createWritableStdioStream(fd); - /** * Is stdout a TTY? Colored output is enabled when `true`. */ @@ -75,7 +73,7 @@ var stream = 1 === fd ? process.stdout : function useColors() { return 'colors' in exports.inspectOpts ? Boolean(exports.inspectOpts.colors) - : tty.isatty(fd); + : tty.isatty(process.stderr.fd); } /** @@ -111,22 +109,30 @@ function formatArgs(args) { if (useColors) { var c = this.color; - var prefix = ' \u001b[3' + c + ';1m' + name + ' ' + '\u001b[0m'; + var colorCode = '\u001b[3' + (c < 8 ? c : '8;5;' + c); + var prefix = ' ' + colorCode + ';1m' + name + ' ' + '\u001b[0m'; args[0] = prefix + args[0].split('\n').join('\n' + prefix); - args.push('\u001b[3' + c + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); + args.push(colorCode + 'm+' + exports.humanize(this.diff) + '\u001b[0m'); + } else { + args[0] = getDate() + name + ' ' + args[0]; + } +} + +function getDate() { + if (exports.inspectOpts.hideDate) { + return ''; } else { - args[0] = new Date().toUTCString() - + ' ' + name + ' ' + args[0]; + return new Date().toISOString() + ' '; } } /** - * Invokes `util.format()` with the specified arguments and writes to `stream`. + * Invokes `util.format()` with the specified arguments and writes to stderr. */ function log() { - return stream.write(util.format.apply(util, arguments) + '\n'); + return process.stderr.write(util.format.apply(util, arguments) + '\n'); } /** @@ -157,74 +163,6 @@ function load() { return process.env.DEBUG; } -/** - * Copied from `node/src/node.js`. - * - * XXX: It's lame that node doesn't expose this API out-of-the-box. It also - * relies on the undocumented `tty_wrap.guessHandleType()` which is also lame. - */ - -function createWritableStdioStream (fd) { - var stream; - var tty_wrap = process.binding('tty_wrap'); - - // Note stream._type is used for test-module-load-list.js - - switch (tty_wrap.guessHandleType(fd)) { - case 'TTY': - stream = new tty.WriteStream(fd); - stream._type = 'tty'; - - // Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - case 'FILE': - var fs = require('fs'); - stream = new fs.SyncWriteStream(fd, { autoClose: false }); - stream._type = 'fs'; - break; - - case 'PIPE': - case 'TCP': - var net = require('net'); - stream = new net.Socket({ - fd: fd, - readable: false, - writable: true - }); - - // FIXME Should probably have an option in net.Socket to create a - // stream from an existing fd which is writable only. But for now - // we'll just add this hack and set the `readable` member to false. - // Test: ./node test/fixtures/echo.js < /etc/passwd - stream.readable = false; - stream.read = null; - stream._type = 'pipe'; - - // FIXME Hack to have stream not keep the event loop alive. - // See https://github.com/joyent/node/issues/1726 - if (stream._handle && stream._handle.unref) { - stream._handle.unref(); - } - break; - - default: - // Probably an error on in uv_guess_handle() - throw new Error('Implement me. Unknown stream file type!'); - } - - // For supporting legacy API we put the FD here. - stream.fd = fd; - - stream._isStdio = true; - - return stream; -} - /** * Init logic for `debug` instances. * diff --git a/back/node_modules/express/package.json b/back/node_modules/express/package.json index 3fddb55e74b775ca3fe14b0bd47f77f5aa4eb6d9..f94bf27cfbf7cf39158fcbfc4236b3e7a8a5bd86 100644 --- a/back/node_modules/express/package.json +++ b/back/node_modules/express/package.json @@ -4,7 +4,9 @@ "_inBundle": false, "_integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", "_location": "/express", - "_phantomChildren": {}, + "_phantomChildren": { + "ms": "2.0.0" + }, "_requested": { "type": "version", "registry": true, diff --git a/back/node_modules/finalhandler/package.json b/back/node_modules/finalhandler/package.json index a49cd142505b1bbea52ab412140b03dd6cb59735..d698fe972443effd6c29cd5383a60ac0c3664841 100644 --- a/back/node_modules/finalhandler/package.json +++ b/back/node_modules/finalhandler/package.json @@ -4,7 +4,9 @@ "_inBundle": false, "_integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", "_location": "/finalhandler", - "_phantomChildren": {}, + "_phantomChildren": { + "ms": "2.0.0" + }, "_requested": { "type": "range", "registry": true, diff --git a/back/node_modules/glob-parent/index.js b/back/node_modules/glob-parent/index.js index 2ded6ea7e63ba0533a7525cd2024949de823bd67..789dbbf2ff09ef431eb7296c0b3cdc44c645c549 100644 --- a/back/node_modules/glob-parent/index.js +++ b/back/node_modules/glob-parent/index.js @@ -8,7 +8,7 @@ var slash = '/'; var backslash = /\\/g; var enclosure = /[\{\[].*[\/]*.*[\}\]]$/; var globby = /(^|[^\\])([\{\[]|\([^\)]+$)/; -var escaped = /\\([\*\?\|\[\]\(\)\{\}])/g; +var escaped = /\\([\!\*\?\|\[\]\(\)\{\}])/g; /** * @param {string} str diff --git a/back/node_modules/glob-parent/package.json b/back/node_modules/glob-parent/package.json index 0d42cba74a1de7ef2e9c859ebee0808916570880..946815837edf739ec335051e6e06084d7e1edbb4 100644 --- a/back/node_modules/glob-parent/package.json +++ b/back/node_modules/glob-parent/package.json @@ -1,8 +1,8 @@ { "_from": "glob-parent@~5.1.0", - "_id": "glob-parent@5.1.0", + "_id": "glob-parent@5.1.1", "_inBundle": false, - "_integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "_integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", "_location": "/glob-parent", "_phantomChildren": {}, "_requested": { @@ -18,8 +18,8 @@ "_requiredBy": [ "/chokidar" ], - "_resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", - "_shasum": "5f4c1d1e748d30cd73ad2944b3577a81b081e8c2", + "_resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "_shasum": "b6c1ef417c4e5663ea498f1c45afac6916bbc229", "_spec": "glob-parent@~5.1.0", "_where": "/home/coshyperbolix/Projets_git/leaderboard/back/node_modules/chokidar", "author": { @@ -47,7 +47,7 @@ "deprecated": false, "description": "Extract the non-magic parent path from a glob string.", "devDependencies": { - "coveralls": "github:phated/node-coveralls#2.x", + "coveralls": "^3.0.11", "eslint": "^2.13.1", "eslint-config-gulp": "^3.0.1", "expect": "^1.20.2", @@ -86,5 +86,5 @@ "pretest": "npm run lint", "test": "nyc mocha --async-only" }, - "version": "5.1.0" + "version": "5.1.1" } diff --git a/back/node_modules/ms/package.json b/back/node_modules/ms/package.json index 984bda5ab4a4e2a062fef2a6a6ee49a5c4632db3..4fd669355a13b2ce95d6a6355270afdfb8c5b1fa 100644 --- a/back/node_modules/ms/package.json +++ b/back/node_modules/ms/package.json @@ -16,7 +16,11 @@ "fetchSpec": "2.0.0" }, "_requiredBy": [ - "/debug" + "/body-parser/debug", + "/debug", + "/express/debug", + "/finalhandler/debug", + "/undefsafe/debug" ], "_resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "_shasum": "5608aeadfc00be6c2901df5f9861788de0d597c8", diff --git a/back/node_modules/picomatch/CHANGELOG.md b/back/node_modules/picomatch/CHANGELOG.md old mode 100644 new mode 100755 index e672bd399302015b69075c24de58853a165086b2..7af58619f75cc850f9da1c0a3200b1a891262435 --- a/back/node_modules/picomatch/CHANGELOG.md +++ b/back/node_modules/picomatch/CHANGELOG.md @@ -32,6 +32,12 @@ Changelog entries are classified using the following labels _(from [keep-a-chang </details> +## 2.2.2 (2020-03-21) + +### Fixed + +* Correctly handle parts of the pattern after parentheses in the `scan` method ([e15b920](https://github.com/micromatch/picomatch/commit/e15b920)). + ## 2.2.1 (2020-01-04) * Fixes [#49](https://github.com/micromatch/picomatch/issues/49), so that braces with no sets or ranges are now propertly treated as literals. diff --git a/back/node_modules/picomatch/LICENSE b/back/node_modules/picomatch/LICENSE old mode 100644 new mode 100755 diff --git a/back/node_modules/picomatch/README.md b/back/node_modules/picomatch/README.md old mode 100644 new mode 100755 index ebdf473df98ec286c8f327346a5e930deab5c72c..7737151bf7bba676127f39f805660b14712db48b --- a/back/node_modules/picomatch/README.md +++ b/back/node_modules/picomatch/README.md @@ -234,13 +234,13 @@ console.log(result); negated: true } ``` -### [.compileRe](lib/picomatch.js#L249) +### [.compileRe](lib/picomatch.js#L250) -Create a regular expression from a glob pattern. +Create a regular expression from a parsed glob pattern. **Params** -* `input` **{String}**: A glob pattern to convert to regex. +* `state` **{String}**: The object returned from the `.parse` method. * `options` **{Object}** * `returns` **{RegExp}**: Returns a regex created from the given pattern. @@ -248,13 +248,14 @@ Create a regular expression from a glob pattern. ```js const picomatch = require('picomatch'); -// picomatch.makeRe(input[, options]); +const state = picomatch.parse('*.js'); +// picomatch.compileRe(state[, options]); -console.log(picomatch.makeRe('*.js')); +console.log(picomatch.compileRe(state)); //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ ``` -### [.toRegex](lib/picomatch.js#L317) +### [.toRegex](lib/picomatch.js#L318) Create a regular expression from the given regex source string. diff --git a/back/node_modules/picomatch/index.js b/back/node_modules/picomatch/index.js old mode 100644 new mode 100755 diff --git a/back/node_modules/picomatch/lib/constants.js b/back/node_modules/picomatch/lib/constants.js old mode 100644 new mode 100755 diff --git a/back/node_modules/picomatch/lib/parse.js b/back/node_modules/picomatch/lib/parse.js old mode 100644 new mode 100755 index e4c8042e79837ffc50ecd769eb0b92d21e008ff3..34bdc2f90e5786e3cff20ee702c219977bad4f88 --- a/back/node_modules/picomatch/lib/parse.js +++ b/back/node_modules/picomatch/lib/parse.js @@ -228,8 +228,6 @@ const parse = (input, options) => { const output = (opts.capture ? '(' : '') + token.open; increment('parens'); - - push({ type, value, output: state.output ? '' : ONE_CHAR }); push({ type: 'paren', extglob: true, value: advance(), output }); extglobs.push(token); @@ -585,7 +583,7 @@ const parse = (input, options) => { const out = state.output.slice(0, brace.outputIndex); const toks = state.tokens.slice(brace.tokensIndex); brace.value = brace.output = '\\{'; - value = output = `\\}`; + value = output = '\\}'; state.output = out; for (const t of toks) { state.output += (t.output || t.value); diff --git a/back/node_modules/picomatch/lib/picomatch.js b/back/node_modules/picomatch/lib/picomatch.js old mode 100644 new mode 100755 index 7fe41db0f7a02f9fb9dfb4be14920424f8fc8058..df7438a94f826aa070313f7ae16b21a70a493a60 --- a/back/node_modules/picomatch/lib/picomatch.js +++ b/back/node_modules/picomatch/lib/picomatch.js @@ -231,16 +231,17 @@ picomatch.parse = (pattern, options) => { picomatch.scan = (input, options) => scan(input, options); /** - * Create a regular expression from a glob pattern. + * Create a regular expression from a parsed glob pattern. * * ```js * const picomatch = require('picomatch'); - * // picomatch.makeRe(input[, options]); + * const state = picomatch.parse('*.js'); + * // picomatch.compileRe(state[, options]); * - * console.log(picomatch.makeRe('*.js')); + * console.log(picomatch.compileRe(state)); * //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/ * ``` - * @param {String} `input` A glob pattern to convert to regex. + * @param {String} `state` The object returned from the `.parse` method. * @param {Object} `options` * @return {RegExp} Returns a regex created from the given pattern. * @api public diff --git a/back/node_modules/picomatch/lib/scan.js b/back/node_modules/picomatch/lib/scan.js old mode 100644 new mode 100755 index f291890df0fe029277f5a64ba74fcae54786daa2..31ae6adbe8a8ce3316bdbc79fe2a2252de8b6471 --- a/back/node_modules/picomatch/lib/scan.js +++ b/back/node_modules/picomatch/lib/scan.js @@ -247,23 +247,24 @@ const scan = (input, options) => { } if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) { - while (eos() !== true && (code = advance())) { - if (code === CHAR_BACKWARD_SLASH) { - backslashes = token.backslashes = true; - code = advance(); - continue; - } - - if (code === CHAR_RIGHT_PARENTHESES) { - isGlob = token.isGlob = true; - finished = true; + isGlob = token.isGlob = true; - if (scanToEnd === true) { + if (scanToEnd === true) { + while (eos() !== true && (code = advance())) { + if (code === CHAR_LEFT_PARENTHESES) { + backslashes = token.backslashes = true; + code = advance(); continue; } - break; + + if (code === CHAR_RIGHT_PARENTHESES) { + finished = true; + break; + } } + continue; } + break; } if (isGlob === true) { diff --git a/back/node_modules/picomatch/lib/utils.js b/back/node_modules/picomatch/lib/utils.js old mode 100644 new mode 100755 diff --git a/back/node_modules/picomatch/package.json b/back/node_modules/picomatch/package.json old mode 100644 new mode 100755 index 000825a5f33125e72a1ee0426ba7313c40136057..544f2c2c1cf55e4b227e9b6c3c53a1b0758febb2 --- a/back/node_modules/picomatch/package.json +++ b/back/node_modules/picomatch/package.json @@ -1,8 +1,8 @@ { "_from": "picomatch@^2.0.4", - "_id": "picomatch@2.2.1", + "_id": "picomatch@2.2.2", "_inBundle": false, - "_integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==", + "_integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", "_location": "/picomatch", "_phantomChildren": {}, "_requested": { @@ -19,8 +19,8 @@ "/anymatch", "/readdirp" ], - "_resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", - "_shasum": "21bac888b6ed8601f831ce7816e335bc779f0a4a", + "_resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "_shasum": "21f333e9b6b8eaff02468f5146ea406d345f4dad", "_spec": "picomatch@^2.0.4", "_where": "/home/coshyperbolix/Projets_git/leaderboard/back/node_modules/anymatch", "author": { @@ -73,7 +73,7 @@ "lint": "eslint --cache --cache-location node_modules/.cache/.eslintcache --report-unused-disable-directives --ignore-path .gitignore .", "mocha": "mocha --reporter dot", "test": "npm run lint && npm run mocha", - "test:ci": "npm run lint && npm run test:cover", + "test:ci": "npm run test:cover", "test:cover": "nyc npm run mocha" }, "verb": { @@ -109,5 +109,5 @@ "picomatch" ] }, - "version": "2.2.1" + "version": "2.2.2" } diff --git a/back/node_modules/undefsafe/package.json b/back/node_modules/undefsafe/package.json index 81c8aeaf513643b40f757f2fe34410ffaa21a1de..9229ec9b951903667a54747184c1f68c47510217 100644 --- a/back/node_modules/undefsafe/package.json +++ b/back/node_modules/undefsafe/package.json @@ -4,7 +4,9 @@ "_inBundle": false, "_integrity": "sha512-nrXZwwXrD/T/JXeygJqdCO6NZZ1L66HrxM/Z7mIq2oPanoN0F1nLx3lwJMu6AwJY69hdixaFQOuoYsMjE5/C2A==", "_location": "/undefsafe", - "_phantomChildren": {}, + "_phantomChildren": { + "ms": "2.0.0" + }, "_requested": { "type": "range", "registry": true, diff --git a/back/package-lock.json b/back/package-lock.json index 062d720a49ac5e1fecc8ce608c187ceca5f97955..d30269e3cf7429fe5a254b18f89b45206f8126fe 100644 --- a/back/package-lock.json +++ b/back/package-lock.json @@ -53,6 +53,14 @@ "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" }, + "axios": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", + "requires": { + "follow-redirects": "1.5.10" + } + }, "balanced-match": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", @@ -83,6 +91,16 @@ "qs": "6.7.0", "raw-body": "2.4.0", "type-is": "~1.6.17" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } } }, "boxen": { @@ -258,9 +276,9 @@ "integrity": "sha1-ojD2T1aDEOFJgAmUB5DsmVRbyn4=" }, "debug": { - "version": "2.6.9", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", - "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", "requires": { "ms": "2.0.0" } @@ -367,6 +385,16 @@ "type-is": "~1.6.18", "utils-merge": "1.0.1", "vary": "~1.1.2" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } } }, "fill-range": { @@ -389,6 +417,24 @@ "parseurl": "~1.3.3", "statuses": "~1.5.0", "unpipe": "~1.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" } }, "forwarded": { @@ -413,9 +459,9 @@ "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "glob-parent": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.0.tgz", - "integrity": "sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw==", + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.1.tgz", + "integrity": "sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ==", "requires": { "is-glob": "^4.0.1" } @@ -797,9 +843,9 @@ "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" }, "picomatch": { - "version": "2.2.1", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.1.tgz", - "integrity": "sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA==" + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==" }, "pify": { "version": "3.0.0", @@ -949,6 +995,21 @@ "statuses": "~1.5.0" }, "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + }, + "dependencies": { + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "ms": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", @@ -1092,6 +1153,16 @@ "integrity": "sha512-nrXZwwXrD/T/JXeygJqdCO6NZZ1L66HrxM/Z7mIq2oPanoN0F1nLx3lwJMu6AwJY69hdixaFQOuoYsMjE5/C2A==", "requires": { "debug": "^2.2.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "requires": { + "ms": "2.0.0" + } + } } }, "unique-string": { diff --git a/back/package.json b/back/package.json index 4418253b0973b4fbd83ec95f9fc86ebb22a0a90c..63760f04da4375bd1920824a9fad0af3cea740ac 100644 --- a/back/package.json +++ b/back/package.json @@ -10,6 +10,7 @@ "author": "", "license": "ISC", "dependencies": { + "axios": "^0.19.2", "cors": "^2.8.5", "express": "^4.17.1", "mysql": "^2.18.1", diff --git a/back/routes/api.js b/back/routes/api.js new file mode 100644 index 0000000000000000000000000000000000000000..238489f70cb0f3b4a3f2751d2f03403c9bb5437a --- /dev/null +++ b/back/routes/api.js @@ -0,0 +1,40 @@ +var express = require('express'); +var router = express.Router(); +const fs = require('fs'); + +const bodyParser = require('body-parser'); + + + +var controller = require('../controller') + + +router.use(bodyParser.json()); +router.use(bodyParser.urlencoded({ extended: true })); + +router.get('/classement_par_equipes', controller.equipe.getClassementEquipe); +router.get('/equipes', controller.equipe.getEquipes); +router.get('/classement_individuel', controller.participant.getClassementIndividuel); +router.get('/participants', controller.participant.getParticipants); +router.get('/objectifs', controller.objectifs.getClassementObjectifs); +router.get('/admin_objectifs', controller.objectifs.getAdminObjectifs); +router.get('/admin_scores', controller.scores.getAdminScores); +router.post('/new_score', controller.scores.addNewScore); +router.post('/update_score/score', controller.scores.updateScoreScore); +router.post('/update_score/equipe', controller.scores.updateScoreEquipe); +router.post('/update_score/participant', controller.scores.updateScoreParticipant); +router.post('/delete_score', controller.scores.deleteScore); +router.post('/new_equipe', controller.equipe.addNewEquipe); +router.post('/update_equipe', controller.equipe.updateEquipe); +router.post('/delete_equipe', controller.equipe.deleteEquipe); +router.post('/new_participant', controller.participant.addNewParticipant); +router.post('/update_participant', controller.participant.updateParticipant); +router.post('/delete_participant', controller.participant.deleteParticipant); +router.post('/new_objectif', controller.objectifs.addNewObjectif); +router.post('/update_objectif/name', controller.objectifs.updateObjectifName); +router.post('/update_objectif/description', controller.objectifs.updateObjectifDescription); +router.post('/update_objectif/value', controller.objectifs.updateObjectifValue); +router.post('/update_objectif/coef', controller.objectifs.updateObjectifCoef); +router.post('/delete_objectif', controller.objectifs.deleteObjectif); + +module.exports = router; diff --git a/back/secrets.js b/back/secrets.js new file mode 100644 index 0000000000000000000000000000000000000000..5e95fe7769fcdf2e5f223c3f4e25230c525d68a4 --- /dev/null +++ b/back/secrets.js @@ -0,0 +1,5 @@ +const dbhost = "localhost"; +const dbpassword = "samplepassword"; +const dbuser = "sampleuser"; + +module.exports = [dbhost, dbpassword, dbuser]; diff --git a/back/secrets.js.example b/back/secrets.js.example new file mode 100644 index 0000000000000000000000000000000000000000..f4efb5e999de742259b0aebe6a9fca806f05a5f0 --- /dev/null +++ b/back/secrets.js.example @@ -0,0 +1,8 @@ +const client_id = ""; +const client_secret = ""; +const username = ""; +const password = ""; +const dbpassword = ""; +const dbuser = ""; + +module.exports = [client_id, client_secret, username, password, dbpassword, dbuser]; diff --git a/back/yarn.lock b/back/yarn.lock index 0ecb07a640d4b0ebe436813972b85df8f994c88f..deaa08a7d08178f1a8c98d3870bc4ce41731dcde 100644 --- a/back/yarn.lock +++ b/back/yarn.lock @@ -47,6 +47,13 @@ array-flatten@1.1.1: resolved "https://registry.yarnpkg.com/array-flatten/-/array-flatten-1.1.1.tgz#9a5f699051b1e7073328f2a008968b64ea2955d2" integrity sha1-ml9pkFGx5wczKPKgCJaLZOopVdI= +axios@^0.19.2: + version "0.19.2" + resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27" + integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA== + dependencies: + follow-redirects "1.5.10" + balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -247,6 +254,13 @@ debug@2.6.9, debug@^2.2.0: dependencies: ms "2.0.0" +debug@=3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/debug/-/debug-3.1.0.tgz#5bb5a0672628b64149566ba16819e61518c67261" + integrity sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g== + dependencies: + ms "2.0.0" + debug@^3.2.6: version "3.2.6" resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.6.tgz#e83d17de16d8a7efb7717edbe5fb10135eee629b" @@ -375,6 +389,13 @@ finalhandler@~1.1.2: statuses "~1.5.0" unpipe "~1.0.0" +follow-redirects@1.5.10: + version "1.5.10" + resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a" + integrity sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ== + dependencies: + debug "=3.1.0" + forwarded@~0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.1.2.tgz#98c23dab1175657b8c0573e8ceccd91b0ff18c84" @@ -396,9 +417,9 @@ get-stream@^3.0.0: integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= glob-parent@~5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.0.tgz#5f4c1d1e748d30cd73ad2944b3577a81b081e8c2" - integrity sha512-qjtRgnIVmOfnKUE3NJAQEdk+lKrxfw8t5ke7SXtfMTHcjsBfOfWXCQfdb30zfDoZQ2IRSIiidmjtbHZPZ++Ihw== + version "5.1.1" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.1.tgz#b6c1ef417c4e5663ea498f1c45afac6916bbc229" + integrity sha512-FnI+VGOpnlGHWZxthPGR+QhR78fuiK0sNLkHQv+bL9fQi57lNNdquIbna/WrfROrolq8GK5Ek6BiMwqL/voRYQ== dependencies: is-glob "^4.0.1" @@ -770,9 +791,9 @@ path-to-regexp@0.1.7: integrity sha1-32BBeABfUi8V60SQ5yR6G/qmf4w= picomatch@^2.0.4, picomatch@^2.0.7: - version "2.2.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.1.tgz#21bac888b6ed8601f831ce7816e335bc779f0a4a" - integrity sha512-ISBaA8xQNmwELC7eOjqFKMESB2VIqt4PPDD0nsS95b/9dZXvVKOlz9keMSnoGGKcOHXfTvDD6WMaRoSc9UuhRA== + version "2.2.2" + resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.2.2.tgz#21f333e9b6b8eaff02468f5146ea406d345f4dad" + integrity sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg== pify@^3.0.0: version "3.0.0" diff --git a/db/database.sql b/db/database.sql index 4271e663284d5d0137afda252f89e426d0c33509..5b610391082361895722ca433e6be972d89c9af6 100644 --- a/db/database.sql +++ b/db/database.sql @@ -3,7 +3,7 @@ -- https://www.phpmyadmin.net/ -- -- Hôte : mysql --- Généré le : ven. 20 mars 2020 à 13:03 +-- Généré le : Dim 22 mars 2020 à 13:45 -- Version du serveur : 5.7.29 -- Version de PHP : 7.4.3 @@ -38,6 +38,8 @@ CREATE TABLE `Equipe` ( -- INSERT INTO `Equipe` (`id`, `name`) VALUES +(5, 'DarkCS'), +(8, 'Forum'), (2, 'Hyris'), (3, 'JCS'), (4, 'PCS'), @@ -45,6 +47,28 @@ INSERT INTO `Equipe` (`id`, `name`) VALUES -- -------------------------------------------------------- +-- +-- Structure de la table `Objectif` +-- + +CREATE TABLE `Objectif` ( + `id` int(11) NOT NULL, + `name` varchar(100) NOT NULL DEFAULT 'Objectif', + `description` varchar(500) DEFAULT NULL, + `value` int(11) NOT NULL, + `coef` float NOT NULL DEFAULT '1' +) ENGINE=InnoDB DEFAULT CHARSET=latin1; + +-- +-- Déchargement des données de la table `Objectif` +-- + +INSERT INTO `Objectif` (`id`, `name`, `description`, `value`, `coef`) VALUES +(1, 'Objectif', 'Humaviron 2020', 3000000, 0.005), +(2, 'Objectif 2', 'Humaviron 2020', 4500000, 0.005); + +-- -------------------------------------------------------- + -- -- Structure de la table `Participant` -- @@ -77,7 +101,7 @@ CREATE TABLE `Score` ( `participantId` int(11) DEFAULT NULL, `equipeId` int(11) DEFAULT NULL, `score` bigint(20) NOT NULL, - `createdAt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP + `createdAt` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ) ENGINE=InnoDB DEFAULT CHARSET=latin1; -- @@ -87,7 +111,8 @@ CREATE TABLE `Score` ( INSERT INTO `Score` (`id`, `participantId`, `equipeId`, `score`, `createdAt`) VALUES (1, 3, 2, 20000, '2020-03-19 23:20:57'), (2, 1, NULL, 30000, '2020-03-19 23:21:20'), -(3, NULL, 4, 1500, '2020-03-19 23:22:16'); +(3, NULL, 4, 1500, '2020-03-19 23:22:16'), +(4, 5, 1, 50000, '2020-03-22 13:27:50'); -- -- Index pour les tables déchargées @@ -100,6 +125,12 @@ ALTER TABLE `Equipe` ADD PRIMARY KEY (`id`), ADD UNIQUE KEY `name` (`name`); +-- +-- Index pour la table `Objectif` +-- +ALTER TABLE `Objectif` + ADD PRIMARY KEY (`id`); + -- -- Index pour la table `Participant` -- @@ -121,7 +152,13 @@ ALTER TABLE `Score` -- AUTO_INCREMENT pour la table `Equipe` -- ALTER TABLE `Equipe` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9; + +-- +-- AUTO_INCREMENT pour la table `Objectif` +-- +ALTER TABLE `Objectif` + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=3; -- -- AUTO_INCREMENT pour la table `Participant` @@ -133,7 +170,7 @@ ALTER TABLE `Participant` -- AUTO_INCREMENT pour la table `Score` -- ALTER TABLE `Score` - MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4; + MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5; COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; diff --git a/front/Dockerfile b/front/Dockerfile index a73f4a384dd6359d246ce03d2bb99f8db8783d5e..d2013483dbe4b8765e44646eec7132fe18c1c894 100644 --- a/front/Dockerfile +++ b/front/Dockerfile @@ -5,8 +5,9 @@ WORKDIR /app COPY package.json /app COPY yarn.lock /app -COPY . /app RUN yarn install +COPY . /app + CMD ["yarn", "start"] diff --git a/front/package-lock.json b/front/package-lock.json index 4a14223752d47efde1183d9c5a765be31ac7d49b..93cc530c8a0c0a043dc32c139deda1cc264c2262 100644 --- a/front/package-lock.json +++ b/front/package-lock.json @@ -2362,6 +2362,37 @@ "resolved": "https://registry.npmjs.org/aws4/-/aws4-1.9.1.tgz", "integrity": "sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==" }, + "axios": { + "version": "0.19.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz", + "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==", + "requires": { + "follow-redirects": "1.5.10" + }, + "dependencies": { + "debug": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "requires": { + "ms": "2.0.0" + } + }, + "follow-redirects": { + "version": "1.5.10", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.5.10.tgz", + "integrity": "sha512-0V5l4Cizzvqt5D44aTXbFZz+FtyXV1vrDN6qrelxtfYQKW0KO0W2T/hkE8xvGa/540LkZlkaUjO4ailYTFtHVQ==", + "requires": { + "debug": "=3.1.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" + } + } + }, "axobject-query": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.1.2.tgz", diff --git a/front/package.json b/front/package.json index bd9642c44d3b219cd806a841dc41fa0ff35438c8..3f2b183eb027a31a6ff0b2181f716ba2ad0431ea 100644 --- a/front/package.json +++ b/front/package.json @@ -2,7 +2,6 @@ "name": "leaderboard", "version": "0.1.0", "private": true, - "proxy": "http://server:8000", "dependencies": { "@testing-library/jest-dom": "^4.2.4", "@testing-library/react": "^9.3.2", @@ -12,6 +11,7 @@ "react": "^16.13.0", "react-bootstrap": "^1.0.0-beta.17", "react-dom": "^16.13.0", + "react-hook-form": "^5.1.3", "react-router-dom": "^5.1.2", "react-scripts": "3.4.0" }, diff --git a/front/src/app/accueil/objectifs/TableauObjectifs.js b/front/src/app/accueil/objectifs/TableauObjectifs.js index eeae6eece4f05ba7337fa78e31a28e32284e1b7f..29e3d2071346b9dcc1c3b6b81a2469247f4702bb 100644 --- a/front/src/app/accueil/objectifs/TableauObjectifs.js +++ b/front/src/app/accueil/objectifs/TableauObjectifs.js @@ -4,7 +4,7 @@ import axios from 'axios'; export function TableauObjectifs(){ var [objectifs,setObjectifs] = useState([]); - axios.get('http://localhost:8000/objectifs').then((response) => setObjectifs(response.data)) + axios.get('/api/objectifs').then((response) => setObjectifs(response.data)) return( <table class="table"> <thead class="thead-light"> diff --git a/front/src/app/administration/Admin.js b/front/src/app/administration/Admin.js index 6ed677eb8298bf69ee78920d288da524f216280d..13a0badf475fb57041e058bd0c7e534e8c3d43e2 100644 --- a/front/src/app/administration/Admin.js +++ b/front/src/app/administration/Admin.js @@ -2,5 +2,9 @@ import React from 'react'; //import { Link } from 'react-router-dom'; export default () => ( - <div>Administration</div> + <div class="jumbotron jumbotron-fluid"> + <div class="container"> + <h1 class="display-4">Administration</h1> + </div> + </div> ); diff --git a/front/src/app/administration/GestionEquipes.js b/front/src/app/administration/GestionEquipes.js index bd390fa30abaa2f76fed703826d6bb96ebaf4a59..2d6ba2e99afa689ed80a8d03dc6946e8c0127986 100644 --- a/front/src/app/administration/GestionEquipes.js +++ b/front/src/app/administration/GestionEquipes.js @@ -1,6 +1,22 @@ import React from 'react'; -//import { Link } from 'react-router-dom'; +import { TableauEquipesAdmin } from './gestionEquipes/TableauEquipesAdmin'; export default () => ( - <div>Gestion des équipes</div> + <div class="container"> + <div class="row"> + <div class="col"> + <h1>Gestion des équipes</h1> + </div> + <div class="col-4"> + </div> + <div class="col"> + <a class="btn btn-secondary" href="/admin/equipes/nouveau" role="button">Nouvelle équipe</a> + </div> + </div> + <div class="row"> + <div class="col"> + <TableauEquipesAdmin /> + </div> + </div> + </div> ); diff --git a/front/src/app/administration/GestionObjectifs.js b/front/src/app/administration/GestionObjectifs.js index 96faa9758ba203f996a67b6aa7ac481da59cbe3e..83d6d06f8c80b7b4a78e42d8b403029b932b0f26 100644 --- a/front/src/app/administration/GestionObjectifs.js +++ b/front/src/app/administration/GestionObjectifs.js @@ -1,6 +1,22 @@ import React from 'react'; -//import { Link } from 'react-router-dom'; +import { TableauObjectifsAdmin } from './gestionObjectifs/TableauObjectifsAdmin'; export default () => ( - <div>Gestion des objectifs</div> + <div class="container"> + <div class="row"> + <div class="col"> + <h1>Gestion des objectifs</h1> + </div> + <div class="col-4"> + </div> + <div class="col"> + <a class="btn btn-secondary" href="/admin/objectifs/nouveau" role="button">Saisie nouvel objectif</a> + </div> + </div> + <div class="row"> + <div class="col"> + <TableauObjectifsAdmin /> + </div> + </div> + </div> ); diff --git a/front/src/app/administration/GestionParticipants.js b/front/src/app/administration/GestionParticipants.js index b3a50b0e1155b6dca901e3257e94eacd9fbb6632..2281ebf7028cd3ae25c35be1e6b0fc0972d3b6fa 100644 --- a/front/src/app/administration/GestionParticipants.js +++ b/front/src/app/administration/GestionParticipants.js @@ -1,6 +1,20 @@ import React from 'react'; -//import { Link } from 'react-router-dom'; +import { TableauParticipantsAdmin } from './gestionParticipants/TableauParticipantsAdmin'; export default () => ( - <div>Gestion des participants</div> + <div class="container"> + <div class="row"> + <div class="col"> + <h1>Gestion des participants</h1> + </div> + <div class="col-3"> + <a class="btn btn-secondary" href="/admin/participants/nouveau" role="button">Nouveau participant</a> + </div> + </div> + <div class="row"> + <div class="col"> + <TableauParticipantsAdmin /> + </div> + </div> + </div> ); diff --git a/front/src/app/administration/SaisieScore.js b/front/src/app/administration/SaisieScore.js index 3eff868d6b9b59dd68857165aa34a505e18d0adb..a5fe61345429c5a7b1b40ec776573f040c8d1d3e 100644 --- a/front/src/app/administration/SaisieScore.js +++ b/front/src/app/administration/SaisieScore.js @@ -1,6 +1,22 @@ import React from 'react'; -//import { Link } from 'react-router-dom'; +import { TableauScoresAdmin } from './saisieScore/TableauScoresAdmin'; export default () => ( - <div>Saisie des scores</div> + <div class="container"> + <div class="row"> + <div class="col"> + <h1>Gestion des scores</h1> + </div> + <div class="col-4"> + </div> + <div class="col"> + <a class="btn btn-secondary" href="/admin/scores/nouveau" role="button">Saisie nouveau score</a> + </div> + </div> + <div class="row"> + <div class="col"> + <TableauScoresAdmin /> + </div> + </div> + </div> ); diff --git a/front/src/app/administration/gestionEquipes/DeleteEquipe.js b/front/src/app/administration/gestionEquipes/DeleteEquipe.js new file mode 100644 index 0000000000000000000000000000000000000000..2924fb77eb53e0cda33937dbc71f5f0ccd50a3d4 --- /dev/null +++ b/front/src/app/administration/gestionEquipes/DeleteEquipe.js @@ -0,0 +1,20 @@ +import React from 'react'; +import axios from 'axios'; + +export function DeleteEquipe({ match, location }){ + + const { params: { id } } = match; + + axios.post('/api/delete_equipe',{id: id}) + .then((response) => { + alert('Equipe supprimée'); + window.location='/admin/equipes'; + }, (error) => { + console.log(error); + }); + + return( + <div><h1>Suppression...</h1></div> + ) + +}; diff --git a/front/src/app/administration/gestionEquipes/EditEquipe.js b/front/src/app/administration/gestionEquipes/EditEquipe.js new file mode 100644 index 0000000000000000000000000000000000000000..7877e4a36a89ead7b964d18b5cc3b92668339f9b --- /dev/null +++ b/front/src/app/administration/gestionEquipes/EditEquipe.js @@ -0,0 +1,35 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function UpdateEquipe({ match, location }){ + + const { params: { id } } = match; + + const editEquipe = (props) => { + axios.post('/api/update_equipe',{id: props.id, name:props.name}) + .then((response) => { + alert('Equipe mise à jour'); + window.location='/admin/equipes/' + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editEquipe({id:id,name:data.name})} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Nom</label> + <input type="text" class="form-control" id="scoreInput" name="name" ref={register}/> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) + +}; diff --git a/front/src/app/administration/gestionEquipes/NouvelleEquipe.js b/front/src/app/administration/gestionEquipes/NouvelleEquipe.js new file mode 100644 index 0000000000000000000000000000000000000000..d1875843a1dd6554f5bc3f4dcdbe445e006cf33b --- /dev/null +++ b/front/src/app/administration/gestionEquipes/NouvelleEquipe.js @@ -0,0 +1,34 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function AddEquipeForm(){ + + const addEquipe = (props) => { + axios.post('/api/new_equipe', + { + name: props.name + }) + .then((response) => { + alert("Equipe ajoutée"); + window.location='/admin/equipes'; + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {addEquipe(data)} + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Nom</label> + <input type="text" class="form-control" id="scoreInput" name="name" ref={register} required/> + </div> + <button type="submit" class="btn btn-secondary">Ajouter</button> + </form> + </div> + ) +}; diff --git a/front/src/app/administration/gestionEquipes/TableauEquipesAdmin.js b/front/src/app/administration/gestionEquipes/TableauEquipesAdmin.js new file mode 100644 index 0000000000000000000000000000000000000000..a43fc4ef615a082e600885cb4c4ff300153fdbff --- /dev/null +++ b/front/src/app/administration/gestionEquipes/TableauEquipesAdmin.js @@ -0,0 +1,32 @@ +import React, { useState } from 'react'; +import axios from 'axios'; + +export function TableauEquipesAdmin(){ + var [equipes,setEquipes] = useState([]); + axios.get('/api/equipes').then((response) => setEquipes(response.data)) + + return( + <table class="table"> + <thead class="thead-light"> + <tr> + <th scope="col">Equipe</th> + <th scope="col">Modifier</th> + <th scope="col">Supprimer</th> + </tr> + </thead> + <tbody> + {equipes.map((item) => { + var editUrl='/admin/equipes/edit/'+item.id; + var deleteUrl='/admin/equipes/delete/'+item.id; + return ( + <tr> + <th scope="row">{item.name}</th> + <td><a class="btn btn-secondary" href={editUrl} role="button">Modifier</a></td> + <td><a class="btn btn-danger" href={deleteUrl} role="button">Supprimer</a></td> + </tr> + ) + })} + </tbody> + </table> + ) +}; diff --git a/front/src/app/administration/gestionObjectifs/AfficheObjectif.js b/front/src/app/administration/gestionObjectifs/AfficheObjectif.js new file mode 100644 index 0000000000000000000000000000000000000000..383c36a958741f21bea98f0c92b204dd26b0cbd1 --- /dev/null +++ b/front/src/app/administration/gestionObjectifs/AfficheObjectif.js @@ -0,0 +1,179 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function AfficheObjectif({ match, location }){ + + const { params: { id } } = match; + + const [objectifs, setObjectifs] = useState([]); + useEffect(() => {axios.get('/api/admin_objectifs').then((response) => setObjectifs(response.data))}, []); + const [currentObjectif, setCurrentObjectif] = useState({}); + useEffect(() => { + objectifs.map(item => { + if (item.id==id) {setCurrentObjectif(item)} + }) + }); + + var editNameUrl='/admin/objectifs/edit/name/'+id; + var editDescriptionUrl='/admin/objectifs/edit/description/'+id; + var editValueUrl='/admin/objectifs/edit/value/'+id; + var editCoefUrl='/admin/objectifs/edit/coef/'+id; + return( + <div> + <h1>Modification objectif</h1> + <table class="table"> + <thead class="thead-light"> + <tr> + <th scope="col">Champ</th> + <th scope="col">Valeur</th> + <th scope="col">Action</th> + </tr> + </thead> + <tbody> + <tr> + <th scope="row">Nom</th> + <td>{currentObjectif.name}</td> + <td><a class="btn btn-secondary" href={editNameUrl} role="button">Modifier</a></td> + </tr> + <tr> + <th scope="row">Description</th> + <td>{currentObjectif.description}</td> + <td><a class="btn btn-secondary" href={editDescriptionUrl} role="button">Modifier</a></td> + </tr> + <tr> + <th scope="row">Objectif</th> + <td>{currentObjectif.value}</td> + <td><a class="btn btn-secondary" href={editValueUrl} role="button">Modifier</a></td> + </tr> + <tr> + <th scope="row">Coefficient</th> + <td>{currentObjectif.coef}</td> + <td><a class="btn btn-secondary" href={editCoefUrl} role="button">Modifier</a></td> + </tr> + </tbody> + </table> + </div> + ) +}; + +export function UpdateObjectifName({ match, location }){ + + const { params: { id } } = match; + + const editName = (props) => { + axios.post('/api/update_objectif/name',{id: props.id, name:props.name}) + .then((response) => { + alert('Nom mis à jour'); + window.location='/admin/objectifs/view/'+id; + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editName({id:id,name:data.name})} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Nom</label> + <input type="text" class="form-control" id="scoreInput" name="name" ref={register}/> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) +}; + +export function UpdateObjectifDescription({ match, location }){ + + const { params: { id } } = match; + + const editDescription = (props) => { + axios.post('/api/update_objectif/description',{id: props.id, description:props.description}) + .then((response) => { + alert('Description mise à jour'); + window.location='/admin/objectifs/view/'+id; + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editDescription({id:id,description:data.description})} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="participantInput">Description</label> + <textarea class="form-control" id="participantInput" rows="3" name="description" ref={register}></textarea> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) +}; + +export function UpdateObjectifValue({ match, location }){ + + const { params: { id } } = match; + + const editValue = (props) => { + axios.post('/api/update_objectif/value',{id: props.id, value:props.value}) + .then((response) => { + alert('Objectif mis à jour'); + window.location='/admin/objectifs/view/'+id; + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editValue({id:id,value:data.value})} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Objectif</label> + <input type="number" class="form-control" id="scoreInput" name="value" ref={register}/> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) +}; + +export function UpdateObjectifCoef({ match, location }){ + + const { params: { id } } = match; + + const editCoef = (props) => { + axios.post('/api/update_objectif/coef',{id: props.id, coef:props.coef}) + .then((response) => { + alert('Coefficient mis à jour'); + window.location='/admin/objectifs/view/'+id; + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editCoef({id:id,coef:data.coef})} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Coefficient (utiliser un point et non pas une virgule)</label> + <input class="form-control" id="scoreInput" name="coef" ref={register}/> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) +}; diff --git a/front/src/app/administration/gestionObjectifs/DeleteObjectif.js b/front/src/app/administration/gestionObjectifs/DeleteObjectif.js new file mode 100644 index 0000000000000000000000000000000000000000..a74ee3f86ece19a6df1f1f3b0de8dce499993bba --- /dev/null +++ b/front/src/app/administration/gestionObjectifs/DeleteObjectif.js @@ -0,0 +1,20 @@ +import React from 'react'; +import axios from 'axios'; + +export function DeleteObjectif({ match, location }){ + + const { params: { id } } = match; + + axios.post('/api/delete_objectif',{id: id}) + .then((response) => { + alert('Objectif supprimé'); + window.location='/admin/objectifs'; + }, (error) => { + console.log(error); + }); + + return( + <div><h1>Suppression...</h1></div> + ) + +}; diff --git a/front/src/app/administration/gestionObjectifs/NouvelObjectif.js b/front/src/app/administration/gestionObjectifs/NouvelObjectif.js new file mode 100644 index 0000000000000000000000000000000000000000..a27387862ff4381ccb160f16b6aa99a126975b34 --- /dev/null +++ b/front/src/app/administration/gestionObjectifs/NouvelObjectif.js @@ -0,0 +1,50 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function AddObjectifForm(){ + + const addObjectif = (props) => { + axios.post('/api/new_objectif', + { + name: props.name, + description: props.description, + value: props.value, + coef: props.coef + }) + .then((response) => { + alert("Objectif ajouté"); + window.location='/admin/objectifs'; + }, (error) => { + console.log(error); + }); + }; + + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {addObjectif(data)} + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Nom</label> + <input type="text" class="form-control" id="scoreInput" name="name" ref={register} required/> + </div> + <div class="form-group"> + <label for="participantInput">Description</label> + <textarea class="form-control" id="participantInput" rows="3" name="description" ref={register}></textarea> + </div> + <div class="form-group"> + <label for="equipeInput">Objectif</label> + <input type="number" class="form-control" id="equipeInput" name="value" ref={register} required/> + </div> + <div class="form-group"> + <label for="coefInput">Coefficient</label> + <input type="number" class="form-control" id="coefInput" name="coef" ref={register}/> + </div> + <button type="submit" class="btn btn-secondary">Ajouter</button> + </form> + </div> + ) +}; diff --git a/front/src/app/administration/gestionObjectifs/TableauObjectifsAdmin.js b/front/src/app/administration/gestionObjectifs/TableauObjectifsAdmin.js new file mode 100644 index 0000000000000000000000000000000000000000..57ea87784f80b4b3b491ddecd13a2616943a80c5 --- /dev/null +++ b/front/src/app/administration/gestionObjectifs/TableauObjectifsAdmin.js @@ -0,0 +1,38 @@ +import React, { useState } from 'react'; +import axios from 'axios'; + +export function TableauObjectifsAdmin(){ + var [objectifs,setObjectifs] = useState([]); + axios.get('/api/admin_objectifs').then((response) => setObjectifs(response.data)) + + return( + <table class="table"> + <thead class="thead-light"> + <tr> + <th scope="col">Nom</th> + <th scope="col">Description</th> + <th scope="col">Objectif</th> + <th scope="col">Coefficient</th> + <th scope="col">Modifier</th> + <th scope="col">Supprimer</th> + </tr> + </thead> + <tbody> + {objectifs.map((item) => { + var viewUrl='/admin/objectifs/view/'+item.id; + var deleteUrl='/admin/objectifs/delete/'+item.id; + return ( + <tr> + <th scope="row">{item.name}</th> + <td>{item.description}</td> + <td>{item.value}</td> + <td>{item.coef}</td> + <td><a class="btn btn-secondary" href={viewUrl} role="button">Voir</a></td> + <td><a class="btn btn-danger" href={deleteUrl} role="button">Delete</a></td> + </tr> + ) + })} + </tbody> + </table> + ) +}; diff --git a/front/src/app/administration/gestionParticipants/DeleteParticipant.js b/front/src/app/administration/gestionParticipants/DeleteParticipant.js new file mode 100644 index 0000000000000000000000000000000000000000..027917ad5c278976051109b258372b4b7a56fd30 --- /dev/null +++ b/front/src/app/administration/gestionParticipants/DeleteParticipant.js @@ -0,0 +1,20 @@ +import React from 'react'; +import axios from 'axios'; + +export function DeleteParticipant({ match, location }){ + + const { params: { id } } = match; + + axios.post('/api/delete_participant',{id: id}) + .then((response) => { + alert('Participant supprimé'); + window.location='/admin/participants'; + }, (error) => { + console.log(error); + }); + + return( + <div><h1>Suppression...</h1></div> + ) + +}; diff --git a/front/src/app/administration/gestionParticipants/EditParticipant.js b/front/src/app/administration/gestionParticipants/EditParticipant.js new file mode 100644 index 0000000000000000000000000000000000000000..050a11509e2123eef3088026cdb68d9329f2662b --- /dev/null +++ b/front/src/app/administration/gestionParticipants/EditParticipant.js @@ -0,0 +1,35 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function UpdateParticipant({ match, location }){ + + const { params: { id } } = match; + + const editParticipant = (props) => { + axios.post('/api/update_participant',{id: props.id, name:props.name}) + .then((response) => { + alert('Participant mis à jour'); + window.location='/admin/participants/' + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editParticipant({id:id,name:data.name})} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Nom</label> + <input type="text" class="form-control" id="scoreInput" name="name" ref={register}/> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) + +}; diff --git a/front/src/app/administration/gestionParticipants/NouveauParticipant.js b/front/src/app/administration/gestionParticipants/NouveauParticipant.js new file mode 100644 index 0000000000000000000000000000000000000000..a103c5cf61270a35a0e5a4b7c84336bc30a68421 --- /dev/null +++ b/front/src/app/administration/gestionParticipants/NouveauParticipant.js @@ -0,0 +1,34 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function AddParticipantForm(){ + + const addParticipant = (props) => { + axios.post('/api/new_participant', + { + name: props.name + }) + .then((response) => { + alert("Participant ajouté"); + window.location='/admin/participants'; + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {addParticipant(data)} + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Nom</label> + <input type="text" class="form-control" id="scoreInput" name="name" ref={register} required/> + </div> + <button type="submit" class="btn btn-secondary">Ajouter</button> + </form> + </div> + ) +}; diff --git a/front/src/app/administration/gestionParticipants/TableauParticipantsAdmin.js b/front/src/app/administration/gestionParticipants/TableauParticipantsAdmin.js new file mode 100644 index 0000000000000000000000000000000000000000..e5e8d38b19fce9c2d693d3abbb223291fcb4cac2 --- /dev/null +++ b/front/src/app/administration/gestionParticipants/TableauParticipantsAdmin.js @@ -0,0 +1,32 @@ +import React, { useState } from 'react'; +import axios from 'axios'; + +export function TableauParticipantsAdmin(){ + var [participants,setParticipants] = useState([]); + axios.get('/api/participants').then((response) => setParticipants(response.data)) + + return( + <table class="table"> + <thead class="thead-light"> + <tr> + <th scope="col">Participant</th> + <th scope="col">Modifier</th> + <th scope="col">Supprimer</th> + </tr> + </thead> + <tbody> + {participants.map((item) => { + var editUrl='/admin/participants/edit/'+item.id; + var deleteUrl='/admin/participants/delete/'+item.id; + return ( + <tr> + <th scope="row">{item.name}</th> + <td><a class="btn btn-secondary" href={editUrl} role="button">Modifier</a></td> + <td><a class="btn btn-danger" href={deleteUrl} role="button">Supprimer</a></td> + </tr> + ) + })} + </tbody> + </table> + ) +}; diff --git a/front/src/app/administration/saisieScore/AfficheScore.js b/front/src/app/administration/saisieScore/AfficheScore.js new file mode 100644 index 0000000000000000000000000000000000000000..4406465256d895a7c5ce2b945e0c7964a1661b44 --- /dev/null +++ b/front/src/app/administration/saisieScore/AfficheScore.js @@ -0,0 +1,158 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function AfficheScore({ match, location }){ + + const { params: { id } } = match; + + const [scores, setScores] = useState([]); + useEffect(() => {axios.get('/api/admin_scores').then((response) => setScores(response.data))}, []); + const [currentScore, setCurrentScore] = useState({}); + useEffect(() => { + scores.map(item => { + if (item.id==id) {setCurrentScore(item)} + }) + }); + + var editScoreUrl='/admin/scores/edit/score/'+id; + var editEquipeUrl='/admin/scores/edit/equipe/'+id; + var editParticipantUrl='/admin/scores/edit/participant/'+id; + return( + <div> + <h1>Modification du score</h1> + <table class="table"> + <thead class="thead-light"> + <tr> + <th scope="col">Champ</th> + <th scope="col">Valeur</th> + <th scope="col">Action</th> + </tr> + </thead> + <tbody> + <tr> + <th scope="row">Score</th> + <td>{currentScore.score}</td> + <td><a class="btn btn-secondary" href={editScoreUrl} role="button">Modifier</a></td> + </tr> + <tr> + <th scope="row">Equipe</th> + <td>{currentScore.equipe}</td> + <td><a class="btn btn-secondary" href={editEquipeUrl} role="button">Modifier</a></td> + </tr> + <tr> + <th scope="row">Participant</th> + <td>{currentScore.participant}</td> + <td><a class="btn btn-secondary" href={editParticipantUrl} role="button">Modifier</a></td> + </tr> + </tbody> + </table> + </div> + ) +}; + +export function UpdateScoreScore({ match, location }){ + + const { params: { id } } = match; + + const editScore = (props) => { + axios.post('/api/update_score/score',{id: props.id, score:props.score}) + .then((response) => { + alert('Score mis à jour'); + window.location='/admin/scores/view/'+id; + }, (error) => { + console.log(error); + }); + }; + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editScore({id:id,score:data.score})} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Score</label> + <input type="number" class="form-control" id="scoreInput" name="score" ref={register}/> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) + +}; + +export function UpdateScoreEquipe({ match, location }){ + + const { params: { id } } = match; + + const editEquipe = (props) => { + axios.post('/api/update_score/equipe',{id: id, equipe:props.equipe}) + .then((response) => { + alert('Score mis à jour'); + window.location='/admin/scores/view/'+id; + }, (error) => { + console.log(error); + }); + }; + + const [equipes,setEquipes] = useState([]); + useEffect(() => {axios.get('/api/equipes').then((response) => setEquipes(response.data))}, []); + + console.log(equipes); + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editEquipe(data)} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="equipeInput">Equipe</label> + <select class="form-control" id="equipeInput" name="equipe" ref={register}> + {equipes.map(item => (<option value={item.id}>{item.name}</option>))} + </select> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) + +}; + +export function UpdateScoreParticipant({ match, location }){ + + const { params: { id } } = match; + + const editParticipant = (props) => { + axios.post('/api/update_score/participant',{id: id, participant:props.participant}) + .then((response) => { + alert('Score mis à jour'); + window.location='/admin/scores/view/'+id; + }, (error) => { + console.log(error); + }); + }; + + const [participants,setParticipants] = useState([]); + useEffect(() => {axios.get('/api/participants').then((response) => setParticipants(response.data))}, []); + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {editParticipant(data)} + + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="equipeInput">Equipe</label> + <select class="form-control" id="equipeInput" name="participant" ref={register}> + {participants.map(item => (<option value={item.id}>{item.name}</option>))} + </select> + </div> + <button type="submit" class="btn btn-secondary">Modifier</button> + </form> + </div> + ) + +}; diff --git a/front/src/app/administration/saisieScore/DeleteScore.js b/front/src/app/administration/saisieScore/DeleteScore.js new file mode 100644 index 0000000000000000000000000000000000000000..ae6ec1faf90640b40ca1dab9c2c6155bf9f39ff9 --- /dev/null +++ b/front/src/app/administration/saisieScore/DeleteScore.js @@ -0,0 +1,20 @@ +import React from 'react'; +import axios from 'axios'; + +export function DeleteScore({ match, location }){ + + const { params: { id } } = match; + + axios.post('/api/delete_score',{id: id}) + .then((response) => { + alert('Score supprimé'); + window.location='/admin/scores'; + }, (error) => { + console.log(error); + }); + + return( + <div><h1>Suppression du score...</h1></div> + ) + +}; diff --git a/front/src/app/administration/saisieScore/NouveauScore.js b/front/src/app/administration/saisieScore/NouveauScore.js new file mode 100644 index 0000000000000000000000000000000000000000..1212f9e3f5d029d1375b36d6305ce52a322ba321 --- /dev/null +++ b/front/src/app/administration/saisieScore/NouveauScore.js @@ -0,0 +1,55 @@ +import React, { useState, useEffect } from 'react'; +import axios from 'axios'; +import { useForm } from 'react-hook-form'; +import { Redirect } from 'react-router-dom'; + +export function AddScoreForm(){ + + const addScore = (props) => { + axios.post('/api/new_score', + { + score: props.score, + equipe: props.equipe, + participant: props.participant + }) + .then((response) => { + alert("Score ajouté"); + window.location='/admin/scores'; + }, (error) => { + console.log(error); + }); + }; + + + const [equipes,setEquipes] = useState([]); + const [participants,setParticipants] = useState([]); + + useEffect(() => {axios.get('/api/equipes').then((response) => setEquipes(response.data))}, []); + useEffect(() => {axios.get('/api/participants').then((response) => setParticipants(response.data))}, []); + + const { register, handleSubmit } = useForm(); + const onSubmit = data => {addScore(data)} + return( + <div> + <form onSubmit={handleSubmit(onSubmit)}> + <div class="form-group"> + <label for="scoreInput">Score</label> + <input type="number" class="form-control" id="scoreInput" name="score" ref={register} required/> + </div> + <div class="form-group"> + <label for="participantInput">Participant</label> + <select class="form-control" id="participantInput" name="participant" ref={register}> + {participants.map(item => (<option value={item.id}>{item.name}</option>))} + </select> + </div> + <div class="form-group"> + <label for="equipeInput">Equipe</label> + <select class="form-control" id="equipeInput" name="equipe" ref={register}> + {equipes.map(item => (<option value={item.id}>{item.name}</option>))} + </select> + </div> + <button type="submit" class="btn btn-secondary">Ajouter</button> + </form> + </div> + ) +}; diff --git a/front/src/app/administration/saisieScore/TableauScoresAdmin.js b/front/src/app/administration/saisieScore/TableauScoresAdmin.js new file mode 100644 index 0000000000000000000000000000000000000000..3762f3cbdcdd1cdcae460ad0c6493879a757a351 --- /dev/null +++ b/front/src/app/administration/saisieScore/TableauScoresAdmin.js @@ -0,0 +1,38 @@ +import React, { useState } from 'react'; +import axios from 'axios'; + +export function TableauScoresAdmin(){ + var [scores,setScores] = useState([]); + axios.get('/api/admin_scores').then((response) => setScores(response.data)) + + return( + <table class="table"> + <thead class="thead-light"> + <tr> + <th scope="col">Date</th> + <th scope="col">Score</th> + <th scope="col">Participant</th> + <th scope="col">Equipe</th> + <th scope="col">Modifier</th> + <th scope="col">Supprimer</th> + </tr> + </thead> + <tbody> + {scores.map((item) => { + var viewUrl='/admin/scores/view/'+item.id; + var deleteUrl='/admin/scores/delete/'+item.id; + return ( + <tr> + <th scope="row">{item.date.split('T')[0]} - {item.date.split('T')[1].split('.')[0]}</th> + <td>{item.score}</td> + <td>{item.participant}</td> + <td>{item.equipe}</td> + <td><a class="btn btn-secondary" href={viewUrl} role="button">Voir</a></td> + <td><a class="btn btn-danger" href={deleteUrl} role="button">Delete</a></td> + </tr> + ) + })} + </tbody> + </table> + ) +}; diff --git a/front/src/app/classementEquipe/TableauClassementEquipe.js b/front/src/app/classementEquipe/TableauClassementEquipe.js index d2a2fc7f904da6e5f8621cc59094d372032c8924..c2fdb668856d90fbb99e7b6ef926c14f4f2b56f3 100644 --- a/front/src/app/classementEquipe/TableauClassementEquipe.js +++ b/front/src/app/classementEquipe/TableauClassementEquipe.js @@ -4,7 +4,7 @@ import axios from 'axios'; export function TableauClassementEquipe(){ var [equipes,setEquipes] = useState([]); - axios.get('http://localhost:8000/classement_par_equipes').then((response) => setEquipes(response.data)) + axios.get('api/classement_par_equipes').then((response) => setEquipes(response.data)) return( <table class="table"> <thead class="thead-light"> diff --git a/front/src/app/classementIndividuel/TableauClassementIndividuel.js b/front/src/app/classementIndividuel/TableauClassementIndividuel.js index 65b08e12c2c3b13cda88dd00eab01080b8df3d59..ea6b31ea6584ac5f62393c047de2aa017dcfa5d7 100644 --- a/front/src/app/classementIndividuel/TableauClassementIndividuel.js +++ b/front/src/app/classementIndividuel/TableauClassementIndividuel.js @@ -4,7 +4,7 @@ import axios from 'axios'; export function TableauClassementIndividuel(){ var [participants,setParticipants] = useState([]); - axios.get('http://localhost:8000/classement_individuel').then((response) => setParticipants(response.data)) + axios.get('/api/classement_individuel').then((response) => setParticipants(response.data)) return( <table class="table"> <thead class="thead-light"> diff --git a/front/src/app/navbar/Navbar.js b/front/src/app/navbar/Navbar.js index 3caef29e2bc89f7269cf87026b86b320a8f7cdc2..8c512c07ab887f3e739762849f096602f97ea352 100644 --- a/front/src/app/navbar/Navbar.js +++ b/front/src/app/navbar/Navbar.js @@ -14,11 +14,11 @@ export default () => ( <Nav.Link href="/solo">Classement individuel</Nav.Link> <Nav.Link href="/team">Classement par équipe</Nav.Link> <NavDropdown title="Administration" id="basic-nav-dropdown"> - <NavDropdown.Item href="/admin/saisie">Saisie des scores</NavDropdown.Item> + <NavDropdown.Item href="/admin/scores">Saisie des scores</NavDropdown.Item> <NavDropdown.Item href="/admin/equipes">Gestion des équipes</NavDropdown.Item> <NavDropdown.Item href="/admin/participants">Gestion des participants</NavDropdown.Item> - <NavDropdown.Item href="/admin/admins">Gestion des administrateurs</NavDropdown.Item> <NavDropdown.Item href="/admin/objectifs">Gestion des objectifs</NavDropdown.Item> + <NavDropdown.Item href="/admin/admins">Gestion des administrateurs</NavDropdown.Item> </NavDropdown> </Nav> </Navbar.Collapse> diff --git a/front/src/index.js b/front/src/index.js index 2fcb78899779cc3cf2464879984cdc1676f2f75a..7e7489f4a29cef931333aeb0e9ece4c7de92c69d 100644 --- a/front/src/index.js +++ b/front/src/index.js @@ -11,6 +11,25 @@ import GestionEquipes from './app/administration/GestionEquipes'; import GestionParticipants from './app/administration/GestionParticipants'; import GestionAdministrateurs from './app/administration/GestionAdministrateurs'; import GestionObjectifs from './app/administration/GestionObjectifs'; +import { AddScoreForm } from './app/administration/saisieScore/NouveauScore'; +import { AfficheScore } from './app/administration/saisieScore/AfficheScore'; +import { UpdateScoreScore } from './app/administration/saisieScore/AfficheScore'; +import { UpdateScoreEquipe } from './app/administration/saisieScore/AfficheScore'; +import { UpdateScoreParticipant } from './app/administration/saisieScore/AfficheScore'; +import { DeleteScore } from './app/administration/saisieScore/DeleteScore'; +import { AddEquipeForm } from './app/administration/gestionEquipes/NouvelleEquipe'; +import { UpdateEquipe } from './app/administration/gestionEquipes/EditEquipe'; +import { DeleteEquipe } from './app/administration/gestionEquipes/DeleteEquipe'; +import { AddParticipantForm } from './app/administration/gestionParticipants/NouveauParticipant'; +import { UpdateParticipant } from './app/administration/gestionParticipants/EditParticipant'; +import { DeleteParticipant } from './app/administration/gestionParticipants/DeleteParticipant'; +import { AddObjectifForm } from './app/administration/gestionObjectifs/NouvelObjectif'; +import { AfficheObjectif } from './app/administration/gestionObjectifs/AfficheObjectif'; +import { UpdateObjectifName } from './app/administration/gestionObjectifs/AfficheObjectif'; +import { UpdateObjectifDescription } from './app/administration/gestionObjectifs/AfficheObjectif'; +import { UpdateObjectifValue } from './app/administration/gestionObjectifs/AfficheObjectif'; +import { UpdateObjectifCoef } from './app/administration/gestionObjectifs/AfficheObjectif'; +import { DeleteObjectif } from './app/administration/gestionObjectifs/DeleteObjectif'; import './index.css'; import 'bootstrap/dist/css/bootstrap.min.css'; @@ -23,11 +42,30 @@ ReactDOM.render( <Route path="/solo" component={ClassementIndividuel} /> <Route path="/team" component={ClassementEquipe} /> <Route path="/admin" component={Admin} /> - <Route path="/admin/saisie" component={SaisieScore} /> - <Route path="/admin/equipes" component={GestionEquipes} /> - <Route path="/admin/participants" component={GestionParticipants} /> - <Route path="/admin/admins" component={GestionAdministrateurs} /> - <Route path="/admin/objectifs" component={GestionObjectifs} /> + <Route exact path="/admin/scores" component={SaisieScore} /> + <Route path="/admin/scores/nouveau" component={AddScoreForm} /> + <Route exact path="/admin/equipes" component={GestionEquipes} /> + <Route exact path="/admin/participants" component={GestionParticipants} /> + <Route exact path="/admin/admins" component={GestionAdministrateurs} /> + <Route exact path="/admin/objectifs" component={GestionObjectifs} /> + <Route path="/admin/scores/view/:id" component={AfficheScore} /> + <Route path="/admin/scores/edit/score/:id" component={UpdateScoreScore} /> + <Route path="/admin/scores/edit/equipe/:id" component={UpdateScoreEquipe} /> + <Route path="/admin/scores/edit/participant/:id" component={UpdateScoreParticipant} /> + <Route path="/admin/scores/delete/:id" component={DeleteScore} /> + <Route path="/admin/equipes/nouveau" component={AddEquipeForm} /> + <Route path="/admin/equipes/edit/:id" component={UpdateEquipe} /> + <Route path="/admin/equipes/delete/:id" component={DeleteEquipe} /> + <Route path="/admin/participants/nouveau" component={AddParticipantForm} /> + <Route path="/admin/participants/edit/:id" component={UpdateParticipant} /> + <Route path="/admin/participants/delete/:id" component={DeleteParticipant} /> + <Route path="/admin/objectifs/nouveau" component={AddObjectifForm} /> + <Route path="/admin/objectifs/view/:id" component={AfficheObjectif} /> + <Route path="/admin/objectifs/edit/name/:id" component={UpdateObjectifName} /> + <Route path="/admin/objectifs/edit/description/:id" component={UpdateObjectifDescription} /> + <Route path="/admin/objectifs/edit/value/:id" component={UpdateObjectifValue} /> + <Route path="/admin/objectifs/edit/coef/:id" component={UpdateObjectifCoef} /> + <Route path="/admin/objectifs/delete/:id" component={DeleteObjectif} /> </div> </Router>, document.getElementById('root') diff --git a/front/src/setupProxy.js b/front/src/setupProxy.js new file mode 100644 index 0000000000000000000000000000000000000000..00a477395a2bd22458df867edaa4e9e962eaadb7 --- /dev/null +++ b/front/src/setupProxy.js @@ -0,0 +1,10 @@ +const proxy = require('http-proxy-middleware'); +module.exports = function(app) { + app.use( + '/api', + proxy({ + target: 'http://back:8000', + changeOrigin: true, + }) + ); +}; diff --git a/front/yarn.lock b/front/yarn.lock index 0c6c48056bfc50136b0056bb329c7ea729940b6d..d3cec59fc96fb491095e4690dbc58fec07ee533c 100644 --- a/front/yarn.lock +++ b/front/yarn.lock @@ -8474,6 +8474,11 @@ react-error-overlay@^6.0.6: resolved "https://registry.yarnpkg.com/react-error-overlay/-/react-error-overlay-6.0.6.tgz#ac4d9dc4c1b5c536c2c312bf66aa2b09bfa384e2" integrity sha512-Yzpno3enVzSrSCnnljmr4b/2KUQSMZaPuqmS26t9k4nW7uwJk6STWmH9heNjPuvqUTO3jOSPkHoKgO4+Dw7uIw== +react-hook-form@^5.1.3: + version "5.1.3" + resolved "https://registry.yarnpkg.com/react-hook-form/-/react-hook-form-5.1.3.tgz#24610e11878c6bd143569ce203320f7367893e75" + integrity sha512-6+6wSge72A2Y7WGqMke4afOz0uDJ3gOPSysmYKkjJszSbmw8X8at7tJPzifnZ+cwLDR88b4on/D+jfH5azWbIw== + react-is@^16.12.0: version "16.13.0" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.0.tgz#0f37c3613c34fe6b37cd7f763a0d6293ab15c527" diff --git a/old.index.js b/old.index.js new file mode 100644 index 0000000000000000000000000000000000000000..67cfa3c210d896510c53c170de394795f11d1aa8 --- /dev/null +++ b/old.index.js @@ -0,0 +1,70 @@ +const cors = require('cors'); +const express = require('express'), + app = express(), + bodyParser = require('body-parser'); +const mysql = require('mysql'); + +//Connect to the database +const pool = mysql.createPool({ + host: process.env.MYSQL_HOST_IP, + user: process.env.MYSQL_USER, + password: process.env.MYSQL_PASSWORD, + database: process.env.MYSQL_DATABASE, +}); + +app.use(cors()); + +//Listen to frontend +app.listen(process.env.REACT_APP_SERVER_PORT, () => { + console.log(`App server now listening on port ${process.env.REACT_APP_SERVER_PORT}`); +}); + +//Get data for team ranking +app.get('/classement_par_equipes', (req, res) => { + pool.query(`SELECT Equipe.name,SUM(score) AS score,COUNT(participantId) AS nbParticipant,COUNT(score) AS nbScores FROM Score JOIN Equipe ON Equipe.id=Score.equipeId GROUP BY equipeId ORDER BY score DESC;`, (err, results) => { + if (err) { + return res.send(err); + } else { + return res.send(results); + } + }); +}); + +//Get data for individual ranking +app.get('/classement_individuel', (req, res) => { + pool.query(`SELECT Participant.name,SUM(score) AS score,COUNT(equipeId) AS nbEquipes,COUNT(score) AS nbScores FROM Score JOIN Participant ON Participant.id=Score.participantId GROUP BY participantId ORDER BY score DESC;`, (err, results) => { + if (err) { + return res.send(err); + } else { + return res.send(results); + } + }); +}); + +//Get data about goals +app.get('/objectifs', (req, res) => { + pool.query(`SELECT name,description,value,coef,realise FROM Objectif CROSS JOIN (SELECT SUM(score) as realise FROM Score) AS Realise ORDER BY value DESC;`, (err, results) => { + if (err) { + return res.send(err); + } else { + return res.send(results); + } + }); +}); + +//Get scores for admin page +app.get('/scores_admin', (req, res) => { + pool.query(`SELECT Score.id,score,Participant.name AS participant,Equipe.name AS equipe,createdAt as date FROM Score LEFT JOIN Participant ON Participant.id=Score.ParticipantId LEFT JOIN Equipe ON Score.equipeId=Equipe.id ORDER BY date DESC;`, (err, results) => { + if (err) { + return res.send(err); + } else { + return res.send(results); + } + }); +}); + +//Handle add score request +app.post('/test', function(req, res) { + console.log(req.data); + res.sendStatus(200); +});