Added scoreboard functionality, seperate update admin frontend

This commit is contained in:
2024-05-17 21:24:58 +02:00
parent e36a959071
commit 93d06517e4
4 changed files with 331 additions and 22 deletions
+45 -2
View File
@@ -1,6 +1,10 @@
var express = require('express');
var router = express.Router();
const io = require('../controllers/socketio');
const timer = require('../controllers/timer');
const score = require('../controllers/score');
// Express router endpoint to trigger a frontend refresh on all connected sockets
router.get('/refreshMonitor', function(req, res, next) {
console.log("Monitor neu geladen");
@@ -47,9 +51,48 @@ router.get('/timerGetValues', function(req, res, next) {
res.json(timer.getValues()); // Respond with important values for frontend
});
// Express router endpoint to toggle the scoreboard
router.get('/scoreToggle', function(req, res, next) {
if(score.getEnabled()) { // If scoreboard enabled
console.log("Scoreboard disabled");
score.setEnabled(false) // Disable the scoreboard
res.status(200); // Set http status code to 200 (success)
res.json(score.getValues()) // Respond with all important values to update the frontend
} else {
console.log("Scoreboard enabled");
score.setEnabled(true) // Enable the scoreboard
res.status(200); // Set http status code to 200 (success)
res.json(score.getValues()); // Respond with all important values to update the frontend
}
});
// Express router endpoint to set score of a team
router.post('/scoreSetScore', function(req, res, next) {
score.setScore(req.body.team, req.body.score);
res.status(200);
res.json(score.getValues());
});
// Express router endpoint to alter passed teams score by one in the passed direction
router.post('/scoreAlterScore', function(req, res, next) {
score.alterScore(req.body.team, req.body.dir);
res.status(200);
res.json(score.getValues());
});
// Express router endpoint to switch the score after halftime
router.get('/scoreSwitch', function(req, res, next) {
res.render('admin');
router.post('/scoreSwitch', function(req, res, next) {
});
// Express router endpoint to get important score values
router.get('/scoreGetValues', function(req, res, next) {
res.json(score.getValues()); // Respond with important values for frontend
});
// Express router endpoint to clear score
router.get('/scoreClearScore', function(req, res, next) {
score.clearScore(); // Clear score
res.json(score.getValues()); // Respond with important values for frontend
});
/* GET home page. */