Commit e8fb3db6 authored by Prayas Jain's avatar Prayas Jain

Refactored Manage Projects

parent c4eda0cf
...@@ -123,18 +123,18 @@ myApp.controller("dashboardController", function($scope, $http, myFactory,export ...@@ -123,18 +123,18 @@ myApp.controller("dashboardController", function($scope, $http, myFactory,export
$scope.getEmployeesDashBoardData = function(){ $scope.getEmployeesDashBoardData = function(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/getEmployeesDashBoard" url : appConfig.appUri + "getEmployeesDashBoard"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
//alert("response"+response); //alert("response"+response);
// alert("response"+response.data); // alert("response"+response.data);
if(response.data.length > 10){ if(response.data.records.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
} }
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
}); });
......
...@@ -130,13 +130,13 @@ myApp.controller("myProjectAllocationsController",function($scope, myFactory, $m ...@@ -130,13 +130,13 @@ myApp.controller("myProjectAllocationsController",function($scope, myFactory, $m
method : "GET", method : "GET",
url : appConfig.appUri + "resources/project/"+$scope.projectId url : appConfig.appUri + "resources/project/"+$scope.projectId
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
if(response.data.length > 10){ if(response.data.records.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
} }
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
......
...@@ -104,7 +104,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -104,7 +104,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
method: "GET", method: "GET",
url: appConfig.appUri + "projects/employeeId/"+empId url: appConfig.appUri + "projects/employeeId/"+empId
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
if(response.data.length > 10){ if(response.data.records.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
...@@ -555,15 +555,15 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -555,15 +555,15 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
method: "GET", method: "GET",
url: appConfig.appUri + "resources/project/"+ $scope.projectId + "?status=" + $scope.status url: appConfig.appUri + "resources/project/"+ $scope.projectId + "?status=" + $scope.status
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
if(response.data.length > 10){ if(response.data.records.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
} }
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
for(i=0;i<response.data.length;i++){ for(i=0;i<response.data.records.length;i++){
if(response.data[i].role == 'Lead'){ if(response.data.records[i].role == 'Lead'){
$scope.gridOptions.data[i].role = "Lead"; $scope.gridOptions.data[i].role = "Lead";
}else{ }else{
$scope.gridOptions.data[i].role = "Individual Contributor"; $scope.gridOptions.data[i].role = "Individual Contributor";
...@@ -750,9 +750,9 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -750,9 +750,9 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
$scope.isDisabled = true; $scope.isDisabled = true;
$http({ $http({
method: "GET", method: "GET",
url: appConfig.appUri + "resources/getUnAssignedEmployees" url: appConfig.appUri + "resources/unAssignedEmployees"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
...@@ -823,7 +823,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -823,7 +823,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
method: "GET", method: "GET",
url: appConfig.appUri + "resources/projects" url: appConfig.appUri + "resources/projects"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
...@@ -1143,6 +1143,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1143,6 +1143,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
$scope.alertMsg = "End date should not exceed project end date"; $scope.alertMsg = "End date should not exceed project end date";
} }
else { else {
$scope.id = $scope.id ? $scope.id : $scope.objectId;
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"id":$scope.id,"employeeId":employeeModel.employeeId, "employeeName":employeeModel.employeeName, "emailId": employeeModel.emailId, "designation":employeeModel.designation,"projectId":project,"projectName":projectName,"managerId":managerId,"managerName":managerName,"mobileNumber":employeeModel.mobileNumber,"active":true,"billableStatus":$scope.empBillableStatus,"startDate":$scope.startDate,"endDate":$scope.endDate,"account":account,"role":$scope.employeeRole,"newBillingStartDate":newBillingStartDate,"accountId":$scope.accountId,"domainId":$scope.domainId,"shift":$scope.employeeShift,"projectStartDate":$scope.startDate,"projectEndDate":$scope.endDate}; var record = {"id":$scope.id,"employeeId":employeeModel.employeeId, "employeeName":employeeModel.employeeName, "emailId": employeeModel.emailId, "designation":employeeModel.designation,"projectId":project,"projectName":projectName,"managerId":managerId,"managerName":managerName,"mobileNumber":employeeModel.mobileNumber,"active":true,"billableStatus":$scope.empBillableStatus,"startDate":$scope.startDate,"endDate":$scope.endDate,"account":account,"role":$scope.employeeRole,"newBillingStartDate":newBillingStartDate,"accountId":$scope.accountId,"domainId":$scope.domainId,"shift":$scope.employeeShift,"projectStartDate":$scope.startDate,"projectEndDate":$scope.endDate};
if(action == "Add"){ if(action == "Add"){
...@@ -1449,8 +1450,9 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1449,8 +1450,9 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
$http(req).then(function mySuccess(response) { $http(req).then(function mySuccess(response) {
$scope.result = "Success"; $scope.result = "Success";
var titleOfModel = "Attention"; var titleOfModel = "Attention";
// $scope.objectId = response.data.id; $scope.objectId = response.data.records.id;
if(response.data =="TeamMate added successfuly"){ console.log($scope.id,response.data.records.id ,"$scope.id ");
if(response.data.message =="TeamMate added successfuly"){
titleOfModel = ""; titleOfModel = "";
$timeout(function(){ $timeout(function(){
updateGrid(action,record); updateGrid(action,record);
...@@ -1460,7 +1462,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1460,7 +1462,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
$mdDialog.show($mdDialog.alert({ $mdDialog.show($mdDialog.alert({
skipHide: true, skipHide: true,
title:titleOfModel, title:titleOfModel,
textContent: response.data, textContent: response.data.message,
ok: 'ok' ok: 'ok'
})); }));
...@@ -1473,7 +1475,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1473,7 +1475,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
method: "GET", method: "GET",
url: appConfig.appUri + "resources/project/"+ $scope.projectId + "?status=" + $scope.status url: appConfig.appUri + "resources/project/"+ $scope.projectId + "?status=" + $scope.status
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
if(status == "InActive" || status == "Both"|| dataToPass.status == "InActive"){ if(status == "InActive" || status == "Both"|| dataToPass.status == "InActive"){
$scope.gridOptions.columnDefs[5].visible = false; $scope.gridOptions.columnDefs[5].visible = false;
} }
...@@ -1505,9 +1507,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1505,9 +1507,8 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
data : record data : record
} }
$http(req).then(function mySuccess(response) { $http(req).then(function mySuccess(response) {
console.log("Hi I am Here");
$scope.result = "Success"; $scope.result = "Success";
if(response.data == "TeamMate updated successfuly" || response.data.includes("Resource Successfully moved from") ){ if(response.data.message == "TeamMate updated successfuly"){
$timeout(function () { $timeout(function () {
getProjectDetails($scope.projectId, $scope.status); getProjectDetails($scope.projectId, $scope.status);
removeTab('Add'); removeTab('Add');
...@@ -1515,7 +1516,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS ...@@ -1515,7 +1516,7 @@ myApp.controller("projectController", function ($scope, myFactory, exportUiGridS
} }
$mdDialog.show($mdDialog.alert({ $mdDialog.show($mdDialog.alert({
skipHide: true, skipHide: true,
textContent: response.data, textContent: response.data.message ,
ok: 'ok' ok: 'ok'
})).then(function () { })).then(function () {
$scope.myForm.$setPristine(); $scope.myForm.$setPristine();
......
...@@ -67,7 +67,7 @@ myApp.controller("projectMyTeamController",function($scope, myFactory, $mdDialog ...@@ -67,7 +67,7 @@ myApp.controller("projectMyTeamController",function($scope, myFactory, $mdDialog
method : "GET", method : "GET",
url : appConfig.appUri + "resources/active?employeeId="+myFactory.getEmpId() url : appConfig.appUri + "resources/active?employeeId="+myFactory.getEmpId()
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
......
...@@ -121,9 +121,9 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -121,9 +121,9 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.getUserRoles = function(){ $scope.getUserRoles = function(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getTeamDetails?employeeId="+myFactory.getEmpId() url : appConfig.appUri + "resources/deliverylead/="+myFactory.getEmpId()
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
...@@ -132,7 +132,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -132,7 +132,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.getEmployeesToTeam = function(){ $scope.getEmployeesToTeam = function(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getEmployeesToTeam" url : appConfig.appUri + "employees/active/sortByName"
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.employees=response.data; $scope.employees=response.data;
}, function myError(response) { }, function myError(response) {
...@@ -258,7 +258,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -258,7 +258,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
var loginEmpId = myFactory.getEmpId(); var loginEmpId = myFactory.getEmpId();
var req = { var req = {
method : 'POST', method : 'POST',
url : appConfig.appUri+ "projectTeam/deleteTeammate?loginEmpId="+loginEmpId, url : appConfig.appUri+ "resources?loginEmpId="+loginEmpId,
headers : { headers : {
"Content-type" : "application/json" "Content-type" : "application/json"
}, },
...@@ -327,7 +327,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -327,7 +327,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.getProjects = function(){ $scope.getProjects = function(){
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getProjects?employeeId="+myFactory.getEmpId() url : appConfig.appUri + "projects/employeeId/"+myFactory.getEmpId()
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.projectList = response.data; $scope.projectList = response.data;
}, function myError(response) { }, function myError(response) {
...@@ -400,7 +400,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -400,7 +400,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getTeamDetails?employeeId="+dataToPass.employeeId url : appConfig.appUri + "resources/deliverylead/"+dataToPass.employeeId
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data;
}, function myError(response) { }, function myError(response) {
...@@ -446,19 +446,22 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -446,19 +446,22 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
}; };
function addOrUpdateBilling(record, action){ function addOrUpdateBilling(record, action){
var requestMethod = "";
var urlRequest = ""; var urlRequest = "";
var loginEmpId = myFactory.getEmpId(); var loginEmpId = myFactory.getEmpId();
if(action == "Add"){ if(action == "Add"){
urlRequest = appConfig.appUri+ "projectTeam/addEmployeeBilling?loginEmpId="+loginEmpId; urlRequest = appConfig.appUri+ "billing?loginEmpId="+loginEmpId;
requestMethod = 'POST';
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "projectTeam/updateEmployeeBilling?loginEmpId="+loginEmpId; urlRequest = appConfig.appUri+ "billing?loginEmpId="+loginEmpId;
requestMethod = 'PUT';
} }
else if(action == "Delete"){ else if(action == "Delete"){
urlRequest = appConfig.appUri+ "billing";
urlRequest = appConfig.appUri+ "projectTeam/deleteEmployeeBilling"; requestMethod = 'DELETE';
} }
var req = { var req = {
method : 'POST', method : requestMethod,
url : urlRequest, url : urlRequest,
headers : { headers : {
"Content-type" : "application/json" "Content-type" : "application/json"
...@@ -470,7 +473,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -470,7 +473,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
$scope.objectId = response.data.id; $scope.objectId = response.data.id;
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getEmployeeBillingDetails?employeeId="+record.employeeId+"&projectId="+record.projectId url : appConfig.appUri + "billing/project/" + record.projectId + "? employeeId=" +record.employeeId
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data;
...@@ -595,7 +598,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -595,7 +598,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
}; };
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getEmployeeBillingDetails?employeeId="+dataToPass.employeeId+"&projectId="+dataToPass.projectId url : appConfig.appUri + "billing/project/" + dataToPass.projectId + "? employeeId=" +dataToPass.employeeId
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data;
}, function myError(response) { }, function myError(response) {
...@@ -620,7 +623,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -620,7 +623,7 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
//MT-72 //MT-72
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "/projectTeam/getEmployeeProjectInfo?empId="+$scope.employeeModel.employeeId url : appConfig.appUri + "resources/employeeId/"+$scope.employeeModel.employeeId
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.projectInfoList = response.data; $scope.projectInfoList = response.data;
}, function myError(response) { }, function myError(response) {
...@@ -832,14 +835,17 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog, ...@@ -832,14 +835,17 @@ myApp.controller("projectTeamController",function($scope, myFactory, $mdDialog,
function addOrUpdateRole(record, action){ function addOrUpdateRole(record, action){
var urlRequest = ""; var urlRequest = "";
var requestMethod = "";
var loginEmpId = myFactory.getEmpId(); var loginEmpId = myFactory.getEmpId();
if(action == "Add"){ if(action == "Add"){
urlRequest = appConfig.appUri+ "projectTeam/addEmployeeToTeam?loginEmpId="+loginEmpId; urlRequest = appConfig.appUri+ "resources?loginEmpId="+loginEmpId;
requestMethod = 'POST';
}else if(action == "Update"){ }else if(action == "Update"){
urlRequest = appConfig.appUri+ "projectTeam/updateTeammate?loginEmpId="+loginEmpId; urlRequest = appConfig.appUri+ "resources?loginEmpId="+loginEmpId;
requestMethod = 'PUT';
} }
var req = { var req = {
method : 'POST', method : requestMethod,
url : urlRequest, url : urlRequest,
headers : { headers : {
"Content-type" : "application/json" "Content-type" : "application/json"
......
...@@ -84,9 +84,9 @@ myApp.controller("shiftDetailsController",function($scope, myFactory,exportUiGri ...@@ -84,9 +84,9 @@ myApp.controller("shiftDetailsController",function($scope, myFactory,exportUiGri
method : "GET", method : "GET",
url : appConfig.appUri + "resources/shifts/"+shiftV url : appConfig.appUri + "resources/shifts/"+shiftV
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
$scope.shiftCount=response.data.length; $scope.shiftCount=response.data.records.length;
if(response.data.length > 10){ if(response.data.records.length > 10){
$scope.gridOptions.enablePaginationControls = true; $scope.gridOptions.enablePaginationControls = true;
} }
else{ else{
......
...@@ -296,7 +296,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid ...@@ -296,7 +296,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
//$scope.teamdetails=response.data; //$scope.teamdetails=response.data;
//$scope.gridOptions.data.push(response.data); //$scope.gridOptions.data.push(response.data);
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
...@@ -406,7 +406,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid ...@@ -406,7 +406,7 @@ myApp.controller("viewProjectController",function($scope, myFactory,exportUiGrid
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
//$scope.teamdetails=response.data; //$scope.teamdetails=response.data;
//$scope.gridOptions.data.push(response.data); //$scope.gridOptions.data.push(response.data);
$scope.gridOptions.data = response.data; $scope.gridOptions.data = response.data.records;
}, function myError(response) { }, function myError(response) {
showAlert("Something went wrong while fetching data!!!"); showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = []; $scope.gridOptions.data = [];
......
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