Commit d84b248e authored by Prasad Innamuri's avatar Prasad Innamuri

download and upload function is implemented

parent aee3615f
package com.nisum.myteam.controller; package com.nisum.myteam.controller;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
...@@ -8,6 +11,7 @@ import java.util.List; ...@@ -8,6 +11,7 @@ import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.nisum.myteam.model.dao.EmployeeSubStatus; import com.nisum.myteam.model.dao.EmployeeSubStatus;
import com.nisum.myteam.model.dao.EmployeeVisa; import com.nisum.myteam.model.dao.EmployeeVisa;
...@@ -34,6 +38,7 @@ import com.nisum.myteam.model.dao.Employee; ...@@ -34,6 +38,7 @@ import com.nisum.myteam.model.dao.Employee;
import com.nisum.myteam.service.IEmployeeRoleService; import com.nisum.myteam.service.IEmployeeRoleService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
@RestController @RestController
@Slf4j @Slf4j
...@@ -309,6 +314,26 @@ public class EmployeeController { ...@@ -309,6 +314,26 @@ public class EmployeeController {
return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK); return new ResponseEntity<ResponseDetails>(responseDetails, HttpStatus.OK);
} }
@RequestMapping(value = "/employees/uploadProfile/{empid}", method = RequestMethod.POST)
public ResponseEntity<Employee> handleFileUpload(@PathVariable("empid") String empid, @RequestParam(value = "file") MultipartFile file) throws MyTeamException, IOException {
Employee employeeUpdated = empService.uploadProfile(empid, file);
return new ResponseEntity<>(null, HttpStatus.OK);
}
@RequestMapping(value = "/employees/downloadFile/{empId}", method = RequestMethod.GET)
public void downloadFile(@PathVariable("empId") String empId, HttpServletResponse response) throws IOException {
InputStream is = null;
is = new ByteArrayInputStream(empService.getUploadFile(empId));
response.setContentType("application/msword");
byte[] bytes = new byte[1024];
int bytesRead;
while ((bytesRead = is.read(bytes)) != -1) {
response.getOutputStream().write(bytes, 0, bytesRead);
}
is.close();
}
} }
\ No newline at end of file
...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -10,6 +10,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
...@@ -44,4 +45,35 @@ public class OrgLocationController { ...@@ -44,4 +45,35 @@ public class OrgLocationController {
return new ResponseEntity<>(getRespDetails, HttpStatus.OK); return new ResponseEntity<>(getRespDetails, HttpStatus.OK);
} }
@RequestMapping(value = "/organization/locations/{country}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getSelectedLocations(@PathVariable("country") String country, HttpServletRequest request) throws MyTeamException {
List<String> locationsList = orgLocationService.getLocations().stream()
.filter(e -> (e.isActiveStatus() == true)&&(e.getCountry().equalsIgnoreCase(country))).map(OrgLocation::getLocation).sorted()
.collect(Collectors.toList());
log.info("getLocations " + locationsList);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905,
"Retrieved Organization Locations successfully", "Organization Locations List", locationsList,
request.getRequestURI(), "Organization Location Details", null);
return new ResponseEntity<>(getRespDetails, HttpStatus.OK);
}
@RequestMapping(value = "/organization/countrys/", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> getCountrys(HttpServletRequest request) throws MyTeamException {
log.info("getCountrys Start ");
List<String> countryList = orgLocationService.getLocations().stream()
.filter(e -> (e.isActiveStatus() == true)).map(OrgLocation::getCountry).distinct().sorted()
.collect(Collectors.toList());
log.info("getLocations " + countryList);
ResponseDetails getRespDetails = new ResponseDetails(new Date(), 905,
"Retrieved Organization Locations successfully", "Organization Country List", countryList,
request.getRequestURI(), "Organization Country Details", null);
log.info("getCountrys End ");
return new ResponseEntity<>(getRespDetails, HttpStatus.OK);
}
} }
...@@ -20,6 +20,7 @@ import lombok.Getter; ...@@ -20,6 +20,7 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import lombok.ToString; import lombok.ToString;
import org.springframework.data.mongodb.core.mapping.Field;
@Setter @Setter
@Getter @Getter
...@@ -134,6 +135,10 @@ public class Employee implements Serializable { ...@@ -134,6 +135,10 @@ public class Employee implements Serializable {
private String createdBy; private String createdBy;
private String modifiedBy; private String modifiedBy;
private String country;
private Date lastUpdateProfile;
@Field
private byte[] updateProfile;
......
...@@ -5,7 +5,9 @@ import com.nisum.myteam.model.FunctionalGroup; ...@@ -5,7 +5,9 @@ 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;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
...@@ -63,4 +65,8 @@ public interface IEmployeeService { ...@@ -63,4 +65,8 @@ public interface IEmployeeService {
public int getEmployeesCountByDesignation(String designation); public int getEmployeesCountByDesignation(String designation);
Employee uploadProfile(String empId, MultipartFile file) throws MyTeamException, IOException;
byte[] getUploadFile(String empId);
} }
...@@ -21,6 +21,8 @@ import org.springframework.data.mongodb.core.query.Criteria; ...@@ -21,6 +21,8 @@ import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
import org.springframework.data.mongodb.core.query.Update; import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -370,7 +372,8 @@ public class EmployeeService implements IEmployeeService { ...@@ -370,7 +372,8 @@ public class EmployeeService implements IEmployeeService {
} else if (status.equals("Resigned")) { } else if (status.equals("Resigned")) {
return employeeRepo.findByEmpSubStatusOrderByEmployeeNameAsc("Resigned"); return employeeRepo.findByEmpSubStatusOrderByEmployeeNameAsc("Resigned");
} else { } else {
return employeesList.stream().filter(e -> e.getEmpStatus().equals(status)).collect(Collectors.toList()); return employeesList.stream().filter(e->Optional.ofNullable(e.getEmpStatus()).isPresent() && e.getEmpStatus().equals(status)).collect(Collectors.toList());
} }
} }
...@@ -495,4 +498,22 @@ public class EmployeeService implements IEmployeeService { ...@@ -495,4 +498,22 @@ public class EmployeeService implements IEmployeeService {
return onDate.after(e.getDateOfJoining()) && Optional.ofNullable(e.getEndDate()).isPresent() ? onDate.before(e.getEndDate()):true; return onDate.after(e.getDateOfJoining()) && Optional.ofNullable(e.getEndDate()).isPresent() ? onDate.before(e.getEndDate()):true;
} }
@Override
public Employee uploadProfile(String empId, MultipartFile file) throws MyTeamException, IOException {
Employee existingEmployee = employeeRepo.findByEmployeeId(empId);
// Employee employee=new Employee();
// employee.setEmployeeId(empId);
existingEmployee.setUpdateProfile(file.getBytes());
existingEmployee.setLastUpdateProfile(new Date());
Employee employeePersisted = employeeRepo.save(existingEmployee);
return employeePersisted;
}
@Override
public byte[] getUploadFile(String empId) {
Employee emp= employeeRepo.findByEmployeeId(empId);
return emp.getUpdateProfile();
}
} }
...@@ -13,6 +13,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -13,6 +13,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
var getCellTemplate = '<p ng-show="row.entity.empStatus == \'Active\'" class="col-lg-12"><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Update\')"></i>'+ var getCellTemplate = '<p ng-show="row.entity.empStatus == \'Active\'" class="col-lg-12"><i class="fa fa-pencil-square-o fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Update\')"></i>'+
'&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'; '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;';
var getDownloadTemplate = '<a target="_self" class="add-btn md-raised md-primary" href ng-click="grid.appScope.download(row)"> Download</a>';
// <i class="fa fa-minus-circle fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p> // <i class="fa fa-minus-circle fa-2x" aria-hidden="true" style="font-size:1.5em;margin-top:3px;cursor:pointer;" ng-click="grid.appScope.getRowData(row,\'Delete\')"></i></p>
$scope.gridOptions = { $scope.gridOptions = {
paginationPageSizes : [ 10, 20, 30, 40, 50, 100], paginationPageSizes : [ 10, 20, 30, 40, 50, 100],
...@@ -50,7 +51,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -50,7 +51,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
{field : 'functionalGroup',displayName: 'Func. Org', enableColumnMenu: false, enableSorting: false,enableFiltering:true,width:'*', cellClass: 'grid-align'}, {field : 'functionalGroup',displayName: 'Func. Org', enableColumnMenu: false, enableSorting: false,enableFiltering:true,width:'*', cellClass: 'grid-align'},
{field : 'dateOfJoining',displayName: 'DOJ', enableColumnMenu: true, enableSorting: true,enableFiltering:true,cellFilter:'date:"dd-MMM-yyyy"',width:'*', cellClass: 'grid-align'}, {field : 'dateOfJoining',displayName: 'DOJ', enableColumnMenu: true, enableSorting: true,enableFiltering:true,cellFilter:'date:"dd-MMM-yyyy"',width:'*', cellClass: 'grid-align'},
{field : 'endDate',displayName: 'DOL', enableColumnMenu: true, enableSorting: true,enableFiltering:true,cellFilter:'date:"dd-MMM-yyyy"',width:'*', cellClass: 'grid-align'}, {field : 'endDate',displayName: 'DOL', enableColumnMenu: true, enableSorting: true,enableFiltering:true,cellFilter:'date:"dd-MMM-yyyy"',width:'*', cellClass: 'grid-align'},
{name : 'Actions', displayName: 'Actions',cellTemplate: getCellTemplate, enableColumnMenu: false, enableSorting: false,enableFiltering: false} {name : 'Actions', displayName: 'Actions',cellTemplate: getCellTemplate, enableColumnMenu: false, enableSorting: false,enableFiltering: false} ,
{name : 'Dowload Profile', displayName: 'Dowload',cellTemplate: getDownloadTemplate, enableColumnMenu: false, enableSorting: false,enableFiltering: false, width:100,cellClass: 'grid-align'}
] ]
}; };
...@@ -81,6 +83,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -81,6 +83,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.parentData.mobileNumber = row.entity.mobileNumber; $scope.parentData.mobileNumber = row.entity.mobileNumber;
$scope.parentData.emailId = row.entity.emailId; $scope.parentData.emailId = row.entity.emailId;
$scope.parentData.role = row.entity.role; $scope.parentData.role = row.entity.role;
$scope.parentData.empCountry = row.entity.empCountry;
$scope.parentData.empLocation = row.entity.empLocation; $scope.parentData.empLocation = row.entity.empLocation;
$scope.parentData.designation = row.entity.designation; $scope.parentData.designation = row.entity.designation;
$scope.parentData.functionalGroup = row.entity.functionalGroup; $scope.parentData.functionalGroup = row.entity.functionalGroup;
...@@ -103,6 +106,30 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -103,6 +106,30 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.deleteRole(row); $scope.deleteRole(row);
} }
$scope.download = function(row){
var employeeId = row.entity.employeeId;
var urlRequest = appConfig.appUri+ "/employees/downloadFile/"+employeeId;
$http({
method : "GET",
url : urlRequest,
headers:{'Content-type': 'application/msword'},
responseType : 'arraybuffer',
}).then(function mySuccess(response) {
var value=response.data;
var fileName=employeeId+".doc"
var file = new Blob([value], {type: 'application/msword'});
var url = window.URL || window.webkitURL;
var downloadLink = angular.element('<a></a>');
downloadLink.attr('href',url.createObjectURL(file));
downloadLink.attr('target','_self');
downloadLink.attr('download', fileName);
downloadLink[0].click();
}, function myError(response) {
showAlert(" Unable to find the profile , Please Upload profile in my Profile link");
});
}
$scope.refreshPage = function(){ $scope.refreshPage = function(){
$scope.empSearchId = ""; $scope.empSearchId = "";
$scope.getUserRoles(); $scope.getUserRoles();
...@@ -125,7 +152,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -125,7 +152,8 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
{field : 'emailId',displayName: 'Email', enableColumnMenu: false, enableSorting: false,enableFiltering: true}, {field : 'emailId',displayName: 'Email', enableColumnMenu: false, enableSorting: false,enableFiltering: true},
{field : 'baseTechnology',displayName: 'Skill', enableColumnMenu: false, enableSorting: false,enableFiltering: true}, {field : 'baseTechnology',displayName: 'Skill', enableColumnMenu: false, enableSorting: false,enableFiltering: true},
{field : 'designation',displayName: 'Designation', enableColumnMenu: false, enableSorting: true,enableFiltering: true}, {field : 'designation',displayName: 'Designation', enableColumnMenu: false, enableSorting: true,enableFiltering: true},
{name : 'Actions', displayName: 'Actions',cellTemplate: getCellTemplate, enableColumnMenu: false, enableSorting: false,enableFiltering: false, width:100} {name : 'Actions', displayName: 'Actions',cellTemplate: getCellTemplate, enableColumnMenu: false, enableSorting: false,enableFiltering: false, width:100} ,
{name : 'Dowload Profile', displayName: 'Dowload',downloadTemplate: getDownloadTemplate, enableColumnMenu: false, enableSorting: false,enableFiltering: false, width:100}
] ]
}; };
$scope.getUserRoles = function(){ $scope.getUserRoles = function(){
...@@ -271,6 +299,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -271,6 +299,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.empSubStatus; $scope.empSubStatus;
$scope.employmentType; $scope.employmentType;
$scope.designation; $scope.designation;
$scope.empCountry ;
$scope.empLocation; $scope.empLocation;
$scope.dateOfJoining; $scope.dateOfJoining;
$scope.domain = ""; $scope.domain = "";
...@@ -293,6 +322,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -293,6 +322,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
$scope.empRole = dataToPass.role; $scope.empRole = dataToPass.role;
$scope.empMobileNo = dataToPass.mobileNumber; $scope.empMobileNo = dataToPass.mobileNumber;
$scope.empEmail = dataToPass.emailId; $scope.empEmail = dataToPass.emailId;
$scope.empCountry = dataToPass.empCountry;
$scope.empLocation = dataToPass.empLocation; $scope.empLocation = dataToPass.empLocation;
$scope.functionalGroup = dataToPass.functionalGroup; $scope.functionalGroup = dataToPass.functionalGroup;
$scope.empStatus = dataToPass.empStatus; $scope.empStatus = dataToPass.empStatus;
...@@ -313,6 +343,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -313,6 +343,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
} }
$scope.domains = myFactory.getDomains(); $scope.domains = myFactory.getDomains();
$scope.roles = myFactory.getRoles(); $scope.roles = myFactory.getRoles();
$scope.countrys=myFactory.getCountrys();
$scope.locations=myFactory.getLocations(); $scope.locations=myFactory.getLocations();
$scope.designations=myFactory.getDesignations(); $scope.designations=myFactory.getDesignations();
$scope.functionalGroups=myFactory.getFunctionalgroups(); $scope.functionalGroups=myFactory.getFunctionalgroups();
...@@ -326,6 +357,26 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -326,6 +357,26 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
return "Please select a role"; return "Please select a role";
} }
}; };
$scope.getSelectedCountry = function(){
if ($scope.empCountry !== undefined) {
$scope.empLocation="";
$scope.locations="";
getAllLocationsCountry($scope.empCountry );
return $scope.empCountry;
} else {
return "Please select a Country";
}
};
function getAllLocationsCountry(country){
$http({
method : "GET",
url : appConfig.appUri +"/organization/locations/"+country
}).then(function mySuccess(response) {
$scope.locations=response.data.records;
}, function myError(response) {
});
};
$scope.getSelectedLocation = function(){ $scope.getSelectedLocation = function(){
if ($scope.empLocation !== undefined) { if ($scope.empLocation !== undefined) {
return $scope.empLocation; return $scope.empLocation;
...@@ -539,6 +590,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -539,6 +590,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
var empEmail = $scope.empEmail; var empEmail = $scope.empEmail;
var empMobileNo = $scope.empMobileNo; var empMobileNo = $scope.empMobileNo;
var designation = $scope.designation; var designation = $scope.designation;
var empCountry = $scope.empCountry;
var empLocation = $scope.empLocation; var empLocation = $scope.empLocation;
var employmentType = $scope.employmentType; var employmentType = $scope.employmentType;
var functionalGroup = $scope.functionalGroup; var functionalGroup = $scope.functionalGroup;
...@@ -619,7 +671,10 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -619,7 +671,10 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
}else if(designation == undefined){ }else if(designation == undefined){
$scope.alertMsg = "Please select a designation"; $scope.alertMsg = "Please select a designation";
document.getElementById('designation').focus(); document.getElementById('designation').focus();
}else if(empLocation == undefined){ }else if(empCountry == undefined){
$scope.alertMsg = "Please select a Country";
document.getElementById('empCountry').focus();
}else if(empLocation == undefined || empLocation==""){
$scope.alertMsg = "Please select a location"; $scope.alertMsg = "Please select a location";
document.getElementById('empLocation').focus(); document.getElementById('empLocation').focus();
}else if(employmentType == undefined){ }else if(employmentType == undefined){
...@@ -665,7 +720,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -665,7 +720,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
}else{ }else{
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "gender": $scope.gender,"mobileNumber": $scope.empMobileNo, "emailId": $scope.empEmail, var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "gender": $scope.gender,"mobileNumber": $scope.empMobileNo, "emailId": $scope.empEmail,
"role": $scope.empRole, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup, "role": $scope.empRole,"country":$scope.empCountry, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup,
"empStatus": $scope.empStatus,"employmentType": $scope.employmentType,"dateOfJoining":$scope.dateOfJoining, "empStatus": $scope.empStatus,"employmentType": $scope.employmentType,"dateOfJoining":$scope.dateOfJoining,
"dateOfBirth":$scope.dateOfBirth,"hasPassort":$scope.hasPassort,"hasB1":$scope.hasB1,"passportExpiryDate":$scope.passportExpiryDate, "dateOfBirth":$scope.dateOfBirth,"hasPassort":$scope.hasPassort,"hasB1":$scope.hasB1,"passportExpiryDate":$scope.passportExpiryDate,
"b1ExpiryDate":$scope.b1ExpiryDate, "endDate":$scope.exitDate,"empSubStatus":empSubStatusObj "b1ExpiryDate":$scope.b1ExpiryDate, "endDate":$scope.exitDate,"empSubStatus":empSubStatusObj
...@@ -676,7 +731,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -676,7 +731,7 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
} }
else{ else{
var recordFromDb = {"employeeId":dataToPass.employeeId, "employeeName": dataToPass.employeeName, "gender": dataToPass.gender,"mobileNumber": dataToPass.mobileNumber,"emailId": dataToPass.emailId, var recordFromDb = {"employeeId":dataToPass.employeeId, "employeeName": dataToPass.employeeName, "gender": dataToPass.gender,"mobileNumber": dataToPass.mobileNumber,"emailId": dataToPass.emailId,
"role": dataToPass.role, "empLocation": dataToPass.empLocation,"designation": dataToPass.designation,"functionalGroup": dataToPass.functionalGroup, "role": dataToPass.role,"country":dataToPass.empCountry, "empLocation": dataToPass.empLocation,"designation": dataToPass.designation,"functionalGroup": dataToPass.functionalGroup,
"empStatus": dataToPass.empStatus,"empSubStatus":dataToPass.empSubStatus, "employmentType": dataToPass.employmentType,"dateOfJoining":new Date(dataToPass.dateOfJoining), "empStatus": dataToPass.empStatus,"empSubStatus":dataToPass.empSubStatus, "employmentType": dataToPass.employmentType,"dateOfJoining":new Date(dataToPass.dateOfJoining),
"dateOfBirth":new Date(dataToPass.dateOfBirth),"hasPassort":dataToPass.hasPassort,"hasB1":dataToPass.hasB1,"passportExpiryDate":new Date(dataToPass.passportExpiryDate), "dateOfBirth":new Date(dataToPass.dateOfBirth),"hasPassort":dataToPass.hasPassort,"hasB1":dataToPass.hasB1,"passportExpiryDate":new Date(dataToPass.passportExpiryDate),
"b1ExpiryDate":new Date(dataToPass.b1ExpiryDate), "endDate":new Date(dataToPass.endDate) ,"empSubStatus": prevEmpSubStatusObj "b1ExpiryDate":new Date(dataToPass.b1ExpiryDate), "endDate":new Date(dataToPass.endDate) ,"empSubStatus": prevEmpSubStatusObj
...@@ -745,14 +800,14 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $ ...@@ -745,14 +800,14 @@ myApp.controller("assignRoleController",function($scope, myFactory, $mdDialog, $
}; };
var record = { var record = {
"employeeId":$scope.empId, "employeeName": $scope.empName, "gender": $scope.gender,"mobileNumber": $scope.empMobileNo,"emailId": $scope.empEmail, "employeeId":$scope.empId, "employeeName": $scope.empName, "gender": $scope.gender,"mobileNumber": $scope.empMobileNo,"emailId": $scope.empEmail,
"role": $scope.empRole, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup, "role": $scope.empRole,"country":$scope.empCountry, "empLocation": $scope.empLocation,"designation": $scope.designation,"functionalGroup": $scope.functionalGroup,
"empStatus": $scope.empStatus, "empSubStatus":$scope.empSubStatus, "employmentType": $scope.employmentType,"dateOfJoining":$scope.dateOfJoining, "empStatus": $scope.empStatus, "empSubStatus":$scope.empSubStatus, "employmentType": $scope.employmentType,"dateOfJoining":$scope.dateOfJoining,
"dateOfBirth":$scope.dateOfBirth,"hasPassort":$scope.hasPassort,"hasB1":$scope.hasB1,"passportExpiryDate":$scope.passportExpiryDate, "dateOfBirth":$scope.dateOfBirth,"hasPassort":$scope.hasPassort,"hasB1":$scope.hasB1,"passportExpiryDate":$scope.passportExpiryDate,
"b1ExpiryDate":$scope.b1ExpiryDate, "endDate":$scope.exitDate ,"empSubStatus":empSubStatusObj "b1ExpiryDate":$scope.b1ExpiryDate, "endDate":$scope.exitDate ,"empSubStatus":empSubStatusObj
}; };
var recordFromDb = { var recordFromDb = {
"employeeId":dataToPass.employeeId, "employeeName": dataToPass.employeeName, "gender": dataToPass.gender,"mobileNumber": dataToPass.mobileNumber,"emailId": dataToPass.emailId, "employeeId":dataToPass.employeeId, "employeeName": dataToPass.employeeName, "gender": dataToPass.gender,"mobileNumber": dataToPass.mobileNumber,"emailId": dataToPass.emailId,
"role": dataToPass.role, "empLocation": dataToPass.empLocation,"designation": dataToPass.designation,"functionalGroup": dataToPass.functionalGroup, "role": dataToPass.role,"country":dataToPass.empCountry, "empLocation": dataToPass.empLocation,"designation": dataToPass.designation,"functionalGroup": dataToPass.functionalGroup,
"empStatus": dataToPass.empStatus, "empSubStatus":dataToPass.empSubStatus, "employmentType": dataToPass.employmentType,"dateOfJoining":new Date(dataToPass.dateOfJoining), "empStatus": dataToPass.empStatus, "empSubStatus":dataToPass.empSubStatus, "employmentType": dataToPass.employmentType,"dateOfJoining":new Date(dataToPass.dateOfJoining),
"dateOfBirth":new Date(dataToPass.dateOfBirth),"hasPassort":dataToPass.hasPassort,"hasB1":dataToPass.hasB1,"passportExpiryDate":new Date(dataToPass.passportExpiryDate), "dateOfBirth":new Date(dataToPass.dateOfBirth),"hasPassort":dataToPass.hasPassort,"hasB1":dataToPass.hasB1,"passportExpiryDate":new Date(dataToPass.passportExpiryDate),
"b1ExpiryDate":new Date(dataToPass.b1ExpiryDate), "endDate":new Date(dataToPass.endDate) , "empSubStatus":prevEmpSubStatusObj "b1ExpiryDate":new Date(dataToPass.b1ExpiryDate), "endDate":new Date(dataToPass.endDate) , "empSubStatus":prevEmpSubStatusObj
......
...@@ -11,6 +11,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -11,6 +11,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
getAllLocations(); getAllLocations();
getAllAccounts(); getAllAccounts();
getMasterData(); getMasterData();
getAllCountrys();
$("#start").trigger("click"); $("#start").trigger("click");
} }
...@@ -86,6 +87,16 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -86,6 +87,16 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
}); });
}; };
function getAllCountrys(){
$http({
method : "GET",
url : appConfig.appUri +"/organization/countrys/"
}).then(function mySuccess(response) {
myFactory.setCountrys(response.data.records);
}, function myError(response) {
});
};
function getAllAccounts(){ function getAllAccounts(){
$http({ $http({
method : "GET", method : "GET",
...@@ -132,13 +143,20 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -132,13 +143,20 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
$scope.empShift; $scope.empShift;
$scope.shifts = myFactory.getTechnologies(); $scope.shifts = myFactory.getTechnologies();
$scope.locations = myFactory.getLocations();//["Shift 1(09:00 AM - 06:00 PM)","Shift 2(03:30 PM - 12:30 PM)", "Shift 3(09:00 PM - 06:00 AM)"]; $scope.locations = myFactory.getLocations();//["Shift 1(09:00 AM - 06:00 PM)","Shift 2(03:30 PM - 12:30 PM)", "Shift 3(09:00 PM - 06:00 AM)"];
$scope.country=myFactory.getAllCountrys();
$scope.getSelectedShift = function(){ $scope.getSelectedShift = function(){
if ($scope.empShift !== undefined) { if ($scope.empShift !== undefined) {
return $scope.empShift; return $scope.empShift;
} else { } else {
return "Please select primary skill"; return "Please select primary skill";
} }
};
$scope.getSelectedCountry = function(){
if ($scope.empCountry !== undefined) {
return $scope.empCountry;
} else {
return "Please select work Country";
}
}; };
$scope.getSelectedLocation = function(){ $scope.getSelectedLocation = function(){
if ($scope.empLocation !== undefined) { if ($scope.empLocation !== undefined) {
...@@ -205,13 +223,15 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -205,13 +223,15 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
}else if(empShift == undefined){ }else if(empShift == undefined){
$scope.alertMsg = "Please select a primary skill"; $scope.alertMsg = "Please select a primary skill";
document.getElementById('empShift').focus(); document.getElementById('empShift').focus();
} }else if($scope.country == ""){
else if(empLocation == undefined){ $scope.alertMsg = "Country is mandatory";
document.getElementById('empName').focus();
} else if(empLocation == undefined){
$scope.alertMsg = "Please select a work location"; $scope.alertMsg = "Please select a work location";
document.getElementById('empLocation').focus(); document.getElementById('empLocation').focus();
}else{ }else{
$scope.alertMsg = ""; $scope.alertMsg = "";
var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "emailId": $scope.empEmail, "role": "Employee", "shift": "Shift 1(09:00 AM - 06:00 PM)","mobileNumber":$scope.mobileNumber,"baseTechnology": $scope.empShift,"empLocation": $scope.empLocation}; var record = {"employeeId":$scope.empId, "employeeName": $scope.empName, "emailId": $scope.empEmail, "role": "Employee", "shift": "Shift 1(09:00 AM - 06:00 PM)","mobileNumber":$scope.mobileNumber,"baseTechnology": $scope.empShift,"empLocation": $scope.empLocation,"country": $scope.country};
addEmployee(record); addEmployee(record);
} }
}; };
...@@ -372,7 +392,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -372,7 +392,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
auth2.disconnect(); auth2.disconnect();
//Clear if any values set to factory //Clear if any values set to factory
var menuItems = [], designations = [], accounts = [], technologies = [], shifts = [],locations=[]; var menuItems = [], designations = [], accounts = [], technologies = [], shifts = [],locations=[], countrys = [];
myFactory.setEmpId(""); myFactory.setEmpId("");
myFactory.setEmpName(""); myFactory.setEmpName("");
myFactory.setEmpEmailId(""); myFactory.setEmpEmailId("");
...@@ -384,6 +404,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window ...@@ -384,6 +404,7 @@ myApp.controller("loginController",function($scope, myFactory, $compile, $window
myFactory.setAccounts(accounts); myFactory.setAccounts(accounts);
myFactory.setTechnologies(technologies); myFactory.setTechnologies(technologies);
myFactory.setShifts(shifts); myFactory.setShifts(shifts);
myFactory.setCountrys(countrys);
myFactory.setLocations(locations); myFactory.setLocations(locations);
var element = document.getElementById('home'); var element = document.getElementById('home');
var path = "'templates/login.html'"; var path = "'templates/login.html'";
......
myApp.controller("profileController", function($scope, $http, myFactory, $mdDialog, appConfig) { myApp.controller("profileController", function($scope, $http, myFactory, $mdDialog, appConfig,$window) {
$scope.records = []; $scope.records = [];
$scope.empId = myFactory.getEmpId(); $scope.empId = myFactory.getEmpId();
$scope.empName = myFactory.getEmpName(); $scope.empName = myFactory.getEmpName();
...@@ -34,6 +34,29 @@ myApp.controller("profileController", function($scope, $http, myFactory, $mdDial ...@@ -34,6 +34,29 @@ myApp.controller("profileController", function($scope, $http, myFactory, $mdDial
$scope.refreshPage(); $scope.refreshPage();
}); });
}; };
$scope.download = function(){
var empId = $scope.empId;
var urlRequest = appConfig.appUri+ "/employees/downloadFile/"+empId;
$http({
method : "GET",
url : urlRequest,
headers:{'Content-type': 'application/msword'},
responseType : 'arraybuffer',
}).then(function mySuccess(response) {
var value=response.data;
var fileName=empId+".doc"
var file = new Blob([value], {type: 'application/msword'});
var url = window.URL || window.webkitURL;
var downloadLink = angular.element('<a></a>');
downloadLink.attr('href',url.createObjectURL(file));
downloadLink.attr('target','_self');
downloadLink.attr('download', fileName);
downloadLink[0].click();
}, function myError(response) {
showAlert(" Unable to find the profile , Please Upload profile ");
});
};
function UpdateProfileController($scope, $mdDialog, dataToPass) { function UpdateProfileController($scope, $mdDialog, dataToPass) {
$scope.profile = dataToPass; $scope.profile = dataToPass;
...@@ -45,6 +68,7 @@ myApp.controller("profileController", function($scope, $http, myFactory, $mdDial ...@@ -45,6 +68,7 @@ myApp.controller("profileController", function($scope, $http, myFactory, $mdDial
$scope.personalEmailId=dataToPass.personalEmailId; $scope.personalEmailId=dataToPass.personalEmailId;
$scope.technologyKnown=dataToPass.technologyKnown; $scope.technologyKnown=dataToPass.technologyKnown;
$scope.designationEmp=(dataToPass.designation == null ? undefined: dataToPass.designation); $scope.designationEmp=(dataToPass.designation == null ? undefined: dataToPass.designation);
$scope.uploadFile=dataToPass.uploadFile;
$scope.cancel = function() { $scope.cancel = function() {
$mdDialog.hide(); $mdDialog.hide();
}; };
...@@ -63,6 +87,43 @@ myApp.controller("profileController", function($scope, $http, myFactory, $mdDial ...@@ -63,6 +87,43 @@ myApp.controller("profileController", function($scope, $http, myFactory, $mdDial
return "Please select designation"; return "Please select designation";
} }
}; };
$scope.uploadFile = function(){
var file =$scope.file;
if(this.file == undefined ){
showAlert("Please Upload profile .DOC or .DOCX");
}
var ext=this.file.name.split(".").pop();
if(this.file == undefined &&(ext!="docx" || ext!="doc")){
showAlert("Please Upload profile .DOC and .DOCX");
}
var formData = new FormData();
formData.append('file',$scope.file);
$scope.alertMsg = "";
var empid=$scope.profile.employeeId
// var record = {"employeeId":$scope.profile.employeeId, "mobileNumber": $scope.mobileNumber, "alternateMobileNumber": $scope.alternateMobileNumber, "personalEmailId": $scope.personalEmailId, "baseTechnology": $scope.baseTechnology, "technologyKnown": $scope.technologyKnown};
var urlRequest = "";
urlRequest = appConfig.appUri+ "/employees/uploadProfile/"+$scope.profile.employeeId;
var req = {
method : 'POST',
url : urlRequest,
headers : {
"Content-type" : undefined
},
transformRequest: angular.identity,
data : formData
}
$http(req).then(function mySuccess(response) {
$mdDialog.hide('Success');
$scope.dataToPass=response.data;
}, function myError(response){
$mdDialog.hide('Error');
});
};
$scope.validateFields = function(){ $scope.validateFields = function(){
var mobileNumber = $scope.mobileNumber; var mobileNumber = $scope.mobileNumber;
$scope.alertMsg = ""; $scope.alertMsg = "";
......
...@@ -46,6 +46,7 @@ myApp.factory('myFactory', function() { ...@@ -46,6 +46,7 @@ myApp.factory('myFactory', function() {
var employeeSubStatus=""; var employeeSubStatus="";
var employementTypes=""; var employementTypes="";
var domains=""; var domains="";
var countrys="";
function setEmpId(id) { function setEmpId(id) {
empId = id; empId = id;
} }
...@@ -178,6 +179,12 @@ myApp.factory('myFactory', function() { ...@@ -178,6 +179,12 @@ myApp.factory('myFactory', function() {
} }
return false; return false;
} }
function setCountrys(country1) {
countrys = country1;
}
function getCountrys() {
return countrys;
}
// function addFormDataCheck(form){ // function addFormDataCheck(form){
// var obj = {}; // var obj = {};
...@@ -255,6 +262,8 @@ myApp.factory('myFactory', function() { ...@@ -255,6 +262,8 @@ myApp.factory('myFactory', function() {
getDomains : getDomains, getDomains : getDomains,
setTechnologies : setTechnologies, setTechnologies : setTechnologies,
getTechnologies : getTechnologies, getTechnologies : getTechnologies,
setCountrys : setCountrys,
getCountrys : getCountrys,
setLocations : setLocations, setLocations : setLocations,
getLocations : getLocations, getLocations : getLocations,
setFunctionalgroups : setFunctionalgroups, setFunctionalgroups : setFunctionalgroups,
......
...@@ -161,6 +161,14 @@ ...@@ -161,6 +161,14 @@
ng-value="designation" ng-repeat="designation in designations">{{designation}}</md-option> ng-value="designation" ng-repeat="designation in designations">{{designation}}</md-option>
</md-optgroup> </md-select></td> </md-optgroup> </md-select></td>
</tr> </tr>
<tr>
<td colspan="4"><b>Country:</b><span class="mandatory"></span></td>
<td colspan="8"><md-select ng-model="empCountry" ng-blur="validateMessage()" name="empCountry"
md-selected-text="getSelectedCountry()" id="empCountry">
<md-optgroup label="countrys"> <md-option
ng-value="country" ng-repeat="country in countrys">{{country}}</md-option>
</md-optgroup> </md-select></td>
</tr>
<tr> <tr>
<td colspan="4"><b>Work &nbsp;Location:</b><span class="mandatory"></span></td> <td colspan="4"><b>Work &nbsp;Location:</b><span class="mandatory"></span></td>
......
<div class="md-padding my-profile" id="popupContainer" ng-controller="profileController" ng-init="getProfileData()"> <div class="md-padding my-profile" id="popupContainer" ng-controller="profileController" ng-init="getProfileData()">
<h1 class="no-padding">My Profile <h1 class="no-padding">My Profile
<span class="right"> <span class="right">
<md-button class="add-btn md-raised md-primary" ng-click="download()"> <i class="fa fa-pencil-square-o fa-1x"></i> Download Profile
</md-button>
<md-button class="add-btn md-raised md-primary" ng-click="updateProfile()"> <i class="fa fa-pencil-square-o fa-1x"></i> Update Profile <md-button class="add-btn md-raised md-primary" ng-click="updateProfile()"> <i class="fa fa-pencil-square-o fa-1x"></i> Update Profile
</md-button> </md-button>
<i class="fa fa-refresh" aria-hidden="true" ng-click="refreshPage()"></i> <i class="fa fa-refresh" aria-hidden="true" ng-click="refreshPage()"></i>
...@@ -244,6 +246,30 @@ ...@@ -244,6 +246,30 @@
</p> </p>
</div> </div>
</div> </div>
<div class="row">
<div class="col-lg-4 col-xs-6">
<p>
<b>Country</b> <b class="right">:</b>
</p>
</div>
<div class="col-lg-7 col-xs-6">
<p>
{{profile.country}}
</p>
</div>
</div>
<div class="row">
<div class="col-lg-4 col-xs-6">
<p>
<b>Last Update Profile</b> <b class="right">:</b>
</p>
</div>
<div class="col-lg-7 col-xs-6">
<p>
{{profile.lastUpdateProfile | date:'dd-MMM-yyyy'}}
</p>
</div>
</div>
</div> </div>
</div> </div>
<div class="col-lg-2 col-xs-12"></div> <div class="col-lg-2 col-xs-12"></div>
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
ng-repeat="tech in technologies">{{tech}}</md-option> </md-optgroup> </md-select> ng-repeat="tech in technologies">{{tech}}</md-option> </md-optgroup> </md-select>
<textarea rows="4" cols="10" class="form-control" id="technologyKnown" name="technologyKnown" <textarea rows="4" cols="10" class="form-control" id="technologyKnown" name="technologyKnown"
ng-model="technologyKnown" placeholder="Technologies Known" /> ng-model="technologyKnown" placeholder="Technologies Known" />
<input type="file" file-model="file" class="form-control" id="uploadFile" name="uploadFile" ng-model="uploadFile" placeholder="Upload Profile" multiple/>
<div role="alert"> <div role="alert">
<span class="error" style="color: red;">{{alertMsg}}</span> <span class="error" style="color: red;">{{alertMsg}}</span>
</div> </div>
...@@ -31,10 +32,10 @@ ...@@ -31,10 +32,10 @@
</md-dialog-content> </md-dialog-content>
<md-dialog-actions layout="row"> <md-button <md-dialog-actions layout="row">
class="md-raised" data-ng-click="validateFields()"> <md-button class="md-raised" data-ng-click="uploadFile()">Upload </md-button>
Update </md-button> <md-button class="md-raised" ng-click="cancel()"> <md-button class="md-raised" data-ng-click="validateFields()"> Update </md-button>
Cancel </md-button> </md-dialog-actions> <md-button class="md-raised" ng-click="cancel()"> Cancel </md-button> </md-dialog-actions>
</form> </form>
</md-dialog> </md-dialog>
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