From a0f6d4abbac070583593daa36a29c3588c6f56ea Mon Sep 17 00:00:00 2001 From: nau Date: Fri, 9 Sep 2016 18:41:08 +0200 Subject: [PATCH] work traking and stopping functionallity semi implemented --- controllers/projectController.js | 42 ++++++++++++++++++++++++++++++ controllers/userController.js | 23 +++++++++-------- models/projectModel.js | 11 +++++++- server.js | 5 ++++ webapp/controllers.js | 44 +++++++++++++++++++------------- 5 files changed, 96 insertions(+), 29 deletions(-) diff --git a/controllers/projectController.js b/controllers/projectController.js index 8b064b0..ed57844 100644 --- a/controllers/projectController.js +++ b/controllers/projectController.js @@ -88,7 +88,49 @@ exports.addUserToProject = function(req, res) { }); }); }; +exports.userStartWorking = function(req, res) { + console.log("userStartWorking"); + projectModel.findById(req.params.id, function(err, project) { + var workstrike={ + username: req.body.username, + start: new Date(), + end: "", + }; + project.workStrikes.push(workstrike); + console.log(project); + project.save(function(err) { + if(err) return res.send(500, err.message); + + projectModel.find(function(err, projects) { + if(err) res.send(500, err.message); + res.status(200).jsonp(projects); + }); + }); + }); +}; +exports.userStopWorking = function(req, res) { + console.log("userStopWorking"); + projectModel.findById(req.params.id, function(err, project) { + for(var i=0; i