Compare commits
No commits in common. "master" and "feature/FEATURE002_modif_resto" have entirely different histories.
master
...
feature/FE
6 changed files with 85 additions and 88 deletions
BIN
database.sqlite
BIN
database.sqlite
Binary file not shown.
|
|
@ -1,14 +1,13 @@
|
||||||
const axios = require("axios");
|
const axios = require("axios");
|
||||||
|
|
||||||
const { getUserByGId } = require('../users/getUsers');
|
const { getUserByDId } = require('../users/getUsers');
|
||||||
const { postUser } = require('../users/postUsers');
|
const { postUser } = require('../users/postUsers');
|
||||||
|
|
||||||
const CLIEN_ID = "71229835507-9413gbpdamv2qbcb2ov8oda2oqgcsk8q.apps.googleusercontent.com";
|
const CLIEN_ID = "71229835507-9413gbpdamv2qbcb2ov8oda2oqgcsk8q.apps.googleusercontent.com";
|
||||||
const GOOGLE_SECRET = "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";
|
const GOOGLE_SECRET = "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";
|
||||||
const GOOGLE_REDIRECT_URI = "http://localhost:3000/auth/google/callback";
|
const REDIRECT_URI = "http://localhost:3000/auth/google/callback";
|
||||||
|
|
||||||
exports.handleGoogleAuth = async (req, res) => {
|
exports.handleGoogleAuth = async (code, res) => {
|
||||||
const code = req.query.code;
|
|
||||||
if (!code) return res.status(400).json({ error: "Code de validation manquant" });
|
if (!code) return res.status(400).json({ error: "Code de validation manquant" });
|
||||||
try {
|
try {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
|
|
@ -42,6 +41,8 @@ exports.handleGoogleAuth = async (req, res) => {
|
||||||
const newUser = {
|
const newUser = {
|
||||||
username: userData.name || userData.email,
|
username: userData.name || userData.email,
|
||||||
google_id: userData.id,
|
google_id: userData.id,
|
||||||
|
email: userData.email,
|
||||||
|
avatar: userData.picture || null,
|
||||||
};
|
};
|
||||||
savedUser = await postUser(newUser);
|
savedUser = await postUser(newUser);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ main {
|
||||||
}
|
}
|
||||||
|
|
||||||
.chart-placeholder {
|
.chart-placeholder {
|
||||||
width: 200px;
|
width: 150px;
|
||||||
height: 200px;
|
height: 150px;
|
||||||
background: #eee;
|
background: #eee;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
|
||||||
11
routes.js
11
routes.js
|
|
@ -22,17 +22,6 @@ router.get('/auth/discord', (req, res) => {
|
||||||
|
|
||||||
router.get('/auth/discord/callback', require('./modules/auth/discord').handleDiscordAuth);
|
router.get('/auth/discord/callback', require('./modules/auth/discord').handleDiscordAuth);
|
||||||
|
|
||||||
// Auth Google
|
|
||||||
router.get('/auth/google', (req, res) => {
|
|
||||||
const clientId = '71229835507-9413gbpdamv2qbcb2ov8oda2oqgcsk8q.apps.googleusercontent.com';
|
|
||||||
const redirectUri = 'http://localhost:3000/auth/google/callback';
|
|
||||||
const scope = 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile';
|
|
||||||
const googleAuthUrl = `https://accounts.google.com/o/oauth2/auth?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${encodeURIComponent(scope)}`;
|
|
||||||
res.redirect(googleAuthUrl);
|
|
||||||
});
|
|
||||||
|
|
||||||
router.get('/auth/google/callback', require('./modules/auth/google').handleGoogleAuth);
|
|
||||||
|
|
||||||
// Déconnexion
|
// Déconnexion
|
||||||
router.get('/logout', (req, res) => {
|
router.get('/logout', (req, res) => {
|
||||||
req.session.destroy((err) => {
|
req.session.destroy((err) => {
|
||||||
|
|
|
||||||
76
views/graphique.ejs
Normal file
76
views/graphique.ejs
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Diagramme Radar avec Chart.js</title>
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div style="width: 35%; margin: 0 auto;">
|
||||||
|
<canvas id="radarChart"></canvas>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const ctx = document.getElementById('radarChart').getContext('2d');
|
||||||
|
const radarChart = new Chart(ctx, {
|
||||||
|
type: 'radar',
|
||||||
|
data: {
|
||||||
|
labels: ['Qualité des plats', 'Ambiance', 'Accessibilité', 'Service', 'Tradition'],
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: 'Moyenne des notes',
|
||||||
|
data: [4.7, 4.6, 4.4, 4.3, 4.8],
|
||||||
|
fill: true,
|
||||||
|
backgroundColor: 'rgba(25, 80, 233, 0.2)',
|
||||||
|
borderColor: 'rgb(25, 80, 233, 10)',
|
||||||
|
pointBackgroundColor: 'rgb(55, 99, 132)',
|
||||||
|
pointBorderColor: '#fff',
|
||||||
|
pointHoverBackgroundColor: '#fff',
|
||||||
|
pointHoverBorderColor: 'rgb(255, 99, 132)',
|
||||||
|
pointStyle: 'circle',
|
||||||
|
pointRadius: 5,
|
||||||
|
pointRotation: 0,
|
||||||
|
},
|
||||||
|
]
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
display: false
|
||||||
|
},
|
||||||
|
tooltip: {
|
||||||
|
callbacks: {
|
||||||
|
label: function(context) {
|
||||||
|
let label = context.dataset.label || '';
|
||||||
|
if (label) {
|
||||||
|
label += ': ';
|
||||||
|
}
|
||||||
|
label += context.formattedValue;
|
||||||
|
return label;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
r: {
|
||||||
|
max: 5,
|
||||||
|
min: 0,
|
||||||
|
ticks: {
|
||||||
|
stepSize: 1,
|
||||||
|
callback: function(value, index, values) {
|
||||||
|
return value.toFixed(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
elements: {
|
||||||
|
line: {
|
||||||
|
borderWidth: 3
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
@ -21,9 +21,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="chart">
|
<div class="chart">
|
||||||
<div class="chart-placeholder">
|
<div class="chart-placeholder">Graph radar</div>
|
||||||
<canvas id="radarChart"></canvas>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -97,70 +95,3 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const ctx = document.getElementById('radarChart').getContext('2d');
|
|
||||||
const radarChart = new Chart(ctx, {
|
|
||||||
type: 'radar',
|
|
||||||
data: {
|
|
||||||
labels: ['Qualité des plats', 'Ambiance', 'Accessibilité', 'Service', 'Tradition'],
|
|
||||||
datasets: [
|
|
||||||
{
|
|
||||||
label: 'Moyenne des notes',
|
|
||||||
data: [4.7, 4.6, 4.4, 4.3, 4.8],
|
|
||||||
fill: true,
|
|
||||||
backgroundColor: 'rgba(255,215, 0, 0.2)',
|
|
||||||
borderColor: 'rgb(255,215, 0, 1)',
|
|
||||||
pointBackgroundColor: 'rgb(255,215, 0)',
|
|
||||||
pointBorderColor: '#fff',
|
|
||||||
pointHoverBackgroundColor: '#fff',
|
|
||||||
pointHoverBorderColor: 'rgb(255,215, 0)',
|
|
||||||
pointStyle: 'circle',
|
|
||||||
pointRadius: 5,
|
|
||||||
pointRotation: 0,
|
|
||||||
},
|
|
||||||
]
|
|
||||||
},
|
|
||||||
options: {
|
|
||||||
plugins: {
|
|
||||||
legend: {
|
|
||||||
display: false
|
|
||||||
},
|
|
||||||
tooltip: {
|
|
||||||
callbacks: {
|
|
||||||
label: function(context) {
|
|
||||||
let label = context.dataset.label || '';
|
|
||||||
if (label) {
|
|
||||||
label += ': ';
|
|
||||||
}
|
|
||||||
label += context.formattedValue;
|
|
||||||
return label;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
scales: {
|
|
||||||
r: {
|
|
||||||
max: 5,
|
|
||||||
min: 0,
|
|
||||||
ticks: {
|
|
||||||
stepSize: 1,
|
|
||||||
display: false,
|
|
||||||
callback: function(value, index, values) {
|
|
||||||
return value.toFixed(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
elements: {
|
|
||||||
line: {
|
|
||||||
borderWidth: 3
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
Loading…
Add table
Reference in a new issue