Commit 33b8a8f7 authored by Prayas Jain's avatar Prayas Jain

Added endpoint for open pool and edit functionality in onbehalf feature

parent 7559e41a
......@@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
@RestController
@RequestMapping
......@@ -131,6 +132,17 @@ public class ResourceController {
"List of Resources for a project", null, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
@RequestMapping(value = "/resources/openPool/active", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getResourcesForOpenPool(HttpServletRequest request)
throws MyTeamException {
List<ResourceVO> resourcesList = resourceService.getResourcesForOpenPool(MyTeamUtils.BENCH_PROJECT_ID, MyTeamUtils.ACTIVE).stream()
.sorted((o1, o2) -> o1.getEmployeeName().trim().compareTo(o2.getEmployeeName().trim()))
.collect(Collectors.toList());
ResponseDetails responseDetails = new ResponseDetails(new Date(), 602, "Resources have been retrieved successfully",
"List of Resources for a project", resourcesList, request.getRequestURI(), "Resource details", null);
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
}
@RequestMapping(value = "/resources/getMyProjectAllocations", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getMyProjectAllocations(
......
......@@ -71,6 +71,8 @@ public interface IResourceService {
Resource getCurrentAllocation(String employeeId);
List<ResourceVO> getResourcesForOpenPool(String projectId, String statusFlag);
// List<Resource> getAllResourcesForProject(String projectId, String status);
......
......@@ -166,6 +166,7 @@ public class ResourceService implements IResourceService {
nextAllocation.setBillingStartDate(MyTeamDateUtils.getDayMoreThanDate(resourceReq.getBillingEndDate()));
this.updateExistedResource(nextAllocation);
}
resource.setOnBehalfOf(resourceReq.getOnBehalfOf());
resource.setBillableStatus(resourceReq.getBillableStatus());
resource.setBillingStartDate(resourceReq.getBillingStartDate());
resource.setBillingEndDate(resourceReq.getBillingEndDate());
......@@ -680,6 +681,38 @@ public class ResourceService implements IResourceService {
}
return resourcesList;
}
@Override
public List<ResourceVO> getResourcesForOpenPool(String projectId, String statusFlag) {
List<ResourceVO> resourcesList = new ArrayList<>();
for (Resource resource : resourceRepo.findByProjectId(projectId)) {
Date billingEndDate = resource.getBillingEndDate();
Date todayDate = new Date();
if (billingEndDate != null) {
Employee employee = employeeService.getEmployeeById(resource.getEmployeeId());
if(employee.getEmpStatus().equalsIgnoreCase(MyTeamUtils.ACTIVE) && billingEndDate.compareTo(todayDate)>0) {
ResourceVO resourceVO = new ResourceVO();
resourceVO.setId(resource.getId());
resourceVO.setProjectId(resource.getProjectId());
resourceVO.setProjectName(projectService.getProjectByProjectId(resource.getProjectId()).getProjectName());
resourceVO.setResourceRole(resource.getResourceRole());
resourceVO.setBillingStartDate(resource.getBillingStartDate());
resourceVO.setBillingEndDate(resource.getBillingEndDate());
resourceVO.setBillableStatus(resource.getBillableStatus());
resourceVO.setEmployeeId(resource.getEmployeeId());
resourceVO.setStatus(resource.getStatus());
resourceVO.setOnBehalfOf(resource.getOnBehalfOf()!=null?employeeService.getEmployeeById(resource.getOnBehalfOf()).getEmployeeName():"");
resourceVO.setEmailId(employee.getEmailId());
resourceVO.setEmployeeName(employee.getEmployeeName());
resourceVO.setDesignation(employee.getDesignation());
resourcesList.add(resourceVO);
}
}
}
return resourcesList;
}
@Override
......
......@@ -76,14 +76,10 @@ myApp.controller("openPoolController", function($scope, $http, myFactory, $mdDia
}
$http({
method : "GET",
url : appConfig.appUri + 'resources/project/Nisum0000?status=Active'
url : appConfig.appUri + 'resources/openPool/active'
}).then(function mySuccess(response) {
$mdDialog.hide();
today.setHours(0, 0, 0, 0);
var openPoolRecords = response.data.records.filter(function (employee) {
return employee.billingEndDate >= today;
});
$scope.gridOptions.data = openPoolRecords;
$scope.gridOptions.data = response.data.records;
if(response.data.records.length > 10){
$scope.gridOptions.enablePaginationControls = true;
}
......
......@@ -657,9 +657,6 @@ cursor: pointer;
.manage-employee-efforts {
height: calc(100vh - 260px) !important;
}
.manage-open-pool {
height: calc(100vh - 230px) !important;
}
.md-datepicker-input-mask {
height : 0px;
}
......@@ -690,6 +687,7 @@ cursor: pointer;
.substatus-dropdown md-datepicker {
padding:0;
}
.substatus-dropdown >md-select {
margin:0;
}
......
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