Commit 220b4cac authored by Romain OZDEN's avatar Romain OZDEN

Lecture des annales 100% fonctionnelle

parent 69f7ef2c
'use strict';
const allah = require('alasql');
allah(`
......@@ -8,7 +10,7 @@ USE annales;
const router = require('express').Router();
router.get('/', (req, res) => {
res.send(allah.exec(`select * from Annee`));
res.send(allah.exec('select * from Annee'));
});
......
'use strict';
const allah = require('alasql');
allah(`
......@@ -9,7 +11,7 @@ const router = require('express').Router();
router.get('/getMatieresByPromo', (req, res) => {
res.send(allah.exec(`select * from Matiere where promo_id = ${req.query.promo}`));
})
});
module.exports = router;
\ No newline at end of file
'use strict';
const allah = require('alasql');
allah(`
......@@ -8,12 +10,12 @@ USE annales;
const router = require('express').Router();
router.get('/', (req, res) => {
res.send(allah.exec(`select * from Promo`));
res.send(allah.exec('select * from Promo'));
});
router.post('/temp', (req, res) => {
let promo = allah.exec(`SELECT * FROM Promo WHERE annee_id = ${req.body.annee} AND specialite_id = ${req.body.specialite}`)[0].promo_id;
res.redirect('/selection_annale?matiere='+promo);
res.redirect('/selection_annale?promo=' + promo);
});
module.exports = router;
\ No newline at end of file
'use strict';
const allah = require('alasql');
allah(`
......@@ -8,9 +10,7 @@ USE annales;
const router = require('express').Router();
router.get('/', (req, res) => {
res.send(allah.exec(`select * from Specialite`));
res.send(allah.exec('select * from Specialite'));
});
module.exports = router;
\ No newline at end of file
'use strict';
const fs = require('fs-extra');
var multiparty = require('multiparty');
const allah = require('alasql');
allah(`
......@@ -5,6 +9,15 @@ ATTACH FILESTORAGE DATABASE annales("${__dirname}/../../db/db.json");
USE annales;
`);
function getMaxSujetId() {
let id;
id = allah.exec('select sujet_id from Sujet ORDER BY sujet_id DESC')[0].sujet_id + 1;
if (!id) {
id = 1;
}
return id;
}
const router = require('express').Router();
router.get('/getSujetsByMatiere', (req, res) => {
......@@ -12,7 +25,40 @@ router.get('/getSujetsByMatiere', (req, res) => {
});
router.get('/viewSujet', (req, res) => {
res.send(allah.exec(`select * from Sujet where matiere_id = ${req.query.sujet}`));
res.send(allah.exec(`select * from Sujet where sujet_id = ${req.query.sujet}`));
});
router.post('/add', (req, res) => {
let matiere = parseInt(req.query.matiere);
let form = new multiparty.Form();
let files_array = [];
let fstream;
req.pipe(req.busboy);
req.busboy.on('file', function (fieldname, file, filename) {
if (filename) {
filename = getMaxSujetId() + '_' + files_array.length + '_' + new Date().getTime() + filename;
fstream = fs.createWriteStream(__dirname + '../../../storage_H/annales/' + filename);
files_array.push(filename);
file.pipe(fstream);
fstream.on('close', () => {
console.log('Upload Finished of ' + filename);
});
}
});
form.parse(req, function (err, fields) {
let today = new Date();
let dd = String(today.getDate()).padStart(2, '0');
let mm = String(today.getMonth() + 1).padStart(2, '0');
let yyyy = today.getFullYear();
today = yyyy + '-' + mm + '-' + dd;
let sujet = files_array[0] === undefined ? '' : files_array[0];
let corrige = files_array[1] === undefined ? '' : files_array[1];
allah.exec(`insert into Sujet(sujet_id, nom, pdf_sujet, pdf_correction, verif, date_depot, matiere_id) VALUES
(?,?,?,?,?,?,?);`, [getMaxSujetId(), fields.name, sujet, corrige, false, today, matiere]);
});
let promo = allah.exec('select promo_id from Matiere where matiere_id = 1', [matiere])[0].promo_id;
res.redirect('/selection_annale?promo=' + promo);
});
......
const { create,
'use strict';
const {create,
getUsers,
updateUser,
deleteUser,
getUserByUsername,
} = require('./user.service');
const { genSaltSync, hashSync, compareSync } = require('bcrypt');
const { sign } = require('jsonwebtoken');
const {genSaltSync, hashSync} = require('bcrypt');
module.exports = {
createUser: (req, res) => {
......@@ -19,9 +19,10 @@ module.exports = {
console.log(err);
return res.status(500).json({
success: 0,
message: 'Error'
message: 'Error',
});
} else {
}
else {
console.log(results);
return res.redirect('/login');
}
......@@ -30,9 +31,9 @@ module.exports = {
getUsers: (req, res) => {
getUsers((results) => {
return res.json({
data: results
data: results,
});
})
});
},
updateUser: (req, res) => {
const body = req.body;
......@@ -46,12 +47,12 @@ module.exports = {
if (!results) {
return res.json({
success: 0,
message: 'Failed to update user'
})
message: 'Failed to update user',
});
}
return res.json({
success: 1,
message: 'updated successfully'
message: 'updated successfully',
});
});
},
......@@ -65,13 +66,13 @@ module.exports = {
if (!results) {
return res.json({
success: 0,
message: 'Record not found'
message: 'Record not found',
});
}
return res.json({
success: 1,
message: 'user deleted successfully'
message: 'user deleted successfully',
});
});
},
}
\ No newline at end of file
};
\ No newline at end of file
const { createUser,
'use strict';
const {createUser,
getUsers,
updateUser,
deleteUser,
......@@ -9,7 +11,7 @@ const {getUserByUsername} = require('./user.service');
module.exports = (passport) => {
const router = require('express').Router();
router.post('/add', createUser);
router.get('/getusers', sec.ensureLoggedIn(), getUsers);
router.get('/currentuser', (req, res) => {
......@@ -17,11 +19,11 @@ module.exports = (passport) => {
});
router.patch('/', updateUser);
router.delete('/', deleteUser);
router.post('/login', (req,res,next) => {
router.post('/login', (req, res, next) => {
const body = req.body;
getUserByUsername(body.username, results => {
if (!results) {
return res.json({ success: 0, data: 'User not found' });
return res.json({success: 0, data: 'User not found'});
}
passport.authenticate('local', function (err, user) {
if (err) {
......@@ -39,10 +41,10 @@ module.exports = (passport) => {
})(req, res, next);
});
});
router.get('/logout', (req,res) => {
router.get('/logout', (req, res) => {
req.logout();
res.redirect('/');
});
return router;
}
\ No newline at end of file
};
\ No newline at end of file
const sqlcon = undefined;
'use strict';
const allah = require('alasql');
allah(`
......@@ -8,7 +9,7 @@ USE annales;
function getMaxUserId() {
let id;
id = allah.exec(`select user_id from Utilisateur ORDER BY user_id DESC`)[0].user_id + 1;
id = allah.exec('select user_id from Utilisateur ORDER BY user_id DESC')[0].user_id + 1;
if (!id) {
id = 1;
}
......@@ -31,21 +32,21 @@ module.exports = {
],
(res) => {
callBack(res);
}
},
);
},
getUsers: callBack => {
allah.exec(
`select * from Utilisateur`,
'select * from Utilisateur',
[],
(results) => {
return callBack(results);
}
},
);
},
updateUser: (data, callBack) => {
allah.exec(
`update utilisateur set nom=?, prenom=?, username=?, password=?, email=? where id = ?`,
'update utilisateur set nom=?, prenom=?, username=?, password=?, email=? where id = ?',
[
data.nom,
data.prenom,
......@@ -54,34 +55,34 @@ module.exports = {
data.email,
data.id,
],
(error, results, fields) => {
(error, results) => {
if (error) {
callBack(error);
}
return callBack(null, results);
}
},
);
},
deleteUser: (data, callBack) => {
allah.exec(
`delete from utilisateur where id = ?`,
'delete from utilisateur where id = ?',
[data.id],
(error, results, fields) => {
(error, results) => {
if (error) {
callBack(error);
}
return this.callBack(null, results[0]);
}
)
},
);
},
getUserByUsername: (username, callBack) => {
console.log(username);
allah.exec(
`select * from Utilisateur where username = ?`,
'select * from Utilisateur where username = ?',
[username],
(res) => {
return callBack(res[0]);
}
},
);
}
},
};
\ No newline at end of file
......@@ -3,7 +3,7 @@
const {getUserByUsername} = require('../api/users/user.service');
const { compareSync } = require('bcrypt');
const {compareSync} = require('bcrypt');
const allah = require('alasql');
......@@ -26,7 +26,7 @@ passport.use(new LocalStrategy(
// On récupère les information (mot de passe) de l'utilisateur
// passé en paramètre
getUserByUsername(username, (user) => {
console.log('user.password = '+ user.password + ', password = ' + password );
console.log('user.password = ' + user.password + ', password = ' + password );
if (!user) {
cb(null, false);
}
......@@ -39,7 +39,7 @@ passport.use(new LocalStrategy(
cb(null, false);
}
});
}
},
));
// Stocke les données de l'utilisation dans le cookie de session
......@@ -51,15 +51,15 @@ passport.serializeUser(function (user, cb) {
// Récupère les données de l'utilisateur depuis le cookie de session
passport.deserializeUser(function (id, cb) {
console.debug('deserializeUser ' + id);
allah.exec("select * from Utilisateur where user_id = ? ",[id], (results) => {
allah.exec('select * from Utilisateur where user_id = ?', [id], (results) => {
cb(null, results[0]);
});
});
// Puisque c'est un module, on export au moins une fonction
// Ici c'est un "constructeur" qui prend une application express
// Ici c'est un "constructeur" qui prend une application express
// en paramètre afin de se déclarer comme middlewwre et pouvoir gérer
// l'authentification sur toutes les routes du site
// l'authentification sur toutes les routes du site
module.exports = function (app) {
app.use(require('cookie-parser')());
app.use(require('body-parser').urlencoded({extended: true}));
......@@ -71,4 +71,4 @@ module.exports = function (app) {
app.use(passport.session());
return passport;
};
};
\ No newline at end of file
{"tables":{"Specialite":{"columns":[{"columnid":"specialite_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"name","dbtypeid":"STRING"}],"dirty":true},"Annee":{"columns":[{"columnid":"annee_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"name","dbtypeid":"STRING"}],"dirty":true},"Promo":{"columns":[{"columnid":"promo_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"annee_id","dbtypeid":"NUMBER"},{"columnid":"specialite_id","dbtypeid":"NUMBER"}],"dirty":true},"Role":{"columns":[{"columnid":"role_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"nom","dbtypeid":"STRING"}]},"Utilisateur":{"columns":[{"columnid":"user_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"username","dbtypeid":"STRING","notnull":true},{"columnid":"password","dbtypeid":"STRING","notnull":true},{"columnid":"firstname","dbtypeid":"STRING"},{"columnid":"lastname","dbtypeid":"STRING"},{"columnid":"email","dbtypeid":"STRING"},{"columnid":"role_id","dbtypeid":"NUMBER UNSIGNED","notnull":true}]},"Matiere":{"columns":[{"columnid":"matiere_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"name","dbtypeid":"STRING"},{"columnid":"user_id","dbtypeid":"NUMBER UNSIGNED","notnull":true},{"columnid":"promo_id","dbtypeid":"NUMBER UNSIGNED","notnull":true}],"dirty":true},"Sujet":{"columns":[{"columnid":"sujet_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"nom","dbtypeid":"STRING"},{"columnid":"pdf_sujet","dbtypeid":"STRING"},{"columnid":"pdf_correction","dbtypeid":"STRING"},{"columnid":"verif","dbtypeid":"BOOLEAN"},{"columnid":"date_depot","dbtypeid":"DATE"},{"columnid":"matiere_id","dbtypeid":"NUMBER UNSIGNED","notnull":true}],"dirty":true},"Commentaire":{"columns":[{"columnid":"com_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"position","dbtypeid":"NUMBER UNSIGNED"},{"columnid":"message","dbtypeid":"STRING"},{"columnid":"typesujet","dbtypeid":"STRING"},{"columnid":"sujet_id","dbtypeid":"NUMBER UNSIGNED","notnull":true},{"columnid":"user_id","dbtypeid":"NUMBER UNSIGNED","notnull":true}]},"Notification":{"columns":[{"columnid":"notif_id","dbtypeid":"NUMBER UNSIGNED","notnull":true,"identity":{"value":1,"step":1}},{"columnid":"user_id","dbtypeid":"NUMBER UNSIGNED","notnull":true}]},"Suivre":{"columns":[{"columnid":"matiere_id","dbtypeid":"NUMBER UNSIGNED","notnull":true},{"columnid":"user_id","dbtypeid":"NUMBER UNSIGNED","notnull":true}]}},"Specialite":[{"specialite_id":1,"name":"Informatique"},{"specialite_id":2,"name":"ETN"},{"specialite_id":3,"name":"Matériaux"},{"specialite_id":4,"name":"TE"}],"Annee":[{"annee_id":1,"name":"3A"},{"annee_id":2,"name":"4A"},{"annee_id":3,"name":"5A"}],"Promo":[{"promo_id":1,"specialite_id":1,"annee_id":1},{"promo_id":2,"specialite_id":1,"annee_id":2},{"promo_id":3,"specialite_id":1,"annee_id":3},{"promo_id":5,"specialite_id":2,"annee_id":1},{"promo_id":4,"specialite_id":2,"annee_id":2},{"promo_id":6,"specialite_id":2,"annee_id":3},{"promo_id":7,"specialite_id":3,"annee_id":1},{"promo_id":8,"specialite_id":3,"annee_id":2},{"promo_id":9,"specialite_id":3,"annee_id":3},{"promo_id":10,"specialite_id":4,"annee_id":1},{"promo_id":11,"specialite_id":4,"annee_id":2},{"promo_id":12,"specialite_id":4,"annee_id":3}],"Role":[],"Utilisateur":[],"Matiere":[{"matiere_id":1,"name":"C++","promo_id":1},{"matiere_id":2,"name":"Systèmes","promo_id":1},{"matiere_id":3,"name":"Droit","promo_id":1},{"matiere_id":4,"name":"IHM","promo_id":1},{"matiere_id":5,"name":"Outils de gestion","promo_id":1},{"matiere_id":6,"name":"Statistiques I","promo_id":1},{"matiere_id":7,"name":"Statistiques II","promo_id":1},{"matiere_id":8,"name":"Théorie des graphes","promo_id":1},{"matiere_id":9,"name":"Réseau","promo_id":1},{"matiere_id":10,"name":"WEB","promo_id":1}],"Sujet":[{"sujet_id":1,"nom":"Annale c++ 2019","pdf_sujet":"exam_cpp_2018_2019_Info3.pdf","pdf_correction":"exam_cpp_2018_2019_Info3.pdf","verif":true,"date_depot":"2020-05-28","matiere_id":1}],"Commentaire":[],"Notification":[],"Suivre":[]}
\ No newline at end of file
{"tables":{}}
\ No newline at end of file
'use strict';
(function dbInit() {
const alasql = require('alasql');
alasql(`
......
......@@ -390,6 +390,11 @@
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"at-least-node": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/at-least-node/-/at-least-node-1.0.0.tgz",
"integrity": "sha512-+q/t7Ekv1EDY2l6Gda6LLiX14rU9TV20Wa3ofeQmwPFZbOMo9DXrLbOjFaaclkXKWidIaopwAObQDqwWtGUjqg=="
},
"atob": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz",
......@@ -621,6 +626,14 @@
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz",
"integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A=="
},
"busboy": {
"version": "0.3.1",
"resolved": "https://registry.npmjs.org/busboy/-/busboy-0.3.1.tgz",
"integrity": "sha512-y7tTxhGKXcyBxRKAni+awqx8uqaJKrSFSNFSeRG5CsWNdmy2BIK+6VGWEW7TZnIO/533mtMEA4rOevQV815YJw==",
"requires": {
"dicer": "0.3.0"
}
},
"bytes": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz",
......@@ -967,6 +980,14 @@
"xdg-basedir": "^4.0.0"
}
},
"connect-busboy": {
"version": "0.0.2",
"resolved": "https://registry.npmjs.org/connect-busboy/-/connect-busboy-0.0.2.tgz",
"integrity": "sha1-rFyclmchcYheV2xmsr/ZXTuxEJc=",
"requires": {
"busboy": "*"
}
},
"connect-ensure-login": {
"version": "0.1.1",
"resolved": "https://registry.npmjs.org/connect-ensure-login/-/connect-ensure-login-0.1.1.tgz",
......@@ -1229,6 +1250,14 @@
"resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
"integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
},
"dicer": {
"version": "0.3.0",
"resolved": "https://registry.npmjs.org/dicer/-/dicer-0.3.0.tgz",
"integrity": "sha512-MdceRRWqltEG2dZqO769g27N/3PXfcKl04VhYnBlo2YhH7zPi88VebsjTKclaOyiuMaGU72hTfw3VkUitGcVCA==",
"requires": {
"streamsearch": "0.1.2"
}
},
"doctrine": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz",
......@@ -1854,6 +1883,14 @@
"resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz",
"integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc="
},
"fd-slicer": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/fd-slicer/-/fd-slicer-1.1.0.tgz",
"integrity": "sha1-JcfInLH5B3+IkbvmHY85Dq4lbx4=",
"requires": {
"pend": "~1.2.0"
}
},
"figures": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz",
......@@ -2036,6 +2073,17 @@
"resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz",
"integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac="
},
"fs-extra": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-9.0.0.tgz",
"integrity": "sha512-pmEYSk3vYsG/bF651KPUXZ+hvjpgWYw/Gc7W9NFUe3ZVLczKKWIij3IKpOrQcdw4TILtibFslZ0UmR8Vvzig4g==",
"requires": {
"at-least-node": "^1.0.0",
"graceful-fs": "^4.2.0",
"jsonfile": "^6.0.1",
"universalify": "^1.0.0"
}
},
"fs-minipass": {
"version": "1.2.7",
"resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-1.2.7.tgz",
......@@ -3144,6 +3192,15 @@
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus="
},
"jsonfile": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-6.0.1.tgz",
"integrity": "sha512-jR2b5v7d2vIOust+w3wtFKZIfpC2pnRmFAhAC/BuweZFQR8qZzxH1OyrQ10HmdVYiXWkYUqPVsz91cG7EL2FBg==",
"requires": {
"graceful-fs": "^4.1.6",
"universalify": "^1.0.0"
}
},
"jsonwebtoken": {
"version": "8.5.1",
"resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-8.5.1.tgz",
......@@ -3549,6 +3606,24 @@
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g="
},
"multiparty": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/multiparty/-/multiparty-4.2.1.tgz",
"integrity": "sha512-AvESCnNoQlZiOfP9R4mxN8M9csy2L16EIbWIkt3l4FuGti9kXBS8QVzlfyg4HEnarJhrzZilgNFlZtqmoiAIIA==",
"requires": {
"fd-slicer": "1.1.0",
"http-errors": "~1.7.0",
"safe-buffer": "5.1.2",
"uid-safe": "2.1.5"
},
"dependencies": {
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
}
}
},
"mute-stdout": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/mute-stdout/-/mute-stdout-1.0.1.tgz",
......@@ -4198,6 +4273,15 @@
"resolved": "https://registry.npmjs.org/passport-strategy/-/passport-strategy-1.0.0.tgz",
"integrity": "sha1-tVOaqPwiWj0a0XlHbd8ja0QPUuQ="
},
"path": {
"version": "0.12.7",
"resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
"integrity": "sha1-1NwqUGxM4hl+tIHr/NWzbAFAsQ8=",
"requires": {
"process": "^0.11.1",
"util": "^0.10.3"
}
},
"path-dirname": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/path-dirname/-/path-dirname-1.0.2.tgz",
......@@ -4256,6 +4340,11 @@
"resolved": "https://registry.npmjs.org/pause/-/pause-0.0.1.tgz",
"integrity": "sha1-HUCLP9t2kjuVQ9lvtMnf1TXZy10="
},
"pend": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pend/-/pend-1.2.0.tgz",
"integrity": "sha1-elfrVQpng/kRUzH89GY9XI4AelA="
},
"performance-now": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/performance-now/-/performance-now-2.1.0.tgz",
......@@ -4325,6 +4414,11 @@
"resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz",
"integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ=="
},
"process": {
"version": "0.11.10",
"resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
"integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI="
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
......@@ -5135,6 +5229,11 @@
"resolved": "https://registry.npmjs.org/stream-shift/-/stream-shift-1.0.1.tgz",
"integrity": "sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ=="
},
"streamsearch": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz",
"integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo="
},
"string-width": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz",
......@@ -5523,6 +5622,11 @@
"crypto-random-string": "^2.0.0"
}
},
"universalify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-1.0.0.tgz",
"integrity": "sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug=="
},
"unpipe": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
......@@ -5639,6 +5743,14 @@
"resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
"integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ=="
},
"util": {
"version": "0.10.4",
"resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
"integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
"requires": {
"inherits": "2.0.3"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
......
......@@ -34,4 +34,20 @@
.annale-container iframe {
width: 100%;
height: 100vh;
}
#hidden-correction-message {
position: relative;
top: 24vh;
text-align: center;
display: block;
height: 0;
margin: 0;
font-size: 20px;
}
.tab-legende {
margin: 20px;
border: 1px solid black;
padding: 10px;
}
\ No newline at end of file
......@@ -11,7 +11,7 @@
// pour les templates Mustache
let context = {'logged': false};
// fonction utilitaire permettant de faire du
// fonction utilitaire permettant de faire du
// lazy loading (chargement à la demande) des templates
const templates = (() => {
let templates = {};
......@@ -26,10 +26,10 @@ const templates = (() => {
return templates[url] = text;
});
}
}
};
})();
// Fonction utilitaire qui permet de charger en parallèle les
// Fonction utilitaire qui permet de charger en parallèle les
// différents "partial" (morceaux de template. Ex: header)
const loadPartials = (() => {
let partials;
......@@ -47,7 +47,7 @@ const loadPartials = (() => {
partials = Object.fromEntries(await Promise.all(promises));
}
return partials;
}
};
})();
......@@ -69,14 +69,14 @@ page('/accueil', async function () {
annees = await annees.json();
let specialites = await fetch('api/specialite');
specialites = await specialites.json();
await renderTemplate(templates('public/templates/accueil.mustache'), {...context, annees, specialites});
/*let valide = document.querySelector('#form');
valide.addEventListener('click', function () {
//evt.preventDefault();
let specialite = getElementByName("#specialite");
let annee = getElementByName("#annee");
//Faire une requête du style SELECT name FROM promo WHERE promo = <specialite> AND year = <annee>
//Faire une requête du style SELECT name FROM promo WHERE promo = <specialite> AND year = <annee>
let promo = 'Informatique'; //Ce que doit renvoyer la requête
page(`/selection_annale`);
......@@ -99,41 +99,47 @@ page('/selection_annale', async function () {
const promo = window.location.search.split('=')[1];
let matieres = await fetch('api/matiere/getMatieresByPromo?promo=' + promo);
matieres = await matieres.json();