diff options
Diffstat (limited to 'web/routes')
| -rw-r--r-- | web/routes/index.js | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/web/routes/index.js b/web/routes/index.js index 23fcf36..f07856a 100644 --- a/web/routes/index.js +++ b/web/routes/index.js @@ -11,9 +11,7 @@ router.get('/', function(req, res, next) { /* GET Map page. */ router.get('/map', function(req,res) { - // load the map with all the points - // Mockpoints.get_points(function(err, points){ - Points.get_points(function(err, points){ + Points.get_all_active_points(function(err, points){ res.render('map', { lat : 43.665234, lng : -79.383370, @@ -40,6 +38,30 @@ router.post('/mobilerequest', function(req, res) { }); +router.post('/savestatus/:status', function(req, res) { + var data = req.body; + var pointId = data.id; + var setStatus = req.params.status; + if ( + setStatus !== "new" && + setStatus !== "pending" && + setStatus !== "complete" + ) { + console.log("Invalid status supplied."); + return res.status(422).send({error: "Error: Status must be one of 'new', 'pending', or 'complete'"}); + } + + // here we are guaranteed to be able to do the query + Points.update_point_status(pointId, setStatus, function(err, result) { + if (err) { + console.log(`err updating point status in db: ${err}`); + res.status(500).send({ error: "Oops. Something went wrong on our end." }); + } else { + console.log(result); + res.status(200).send({'status': 'success'}); + } + }); +}); router.get('/stream', function(req, res){ // set up server side event (communication line between front end and server) |
