Commit 0fe58fd7 authored by Phạm Duy Phi's avatar Phạm Duy Phi

no message

parent 483f0e7d
/*
*/
angular.module("myApp").controller("timeSheetController", function($scope, $http, $state) {
angular.module("MyTimeSheet").controller("timesheetController", function($scope, $http,$window) {
console.log("Time Sheet controller"); console.log("Time Sheet controller");
$scope.ts = { $scope.ts = {
"id": "",
"title": "",
"content": "",
"note": "",
"eproject": "",
"updatedAt": ""
};
$scope.tsdto = {
"id": "",
"title": "", "title": "",
"content": "", "content": "",
"note": "", "note": ""
"eprojectId": "",
"employeeId": ""
}; };
//get all time sheet
$http({ $http({
header : 'Access-Control-Allow-Origin: http://localhost:63342/MockProject_01/public/pages/timesheet/timesheet.html?_ijt=ee540pqfq7tplkmo9mjj447ne',
method : 'GET', method : 'GET',
url : "http://localhost:8080/eproject/timesheet/show" url : "http://localhost:8080/eproject/timesheet",
}).then(function successCallback(response) { }).then(function successCallback(response) {
console.log(response);
$scope.myTimeSheets=response.data;
}, function errorCallback(response) {
console.log(response) console.log(response)
}); $scope.timesheet=response.data;
//delete time sheet
$scope.delete = function (ts) {
$http({
method : 'DELETE',
url : "http://localhost:8080/eproject/timesheet/delete/" + ts.id
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response);
$state.reload();
});
};
$scope.save = save;
function save(){
console.log($scope.tsdto);
$http({
method : 'POST',
url : "http://localhost:8080/eproject/timesheet/add",
data: $scope.tsdto
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) {
console.log(response);
$state.reload();
});
}
$scope.getTs = getTs;
function getTs(ts) {
$scope.tsdto.id = ts.id;
$scope.tsdto.title = ts.title;
$scope.tsdto.content = ts.content;
$scope.tsdto.note = ts.note;
$scope.tsdto.employeeId = ts.eproject.employee.id;
}
$scope.update = update;
function update(){
$http({
headers: "content-type: application/json",
method : 'POST',
url : "http://localhost:8080/eproject/timesheet/update",
data: $scope.tsdto
}).then(function successCallback(response) {
console.log(response);
$state.reload();
}, function errorCallback(response) { }, function errorCallback(response) {
console.log(response); console.log(response)
$state.reload();
});
}
}).directive('pgnTable', ['$compile', function ($compile) {
return {
restrict: 'EA',
templateUrl: 'pages/timesheet/timeSheet.html',
replace: true,
scope: {
pages: "=pgnTable"
},
controller: function ($scope) {
$scope.currentPage=1;
$scope.numLimit=5;
$scope.start = 0;
$scope.$watch("pages",function(newVal){
if(newVal){
$scope.pages=Math.ceil($scope.pages.length/$scope.numLimit);
}
}); });
$scope.hideNext=function(){ });
if(($scope.start + $scope.numLimit) < $scope.pages.length){ \ No newline at end of file
return false;
}
else
return true;
};
$scope.hidePrev=function(){
if($scope.start===0){
return true;
}
else
return false;
};
$scope.nextPage=function(){
console.log("next pages");
$scope.currentPage++;
$scope.start=$scope.start+ $scope.numLimit;
console.log( $scope.start)
};
$scope.PrevPage=function(){
if($scope.currentPage>1){
$scope.currentPage--;
}
console.log("next pages");
$scope.start=$scope.start - $scope.numLimit;
console.log( $scope.start)
};
},
compile: function(elem) {
return function(ielem, $scope) {
$compile(ielem)($scope);
};
}
};
}]);
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment