Skip to content
Snippets Groups Projects
Commit 7d4f27c9 authored by ExtraDev's avatar ExtraDev
Browse files

Ajout de l'interface public pour l'affichage des passage

parent ec174c53
No related branches found
No related tags found
No related merge requests found
node_modules
\ No newline at end of file
FROM node:16
WORKDIR /usr/app
COPY package*.json ./
RUN npm install
COPY . .
ENV PORT=8000
EXPOSE 8000
\ No newline at end of file
...@@ -21,7 +21,7 @@ const options = { ...@@ -21,7 +21,7 @@ const options = {
origin: "*" origin: "*"
}; };
const app = (0, express_1.default)(); const app = (0, express_1.default)();
const port = process.env.API_PORT; const port = process.env.API_PORT || 8000;
app.use((0, cors_1.default)(options)); app.use((0, cors_1.default)(options));
app.use(express_1.default.json()); app.use(express_1.default.json());
app.use(express_1.default.urlencoded()); app.use(express_1.default.urlencoded());
......
...@@ -20,7 +20,7 @@ const options: cors.CorsOptions = { ...@@ -20,7 +20,7 @@ const options: cors.CorsOptions = {
}; };
const app = express(); const app = express();
const port = process.env.API_PORT; const port = process.env.API_PORT || 8000;
app.use(cors(options)); app.use(cors(options));
app.use(express.json()); app.use(express.json());
......
...@@ -27,6 +27,16 @@ services: ...@@ -27,6 +27,16 @@ services:
# command: npm run dev # command: npm run dev
# volumes: # volumes:
# - ./frontend:/usr/app/ # - ./frontend:/usr/app/
# - ./frontend/node_modules:/usr/app/node_modules
# ports: # ports:
# - "5173:5173" # - "5173:5173"
# api:
# build: ./api
# command: npm run dev
# volumes:
# - ./api:/usr/app/
# ports:
# - "8000:8000"
# env_file: ./.env
# depends_on:
# - database
# restart: on-failure
<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
html, body {
margin: 0;
padding: 0;
font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
#container {
margin: auto;
width: 90%;
max-width: 800px;
}
h1 {
text-align: center;
}
#classment {
margin-top: 50px;
width: 100%;
}
#classment tr td {
text-align: center;
}
form {
text-align: center;
}
table,
tr,
td{
border: 1px solid black;
}
tr:nth-child(even){background-color: #f2f2f2;}
tr:hover {background-color: #ddd;}
table {
border-collapse: collapse;
width: 100%;
margin-top: 15px;
margin-bottom: 15px;
}
th {
background-color: #061b41;
color: white;
font-size: 1.2em;
}
</style>
</head>
<body>
<div id="container">
<h1>Bol d'or Mirabaud - classement</h1>
<form action="#">
<select name="edition" id="edition">
<option value="">2022</option>
<option value="">2023</option>
<option value="">2024</option>
<option value="">2025</option>
</select>
<label for="refresh">Vitesse de rafraichissement (ms)</label>
<input type="number" for="refresh" min="500" value="1000">
<button id="btn_display_classment">Affiche les résultats</button>
</form>
<table id="classment">
<thead>
<th>Classement</th>
<th>Équipe</th>
<th>Heure de passage</th>
</thead>
<tbody id="classment-body">
</tbody>
</table>
</div>
<script>
window.addEventListener("load", function() {
const EDITIONS = "http://localhost:8000/editions";
const ENTRY = "http://localhost:8000/entry?year=";
let year = 2022;
let classment = document.getElementById("classment-body");
let btn_display = document.getElementById("btn_display_classment");
let refresh = 1000; //ms to refresh
btn_display.addEventListener("click", function(){
getClassment();
});
function getClassment() {
classment.innerHTML = "";
let entries_url = ENTRY + year;
fetch(entries_url)
.then((response) => response.json())
.then((entries_data) => {
for (let i in entries_data) {
let tr = document.createElement("tr");
let td1 = document.createElement("td");
let td2 = document.createElement("td");
let td3 = document.createElement("td");
td1.innerHTML = i;
td2.innerHTML = entries_data[i].name;
td3.innerHTML = parseTimeStamp(entries_data[i].time_stamp);
tr.appendChild(td1);
tr.appendChild(td2);
tr.appendChild(td3);
classment.appendChild(tr);
}
});
}
function parseTimeStamp(time_stamp) {
return time_stamp.split("T")[1].split(".")[0];
}
getClassment();
})
</script>
</body>
</html>
\ No newline at end of file
node_modules
\ No newline at end of file
FROM node:latest FROM node:16
RUN mkdir -p /usr/app/node_modules && chown -R node:node /usr/app
WORKDIR /usr/app WORKDIR /usr/app
COPY package.json . COPY package*.json ./
USER node
RUN npm install RUN npm install
COPY --chown=node:node . . COPY . .
ENV PORT=5173
EXPOSE 5173 EXPOSE 5173
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment