mirror of
https://github.com/arnaucube/openworktime.git
synced 2026-02-07 11:46:40 +01:00
user working parameter added
This commit is contained in:
@@ -112,7 +112,19 @@ exports.userStartWorking = function(req, res) {
|
|||||||
res.status(200).jsonp(projects);
|
res.status(200).jsonp(projects);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
userModel.findById(req.body._id, function(err, user) {
|
||||||
|
user.working=true;
|
||||||
|
|
||||||
|
user.save(function(err) {
|
||||||
|
if(err) return res.send(500, err.message);
|
||||||
|
console.log("user working=true");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
exports.userStopWorking = function(req, res) {
|
exports.userStopWorking = function(req, res) {
|
||||||
console.log("userStopWorking");
|
console.log("userStopWorking");
|
||||||
@@ -142,6 +154,15 @@ exports.userStopWorking = function(req, res) {
|
|||||||
res.status(200).jsonp(projects);
|
res.status(200).jsonp(projects);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
userModel.findById(req.body._id, function(err, user) {
|
||||||
|
user.working=false;
|
||||||
|
|
||||||
|
user.save(function(err) {
|
||||||
|
if(err) return res.send(500, err.message);
|
||||||
|
console.log("user working=false");
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
//PUT
|
//PUT
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ var userSchema = new Schema({
|
|||||||
github: { type: String },
|
github: { type: String },
|
||||||
web: { type: String },
|
web: { type: String },
|
||||||
projects: { type: String },
|
projects: { type: String },
|
||||||
connected: { type: Boolean }
|
connected: { type: Boolean },
|
||||||
|
working: { type: Boolean }
|
||||||
})
|
})
|
||||||
module.exports = mongoose.model('userModel', userSchema);
|
module.exports = mongoose.model('userModel', userSchema);
|
||||||
|
|||||||
@@ -136,6 +136,6 @@ app.use('/api', apiRoutes);
|
|||||||
// end of API routes -------------------------------------
|
// end of API routes -------------------------------------
|
||||||
|
|
||||||
// Start server
|
// Start server
|
||||||
app.listen(config.port, function() {
|
app.listen(config.port, "localhost", function() {
|
||||||
console.log("Node server running on http://localhost:3000");
|
console.log("Node server running on http://localhost:3000");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
var urlapi = "http://192.168.1.41:3000/api/";
|
||||||
var urlapi = "http://localhost:3000/api/";
|
var urlapi = "http://localhost:3000/api/";
|
||||||
|
|
||||||
angular.module('workApp', ['chart.js'])
|
angular.module('workApp', ['chart.js'])
|
||||||
@@ -10,6 +11,22 @@ angular.module('workApp', ['chart.js'])
|
|||||||
$scope.projects={};
|
$scope.projects={};
|
||||||
$scope.currentInclude='login.html';
|
$scope.currentInclude='login.html';
|
||||||
var refreshTime=20000;
|
var refreshTime=20000;
|
||||||
|
$scope.getLoggedUser = function(){
|
||||||
|
//get logged user
|
||||||
|
$http.get(urlapi + 'users/byusername/' + $scope.user.username)
|
||||||
|
.success(function(data, status, headers,config){
|
||||||
|
console.log(data);
|
||||||
|
$scope.user=data;
|
||||||
|
})
|
||||||
|
.error(function(data, status, headers,config){
|
||||||
|
console.log("server not responding, data error");
|
||||||
|
toastr.error("server not responding");
|
||||||
|
$scope.$broadcast('scroll.refreshComplete');//refresher stop
|
||||||
|
})
|
||||||
|
.then(function(result){
|
||||||
|
users = result.data;
|
||||||
|
});
|
||||||
|
};
|
||||||
/* DASHBOARD initialization */
|
/* DASHBOARD initialization */
|
||||||
$scope.dashboardInit = function(){
|
$scope.dashboardInit = function(){
|
||||||
if(localStorage.getItem('owt_token')){// adding token to the headers
|
if(localStorage.getItem('owt_token')){// adding token to the headers
|
||||||
@@ -23,6 +40,7 @@ angular.module('workApp', ['chart.js'])
|
|||||||
$scope.currentInclude="login.html";
|
$scope.currentInclude="login.html";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$scope.getLoggedUser();
|
||||||
//getting users
|
//getting users
|
||||||
$http.get(urlapi + 'users')
|
$http.get(urlapi + 'users')
|
||||||
.success(function(data, status, headers,config){
|
.success(function(data, status, headers,config){
|
||||||
@@ -76,9 +94,17 @@ angular.module('workApp', ['chart.js'])
|
|||||||
|
|
||||||
|
|
||||||
$scope.user={};
|
$scope.user={};
|
||||||
|
|
||||||
|
$http.defaults.headers.post['Content-Type'] = 'application/json';
|
||||||
if(localStorage.getItem("owt_user")){
|
if(localStorage.getItem("owt_user")){
|
||||||
|
if(localStorage.getItem('owt_token')){// adding token to the headers
|
||||||
|
$http.defaults.headers.post['X-Access-Token'] = localStorage.getItem('owt_token');
|
||||||
|
$http.defaults.headers.post['Content-Type'] = 'application/json';
|
||||||
|
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('owt_token');
|
||||||
|
}
|
||||||
$scope.user=JSON.parse(localStorage.getItem("owt_user"));
|
$scope.user=JSON.parse(localStorage.getItem("owt_user"));
|
||||||
$scope.currentInclude="dashboard.html";
|
$scope.currentInclude="dashboard.html";
|
||||||
|
$scope.getLoggedUser();
|
||||||
$scope.dashboardInit();
|
$scope.dashboardInit();
|
||||||
intervalGetData = $interval(function(){
|
intervalGetData = $interval(function(){
|
||||||
$scope.dashboardInit();
|
$scope.dashboardInit();
|
||||||
@@ -153,7 +179,7 @@ angular.module('workApp', ['chart.js'])
|
|||||||
|
|
||||||
|
|
||||||
//localStorage.clear();
|
//localStorage.clear();
|
||||||
$scope.working=false;
|
//$scope.working=false;
|
||||||
$scope.currentproject={};
|
$scope.currentproject={};
|
||||||
|
|
||||||
$scope.newproject={};
|
$scope.newproject={};
|
||||||
@@ -214,7 +240,8 @@ angular.module('workApp', ['chart.js'])
|
|||||||
};
|
};
|
||||||
$scope.currentprojectIndex;
|
$scope.currentprojectIndex;
|
||||||
$scope.projectSelect = function(index){
|
$scope.projectSelect = function(index){
|
||||||
$scope.btnStop();
|
//$scope.btnStop();
|
||||||
|
console.log(index);
|
||||||
$scope.currentprojectIndex=index;
|
$scope.currentprojectIndex=index;
|
||||||
$scope.currentproject=$scope.projects[index];
|
$scope.currentproject=$scope.projects[index];
|
||||||
};
|
};
|
||||||
@@ -239,7 +266,7 @@ angular.module('workApp', ['chart.js'])
|
|||||||
$scope.currentStrike=0;
|
$scope.currentStrike=0;
|
||||||
$scope.btnWork = function(){
|
$scope.btnWork = function(){
|
||||||
//$scope.editingProject=false;
|
//$scope.editingProject=false;
|
||||||
$scope.working=true;
|
$scope.user.working=true;
|
||||||
$http({
|
$http({
|
||||||
url: urlapi + 'projects/' + $scope.currentproject._id + '/startworking',
|
url: urlapi + 'projects/' + $scope.currentproject._id + '/startworking',
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
@@ -247,14 +274,15 @@ angular.module('workApp', ['chart.js'])
|
|||||||
}).then(function(response) {
|
}).then(function(response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
$scope.projects=response.data;
|
$scope.projects=response.data;
|
||||||
|
$scope.getLoggedUser();
|
||||||
},
|
},
|
||||||
function(response) {// failed
|
function(response) {// failed
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
$scope.btnStop = function(){
|
$scope.btnStop = function(){
|
||||||
if($scope.working==true)
|
if($scope.user.working==true)
|
||||||
{
|
{
|
||||||
$scope.working=false;
|
//$scope.user.working=false;
|
||||||
$http({
|
$http({
|
||||||
url: urlapi + 'projects/' + $scope.currentproject._id + '/stopworking',
|
url: urlapi + 'projects/' + $scope.currentproject._id + '/stopworking',
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
@@ -267,6 +295,7 @@ angular.module('workApp', ['chart.js'])
|
|||||||
response.data[i].chart=translateWorkStrikes2Chart(response.data[i].workStrikes);
|
response.data[i].chart=translateWorkStrikes2Chart(response.data[i].workStrikes);
|
||||||
}
|
}
|
||||||
$scope.projects=response.data;
|
$scope.projects=response.data;
|
||||||
|
$scope.getLoggedUser();
|
||||||
},
|
},
|
||||||
function(response) {// failed
|
function(response) {// failed
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -129,8 +129,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-action">
|
<div class="card-action">
|
||||||
<div ng-show="arrayObjectIndexOf(currentproject.users, user.username, 'username')!=-1">
|
<div ng-show="arrayObjectIndexOf(currentproject.users, user.username, 'username')!=-1">
|
||||||
<a ng-click="btnWork()" ng-show="!working" class="waves-effect waves-light btn green lighten-2">Work!</a>
|
<a ng-click="btnWork()" ng-show="!user.working" class="waves-effect waves-light btn green lighten-2">Work!</a>
|
||||||
<a ng-click="btnStop()" ng-show="working" class="waves-effect waves-light btn red lighten-2">Stop!</a>
|
<a ng-click="btnStop()" ng-show="user.working" class="waves-effect waves-light btn red lighten-2">Stop!</a>
|
||||||
</div>
|
</div>
|
||||||
<div ng-show="arrayObjectIndexOf(currentproject.users, user.username, 'username')==-1">
|
<div ng-show="arrayObjectIndexOf(currentproject.users, user.username, 'username')==-1">
|
||||||
<a ng-click="joinProject()" class="waves-effect waves-light btn blue lighten-2">Join!</a>
|
<a ng-click="joinProject()" class="waves-effect waves-light btn blue lighten-2">Join!</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user