|
@ -9,21 +9,28 @@ angular.module('workApp', ['chart.js']) |
|
|
$scope.users={}; |
|
|
$scope.users={}; |
|
|
$scope.projects={}; |
|
|
$scope.projects={}; |
|
|
$scope.currentInclude='login.html'; |
|
|
$scope.currentInclude='login.html'; |
|
|
|
|
|
var refreshTime=20000; |
|
|
/* 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
|
|
|
$http.defaults.headers.post['X-Access-Token'] = localStorage.getItem('owt_token'); |
|
|
$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'); |
|
|
$http.defaults.headers.common['X-Access-Token'] = localStorage.getItem('owt_token'); |
|
|
} |
|
|
} |
|
|
|
|
|
if(localStorage.getItem("owt_user")){ |
|
|
|
|
|
$scope.user=JSON.parse(localStorage.getItem("owt_user")); |
|
|
|
|
|
}else{ |
|
|
|
|
|
$scope.currentInclude="login.html"; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
//getting users
|
|
|
//getting users
|
|
|
$http.get(urlapi + 'users') |
|
|
$http.get(urlapi + 'users') |
|
|
.success(function(data, status, headers,config){ |
|
|
.success(function(data, status, headers,config){ |
|
|
if(data.success==false){ |
|
|
if(data.success==false){ |
|
|
localStorage.removeItem("owt_token"); |
|
|
|
|
|
|
|
|
/*localStorage.removeItem("owt_token"); |
|
|
localStorage.removeItem("owt_user"); |
|
|
localStorage.removeItem("owt_user"); |
|
|
$scope.currentInclude="login.html"; |
|
|
$scope.currentInclude="login.html"; |
|
|
console.log("token ended"); |
|
|
|
|
|
|
|
|
console.log("token ended");*/ |
|
|
}else{ |
|
|
}else{ |
|
|
console.log(data); |
|
|
console.log(data); |
|
|
$scope.users=data; |
|
|
$scope.users=data; |
|
@ -64,7 +71,7 @@ angular.module('workApp', ['chart.js']) |
|
|
$scope.dashboardInit(); |
|
|
$scope.dashboardInit(); |
|
|
intervalGetData = $interval(function(){ |
|
|
intervalGetData = $interval(function(){ |
|
|
$scope.dashboardInit(); |
|
|
$scope.dashboardInit(); |
|
|
}, 2000); |
|
|
|
|
|
|
|
|
}, refreshTime); |
|
|
}else{ |
|
|
}else{ |
|
|
$scope.currentInclude="login.html"; |
|
|
$scope.currentInclude="login.html"; |
|
|
} |
|
|
} |
|
@ -107,7 +114,7 @@ angular.module('workApp', ['chart.js']) |
|
|
|
|
|
|
|
|
intervalGetData = $interval(function(){ |
|
|
intervalGetData = $interval(function(){ |
|
|
$scope.dashboardInit(); |
|
|
$scope.dashboardInit(); |
|
|
}, 2000); |
|
|
|
|
|
|
|
|
}, refreshTime); |
|
|
}else{ |
|
|
}else{ |
|
|
toastr.error(response.data.message); |
|
|
toastr.error(response.data.message); |
|
|
} |
|
|
} |
|
@ -159,6 +166,7 @@ angular.module('workApp', ['chart.js']) |
|
|
}).then(function(response) { |
|
|
}).then(function(response) { |
|
|
console.log("project posted"); |
|
|
console.log("project posted"); |
|
|
console.log(response); |
|
|
console.log(response); |
|
|
|
|
|
$scope.projects=response.data; |
|
|
toastr.success("project created at server"); |
|
|
toastr.success("project created at server"); |
|
|
$scope.newproject={}; |
|
|
$scope.newproject={}; |
|
|
}, |
|
|
}, |
|
@ -179,14 +187,43 @@ angular.module('workApp', ['chart.js']) |
|
|
$scope.editingProject=false; |
|
|
$scope.editingProject=false; |
|
|
}; |
|
|
}; |
|
|
$scope.removeProject = function(index){ |
|
|
$scope.removeProject = function(index){ |
|
|
$scope.projects.splice(index, 1); |
|
|
|
|
|
localStorage.setItem("w_l_projects", angular.toJson($scope.projects)); |
|
|
|
|
|
$scope.projectSelect(0); |
|
|
|
|
|
|
|
|
/*$scope.projects.splice(index, 1); |
|
|
|
|
|
localStorage.setItem("w_l_projects", angular.toJson($scope.projects));*/ |
|
|
|
|
|
$http({ |
|
|
|
|
|
url: urlapi + 'projects/' + $scope.projects[index]._id, |
|
|
|
|
|
method: "DELETE", |
|
|
|
|
|
data: $scope.user._id |
|
|
|
|
|
}).then(function(response) { |
|
|
|
|
|
console.log(response); |
|
|
|
|
|
$scope.projects=response.data; |
|
|
|
|
|
$scope.projectSelect(null); |
|
|
|
|
|
}, |
|
|
|
|
|
function(response) {// failed
|
|
|
|
|
|
}); |
|
|
}; |
|
|
}; |
|
|
|
|
|
$scope.currentprojectIndex; |
|
|
$scope.projectSelect = function(index){ |
|
|
$scope.projectSelect = function(index){ |
|
|
$scope.btnStop(); |
|
|
$scope.btnStop(); |
|
|
|
|
|
$scope.currentprojectIndex=index; |
|
|
$scope.currentproject=$scope.projects[index]; |
|
|
$scope.currentproject=$scope.projects[index]; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
$scope.joinProject = function(){ |
|
|
|
|
|
console.log($scope.user); |
|
|
|
|
|
$http({ |
|
|
|
|
|
url: urlapi + 'projects/'+$scope.currentproject._id+'/adduser', |
|
|
|
|
|
method: "PUT", |
|
|
|
|
|
data: $scope.user |
|
|
|
|
|
}).then(function(response) { |
|
|
|
|
|
console.log("project joined"); |
|
|
|
|
|
$scope.projects=response.data; |
|
|
|
|
|
//re select currentproject
|
|
|
|
|
|
$scope.currentproject=$scope.projects[$scope.currentprojectIndex]; |
|
|
|
|
|
toastr.success("project joined"); |
|
|
|
|
|
}, |
|
|
|
|
|
function(response) {// failed
|
|
|
|
|
|
}); |
|
|
|
|
|
}; |
|
|
var interval; |
|
|
var interval; |
|
|
$scope.currentStrike=0; |
|
|
$scope.currentStrike=0; |
|
|
$scope.btnWork = function(){ |
|
|
$scope.btnWork = function(){ |
|
@ -197,6 +234,15 @@ angular.module('workApp', ['chart.js']) |
|
|
$scope.currentStrike++; |
|
|
$scope.currentStrike++; |
|
|
$scope.currentproject.totaltime++; |
|
|
$scope.currentproject.totaltime++; |
|
|
}, 1000); |
|
|
}, 1000); |
|
|
|
|
|
$http({ |
|
|
|
|
|
url: urlapi + 'users', |
|
|
|
|
|
method: "POST", |
|
|
|
|
|
data: $scope.user |
|
|
|
|
|
}).then(function(response) { |
|
|
|
|
|
$scope.currentInclude="login.html"; |
|
|
|
|
|
}, |
|
|
|
|
|
function(response) {// failed
|
|
|
|
|
|
}); |
|
|
}; |
|
|
}; |
|
|
$scope.btnStop = function(){ |
|
|
$scope.btnStop = function(){ |
|
|
$interval.cancel(interval); |
|
|
$interval.cancel(interval); |
|
|