From 0eeb2cab2f26765f0fb523dd7186c31bee57cf09 Mon Sep 17 00:00:00 2001 From: nau Date: Fri, 9 Sep 2016 19:24:13 +0200 Subject: [PATCH] work and stopwork system done, project time data structure runs ok --- controllers/projectController.js | 15 +++++++++++- models/projectModel.js | 8 +++++-- package.json | 3 ++- webapp/controllers.js | 41 ++++++++++++++++++++++++++++++++ webapp/dashboard.html | 10 ++++---- 5 files changed, 68 insertions(+), 9 deletions(-) diff --git a/controllers/projectController.js b/controllers/projectController.js index ed57844..c88f606 100644 --- a/controllers/projectController.js +++ b/controllers/projectController.js @@ -1,5 +1,6 @@ //File: controllers/projectController.js var mongoose = require('mongoose'); +var moment = require('moment'); var projectModel = mongoose.model('projectModel'); var userModel = mongoose.model('userModel'); @@ -75,7 +76,11 @@ exports.addUserToProject = function(req, res) { console.log(req.body); projectModel.findById(req.params.id, function(err, project) { console.log(project); - project.users.push(req.body.username); + var auxUser={ + username: req.body.username, + time: 0 + }; + project.users.push(auxUser); console.log(project.users); project.save(function(err) { if(err) return res.send(500, err.message); @@ -117,6 +122,14 @@ exports.userStopWorking = function(req, res) { if((project.workStrikes[i].username==req.body.username)&&(project.workStrikes[i].end==null)) { project.workStrikes[i].end= new Date(); + project.workStrikes[i].time=moment(project.workStrikes[i].end).diff(project.workStrikes[i].start, 'seconds'); + for(var j=0; j{{project.description}}

{{project.totaltime | secondsToDateTime | date:'HH:mm:ss'}}

-

{{user}}
+
{{user.username}}

@@ -122,17 +122,17 @@

Total time: {{currentproject.totaltime | secondsToDateTime | date:'HH:mm:ss'}}

-

- Current strike time: {{currentStrike | secondsToDateTime | date:'HH:mm:ss'}} +

+ {{user.username}}: {{user.time | secondsToDateTime | date:'HH:mm:ss'}}

-
+
Work! Stop!
-
+