Commit c09dddb7 authored by Ashok Kumar K's avatar Ashok Kumar K

implementation of Manage Designation page

parents 2c1ef7be 123699ea
package com.nisum.myteam.controller; package com.nisum.myteam.controller;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -27,10 +28,10 @@ public class FunctionalGroupController { ...@@ -27,10 +28,10 @@ public class FunctionalGroupController {
@RequestMapping(value = "/getAllFunctionalGroups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @RequestMapping(value = "/getAllFunctionalGroups", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getAllFunctionalGroups(HttpServletRequest request) { public ResponseEntity<?> getAllFunctionalGroups(HttpServletRequest request) {
List<String> functionalGroupsList = new ArrayList<>();
List<String> functionalGroupsList = functionalGroupService.getAllFunctionalGroups().stream(). functionalGroupsList.add("ALL");
filter(f -> !Arrays.asList("IT","Recruiter","Admin","HR","Accounts").contains(f.getName())).map(f -> f.getName()).collect(Collectors.toList()); functionalGroupsList.addAll(functionalGroupService.getAllFunctionalGroups().stream().
filter(f -> !Arrays.asList("IT","Recruiter","Admin","HR","Accounts").contains(f.getName())).map(f -> f.getName()).collect(Collectors.toList()));
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905, "Retrieved FunctionalGroups successfully", ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905, "Retrieved FunctionalGroups successfully",
"FunctionalGroups list", functionalGroupsList, request.getRequestURI(), "FunctionalGroups Details: Status", null); "FunctionalGroups list", functionalGroupsList, request.getRequestURI(), "FunctionalGroups Details: Status", null);
return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(getRespDetails, HttpStatus.OK);
......
...@@ -426,5 +426,25 @@ public class ReportsController { ...@@ -426,5 +426,25 @@ public class ReportsController {
} }
return new ResponseEntity<>(reports, HttpStatus.OK); return new ResponseEntity<>(reports, HttpStatus.OK);
} }
@RequestMapping(value = "/getPieChartReport",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ReportVo allBillabilityReport(@RequestParam("byType") String byType,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
System.out.println("allBillabilityReport start");
return reportService.getPieChartReport(byType,onDate);
}
@RequestMapping(value = "/fetchEmployeesByBillabilityType",
method = RequestMethod.GET,
produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<Reports>> getEmployeesByBillabilityType(
@RequestParam("billableStatus") String billableStatus,
@RequestParam("onDate") @DateTimeFormat(iso = DateTimeFormat.ISO.DATE) Date onDate) throws MyTeamException {
List<Reports> empList = null;
empList = reportService.getEmployeeDetailsByBillabilityType(billableStatus, onDate);
return new ResponseEntity<>(empList, HttpStatus.OK);
}
} }
package com.nisum.myteam.service; package com.nisum.myteam.service;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.dao.Account; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -55,6 +56,8 @@ public interface IEmployeeService { ...@@ -55,6 +56,8 @@ public interface IEmployeeService {
public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift); public List<Employee> getEmployeesByEmpStatusAndShift(String empStatus, String shift);
public List<Employee> getAllEmployeeListByFunGrps(List<String> functionalGroupList);
public List<Employee> getEmployeesByDesignation(String designation); public List<Employee> getEmployeesByDesignation(String designation);
public int getEmployeesCountByDesignation(String designation); public int getEmployeesCountByDesignation(String designation);
......
...@@ -9,4 +9,6 @@ public interface IFunctionalGroupService { ...@@ -9,4 +9,6 @@ public interface IFunctionalGroupService {
public List<FunctionalGroup> getAllFunctionalGroups(); public List<FunctionalGroup> getAllFunctionalGroups();
public FunctionalGroup getFunctionalGroup(String functionalGroupName); public FunctionalGroup getFunctionalGroup(String functionalGroupName);
public List<FunctionalGroup> getAllBillableFunctionalGroups();
} }
...@@ -19,5 +19,9 @@ public interface IReportService { ...@@ -19,5 +19,9 @@ public interface IReportService {
public Project getProjectById(String employeeId); public Project getProjectById(String employeeId);
public List<Reports> getEmployeeDetailsByFGAccountAndBillability(String fGroup, String billableStatus, String account,Date onDate) throws MyTeamException; public List<Reports> getEmployeeDetailsByFGAccountAndBillability(String fGroup, String billableStatus, String account,Date onDate) throws MyTeamException;
public ReportVo getPieChartReport(String byType, Date onDate) throws MyTeamException;
public List<Reports> getEmployeeDetailsByBillabilityType(String billabilityType, Date onDate) throws MyTeamException;
} }
\ No newline at end of file
package com.nisum.myteam.service.impl; package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.dao.Account; import com.nisum.myteam.model.dao.Account;
import com.nisum.myteam.model.dao.Domain; import com.nisum.myteam.model.dao.Domain;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
...@@ -483,4 +484,10 @@ public class EmployeeService implements IEmployeeService { ...@@ -483,4 +484,10 @@ public class EmployeeService implements IEmployeeService {
return employeeRepo.findByEmployeeIdAndEmpStatus(employeeId, active); return employeeRepo.findByEmployeeIdAndEmpStatus(employeeId, active);
} }
public List<Employee> getAllEmployeeListByFunGrps(List<String> functionalGroupList){
Query query = new Query(Criteria.where("empStatus").is("Active").andOperator(Criteria.where("functionalGroup").in(functionalGroupList)));
List<Employee> employeePersistedList = mongoTemplate.find(query, Employee.class);
return employeePersistedList;
}
} }
package com.nisum.myteam.service.impl; package com.nisum.myteam.service.impl;
import com.nisum.myteam.model.FunctionalGroup; import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.repository.FunctionalGroupRepo; import com.nisum.myteam.repository.FunctionalGroupRepo;
import com.nisum.myteam.service.IFunctionalGroupService; import com.nisum.myteam.service.IFunctionalGroupService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.Arrays;
import java.util.List; import java.util.List;
@Service @Service
public class FunctionalGroupService implements IFunctionalGroupService { public class FunctionalGroupService implements IFunctionalGroupService {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired @Autowired
private FunctionalGroupRepo functionalGroupRepo; private FunctionalGroupRepo functionalGroupRepo;
...@@ -22,4 +30,11 @@ public class FunctionalGroupService implements IFunctionalGroupService { ...@@ -22,4 +30,11 @@ public class FunctionalGroupService implements IFunctionalGroupService {
public FunctionalGroup getFunctionalGroup(String functionalGroupName) { public FunctionalGroup getFunctionalGroup(String functionalGroupName) {
return functionalGroupRepo.findByName(functionalGroupName); return functionalGroupRepo.findByName(functionalGroupName);
} }
@Override
public List<FunctionalGroup> getAllBillableFunctionalGroups() {
Query query = new Query(Criteria.where("name").nin(Arrays.asList("IT","Recruiter","Admin","HR","Accounts","Delivery Org","Global Mobility")));
List<FunctionalGroup> functionalGroupList = mongoTemplate.find(query, FunctionalGroup.class);
return functionalGroupList;
}
} }
package com.nisum.myteam.service.impl; package com.nisum.myteam.service.impl;
import com.nisum.myteam.exception.handler.MyTeamException; import com.nisum.myteam.exception.handler.MyTeamException;
import com.nisum.myteam.model.FunctionalGroup;
import com.nisum.myteam.model.Reports; import com.nisum.myteam.model.Reports;
import com.nisum.myteam.model.dao.Employee; import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.model.dao.Project; import com.nisum.myteam.model.dao.Project;
...@@ -149,7 +150,19 @@ public class ReportService implements IReportService { ...@@ -149,7 +150,19 @@ public class ReportService implements IReportService {
return resultantEmployeeWithBillability(empList,billableStatus,onDate); return resultantEmployeeWithBillability(empList,billableStatus,onDate);
} }
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees, @Override
public ReportVo getPieChartReport(String byType, Date onDate) throws MyTeamException {
List<Employee> employeeList = employeeService.getAllEmployeeListByFunGrps(functionalGroupService.getAllBillableFunctionalGroups().stream().collect(Collectors.mapping(FunctionalGroup::getName, Collectors.toList())));
return preparePieChartData(byType, onDate, employeeList);
}
@Override
public List<Reports> getEmployeeDetailsByBillabilityType(String billabilityType, Date onDate) throws MyTeamException {
List<Employee> employeeList = employeeService.getAllEmployeeListByFunGrps(functionalGroupService.getAllBillableFunctionalGroups().stream().collect(Collectors.mapping(FunctionalGroup::getName, Collectors.toList())));
return resultantEmployeeWithBillability(employeeList, billabilityType, onDate);
}
private List<Reports> resultantEmployeeWithBillability(List<Employee> employees,
String billableStatus,Date ondate) throws MyTeamException { String billableStatus,Date ondate) throws MyTeamException {
List<Reports> billableEmployees=new ArrayList<Reports>(); List<Reports> billableEmployees=new ArrayList<Reports>();
...@@ -199,4 +212,48 @@ public class ReportService implements IReportService { ...@@ -199,4 +212,48 @@ public class ReportService implements IReportService {
return projectService.getProjectByProjectId(projectId); return projectService.getProjectByProjectId(projectId);
} }
public ReportVo preparePieChartData(String byType, Date onDate, List<Employee> employeeList) throws MyTeamException {
ReportVo reportVo = new ReportVo();
Integer billableCount = 0;
Integer nonBillableCount = 0;
Integer traineeCount = 0;
Integer allEmployeesSize = employeeList.size();
float traineePer;
float billper;
Map<String, Object> billableObj = new HashMap();
Map<String, Object> nonBillableObj = new HashMap();
Map<String, Object> traineeObj = new HashMap();
float nonBillPer;
Map<String,List<Resource>> resourceServiceAllocationOfDateMap = resourceService.getAllocationOfDateMap(employeeList.stream().collect(Collectors.mapping(Employee::getEmployeeId, Collectors.toList())), onDate);
Map<String, Integer> utilityResourceDataMap = new HashMap<>();
utilityResourceDataMap.put("Billable", billableCount);
utilityResourceDataMap.put("Non-Billable", nonBillableCount);
utilityResourceDataMap.put("Trainee", traineeCount);
resourceServiceAllocationOfDateMap.forEach((s, resources) -> {
Resource resource = resources.stream().findFirst().get();
if (resource != null && resource.getBillableStatus().equals("Billable")) {
utilityResourceDataMap.put("Billable", utilityResourceDataMap.get("Billable")+1);
} else if (resource != null && resource.getBillableStatus().equals("Trainee")) {
utilityResourceDataMap.put("Trainee", utilityResourceDataMap.get("Trainee")+1);
} else if (resource != null) {
utilityResourceDataMap.put("Non-Billable", utilityResourceDataMap.get("Non-Billable")+1);
}
});
billper = ((utilityResourceDataMap.get("Billable") / (float) (allEmployeesSize - utilityResourceDataMap.get("Trainee"))) * 100);
nonBillPer = utilityResourceDataMap.get("Non-Billable") / (float) (allEmployeesSize - utilityResourceDataMap.get("Trainee")) * 100;
traineePer = utilityResourceDataMap.get("Trainee") / (float) (allEmployeesSize - (utilityResourceDataMap.get("Billable") + utilityResourceDataMap.get("Non-Billable"))) * 100;
billableObj.put("percent", billper);
billableObj.put("y", utilityResourceDataMap.get("Billable"));
billableObj.put("name", "Billable");
nonBillableObj.put("percent", nonBillPer);
nonBillableObj.put("y", utilityResourceDataMap.get("Non-Billable"));
nonBillableObj.put("name", "Non-Billable");
traineeObj.put("y", utilityResourceDataMap.get("Trainee"));
traineeObj.put("name", "Trainee");
traineeObj.put("percent", traineePer);
reportVo.getSeriesDataList().add(billableObj);
reportVo.getSeriesDataList().add(nonBillableObj);
reportVo.getSeriesDataList().add(traineeObj);
return reportVo;
}
} }
...@@ -1161,4 +1161,12 @@ public class ResourceService implements IResourceService { ...@@ -1161,4 +1161,12 @@ public class ResourceService implements IResourceService {
} }
return null; return null;
} }
public Map<String,List<Resource>> getAllocationOfDateMap(List<String> employeeIdList,Date onDate){
Query query = new Query(Criteria.where("employeeId").in(employeeIdList).andOperator(Criteria.where("billingStartDate").lte(onDate),Criteria.where("billingEndDate").gte(onDate)));
List<Resource> resourceList = mongoTemplate.find(query, Resource.class);
Map<String,List<Resource>> resourceMap = resourceList.stream().collect(Collectors.groupingBy(Resource::getEmployeeId,Collectors.toList()));
System.out.println(resourceMap);
return resourceMap;
}
} }
\ No newline at end of file
...@@ -5,11 +5,11 @@ myApp.directive('hcPieChart', function () { ...@@ -5,11 +5,11 @@ myApp.directive('hcPieChart', function () {
template: '<div></div>', template: '<div></div>',
link: function (scope, element) { link: function (scope, element) {
let onLoadSearchedDate = getFormattedDate(scope.searchedReportDate); let onLoadSearchedDate = getFormattedDate(scope.searchedReportDate);
getEmployeeDetails(scope,element[0].baseURI+'reports/getBarChartReport?byType=AllFunctionalOrgs&onDate='+onLoadSearchedDate,'column',element,"Billability For All Functional Orgs"); getEmployeeDetails(scope,element[0].baseURI+'reports/getPieChartReport?byType=ALL&onDate='+onLoadSearchedDate,'pie',element,"Billability For ALL");
//getEmployeeDetails(scope,element[0].baseURI+'reports/billabilityByFunctionalGroup','column',element,"Billability By Functional Group"); //getEmployeeDetails(scope,element[0].baseURI+'reports/billabilityByFunctionalGroup','column',element,"Billability By Functional Group");
//getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByAccount','column',element,"Billability By Account"); //getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByAccount','column',element,"Billability By Account");
scope.getBillabilityReportData = function() { scope.getBillabilityReportData = function() {
let searchedDate = getFormattedDate(scope.searchedReportDate); let searchedDate = getFormattedDate(scope.searchedReportDate);
scope.gridOptions.data = []; scope.gridOptions.data = [];
scope.gridOptions.enablePaginationControls = false; scope.gridOptions.enablePaginationControls = false;
let reportType = scope.reportType; let reportType = scope.reportType;
...@@ -19,36 +19,42 @@ myApp.directive('hcPieChart', function () { ...@@ -19,36 +19,42 @@ myApp.directive('hcPieChart', function () {
getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByMonth','line',element,"Billability Monthly Trends"); getEmployeeDetails(scope,element[0].baseURI+'reports/getBillabilityDetailsByMonth','line',element,"Billability Monthly Trends");
} }
else { else {
if(reportType=='I&A'){ chartType = 'column';
serviceName = 'getBarChartReport';
if(reportType=='ALL'){
reportTypeApiFormat = 'ALL';
chartType = 'pie';
serviceName = 'getPieChartReport';
}else if(reportType=='I&A'){
reportTypeApiFormat = 'I%26A'; reportTypeApiFormat = 'I%26A';
}else if(reportType == "All Functional Orgs"){ }else if(reportType == "All Functional Orgs"){
reportTypeApiFormat = reportType.replace(/\s/g, ""); reportTypeApiFormat = reportType.replace(/\s/g, "");
}else{ }else{
reportTypeApiFormat = reportType; reportTypeApiFormat = reportType;
} }
getEmployeeDetails(scope,element[0].baseURI+'reports/getBarChartReport?byType='+reportTypeApiFormat+'&onDate='+searchedDate,'column',element,"Billability For "+reportType); getEmployeeDetails(scope,element[0].baseURI+'reports/'+serviceName+'?byType='+reportTypeApiFormat+'&onDate='+searchedDate,chartType,element,"Billability For "+reportType);
} }
} }
else { else {
scope.errorMessage =true; scope.errorMessage =true;
scope.alertMsg = 'Please Select Valid Report Type or Date'; scope.alertMsg = 'Please Select Valid Report Type or Date';
} }
} }
} }
} }
}).controller('chartsController', function ($scope, $http, myFactory,exportUiGridService, $mdDialog, appConfig) { }).controller('chartsController', function ($scope, $http, myFactory,exportUiGridService, $mdDialog, appConfig) {
$scope.name = []; $scope.name = [];
$scope.records = []; $scope.records = [];
$scope.empSearchId = ""; $scope.empSearchId = "";
$scope.reportType = "All Functional Orgs"; $scope.reportType = "ALL";
$scope.reportTypeList = ["All Functional Orgs", "Account", "Monthly Trends"]; $scope.reportTypeList = ["All Functional Orgs", "Account", "Monthly Trends"];
var today = new Date(); var today = new Date();
$scope.searchedReportDate = today; $scope.searchedReportDate = today;
$scope.maxReportDate = today; $scope.maxReportDate = today;
$scope.errorMessage = false; $scope.errorMessage = false;
$scope.getAllOptions = function() { $scope.getAllOptions = function() {
$http({ $http({
method: "GET", method: "GET",
...@@ -69,7 +75,7 @@ myApp.directive('hcPieChart', function () { ...@@ -69,7 +75,7 @@ myApp.directive('hcPieChart', function () {
pageNumber: 1, pageNumber: 1,
enableFiltering:true, enableFiltering:true,
pageSize:10, pageSize:10,
columnDefs : [ columnDefs : [
{field : 'employeeId',displayName: 'Employee ID', enableColumnMenu: true, enableSorting: true, enableFiltering:true, width:'*'}, {field : 'employeeId',displayName: 'Employee ID', enableColumnMenu: true, enableSorting: true, enableFiltering:true, width:'*'},
{field : 'employeeName',displayName: 'Employee Name', enableColumnMenu: false, enableSorting: false, enableFiltering:true,width:'*'}, {field : 'employeeName',displayName: 'Employee Name', enableColumnMenu: false, enableSorting: false, enableFiltering:true,width:'*'},
{field : 'emailId',displayName: 'Email', enableColumnMenu: false, enableSorting: false, enableFiltering:true, width:'*'}, {field : 'emailId',displayName: 'Email', enableColumnMenu: false, enableSorting: false, enableFiltering:true, width:'*'},
...@@ -123,11 +129,11 @@ myApp.directive('hcPieChart', function () { ...@@ -123,11 +129,11 @@ myApp.directive('hcPieChart', function () {
}; };
$scope.gridOptions.data = $scope.records; $scope.gridOptions.data = $scope.records;
$scope.gridOptions.enablePaginationControls = false; $scope.gridOptions.enablePaginationControls = false;
$scope.getMyTeamDetails = function(seriesName, category, optionName,title){ $scope.getMyTeamDetails = function(seriesName, category, optionName,title){
let searchedDate = getFormattedDate($scope.searchedReportDate); let searchedDate = getFormattedDate($scope.searchedReportDate);
if(title.trim() == 'Billability For All Functional Orgs On '+searchedDate || if(title.trim() == 'Billability For All Functional Orgs On '+searchedDate ||
title.trim() == 'Billability For All Functional Orgs On Today' ){ title.trim() == 'Billability For All Functional Orgs On Today' ){
if(category=='I&A'){ if(category=='I&A'){
category = 'I%26A'; category = 'I%26A';
...@@ -146,8 +152,25 @@ myApp.directive('hcPieChart', function () { ...@@ -146,8 +152,25 @@ myApp.directive('hcPieChart', function () {
}, 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 = [];
}); });
}else if(title.trim() == 'Billability For Account On '+ searchedDate || }else if(title.trim() == 'Billability For ALL'){
$http({
method : "GET",
url : appConfig.appUri + "reports/fetchEmployeesByBillabilityType?billableStatus="+seriesName+"&onDate="+searchedDate
}).then(function mySuccess(response) {
$scope.gridOptions.data = response.data;
if(response.data.length > 10){
$scope.gridOptions.enablePaginationControls = true;
}
else{
$scope.gridOptions.enablePaginationControls = false;
}
}, function myError(response) {
showAlert("Something went wrong while fetching data!!!");
$scope.gridOptions.data = [];
});
}else if(title.trim() == 'Billability For Account On '+ searchedDate ||
title.trim() == 'Billability For Account On Today'){ title.trim() == 'Billability For Account On Today'){
$http({ $http({
method : "GET", method : "GET",
...@@ -163,7 +186,7 @@ myApp.directive('hcPieChart', function () { ...@@ -163,7 +186,7 @@ myApp.directive('hcPieChart', function () {
}, 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 = [];
}); });
}else if(title.trim() == 'Billability Monthly Trends'){ }else if(title.trim() == 'Billability Monthly Trends'){
$http({ $http({
method : "GET", method : "GET",
...@@ -179,10 +202,10 @@ myApp.directive('hcPieChart', function () { ...@@ -179,10 +202,10 @@ myApp.directive('hcPieChart', function () {
}, 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 = [];
}); });
}else { }else {
var fg = $scope.reportType == 'I&A' ? 'I%26A' : $scope.reportType; var fg = $scope.reportType == 'I&A' ? 'I%26A' : $scope.reportType;
$http({ $http({
method : "GET", method : "GET",
url : appConfig.appUri + "reports/fetchEmployeeDetailsByFGAccountAndBillability?fGroup="+fg+"&billableStatus="+seriesName+"&acccount="+category+"&onDate="+searchedDate url : appConfig.appUri + "reports/fetchEmployeeDetailsByFGAccountAndBillability?fGroup="+fg+"&billableStatus="+seriesName+"&acccount="+category+"&onDate="+searchedDate
}).then(function mySuccess(response) { }).then(function mySuccess(response) {
...@@ -196,18 +219,59 @@ myApp.directive('hcPieChart', function () { ...@@ -196,18 +219,59 @@ myApp.directive('hcPieChart', function () {
}, 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 = [];
}); });
} }
}; };
function showAlert(message) { function showAlert(message) {
$mdDialog.show($mdDialog.alert().parent( $mdDialog.show($mdDialog.alert().parent(
angular.element(document.querySelector('#popupContainer'))) angular.element(document.querySelector('#popupContainer')))
.clickOutsideToClose(true).textContent(message).ariaLabel( .clickOutsideToClose(true).textContent(message).ariaLabel(
'Alert Dialog').ok('Ok')); 'Alert Dialog').ok('Ok'));
} }
$scope.drawPieChart = function(element,chartName,result,title,categoriesList){
Highcharts.chart(element[0], {
chart: {
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
type: 'pie',
height: '300px'
},
title: {
text: title
},
credits: {
enabled: false
},
tooltip: false,
plotOptions: {
pie: {
allowPointSelect: false,
cursor: 'pointer',
dataLabels: {
enabled: true,
format: '<b>{point.name}</b> {point.y} : {point.percentage:.1f} %'
},
showInLegend: false
},
series:{
events:{
click: function(event) {
$scope.getMyTeamDetails(event.point.options.name,'ALL',event.point.options.name,title);
}
}
}
},
series: [{
name: 'Percentage',
colorByPoint: true,
data: result
}]
});
}
$scope.drawChart = function(element,chartName,result,title,categoriesList){ $scope.drawChart = function(element,chartName,result,title,categoriesList){
Highcharts.chart(element[0], { Highcharts.chart(element[0], {
chart: { chart: {
...@@ -216,7 +280,7 @@ myApp.directive('hcPieChart', function () { ...@@ -216,7 +280,7 @@ myApp.directive('hcPieChart', function () {
}, },
title: { title: {
text: title text: title
}, },
credits: { credits: {
enabled: false enabled: false
}, },
...@@ -231,7 +295,7 @@ myApp.directive('hcPieChart', function () { ...@@ -231,7 +295,7 @@ myApp.directive('hcPieChart', function () {
} }
} }
}, },
}, },
legend: { legend: {
align: 'right', align: 'right',
x: -30, x: -30,
...@@ -272,7 +336,7 @@ myApp.directive('hcPieChart', function () { ...@@ -272,7 +336,7 @@ myApp.directive('hcPieChart', function () {
}, },
series:{ series:{
events:{ events:{
click: function(event) { click: function(event) {
$scope.getMyTeamDetails(event.point.series.name,event.point.category,event.point.options.name,title); $scope.getMyTeamDetails(event.point.series.name,event.point.category,event.point.options.name,title);
} }
...@@ -288,24 +352,27 @@ function getEmployeeDetails(scope,uri,chart,element,title){ ...@@ -288,24 +352,27 @@ function getEmployeeDetails(scope,uri,chart,element,title){
var result = []; var result = [];
var categoriesList = []; var categoriesList = [];
let displayTitle = ''; let displayTitle = '';
if(title === 'Billability Monthly Trends') { if(title === 'Billability Monthly Trends') {
displayTitle = title; displayTitle = title;
} }else if(title === 'Billability For ALL') {
else { displayTitle = 'Billability For ALL' ;
displayTitle = getFormattedDate(scope.searchedReportDate) == getFormattedDate(new Date()) ? title+ " On Today" : title+ " On " +getFormattedDate(scope.searchedReportDate); }
} else {
displayTitle = getFormattedDate(scope.searchedReportDate) == getFormattedDate(new Date()) ? title+ " On Today" : title+ " On " +getFormattedDate(scope.searchedReportDate);
}
Highcharts.ajax({ Highcharts.ajax({
url: uri, url: uri,
success: function(data) { success: function(data) {
if(chart=='line' || chart == 'column'){ if(chart=='line' || chart == 'column'){
result = data.seriesDataList; result = data.seriesDataList;
categoriesList = data.categoriesList; categoriesList = data.categoriesList;
scope.drawChart(element,chart,result,displayTitle,categoriesList);
}else if(chart == 'pie'){ }else if(chart == 'pie'){
result = data; result = data.seriesDataList;
categoriesList = data; //categoriesList = data;
scope.drawPieChart(element,chart,result,displayTitle,categoriesList);
} }
scope.drawChart(element,chart,result,displayTitle,categoriesList);
} }
}); });
} }
...@@ -325,4 +392,4 @@ function treatAsUTC(date) { ...@@ -325,4 +392,4 @@ function treatAsUTC(date) {
function daysBetween(fromDate, toDate) { function daysBetween(fromDate, toDate) {
var millisecondsPerDay = 24 * 60 * 60 * 1000; var millisecondsPerDay = 24 * 60 * 60 * 1000;
return Math.round((treatAsUTC(toDate) - treatAsUTC(fromDate)) / millisecondsPerDay); return Math.round((treatAsUTC(toDate) - treatAsUTC(fromDate)) / millisecondsPerDay);
} }
\ No newline at end of file
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
<script src="js/pdf/angular-pdf.min.js"></script> <script src="js/pdf/angular-pdf.min.js"></script>
<script src="js/pdf/print.min.js"></script> <script src="js/pdf/print.min.js"></script>
<link rel="stylesheet" href="css/bootstrap.min.css"></link> <link rel="stylesheet" href="css/bootstrap.min.css"></link>
<!-- <link rel="stylesheet" href="css/default-styles.css"></link> -->
<link rel="stylesheet" href="css/custom-theme.css"></link> <link rel="stylesheet" href="css/custom-theme.css"></link>
<script src="js/bootstrap.min.js"></script> <script src="js/bootstrap.min.js"></script>
<script src="js/angular-idle.js"></script> <script src="js/angular-idle.js"></script>
...@@ -48,9 +47,7 @@ ...@@ -48,9 +47,7 @@
<link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css"> <link rel="stylesheet" href="http://ui-grid.info/release/ui-grid.css" type="text/css">
<!-- <link rel="stylesheet" href="css/leftmenu.css"></link> -->
<link rel="stylesheet" href="css/pdf-viewer.css"></link> <link rel="stylesheet" href="css/pdf-viewer.css"></link>
<!-- <link rel="stylesheet" href="css/user-profile.css"></link> -->
<script src="js/app.js"></script> <script src="js/app.js"></script>
<script src="js/date-text-filter.js"></script> <script src="js/date-text-filter.js"></script>
<script src="js/ui-grid-edit-datepicker.js"></script> <script src="js/ui-grid-edit-datepicker.js"></script>
......
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