diff --git a/BackEnd/Library/ /home/negilbabu/Desktop/project/LibraryRepository/FrontEnd/Library/src/assets/BooksImage/item_pics/item_pics/image.jpeg b/BackEnd/Library/ /home/negilbabu/Desktop/project/LibraryRepository/FrontEnd/Library/src/assets/BooksImage/item_pics/item_pics/image.jpeg deleted file mode 100644 index b476e400..00000000 Binary files a/BackEnd/Library/ /home/negilbabu/Desktop/project/LibraryRepository/FrontEnd/Library/src/assets/BooksImage/item_pics/item_pics/image.jpeg and /dev/null differ diff --git a/BackEnd/Library/ /home/negilbabu/Desktop/project/LibraryRepository/FrontEnd/Library/src/assets/BooksImage/item_picsitem_pics/image.jpeg b/BackEnd/Library/ /home/negilbabu/Desktop/project/LibraryRepository/FrontEnd/Library/src/assets/BooksImage/item_picsitem_pics/image.jpeg deleted file mode 100644 index b476e400..00000000 Binary files a/BackEnd/Library/ /home/negilbabu/Desktop/project/LibraryRepository/FrontEnd/Library/src/assets/BooksImage/item_picsitem_pics/image.jpeg and /dev/null differ diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/configuration/WebSecurityConfiguration.java b/BackEnd/Library/src/main/java/com/innovature/Library/configuration/WebSecurityConfiguration.java index 6209278b..3fd2ef3f 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/configuration/WebSecurityConfiguration.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/configuration/WebSecurityConfiguration.java @@ -53,6 +53,10 @@ protected void configure(HttpSecurity http) throws Exception { .securityContext().and() .anonymous().and() .authorizeRequests() + + .antMatchers(GET,"/users/admin/**/").access("hasRole('ROLE_ADMIN')") + .antMatchers(GET,"/users/admin/viewProfile").access("hasRole('ROLE_ADMIN')") + .antMatchers(OPTIONS, "/users").anonymous() .antMatchers(POST, "/users").anonymous() .antMatchers(OPTIONS, "/login").anonymous() @@ -62,7 +66,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(OPTIONS, "/**").anonymous() //category - .antMatchers(GET,"/category/admin").access("hasRole('ROLE_ADMIN')") + .antMatchers(GET,"/category/admin/**/").access("hasRole('ROLE_ADMIN')") .antMatchers(POST,"/category").access("hasRole('ROLE_ADMIN')") .antMatchers(DELETE,"/category").access("hasRole('ROLE_ADMIN')") .antMatchers(PUT,"/category/{catogoryId}").access("hasRole('ROLE_ADMIN')") @@ -71,6 +75,7 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(GET,"/books/admin/**/").access("hasRole('ROLE_ADMIN')") .antMatchers(GET,"/books/user/**/").access("hasRole('ROLE_USER')") .antMatchers(POST,"/books").access("hasRole('ROLE_ADMIN')") + .antMatchers(POST,"/books/save/image/{booksId}").access("hasRole('ROLE_ADMIN')") .antMatchers(DELETE,"/books/{booksId}").access("hasRole('ROLE_ADMIN')") .antMatchers(PUT,"/books/{booksId}").access("hasRole('ROLE_ADMIN')") @@ -80,6 +85,8 @@ protected void configure(HttpSecurity http) throws Exception { .antMatchers(POST,"/borrow/").access("hasRole('ROLE_USER')") .antMatchers(PUT,"/borrow/admin/**").access("hasRole('ROLE_ADMIN')") + //user + diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/controller/BorrowController.java b/BackEnd/Library/src/main/java/com/innovature/Library/controller/BorrowController.java index 73617045..e5720e06 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/controller/BorrowController.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/controller/BorrowController.java @@ -69,8 +69,27 @@ public Collection list() { return new ResponseEntity>(list,new HttpHeaders(), HttpStatus.OK); + + + } + + @GetMapping("/admin/statusFilter/") + public ResponseEntity>getAllBorrowByStatus( + @RequestParam(defaultValue = "1") Integer pageNo, + @RequestParam(defaultValue = "5") Integer pageSize, + @RequestParam(defaultValue = "borrowId") String sortBy, + @RequestParam(defaultValue = "1") Integer direction, + @RequestParam(defaultValue = "1") Integer status) + { + Page list = bService.getAllBorrByStat(pageNo-1, pageSize, sortBy,direction,status); + return new ResponseEntity>(list,new HttpHeaders(), + HttpStatus.OK); + + + } + //BORROW @ADMIN //pagenated borrow list at admin VIEW borrow single api @GetMapping("/admin/pagenated/") @@ -166,6 +185,20 @@ public Collection listDue() { } + @GetMapping("/admin/fine/") +public ResponseEntity>listfine( + @RequestParam(defaultValue = "1") Integer pageNo, + @RequestParam(defaultValue = "5") Integer pageSize, + @RequestParam(defaultValue = "borrowId") String sortBy, + @RequestParam(defaultValue = "1") Integer direction) +{ + Page list = bService.getAllFine(pageNo-1, pageSize, sortBy,direction); + return new ResponseEntity>(list,new HttpHeaders(), + HttpStatus.OK); + +} + + @GetMapping("admin/fine") public Collection listfine() { return bService.fine(); @@ -238,7 +271,7 @@ public BorrowDetailView undo( - +//chart @GetMapping("/admin/chart") public rentChartView getchart(){ rentChartView test =borrowServices.getChart(); diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/controller/EmailController.java b/BackEnd/Library/src/main/java/com/innovature/Library/controller/EmailController.java index 9fbfda42..c46e8113 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/controller/EmailController.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/controller/EmailController.java @@ -1,7 +1,10 @@ package com.innovature.Library.controller; + import java.util.Random; +import java.time.LocalTime; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; @@ -11,21 +14,17 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; - import com.innovature.Library.form.EmailForm; import com.innovature.Library.form.OtpForm; import com.innovature.Library.repository.EmailRepository; import com.innovature.Library.service.BorrowService; import com.innovature.Library.service.EmailService; - - import com.innovature.Library.entity.Email; import com.innovature.Library.entity.User; import com.innovature.Library.repository.UserRepository; -// tgsrhyrsrthr @RestController @RequestMapping("/email") public class EmailController { @@ -58,41 +57,137 @@ public String sendMail(@PathVariable("userId") Integer userId) { @PostMapping("/emailsentotp") - public ResponseEntitysendOtpEmail(@RequestBody EmailForm form){ + public ResponseEntity sendOtpEmail(@RequestBody EmailForm form){ + String emailid=form.getSentto(); + if("".equals(emailid) ){ + return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("NULL VALUE EXCEPTION-"); + } + else{ User user=userRepository.findByEmailId(form.getSentto()); if(user!=null){ - emailRepository.deleteAll(); + Random random = new Random(); int otp = 100000 + random.nextInt(900000); Email otp2= new Email(); otp2.setOtp(otp); - otp2.setEmail(form.getSentto()); + otp2.setEmail(form.getSentto()); + + LocalTime myObj = LocalTime.now(); + LocalTime exp=myObj; + otp2.setExpiry(exp); - emailRepository.save(otp2); + var email=form.getSentto(); + Email email2= emailRepository.findByEmail(email); + + if(email2!=null){ + email2.setOtp(otp); + email2.setExpiry(exp); + emailRepository.save(email2); + } + else + emailRepository.save(otp2); + boolean result = this.emailService.sendEmail("OTP Verification","Your OTP to change your password is \t"+ otp +"\tuse it to create a new password.", form.getSentto()); // "OTP Verification", "Your OTP to change your password is "+"otp"+"use it to create a new password." if(result){ - return ResponseEntity.ok("Email Sent!"); - }else{ - return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Email not sent."); + return new ResponseEntity(null,HttpStatus.ACCEPTED); + } + else{ + return new ResponseEntity(null,HttpStatus.EXPECTATION_FAILED); } } else{ - return null; + return new ResponseEntity(null,HttpStatus.BAD_REQUEST); + } + } + } + @PostMapping("verify") + public ResponseEntity add(@RequestBody OtpForm form){ + var otp=form.getOtp(); + if(otp==null){ + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("NULL VALUE EXCEPTION"); + } + else{ + ResponseEntity result = emailService.add(form); + + if(result.getStatusCodeValue()==202){ + return new ResponseEntity(HttpStatus.ACCEPTED); + + } + else if(result.getStatusCodeValue()==504){ + return ResponseEntity.status(HttpStatus.GATEWAY_TIMEOUT).body("OTP EXPIRED"); + } + + else + return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("OTP VERIFICATION FAILED"); + } + } - @PostMapping("verify") - public boolean add(@RequestBody OtpForm form){ - return emailService.add(form); + // @PostMapping("verify") + // public ResponseEntity add(@RequestBody OtpForm form){ + // var otp=form.getOtp(); + // if(otp==null){ + // return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("NULL VALUE EXCEPTION"); + // } + // else{ + + // boolean result = emailService.add(form); + // if(result) + // { + // return new ResponseEntity(null,HttpStatus.ACCEPTED); + // // return new ResponseEntity.status(HttpStatus.ACCEPTED).body("OTP VERIFICATION SUCCESS"); + // } + // else + // { + // // return new ResponseEntity(null,HttpStatus.BAD_REQUEST); + + // return ResponseEntity.status(HttpStatus.NOT_ACCEPTABLE).body("OTP VERIFICATION FAILED"); + // } + // } + // } + + + + @PostMapping("verifyPassword") + public ResponseEntity addPassword(@RequestBody OtpForm form){ + + var psd=form.getNewPassword(); + var npsd=form.getCnewPassword(); + + if(psd==null || npsd==null){ + return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("NULL VALUE EXCEPTION"); + } + else if(!psd.equals(npsd) ){ + return ResponseEntity.status(HttpStatus.BAD_GATEWAY).body("PASSWORD MISSMATCH"); + } + else{ + + boolean result = emailService.addPassword(form); + if(result) + { + return new ResponseEntity(null,HttpStatus.ACCEPTED); + } + else + { + return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("PASSWORD CHANGE FAILED"); + } +} + + + + + + } diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/controller/UsersController.java b/BackEnd/Library/src/main/java/com/innovature/Library/controller/UsersController.java index a9ec46b2..4c34a15c 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/controller/UsersController.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/controller/UsersController.java @@ -1,8 +1,4 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ + package com.innovature.Library.controller; import java.security.Principal; @@ -13,29 +9,22 @@ import org.springframework.http.HttpStatus; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.Page; -import org.springframework.http.HttpEntity; import org.springframework.http.ResponseEntity; -import org.springframework.util.StringUtils; + import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; -import org.springframework.web.multipart.MultipartFile; -// import java.util.Collection; import javax.validation.Valid; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; -// import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; + import com.innovature.Library.entity.User; -// import com.innovature.Library.entity.User; import com.innovature.Library.form.UserForm; import com.innovature.Library.security.util.SecurityUtil; import com.innovature.Library.service.UserService; @@ -73,6 +62,10 @@ public Collection list(Principal p) { public Collection viewProfile(){ return userService.viewProfile(SecurityUtil.getCurrentUserId()); } + @GetMapping("/admin/viewProfile/") + public Collection viewAdminProfile(){ + return userService.viewProfile(SecurityUtil.getCurrentUserId()); + } @PutMapping("/{userId}") public UserView updates( @@ -87,11 +80,6 @@ public void deletes( userService.deletes(userId); } - // @GetMapping("/{userId}") - // public void deletes( - // @PathVariable("userId") Integer userId) { - // userService.deletes(userId); - // } @GetMapping("/admin/{userId}") @@ -102,7 +90,7 @@ public Collection getUserById( - @GetMapping("admin/pagenated/") + @GetMapping("/admin/pagenated/") public ResponseEntity>getAllBooks( @RequestParam(defaultValue = "1") Integer pageNo, @RequestParam(defaultValue = "10") Integer pageSize, diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/csv_helper/csvHelper.java b/BackEnd/Library/src/main/java/com/innovature/Library/csv_helper/csvHelper.java index 2c44b3df..efb4ee23 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/csv_helper/csvHelper.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/csv_helper/csvHelper.java @@ -21,52 +21,47 @@ import org.springframework.web.multipart.MultipartFile; import com.innovature.Library.entity.csvUpload; + public class csvHelper { - csvUpload Csv; - public static String TYPE="text/csv"; - static String[] HEADERs={"books_name","publications","books_author","booksCopies","categoryId","status"}; + public static String TYPE = "text/csv"; + static String[] HEADERs = { "books_name", "publications", "books_author", "booksCopies", "categoryId", "status" }; - public static boolean hasCSVFormat(MultipartFile file){ + public static boolean hasCSVFormat(MultipartFile file) { System.out.println(file.getContentType()); - if(TYPE.equals(file.getContentType())||file.getContentType().equals("application/vnd.ms-excel")){ + if (TYPE.equals(file.getContentType()) || file.getContentType().equals("application/vnd.ms-excel")) { return true; } return false; } - public static ListcsvToDb(InputStream is){ - try(BufferedReader fileReader=new BufferedReader(new InputStreamReader(is,"UTF-8")); - CSVParser csvParser = new CSVParser(fileReader, - CSVFormat.DEFAULT.withFirstRecordAsHeader().withIgnoreHeaderCase().withTrim());) { - ListcsvList=new ArrayList<>(); - Iterable csvRecords=csvParser.getRecords(); - for(CSVRecord csvRecord:csvRecords){ - csvUpload csvob=new csvUpload( - csvRecord.get("booksName"), - csvRecord.get("publication"), - csvRecord.get("booksAuther"), - Integer.parseInt(csvRecord.get("booksCopies")), - Integer.parseInt(csvRecord.get("categoryId")), - Integer.parseInt(csvRecord.get("status")) - //csvRecord.get("image") - + public static List csvToDb(InputStream is) { + try (BufferedReader fileReader = new BufferedReader(new InputStreamReader(is, "UTF-8")); + CSVParser csvParser = new CSVParser(fileReader, + CSVFormat.DEFAULT.withFirstRecordAsHeader().withIgnoreHeaderCase().withTrim());) { + List csvList = new ArrayList<>(); + Iterable csvRecords = csvParser.getRecords(); + for (CSVRecord csvRecord : csvRecords) { + csvUpload csvob = new csvUpload( + csvRecord.get("booksName"), + csvRecord.get("publication"), + csvRecord.get("booksAuther"), + Integer.parseInt(csvRecord.get("booksCopies")), + Integer.parseInt(csvRecord.get("categoryId")), + Integer.parseInt(csvRecord.get("status")) + // csvRecord.get("image") ); csvList.add(csvob); } return csvList; - - }catch(IOException e){ - throw new RuntimeException("fail to parse csv file"+e.getMessage()); - } - -} - -} + } catch (IOException e) { + throw new RuntimeException("fail to parse csv file" + e.getMessage()); + } - + } +} diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/entity/Email.java b/BackEnd/Library/src/main/java/com/innovature/Library/entity/Email.java index 47eb0356..c9fb5432 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/entity/Email.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/entity/Email.java @@ -3,6 +3,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import java.time.LocalTime; + @Entity public class Email { @@ -13,11 +15,13 @@ public class Email { @GeneratedValue(strategy = GenerationType.IDENTITY) private Integer otpId; - + private String email; private Integer otp; + private LocalTime expiry; + public String getEmail() { return email; @@ -37,6 +41,12 @@ public Integer getOtp() { public void setOtp(Integer otp) { this.otp = otp; } + public LocalTime getExpiry() { + return expiry; + } + public void setExpiry(LocalTime expiry) { + this.expiry = expiry; + } diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/entity/csvUpload.java b/BackEnd/Library/src/main/java/com/innovature/Library/entity/csvUpload.java index aaa7bdbd..28bc9d55 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/entity/csvUpload.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/entity/csvUpload.java @@ -1,5 +1,4 @@ package com.innovature.Library.entity; -import java.util.Date; import javax.persistence.Column; import javax.persistence.Entity; @@ -7,161 +6,116 @@ import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.Table; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; - @Entity -@Table(name="books") - +@Table(name = "books") -public class csvUpload { public static enum Status { - INACTIVE((byte) 0), - ACTIVE((byte) 1); +public class csvUpload { + public static enum Status { + INACTIVE((byte) 0), + ACTIVE((byte) 1); - public final byte value; + public final byte value; - private Status(byte value) { - this.value = value; + private Status(byte value) { + this.value = value; + } } -} -// @Id -// @GeneratedValue(strategy = GenerationType.IDENTITY) -// @Column(name="book_id") -// private Long booksId; - - -@Id -@GeneratedValue(strategy = GenerationType.IDENTITY) -@Column(name="books_id") -private Integer booksId; - -@Column(name="books_name") -private String booksName; - -@Column(name="auther") -private String booksAuther; - -@Column(name="books_copies") -private Integer booksCopies; - -@Column(name = "status") -private Integer status; - -@Column(name="publication") -private String publication; - -@Column(name="category_id") -private Integer categoryId; - -@Column(name="image") -private String image; - -public csvUpload(){ - -} - - -public csvUpload(String booksName,String publication, String booksAuther, Integer booksCopies,Integer categoryId,Integer status) { -this.booksName = booksName; -this.publication = publication; -this.booksAuther = booksAuther; -this.booksCopies = booksCopies; - -this.categoryId = categoryId; -this.status=status; -// this.image = image; - - -} - -@Override -public String toString() { -return "Csv [ booksName=" + booksName + ", booksAuthor=" + booksAuther + ", booksCopies=" + booksCopies - + ", categoryId=" + categoryId + ", status=" + status + "]"; -} - - -// public Long getBooksId() { -// return booksId; -// } - -// public void setBooksId(Long booksId) { -// this.booksId = booksId; -// } + @Id + @GeneratedValue(strategy = GenerationType.IDENTITY) + @Column(name = "books_id") + private Integer booksId; + @Column(name = "books_name") + private String booksName; -public String getBooksName() { - return booksName; -} + @Column(name = "auther") + private String booksAuther; + @Column(name = "books_copies") + private Integer booksCopies; -public void setBooksName(String booksName) { - this.booksName = booksName; -} + @Column(name = "status") + private Integer status; + @Column(name = "publication") + private String publication; -public String getBooksAuther() { - return booksAuther; -} + @Column(name = "category_id") + private Integer categoryId; + @Column(name = "image") + private String image; -public void setBooksAuther(String booksAuther) { - this.booksAuther = booksAuther; -} - - -public Integer getBooksCopies() { - return booksCopies; -} - - -public void setBooksCopies(Integer booksCopies) { - this.booksCopies = booksCopies; -} - - -public Integer getStatus() { - return status; -} + public csvUpload() { + } -public void setStatus(Integer status) { - this.status = status; -} + public csvUpload(String booksName, String publication, String booksAuther, Integer booksCopies, Integer categoryId, + Integer status) { + this.booksName = booksName; + this.publication = publication; + this.booksAuther = booksAuther; + this.booksCopies = booksCopies; + this.categoryId = categoryId; + this.status = status; -public String getPublication() { - return publication; -} + } + @Override + public String toString() { + return "Csv [ booksName=" + booksName + ", booksAuthor=" + booksAuther + ", booksCopies=" + booksCopies + + ", categoryId=" + categoryId + ", status=" + status + "]"; + } -public void setPublication(String publication) { - this.publication = publication; -} + public String getBooksName() { + return booksName; + } + public void setBooksName(String booksName) { + this.booksName = booksName; + } -public Integer getCategoryId() { - return categoryId; -} + public String getBooksAuther() { + return booksAuther; + } + public void setBooksAuther(String booksAuther) { + this.booksAuther = booksAuther; + } -public void setCategoryId(Integer categoryId) { - this.categoryId = categoryId; -} + public Integer getBooksCopies() { + return booksCopies; + } + public void setBooksCopies(Integer booksCopies) { + this.booksCopies = booksCopies; + } -// public String getImage() { -// return image; -// } + public Integer getStatus() { + return status; + } + public void setStatus(Integer status) { + this.status = status; + } -// public void setImage(String image) { -// this.image = image; -// } + public String getPublication() { + return publication; + } + public void setPublication(String publication) { + this.publication = publication; + } + public Integer getCategoryId() { + return categoryId; + } + public void setCategoryId(Integer categoryId) { + this.categoryId = categoryId; + } } \ No newline at end of file diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/repository/BorrowRepository.java b/BackEnd/Library/src/main/java/com/innovature/Library/repository/BorrowRepository.java index 0ac9378f..3cbc1645 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/repository/BorrowRepository.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/repository/BorrowRepository.java @@ -1,10 +1,8 @@ package com.innovature.Library.repository; -import java.sql.Date; import java.util.Collection; import java.util.List; -//import org.springframework.data.repository.Repository; import org.springframework.data.repository.PagingAndSortingRepository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; @@ -15,139 +13,129 @@ public interface BorrowRepository extends PagingAndSortingRepository { - public Borrow save(Collection borrow); + public Borrow save(Collection borrow); - Collection findAll(); + Collection findAll(); - // Optional findByBorrowId(Integer borrowId) - Borrow findByBorrowId(Integer borrowId); + Borrow findByBorrowId(Integer borrowId); - //Collection findByBorrowId(Integer borrowId); + Collection findAllByUserUserId(Integer userId); - Collection findAllByUserUserId(Integer userId); + // load all @ pagenation + public Page findAll(Pageable paging); - -//load all @ pagenation - public Page findAll(Pageable paging); + // load all @ fine pagenation -//load all with userId(in user-login) - public Page findAllByUserUserId(Integer userId,Pageable paging); + @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date findbyBorrowIdandDueDateandStatus(Pageable paging); - - //To select borrow details with user_id,a day before due day - @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date=date_add(curdate(),interval 1 day) and status='APPROVED' and user_id=?1)", nativeQuery = true) - Collection findBorrowIdbyUserId(Integer userId); + // load all with userId(in user-login) + public Page findAllByUserUserId(Integer userId, Pageable paging); - -//at notification of user to pick data when duedate=currrent date - @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date=curdate() and status='APPROVED' and user_id=?1)", nativeQuery = true) - Collection findbyUserIdDueDate(Integer userId); + // To select borrow details with user_id,a day before due day + @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date=date_add(curdate(),interval 1 day) and status='APPROVED' and user_id=?1)", nativeQuery = true) + Collection findBorrowIdbyUserId(Integer userId); + // at notification of user to pick data when duedate=currrent date + @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date=curdate() and status='APPROVED' and user_id=?1)", nativeQuery = true) + Collection findbyUserIdDueDate(Integer userId); + // To select all user(without used_id) by due date expired(@admin side) + @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date findbyBorrowIdandStatus(); + @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date findbyBorrowIdandDueDateandStatus(); - //To select all user(without used_id) by due date expired(@admin side) - @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date findbyBorrowIdandStatus(); + // To select user by due date expired + @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date findbyUserIdandStatus(Integer userId); + // @Query(value = "select email from user where user_id in(select user_id from + // borrow where borrow_id in(select borrow_id from borrow where + // due_date findbyBorrowId(); - @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date findbyBorrowIdandDueDateandStatus(); + @Query(value = "update borrow set due_days=DATEDIFF(curdate(),due_date) WHERE borrow_id=?", nativeQuery = true) + void findDueDays(Integer borrowId); - - //To select user by due date expired - @Query(value = "select * from borrow where borrow_id in(select borrow_id from borrow where due_date findbyUserIdandStatus(Integer userId); + // total sum of fine /user + // @Query(value=" select sum(fine) from borrow where + // user_id=?",nativeQuery=true) + // LOAD-FILTER @ADMIN ### ON-Load Filterd results + @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and status!='REQUESTED'", nativeQuery = true) + List findbyIssuDate(java.sql.Date date1, java.sql.Date date2); + // GET FILTER-RSLT @ADMIN- filtered results + @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and status!='REQUESTED'", nativeQuery = true) + public Page findbyIssuDate(java.sql.Date date1, java.sql.Date date2, Pageable paging); - // @Query(value = "select email from user where user_id in(select user_id from borrow where borrow_id in(select borrow_id from borrow where due_date findbyBorrowIdandStatus(); + // test + @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and status!='REQUESTED'", nativeQuery = true) + public Page findbyIssuDat(java.sql.Date date1, java.sql.Date date2, Pageable paging); - @Query(value = "select * from borrow where status='APPROVED' and due_date findbyBorrowId(); + // Load Filterd results at user borrow history + @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and user_id=?1", nativeQuery = true) + List findbyIssuDateAndUserId(java.sql.Date date1, java.sql.Date date2); - @Query(value="update borrow set due_days=DATEDIFF(curdate(),due_date) WHERE borrow_id=?",nativeQuery=true) - void findDueDays(Integer borrowId); + // to get total books in-hand by user + @Query(value = "select count(user_id) from borrow where status='APPROVED' and user_id=?1", nativeQuery = true) + Integer findbyUserIdAndStatus(Integer userId); - //total sum of fine /user - // @Query(value=" select sum(fine) from borrow where user_id=?",nativeQuery=true) - // void findFineByUserId(Integer userId); public Page findAll(Pageable paging); + // @Query(value = "SELECT * FROM borrow",nativeQuery = true) + // filter by approved in ADMIN SIDE + @Query(value = "select * from borrow where status='APPROVED' and user_id=?", nativeQuery = true) + public Page findByApprovedStatusUser(Pageable paging); + // @Query(value = "select * from borrow where issue_date between + // date_sub(curdate(),interval 7 day) and curdate()",nativeQuery = true) - //LOAD-FILTER @ADMIN ### ON-Load Filterd results - @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and status!='REQUESTED'", nativeQuery = true) - List findbyIssuDate(java.sql.Date date1,java.sql.Date date2); - -//GET FILTER-RSLT @ADMIN- filtered results - @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and status!='REQUESTED'", nativeQuery = true) - public Page findbyIssuDate( java.sql.Date date1,java.sql.Date date2,Pageable paging); + // filter by approved + @Query(value = "select * from borrow where status='APPROVED' and user_id=?", nativeQuery = true) + public Page findByAppStatusUser(Integer userId, Pageable paging); + // filter by rejected + @Query(value = "select * from borrow where status='REJECTED' and user_id=?", nativeQuery = true) + public Page findByRejStatusUser(Integer userId, Pageable paging); - //test - @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and status!='REQUESTED'", nativeQuery = true) - public Page findbyIssuDat( java.sql.Date date1,java.sql.Date date2,Pageable paging); + // filter by returned + @Query(value = "select * from borrow where status='RETURNED' and user_id=?", nativeQuery = true) + public Page findByRetStatusUser(Integer userId, Pageable paging); - // public Page findbyIssuDate(java.util.Date date1, java.util.Date date2, Pageable paging); + // filter by requested + @Query(value = "select * from borrow where status='REQUESTED' and user_id=?", nativeQuery = true) + public Page findByReqStatusUser(Integer userId, Pageable paging); + @Query(value = "SELECT * FROM borrow", nativeQuery = true) + List findAllC(); - //Load Filterd results at user borrow history - @Query(value = "select * from borrow where issue_date between DATE(?1) and DATE(?2) and user_id=?1", nativeQuery = true) - List findbyIssuDateAndUserId(java.sql.Date date1,java.sql.Date date2); + @Query(value = "select * from borrow where issue_date between date_sub(curdate(),interval 7 day) and curdate()", nativeQuery = true) + List findAllL7(); + // @Query(value = "Select * from borrow where books_name like %?1% order by + // books_name like ?2% DESC,books_name like %?3 DESC,books_name like %?4% ", + // nativeQuery = true) - //to get total books in-hand by user - @Query(value = "select count(user_id) from borrow where status='APPROVED' and user_id=?1", nativeQuery = true) - Integer findbyUserIdAndStatus(Integer userId); - + // @Query(value = "SELECT * FROM borrow INNER JOIN user ON borrow.user_id = + // user.user_id where first_name like %?1% order by first_name like ?2% + // DESC,first_name like %?3 DESC,first_name like %?4% ", nativeQuery = true) - // @Query(value = "SELECT * FROM borrow",nativeQuery = true) - // ListfindAllC(); + // @Query(value = "select * from borrow where user_id in(select user_id from + // user where first_name like %?%", nativeQuery = true) - // @Query(value = "select * from borrow where issue_date between date_sub(curdate(),interval 7 day) and curdate()",nativeQuery = true) - // ListfindAllC(); + // select count(borrow_id) from borrow where book_returned_date between + // '2023-01-01' and '2023-01-07' + // select count(borrow_id) from borrow where book_returned_date='2022-12-27' - // filter by approved - @Query(value = "select * from borrow where status='APPROVED' and user_id=?", nativeQuery = true) - public Page findByAppStatusUser(Integer userId,Pageable paging); - - // filter by rejected - @Query(value = "select * from borrow where status='REJECTED' and user_id=?", nativeQuery = true) - public Page findByRejStatusUser(Integer userId,Pageable paging); - - //filter by returned - @Query(value = "select * from borrow where status='RETURNED' and user_id=?", nativeQuery = true) - public Page findByRetStatusUser(Integer userId,Pageable paging); - - //filter by requested - @Query(value = "select * from borrow where status='REQUESTED' and user_id=?", nativeQuery = true) - public Page findByReqStatusUser(Integer userId,Pageable paging); - - - @Query(value = "SELECT * FROM borrow",nativeQuery = true) - ListfindAllC(); - - @Query(value = "select * from borrow where issue_date between date_sub(curdate(),interval 7 day) and curdate()",nativeQuery = true) - ListfindAllL7(); - - // @Query(value = "Select * from borrow where books_name like %?1% order by books_name like ?2% DESC,books_name like %?3 DESC,books_name like %?4% ", nativeQuery = true) - // public Page findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable); - - - // @Query(value = "SELECT * FROM borrow INNER JOIN user ON borrow.user_id = user.user_id where first_name like %?1% order by first_name like ?2% DESC,first_name like %?3 DESC,first_name like %?4% ", nativeQuery = true) - // public Page findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable); - - // @Query(value = "select * from borrow where user_id in(select user_id from user where first_name like %?%", nativeQuery = true) - // public Page findByKeywords(String keyword, String k, String k1, String k2, Pageable pageable); - - - } - - //mysql> select count(borrow_id) from borrow where book_returned_date between '2023-01-01' and '2023-01-07'; - //select count(borrow_id) from borrow where book_returned_date='2022-12-27'; - - // inner join eg = SELECT user.first_name FROM borrow INNER JOIN user ON borrow.user_id = user.user_id - // >no innerjoin= select user.first_name from user,borrow where user.user_id=borrow.user_id; - //>select * from borrow where user_id in(select user_id from user where first_name like 'ashwin'); \ No newline at end of file + // inner join eg = SELECT user.first_name FROM borrow INNER JOIN user ON + // borrow.user_id = user.user_id + // >no innerjoin= select user.first_name from user,borrow where + // user.user_id=borrow.user_id + // >select * from borrow where user_id in(select user_id from user where + // first_name like 'ashwin') + +} diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/repository/EmailRepository.java b/BackEnd/Library/src/main/java/com/innovature/Library/repository/EmailRepository.java index 134fa683..4e31ab7a 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/repository/EmailRepository.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/repository/EmailRepository.java @@ -6,14 +6,13 @@ import com.innovature.Library.entity.Email; - -public interface EmailRepository extends Repository { +public interface EmailRepository extends Repository { void deleteAll(); Email save(Email email); - CollectionfindAll(); + Collection findAll(); Email findByEmail(String email); diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/service/BorrowService.java b/BackEnd/Library/src/main/java/com/innovature/Library/service/BorrowService.java index 58ef4199..e1f737f3 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/service/BorrowService.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/service/BorrowService.java @@ -38,6 +38,8 @@ public interface BorrowService { List getAllBorrows(Integer pageNo, Integer pageSize, String sortBy); Page getAllBorr(Integer pageNo, Integer pageSize, String sortBy,Integer direction); + Page getAllFine(Integer pageNo, Integer pageSize, String sortBy,Integer direction); //fine + List getAllBorrow(Date date1, Date date2, Integer pageNo, Integer pageSize, String sortBy); Page getAllBor(Date date1, Date date2, Integer pageNo, Integer pageSize, String sortBy,Integer direction); diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/service/CategoryService.java b/BackEnd/Library/src/main/java/com/innovature/Library/service/CategoryService.java index 1a618b6a..fa5f3ca6 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/service/CategoryService.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/service/CategoryService.java @@ -2,21 +2,9 @@ import java.util.Collection; import org.springframework.data.domain.Page; - -//import javax.validation.Valid; - -// import org.springframework.http.HttpEntity; -// import javax.validation.Valid; -// import org.springframework.validation.Errors; import com.innovature.Library.view.CategoryDetailView; -// import com.innovature.Library.entity.Category; -//import com.innovature.Library.view.CategoryListView; import com.innovature.Library.entity.Category; -//import com.innovature.Library.exception.NotFoundException; import com.innovature.Library.form.CategoryForm; -// import com.innovature.Library.entity.Category; -// import com.innovature.Library.exception.BadRequestException; -// import com.innovature.Library.exception.NotFoundException; public interface CategoryService { diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/service/EmailService.java b/BackEnd/Library/src/main/java/com/innovature/Library/service/EmailService.java index dc2e95fc..ac2a77f7 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/service/EmailService.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/service/EmailService.java @@ -1,12 +1,14 @@ package com.innovature.Library.service; - +import org.springframework.http.ResponseEntity; import com.innovature.Library.form.OtpForm; public interface EmailService { boolean sendEmail(String subject, String message, String sentto); // boolean sendOtpEmail(String subject, String message, String sentto); - boolean add(OtpForm form); + ResponseEntity add(OtpForm form); + + boolean addPassword(OtpForm form); } diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BooksServiceImpl.java b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BooksServiceImpl.java index e04cf32f..38b6a1ad 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BooksServiceImpl.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BooksServiceImpl.java @@ -1,14 +1,10 @@ package com.innovature.Library.service.impl; import java.io.IOException; -import java.util.ArrayList; -// import java.net.http.HttpHeaders; import java.util.Collection; import java.util.List; -//import java.util.ArrayList; import javax.transaction.Transactional; -//import java.util.Collection; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -17,8 +13,6 @@ import org.springframework.stereotype.Service; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.view.RedirectView; - - import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -36,7 +30,7 @@ import com.innovature.Library.util.FileUtil; @Service -public class BooksServiceImpl implements BooksService{ +public class BooksServiceImpl implements BooksService { @Autowired private BooksRepository booksRepository; @@ -45,140 +39,129 @@ public class BooksServiceImpl implements BooksService{ CategoryRepository catRepo; @Override - public BooksDetailView add(BooksForm form){ - Category category=catRepo.findByCategoryId(form.getCategoryId()); - return new BooksDetailView(booksRepository.save(new Books(form,category))); + public BooksDetailView add(BooksForm form) { + Category category = catRepo.findByCategoryId(form.getCategoryId()); + return new BooksDetailView(booksRepository.save(new Books(form, category))); } - @Override - public Collection listAll() { - return booksRepository.findAll(); - } + public Collection listAll() { + return booksRepository.findAll(); + } @Override - public Collection listByCategory(Integer categoryId) { - return booksRepository.findbyCategoryId(categoryId); - } - + public Collection listByCategory(Integer categoryId) { + return booksRepository.findbyCategoryId(categoryId); + } @Override public BooksDetailView list(Integer booksId) { - Books books=booksRepository.findByBooksId(booksId); + Books books = booksRepository.findByBooksId(booksId); return new BooksDetailView(books); } - @Override @Transactional - public BooksDetailView updates(Integer booksId, BooksForm form) { + public BooksDetailView updates(Integer booksId, BooksForm form) { - Category category=catRepo.findByCategoryId(form.getCategoryId()); - Books books=booksRepository.findByBooksId(booksId); + Category category = catRepo.findByCategoryId(form.getCategoryId()); + Books books = booksRepository.findByBooksId(booksId); books.setCategory(category); books.setPublication(form.getPublication()); books.setBooksName(form.getBooksName()); books.setAuther(form.getAuther()); books.setBooksCopies(form.getBooksCopies()); - // return new BooksDetailView(booksRepository.save(new Books(form,category))); + return new BooksDetailView(books); } @Override public void deletes(Integer categoryId) throws NotFoundException { booksRepository.delete( - booksRepository.findByBooksId(categoryId) - + booksRepository.findByBooksId(categoryId) + ); } @Override public HttpEntity getImagePic(Integer booksId) { - + String image = booksRepository.findByBooksId(booksId) .getImage(); - + byte[] file = FileUtil.getImage(image); - + HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.IMAGE_PNG); headers.setContentLength(file.length); - + return new HttpEntity<>(file, headers); } - @Override public RedirectView uploadImage(MultipartFile multipartFile) throws IOException { // TODO Auto-generated method stub return null; } - @Override @Transactional - public PagegetAllBooks(Integer pageNo, Integer pageSize, String sortBy,Integer direction){ - - var sortByDescending=Sort.by(sortBy).descending(); - var sortByAscending=Sort.by(sortBy).ascending(); + public Page getAllBooks(Integer pageNo, Integer pageSize, String sortBy, Integer direction) { + + var sortByDescending = Sort.by(sortBy).descending(); + var sortByAscending = Sort.by(sortBy).ascending(); - if(direction==1){ + if (direction == 1) { Pageable paging = PageRequest.of(pageNo, pageSize, sortByDescending); Page pagedResult = booksRepository.findAll(paging); - return pagedResult; + return pagedResult; } - else - { + else { Pageable paging = PageRequest.of(pageNo, pageSize, sortByAscending); Page pagedResult = booksRepository.findAll(paging); - return pagedResult; + return pagedResult; } } - //pie + // pie @Override public List getBookCountByCategory() { return booksRepository.findCountByCategoryId(); } - //book search + // book search @Override - public Page getAllBookStocks(String keyword, Integer pageNo, Integer pageSize, String sortBy,Integer direction) { + public Page getAllBookStocks(String keyword, Integer pageNo, Integer pageSize, String sortBy, + Integer direction) { - var sortByDescending=Sort.by(sortBy).descending(); - var sortByAscending=Sort.by(sortBy).ascending(); + var sortByDescending = Sort.by(sortBy).descending(); + var sortByAscending = Sort.by(sortBy).ascending(); - if(direction==1){ + if (direction == 1) { Pageable paging = PageRequest.of(pageNo, pageSize, sortByDescending); - System.out.println(keyword); - String k = keyword; - String k1 = keyword; - String k2 = keyword; - Page pagedResult = booksRepository.findByKeywords(keyword, k, k1, k2, paging); - return pagedResult; + + String k = keyword; + String k1 = keyword; + String k2 = keyword; + Page pagedResult = booksRepository.findByKeywords(keyword, k, k1, k2, paging); + return pagedResult; } - else - { + else { Pageable paging = PageRequest.of(pageNo, pageSize, sortByAscending); - System.out.println(keyword); + String k = keyword; String k1 = keyword; String k2 = keyword; Page pagedResult = booksRepository.findByKeywords(keyword, k, k1, k2, paging); - return pagedResult; + return pagedResult; } - - } } - - - diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BorrowServiceImpl.java b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BorrowServiceImpl.java index 22cb9ea1..ece74553 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BorrowServiceImpl.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/BorrowServiceImpl.java @@ -2,16 +2,11 @@ import java.util.ArrayList; import java.util.Collection; -// import java.util.Date; import java.util.Date; -//import java.sql.Date; -import java.time.LocalDate; + import java.time.LocalDateTime; -import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; -import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -42,13 +37,12 @@ import com.innovature.Library.view.BorrowListView; import com.innovature.Library.view.rentChartView; -import java.util.List; + @Service public class BorrowServiceImpl implements BorrowService { - // @Autowired - // private JavaMailSender mailSender; + @Autowired private JavaMailSender mailSender; @@ -61,15 +55,13 @@ public class BorrowServiceImpl implements BorrowService { @Autowired UserRepository userRepository; - // private Object mailSender; + @Override public BorrowDetailView add(BorrowForm form) { Books books = booksRepository.findByBooksId(form.getBooksId()); User user = userRepository.findById(SecurityUtil.getCurrentUserId()); - // String status= form.setStatus("REQUESTED"); - // return new BorrowDetailView(borrowRepository.save(new - // Borrow(form,books,user))); + return new BorrowDetailView(borrowRepository.save(new Borrow(books, user))); @@ -95,10 +87,7 @@ public Collection listDueByUser() { return borrowRepository.findbyUserIdandStatus(SecurityUtil.getCurrentUserId()); } - @Override - public Collection fine() { - return borrowRepository.findbyBorrowIdandDueDateandStatus(); - } + @Override public Borrow BorrowDetail(Integer borrowId) { @@ -155,13 +144,7 @@ public BorrowDetailView updates(Integer borrowId, BorrowForm form) { public BorrowDetailView updatereject(Integer borrowId, BorrowForm form) { Borrow borrow = borrowRepository.findByBorrowId(borrowId); - // Books books=booksRepository.findByBooksId(borrowId); - // borrow.setIssueDate("NA"); - // borrow.setDueDate("NA"); - // borrow.setReturnDate("NA"); - // String status= form.setStatus("REQUESTED"); - // category.setCategoryName(form.getCategoryName()); borrow.setReason(form.getReason()); borrow.setIssueDate(null); borrow.setReturnDate(null); @@ -178,10 +161,11 @@ public BorrowDetailView updateReturn(Integer borrowId, BorrowForm form) { Books books = booksRepository.findbyBorrowId(borrowId); borrow.setBookReturnedDate(LocalDateTime.now()); - borrow.setIssueDate(borrow.getIssueDate()); - borrow.setReturnDate(borrow.getReturnDate()); - borrow.setDueDate(borrow.getDueDate()); + // borrow.setIssueDate(borrow.getIssueDate()); + // borrow.setReturnDate(borrow.getReturnDate()); + // borrow.setDueDate(borrow.getDueDate()); borrow.setStatus("RETURNED"); + borrow.setBookReturnedDate(borrow.getBookReturnedDate()); books.setBooksCopies(books.getBooksCopies() + 1); return new BorrowDetailView(borrowRepository.save(borrow)); } @@ -228,7 +212,7 @@ public List getAllBorrow(java.sql.Date date1, java.sql.Date date2, Integ public Page getAllBor(java.sql.Date date1, java.sql.Date date2, Integer pageNo, Integer pageSize, String sortBy, Integer direction) { - // Pageable paging = PageRequest.of(pageNo, pageSize, Sort .by(sortBy)); + var sortByDescending = Sort.by(sortBy).descending(); var sortByAscending = Sort.by(sortBy).ascending(); @@ -245,9 +229,7 @@ public Page getAllBor(java.sql.Date date1, java.sql.Date date2, Integer return pagedResult; } - // Page pagedResult = - // borrowRepository.findbyIssuDat(date1,date2,paging); - // return pagedResult; + } @@ -287,10 +269,13 @@ public Page getAllBorr(Integer pageNo, Integer pageSize, String sortBy, Page pagedResult = borrowRepository.findAll(paging); return pagedResult; } - // return pagedResult; + } + + + @Override @Transactional public List getBorrowHistory(Integer pageNo, Integer pageSize, String sortBy) { @@ -306,37 +291,44 @@ public List getBorrowHistory(Integer pageNo, Integer pageSize, String so } } - // @Override - // public Collection list1() { - // return borrowRepository.findAllByUserUserId(SecurityUtil.getCurrentUserId()); - // } - - // mail// - // @Override - // @Transactional - // @Scheduled(cron="*/50 * * * * * ") - // public void sendMail(Integer userId,String subject,String text) { - // System.out.println("ssss"); - // // User user = userRepository.findByUserId(userId); - // User user=userRepository.findById(userId); - - // SimpleMailMessage simpleMailMessage = new SimpleMailMessage(); - // simpleMailMessage.setFrom("bookstore.shopp@gmail.com"); - // simpleMailMessage.setTo(user.getEmail()); - // simpleMailMessage.setSubject(subject); - // simpleMailMessage.setText(text); - - // this.mailSender.send(simpleMailMessage); - // } + @Override + public Collection fine() { + return borrowRepository.findbyBorrowIdandDueDateandStatus(); + } + + // @admin borrow oninit + @Override + @Transactional + public Page getAllFine(Integer pageNo, Integer pageSize, String sortBy, Integer direction) { + + var sortByDescending = Sort.by(sortBy).descending(); + + var sortByAscending = Sort.by(sortBy).ascending(); + + if (direction == 1) { + + Pageable paging = PageRequest.of(pageNo, pageSize, sortByDescending); + Page pagedResult = borrowRepository.findbyBorrowIdandDueDateandStatus(paging); + return pagedResult; + } + + else { + Pageable paging = PageRequest.of(pageNo, pageSize, sortByAscending); + Page pagedResult = borrowRepository.findbyBorrowIdandDueDateandStatus(paging); + return pagedResult; + } + + + } + + @Override @Transactional // @Scheduled(cron="* */1 * * * * ") @Scheduled(cron = "0 0 12 * * ?") public void sendMails() { - System.out.println("Email sent successfully"); - - // User user=userRepository.findById(userId); + Collection borrow = borrowRepository.findbyBorrowIdandStatus(); for (Borrow bor : borrow) { User user = userRepository.findById(bor.getUser().getUserId()); // fetching uid from user @@ -363,14 +355,11 @@ public void sendMail(Integer userId, String subject, String text) { @Transactional // @Scheduled(cron="* */1 * * * * ") @Scheduled(cron = "0 0 10 * * ?") - public void fineGeneration() { - System.out.println("reachllllllllllllll"); + public void fineGeneration() { Collection borrow = borrowRepository.findbyBorrowId(); - System.out.println("hereeeeeeeeeeeeeee"); - for (Borrow bor : borrow) { - System.out.println(bor.getBorrowId()); + Date d = new Date(); Long due = d.getTime() - bor.getDueDate().getTime(); // date conversion to time due = due / 86400000; // time conversion to date @@ -401,11 +390,9 @@ public rentChartView getChart() { for (Borrow a : s) { if(a.getIssueDate()!=null) { - + LocalDateTime b = a.getIssueDate(); - System.out.println("---------------------------" + b); - // System.out.println("........>>>>>>>>>>>>>>>>....."+ - // b.getDayOfWeek().getValue()); + hm.put(b.getDayOfWeek().getValue(), new Result(hm.get(b.getDayOfWeek().getValue()).getIssueCount() + 1, hm.get(b.getDayOfWeek().getValue()).getReturnedCount())); @@ -416,12 +403,10 @@ public rentChartView getChart() { if (a.getStatus().equals("RETURNED")) { c = a.getBookReturnedDate(); - System.out.println("cccccccccccccccccccccccccccccccccccccccccc=" + c); hm.put(c.getDayOfWeek().getValue(), new Result(hm.get(c.getDayOfWeek().getValue()).getIssueCount(), hm.get(c.getDayOfWeek().getValue()).getReturnedCount() + 1)); - System.out.println(hm.get(c.getDayOfWeek().getValue()).getReturnedCount()); } } for (Map.Entry mapElement : hm.entrySet()) { @@ -460,8 +445,7 @@ public void setReturnedCount(Integer returnedCount) { @Override @Transactional - public Page getAllBorrByStat(Integer pageNo, Integer pageSize, String sortBy, Integer direction, - Integer status) { + public Page getAllBorrByStat(Integer pageNo, Integer pageSize, String sortBy, Integer direction,Integer status) { var sortByDescending = Sort.by(sortBy).descending(); @@ -499,16 +483,19 @@ else if (direction == -1 && status == 2) { Page pagedResult = borrowRepository.findByRejStatusUser(SecurityUtil.getCurrentUserId(), paging); return pagedResult; - } else if (direction == -1 && status == 3) { + } + else if (direction == -1 && status == 3) { Pageable paging = PageRequest.of(pageNo, pageSize, sortByAscending); Page pagedResult = borrowRepository.findByRetStatusUser(SecurityUtil.getCurrentUserId(), paging); return pagedResult; - } else if (direction == -1 && status == 4) { + } + else if (direction == -1 && status == 4) { Pageable paging = PageRequest.of(pageNo, pageSize, sortByAscending); Page pagedResult = borrowRepository.findByReqStatusUser(SecurityUtil.getCurrentUserId(), paging); return pagedResult; - } else { + } + else { return null; } } @@ -518,7 +505,7 @@ else if (direction == -1 && status == 2) { public BorrowDetailView updatePaymentStatus(Integer borrowId, BorrowForm form) { Borrow borrow = borrowRepository.findByBorrowId(borrowId); - Books books = booksRepository.findbyBorrowId(borrowId); + borrow.setPaymentStatus("PAID"); return new BorrowDetailView(borrowRepository.save(borrow)); @@ -530,19 +517,6 @@ public List listcsv() { } -// @Override -// public Page getAllBorrowedUserSearch(String keyword, Integer pageNo, Integer pageSize) { -// Pageable paging = PageRequest.of(pageNo, pageSize); -// System.out.println(keyword); -// String k = keyword; -// String k1 = keyword; -// String k2 = keyword; -// Page pagedResult = borrowRepository.findByKeywords(keyword, k, k1, k2, paging); -// return pagedResult; - -// } - - diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/EmailServiceImpl.java b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/EmailServiceImpl.java index 8c6ac643..786322dc 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/EmailServiceImpl.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/EmailServiceImpl.java @@ -6,17 +6,17 @@ import com.innovature.Library.repository.EmailRepository; import com.innovature.Library.repository.UserRepository; import com.innovature.Library.service.EmailService; - +import org.springframework.http.ResponseEntity; +import org.springframework.http.HttpStatus; import java.util.Properties; - - - import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; import javax.mail.Session; +import java.time.LocalTime; +import java.time.temporal.ChronoUnit; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.security.crypto.password.PasswordEncoder; @@ -24,7 +24,7 @@ @Service public class EmailServiceImpl implements EmailService { - + @Autowired private EmailRepository emailRepository; @@ -33,104 +33,126 @@ public class EmailServiceImpl implements EmailService { @Autowired private UserRepository userRepository; - - + + + @Override - public boolean add(OtpForm form){ - System.out.println("----------------------------"); - Email otp=emailRepository.findByEmail(form.getEmail()); - User user=userRepository.findByEmailId(form.getEmail()); - System.out.println(form.getEmail()); - // System.out.println(form.getOtp()); - System.out.println(otp); + public ResponseEntity add(OtpForm form) { + + Email otp = emailRepository.findByEmail(form.getEmail()); + + LocalTime myObj = LocalTime.now(); + + var exp = otp.getExpiry().until(myObj, ChronoUnit.SECONDS); + if ((form.getOtp().equals(otp.getOtp()))) { - System.out.println("----------inside if of otp ==-------"); + + if (exp < 181) { + + return new ResponseEntity(null,HttpStatus.ACCEPTED); + + } + //otp expiry + return new ResponseEntity(null,HttpStatus.GATEWAY_TIMEOUT); + + } + return new ResponseEntity(null,HttpStatus.NOT_ACCEPTABLE); +} + + +// @Override +// public boolean add(OtpForm form) { + +// Email otp = emailRepository.findByEmail(form.getEmail()); + +// LocalTime myObj = LocalTime.now(); + +// var exp = otp.getExpiry().until(myObj, ChronoUnit.SECONDS); + +// if ((form.getOtp().equals(otp.getOtp()))) { + +// if (exp < 181) { + +// return true; + +// } +// return false; + +// } +// return false; +// } + + + + +@Override +public boolean addPassword(OtpForm form) { + + User user = userRepository.findByEmailId(form.getEmail()); + if (form.getNewPassword().equals(form.getCnewPassword())) - + { - System.out.println("----------inside if of passwrd ==-------"); + user.setPassword(passwordEncoder.encode(form.getNewPassword())); userRepository.save(user); return true; - } + } return false; - - } - else{ - return false; - } - } - - - - - - - - - - - - @Override - public boolean sendEmail(String subject, String message, String to) - { + } - User user=userRepository.findByEmailId(to); - if(user!=null){ - boolean s=false; - String senderEmail="stormhokspam@gmail.com"; - String senderPassword="cyckyhziponehguf"; - - Properties properties = new Properties(); - properties.put("mail.smtp.auth", "true"); - properties.put("mail.smtp.starttls.enable", "true"); - properties.put("mail.smtp.host", "smtp.gmail.com"); - properties.put("mail.smtp.port", "587"); // 587 is TLS port number - Session session = Session.getInstance(properties, new Authenticator() - { - protected PasswordAuthentication getPasswordAuthentication(){ - - return new PasswordAuthentication(senderEmail, senderPassword); - } - }); - try { - MimeMessage msg = new MimeMessage(session); + @Override + public boolean sendEmail(String subject, String message, String to) { - msg.setFrom(new InternetAddress(senderEmail)); + User user = userRepository.findByEmailId(to); + if (user != null) { - msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); + boolean s = false; + String senderEmail = "stormhokspam@gmail.com"; + String senderPassword = "cyckyhziponehguf"; - msg.setSubject(subject); - msg.setText(message); - Transport.send(msg); + Properties properties = new Properties(); + properties.put("mail.smtp.auth", "true"); + properties.put("mail.smtp.starttls.enable", "true"); + properties.put("mail.smtp.host", "smtp.gmail.com"); + properties.put("mail.smtp.port", "587"); // 587 is TLS port number + Session session = Session.getInstance(properties, new Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { - s = true; + return new PasswordAuthentication(senderEmail, senderPassword); + } + }); - }catch(Exception e){ + try { - } - return s; - } + MimeMessage msg = new MimeMessage(session); - else{ - return (Boolean) null; - } - - - - } + msg.setFrom(new InternetAddress(senderEmail)); + msg.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); + msg.setSubject(subject); + msg.setText(message); + Transport.send(msg); + s = true; + } catch (Exception e) { + } + return s; + } + else { + return (Boolean) null; + } + } } \ No newline at end of file diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/UserServiceImpl.java b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/UserServiceImpl.java index fd9ce1a8..36dea071 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/UserServiceImpl.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/service/impl/UserServiceImpl.java @@ -1,21 +1,17 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ + package com.innovature.Library.service.impl; import static com.innovature.Library.security.AccessTokenUserDetailsService.PURPOSE_ACCESS_TOKEN; import java.util.Collection; import javax.transaction.Transactional; -//import javax.validation.Valid; + import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Sort; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.domain.Page; + import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Service; import org.springframework.validation.Errors; @@ -133,11 +129,6 @@ private static BadRequestException badRequestException() { return new BadRequestException("Invalid credentials"); } - // @Override - // public Collection list() { - // return userRepository.findAll(); - // } - @@ -178,7 +169,7 @@ public Collection listAll() { @Override public UserView edit(Integer userId,UserForm form) { - // Integer userId=SecurityUtil.getCurrentUserId(); + User user=userRepository.findById(userId); user.edit( @@ -195,8 +186,7 @@ public UserView edit(Integer userId,UserForm form) { } @Override public Collection viewProfile(Integer userId) { - //User user=userRepository.findById(userId); - // return UserView( userRepository.save(user)); + return userRepository.findByUserId(userId); } diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/view/BooksListView.java b/BackEnd/Library/src/main/java/com/innovature/Library/view/BooksListView.java index 12e1024b..e482ffb4 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/view/BooksListView.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/view/BooksListView.java @@ -1,6 +1,6 @@ package com.innovature.Library.view; -//import com.innovature.Library.entity.Books; + import com.innovature.Library.entity.Category; public class BooksListView { @@ -9,7 +9,6 @@ public class BooksListView { private CategoryDetailView category; private final String publication; private final String auther; - // private final String status; private final Integer booksCopies; private String image; @@ -21,21 +20,11 @@ public BooksListView(int booksId, String booksName,Category category,String publ this.category = new CategoryDetailView(category); this.publication = publication; this.auther = auther; - // this.status = status; - this.image=image; + + this.booksCopies = booksCopies; } - // public BooksListView(int booksId, String booksName,Integer categoryId,String categoryName,String publication,String auther,String booksCopies) - // { - - // this.booksId = booksId; - // this.booksName = booksName; - // this.category = new Category(categoryId,categoryName); - // this.publication = publication; - // this.auther = auther; - // // this.status = status; - // this.booksCopies = booksCopies; - // } + diff --git a/BackEnd/Library/src/main/java/com/innovature/Library/view/BorrowDetailView.java b/BackEnd/Library/src/main/java/com/innovature/Library/view/BorrowDetailView.java index 5344a723..dc0a8bea 100644 --- a/BackEnd/Library/src/main/java/com/innovature/Library/view/BorrowDetailView.java +++ b/BackEnd/Library/src/main/java/com/innovature/Library/view/BorrowDetailView.java @@ -1,6 +1,6 @@ package com.innovature.Library.view; -// import java.util.Date; + import com.innovature.Library.entity.Borrow; diff --git a/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.css b/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.css index 81d3e152..e5adf59a 100644 --- a/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.css +++ b/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.css @@ -1,80 +1,35 @@ -p{ - padding: 0px 0px 30px 1000px; - margin: 0px; - background-color: rgb(0, 0, 0); - /* background-image: url('../../../a.png'); */ - -} - -.btnhome{ - margin-top: 20px; - margin-bottom: 10px; - padding: 7; - border-color: rgb(124, 241, 134); - background-color: rgba(83, 254, 3, 0.853); - font-size: 13px; - border-radius: 25px; - -} .text-danger1{ - width: 160%; + /* width: 160%; */ padding: 8px 6px; margin: 0px; box-sizing: border-box; - border: 1px ; + border: 1px ; background-color: #a7bdb08f; color: rgb(0, 0, 0); - border-radius: 7px; + border-radius: 7px; } -.date{ - width: 160%; - padding: 8px 6px; - margin: 0px; - box-sizing: border-box; - border: 1px ; - background-color: #a7bdb08f; - color: rgb(0, 0, 0); - border-radius: 7px; -} -.btn{ - width: 150%; - padding: 7px 2px; - margin: 5px ; - box-sizing: border-box; - border: 2px solid rgb(250, 97, 97); - background-color:rgba(106, 215, 56, 0.682); - color: rgb(0, 0, 0); - border-radius: 7px; -} -.table-bordered{ - border: 1px solid; -} -th { - background-color: #232524; - color: white; - width: 15%; - text-align: center; - } + + + + td { - background-color: #a7bdb08f; - color: rgb(0, 0, 0); - width: 15%; - text-align: center; + + width: 50%; + height: 50%; + text-align: left; margin-top: auto; - padding: auto; + padding: 5%; + padding-left: 4%; } - .btnList{ - border: none; - padding: 1px; - background: rgb(0, 0, 0); - font-size: 13px; - font-style: italic ; - color: rgb(255, 255, 255); - border-radius: 3px; + +table{ + text-align: left; + /* margin-left: 40%;*/ + margin-top:5%; } diff --git a/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.html b/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.html index cabb0a75..cfa4bded 100644 --- a/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.html +++ b/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.html @@ -2,32 +2,27 @@
-

+
- + - - - -
- -
Return Date      
+ -
Due Date             -
+ -


- -
+ Return Date Return Date is required -

+
Due Date Due Date is required -
+
- + + + + +
-
+ diff --git a/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.ts b/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.ts index d384c8d1..b12d14e8 100644 --- a/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.ts +++ b/FrontEnd/Library/src/app/acceptrequest/acceptrequest.component.ts @@ -4,7 +4,6 @@ import { Router } from '@angular/router'; import { NgToastService } from 'ng-angular-popup'; import { BooksService } from '../books.service'; import { BorrowService } from '../borrow.service'; -import { CategoryService } from '../category.service'; @Component({ selector: 'app-acceptrequest', @@ -22,22 +21,19 @@ export class AcceptrequestComponent implements OnInit { private toast : NgToastService, private booksService:BooksService, private borrowService:BorrowService) { - // this.booksList=[]; + this.borrowList=[]; } ngOnInit(): void { this.date = new Date(); -console.log(this.date) - // this.date = new Date() - // this.cValue = formatDate(this.d1, 'dd-MM-yyyy', 'en-US'); - + } ObjSampleForm:FormGroup=new FormGroup( { - // issueDate:new FormControl('',[Validators.required]), + returnDate:new FormControl('',[Validators.required]), dueDate:new FormControl('',[Validators.required]) @@ -45,49 +41,33 @@ ObjSampleForm:FormGroup=new FormGroup( ) -onSubmit(){ +submit(){ this.update(this.borrowId) } update(borrowId:any){ - console.log("vjydsvajys") - console.log(borrowId) let body={ - // issueDate: this.ObjSampleForm.controls['issueDate'].value, + returnDate: this.ObjSampleForm.controls['returnDate'].value, dueDate: this.ObjSampleForm.controls['dueDate'].value } - - console.log(body) this.borrowService.update(borrowId, body).subscribe({ next: (Response: any) => { - console.log(Response); - this.toast.success({detail:'Success',summary:'The Book '+Response.booksName+' Approved',duration:5000}); - this.router.navigate(['/borrow']) - setTimeout(() => { - - window.location.reload() - }, 5000); - // window.location.reload() + this.toast.success({detail:'Success',summary:' Book Approved',duration:5000}); + this.router.navigate(['/borrow']) }, error: (Response: any) => { - console.log(Response) this.toast.info({detail:'INVALID',summary:'Something went wrong',duration:5000}); - + this.router.navigate(['/borrow']) } }) - // this.router.navigate(['/borrow']) - } - home() - { - this.router.navigate(['/sidenav']) } - datas(){ +datas(){ this.val=this.ObjSampleForm.controls['returnDate'].value; } diff --git a/FrontEnd/Library/src/app/addbooks/addbooks.component.css b/FrontEnd/Library/src/app/addbooks/addbooks.component.css index 42f8c76a..a801ba7d 100644 --- a/FrontEnd/Library/src/app/addbooks/addbooks.component.css +++ b/FrontEnd/Library/src/app/addbooks/addbooks.component.css @@ -1,18 +1,64 @@ -/* /* -.table-bordered{ - border: 1px solid; + +* { +box-sizing: border-box; +} + +@media only screen and (max-width: 620px) { +/* For mobile phones: */ +.right { + width: 87%; + +} +/* .form-control{ + top:15%; +} +*/ +.csvv{ + position: relative; + left: 8%; + top:65px; +} + +.centered{ + top: 18%; + left:45%; +} +.mat-dialog-container{ +margin-left: 20%; +} + +.form-control{ +width: 10%; +} + +.mycls{ + left: 35%; + margin-left: 20%; +} + +.csvv{ + /* position: relative; */ + left: -55%; + /* top:65px; */ +} + + } - */ + + +/* ----- */ + .split { height: 100%; /* width: 50%; */ position: fixed; /* z-index: 1; */ - top: 0; + top: 5%; overflow-x: hidden; - padding-top: 20px; + padding-top: 5%; + padding-bottom: 10%; } .left { @@ -36,34 +82,24 @@ text-align: center; } .form-control{ - width: 50vh; + width: 40vh; + } .csvv{ position: relative; - left: 105%; - /* top:65px; */ + left: 95%; + top:5%; } - /* .centered{ - top: 18%; - left:45%; - } -.mat-dialog-container{ -margin-left: 20%; -} - */ - - - - - table{ width: 90%; + scroll-behavior: auto; border: none; text-align: left; height: 100px; text-size-adjust: auto; + } th { background-color: #ffffff; @@ -76,146 +112,6 @@ margin-left: 20%; padding-top: 6px;padding-bottom: 6px; text-align: left; } - /* .form-control{ - width: fit-content; - } */ - - /* .main { - height: 100%; - overflow: hidden; - overflow-y: scroll; -} */ - -/* div{ - position: relative; - - width: 100%; - -} */ - + - -/* -@import url(//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css); -@import url(https://fonts.googleapis.com/css?family=Titillium+Web:300); -.fa-2x { - font-size: 2em; - } - .fa { - position: relative; - display: table-cell; - width: 60px; - height: 36px; - text-align: center; - vertical-align: middle; - font-size:20px; - } - - .main-menu { - background:#446cb3; - margin: 0%; - - border-right:0px solid #030303; - position:absolute; - top:0; - bottom:0; - height: 770px; - overflow: hidden; - - left:0; - width:220px; - overflow:-moz-hidden-unscrollable; - -webkit-transition:width .05s linear; - transition:width .05s linear; - -webkit-transform:translateZ(0) scale(1,1); - z-index:1000; - } - - .main-menu>ul { - margin:7px 0; - } - body{height: 0vh; - background-color: #030303; - } - .main-menu li { - position:relative; - display:block; - width:250px; - } - - .main-menu li>a { - position:relative; - display:table; - border-collapse:collapse; - border-spacing:0; - color:rgb(237, 248, 244); - font-family: arial; - font-size: 14px; - text-decoration:none; - -webkit-transform:translateZ(0) scale(1,1); - -webkit-transition:all .1s linear; - transition:all .1s linear; - } - - .main-menu .nav-icon { - position:relative; - display:table-cell; - width:60px; - height:36px; - text-align:center; - vertical-align:middle; - font-size:18px; - } - - .main-menu .nav-text { - position:relative; - display:table-cell; - vertical-align:middle; - width:190px; - font-family: 'Titillium Web', sans-serif; - } - - .main-menu>ul.logout { - position:absolute; - left:0; - bottom:0; - } - - .no-touch .scrollable.hover { - overflow-y:hidden; - } - - .no-touch .scrollable.hover:hover { - overflow-y:auto; - overflow:visible; - } - - a:hover,a:focus { - text-decoration:none; - } - - nav { - -webkit-user-select:none; - -moz-user-select:none; - -ms-user-select:none; - -o-user-select:none; - user-select:none; - } - - nav ul,nav li { - outline:0; - margin:0; - padding:0; - } - .main-menu li:hover>a,nav.main-menu li.active>a,.dropdown-menu>li>a:hover,.dropdown-menu>li>a:focus,.dropdown-menu>.active>a,.dropdown-menu>.active>a:hover,.dropdown-menu>.active>a:focus,.no-touch .dashboard-page nav.dashboard-menu ul li:hover a,.dashboard-page nav.dashboard-menu ul li.active a { - color:rgb(243, 234, 234); - background-color:#565985; - } - @font-face { - font-family: 'Titillium Web'; - font-style: normal; - font-weight: 300; - src: local('Titillium WebLight'), local('TitilliumWeb-Light'), url(http://themes.googleusercontent.com/static/fonts/titilliumweb/v2/anMUvcNT0H1YN4FII8wpr24bNCNEoFTpS2BTjF6FB5E.woff) format('woff'); - } - */ \ No newline at end of file diff --git a/FrontEnd/Library/src/app/addbooks/addbooks.component.html b/FrontEnd/Library/src/app/addbooks/addbooks.component.html index 767049f8..7a23c8ee 100644 --- a/FrontEnd/Library/src/app/addbooks/addbooks.component.html +++ b/FrontEnd/Library/src/app/addbooks/addbooks.component.html @@ -1,81 +1,29 @@ - - Borrow - - - - - - - -




- - - - - -
-


-
+
-
+
- - + + + + + cloud_upload + -
- -
-




- +
Book Results
Category-Name diff --git a/FrontEnd/Library/src/app/addbooks/addbooks.component.ts b/FrontEnd/Library/src/app/addbooks/addbooks.component.ts index 112c2cfc..438905f7 100644 --- a/FrontEnd/Library/src/app/addbooks/addbooks.component.ts +++ b/FrontEnd/Library/src/app/addbooks/addbooks.component.ts @@ -67,15 +67,13 @@ currentFile?: File; } search1(key:any){ - console.log("before api=",key); + this.booksService.search(key,this.page,this.tableSize,this.sort,this.direction).subscribe(response=>{ this.result=response.content; - console.log("searchRslt=",this.result); this.data=this.result; - this.count=response.totalElements; - console.log("count=",this.count); + this.count=response.totalElements; this.pkey=this.search.controls['inp'].value; - console.log("pk",this.pkey) + }); } @@ -84,43 +82,37 @@ Load() { this.booksService.pagination1(this.page,this.tableSize,this.sort,this.direction).subscribe(result=>{ this.result=result.content; this.count=result.totalElements - console.log("loaded books=",this.result); - console.log("page=",this.page); this.data=this.result; - this.booksdata=this.result; + this.booksdata=this.result; + }); } sortfn(a:any){ this.sort=a; - // this.page=this.page; - // this.tableSize; if(this.pkey==null){ - if(this.direction==1){ + + if(this.direction==1){ this.direction=-1; - console.log("from desc to :",this.direction) this.ngOnInit(); - } + } - else{ + else{ this.direction=1; - console.log("from asc to desc",this.direction) - this.ngOnInit(); + this.ngOnInit(); } -} + } else{ if(this.direction==1){ this.direction=-1; - console.log("from desc to :",this.direction) this.search1(this.search.controls['inp'].value); } else{ this.direction=1; - console.log("from asc to desc",this.direction) - this.search1(this.search.controls['inp'].value); + this.search1(this.search.controls['inp'].value); } } @@ -128,26 +120,20 @@ else{ } onTableDataChange(event:any) { - // this.pkey==this.search.controls['inp'].value; - console.log("p-",this.pkey) + if(this.pkey==null){ - console.log("page=",event) + this.booksService.pagination1(this.page,this.tableSize,this.sort,this.direction).subscribe(result=>{ this.result=result.content; this.count=result.totalElements - console.log("loaded books=",this.result); this.data=this.result; this.booksdata=this.result; }) } else{ - // this.pkey==this.search.controls['inp'].value; - console.log("page=",event) - console.log("pkey in page=",this.pkey) this.booksService.search(this.pkey,this.page,this.tableSize,this.sort,this.direction).subscribe(result=>{ this.result=result.content; this.count=result.totalElements - console.log("loaded books=",this.result); this.data=this.result; this.booksdata=this.result; }) @@ -161,7 +147,6 @@ onTableDataChange(event:any) { this.dialog.open(BooksComponent, { closeOnNavigation: true, - // width:'32%',height:'70%' width:'55%',height:'auto' } @@ -176,13 +161,11 @@ onTableDataChange(event:any) { delete(booksId:any): void{ if(confirm('Are you sure want to delete?')) { - console.log(booksId); + this.toast.error({detail:'BOOK DELETED',summary:'The book '+booksId.booksName+' Has DELETED',duration:5000}); - this.booksService.delete(booksId.booksId).subscribe({next:(res)=>{ - console.log(res); + this.booksService.delete(booksId.booksId).subscribe({next:(res)=>{ setTimeout(() => { - - window.location.reload() + this.Load(); }, 1000); }, error:(msg)=>{} @@ -194,7 +177,7 @@ onTableDataChange(event:any) { } edit(booksId:any) { - // localStorage.setItem('flag',this.flag); + localStorage.setItem('booksId',booksId); const dialogConfig = new MatDialogConfig(); this.dialog.open(BooksComponent, @@ -214,11 +197,10 @@ onTableDataChange(event:any) { -//////////////////////////////////// + selectFile($event:any) { this.selectedFiles=$event.target.files; - console.log("sel-",this.selectedFiles) } @@ -231,22 +213,20 @@ selectFile($event:any) { if (file) { this.currentFile = file; this.booksService.uploadCsv(this.currentFile).subscribe(res=>{ - console.log(res); - if(res!==null){ - this.toast.success({detail:'SUCCESS',summary:'The CSV File upload is successfull',duration:5000}); - + if(res!==null){ + this.toast.success({detail:'SUCCESS',summary:'The CSV File upload is successfull',duration:5000}); - setTimeout(() => { - - window.location.reload() - }, 5000); + setTimeout(() => { +this.Load() + // window.location.reload() + }, 3000); } - }), - (error: any) =>{ - console.log("in error") - this.toast.error({detail:'CSV upload failed',summary:'Invalid csv file',duration:5000}); - console.log(error)}; + },(error: any) =>{ + this.toast.error({detail:'CSV Upload Failed',summary:'Invalid CSV File',duration:5000}); + this.Load(); + }); + } diff --git a/FrontEnd/Library/src/app/addcategory/addcategory.component.ts b/FrontEnd/Library/src/app/addcategory/addcategory.component.ts index 9c6ba825..4bef77be 100644 --- a/FrontEnd/Library/src/app/addcategory/addcategory.component.ts +++ b/FrontEnd/Library/src/app/addcategory/addcategory.component.ts @@ -1,176 +1,147 @@ import { Component, OnInit } from '@angular/core'; import { CategoryComponent } from '../category/category.component'; -import { MatDialog,MatDialogRef, MatDialogModule} from '@angular/material/dialog'; -import { MatDialogConfig } from '@angular/material/dialog'; +import { MatDialog } from '@angular/material/dialog'; import { Router } from '@angular/router'; import { CategoryService } from '../category.service'; -import { HttpErrorResponse } from '@angular/common/http'; -import { Observable } from 'rxjs'; import { NgToastService } from 'ng-angular-popup'; -import { auto } from '@popperjs/core'; + @Component({ selector: 'app-addcategory', templateUrl: './addcategory.component.html', styleUrls: ['./addcategory.component.css'] }) -export class AddcategoryComponent implements OnInit { +export class AddcategoryComponent implements OnInit { categoryList: any[]; - categoryId:any; - categorydata:any; - // flag:string="ONE"; - + categoryId: any; + categorydata: any; data: any; -page:number=1; -count: any; -tableSize: number = 5; -ProdData: any; -sortedData: any; -a:any; -b:any; -searchResult:any -searchData:any -sort:string="categoryId"; -sort1:string="categoryName"; -len: any; -result: any; + page: number = 1; + count: any; + tableSize: number = 5; + a: any; + b: any; + + sort: string = "categoryId"; + sort1: string = "categoryName"; + len: any; + result: any; booksCount: any; - direction=-1; + direction = -1; category_id: any; categoryName: any; category_name: any; constructor(private dialog: MatDialog, - private router:Router , - private service:CategoryService, - private toast : NgToastService - ) { - this.categoryList=[]; - - } - - ngOnInit(): void { - - this.LoadCategory(); - localStorage.removeItem('categoryId'); + private router: Router, + private service: CategoryService, + private toast: NgToastService + ) { + this.categoryList = []; + + } + + ngOnInit(): void { + + this.LoadCategory(); + localStorage.removeItem('categoryId'); } LoadCategory() { - this.service.CatPageAdmin(this.page,this.tableSize,this.sort,this.direction).subscribe(result=>{ - this.result=result.content; - this.count=result.totalElements - console.log("loaded cat=",this.result); - console.log("page=",this.page); - this.data=this.result; - this.categorydata=this.result; - }); } - - - sortfn(a:any){ - this.sort=a; - console.log("sortbyname",a) - this.page=this.page; - this.tableSize; - - if(this.direction==1){ - this.direction=-1; - console.log("from desc to :",this.direction) - this.ngOnInit(); - } - - else{ - this.direction=1; - console.log("from asc to desc",this.direction) - this.LoadCategory(); - } - + this.service.CatPageAdmin(this.page, this.tableSize, this.sort, this.direction).subscribe(result => { + this.result = result.content; + this.count = result.totalElements + this.data = this.result; + this.categorydata = this.result; + }); + } - onTableDataChange(event:any) { - - console.log("page=",event) - this.service.CatPageAdmin(this.page,this.tableSize,this.sort,this.direction).subscribe(result=>{ - this.result=result.content; - this.count=result.totalElements - console.log("loaded books=",this.result); - this.data=this.result; - this.categorydata=this.result; - }) - } - -openDialog() { + sortfn(a: any) { + this.sort = a; + this.page = this.page; + this.tableSize; + if (this.direction == 1) { + this.direction = -1; + this.LoadCategory(); + } - this.dialog.open(CategoryComponent, - { - // width:'25%',height:'35%' - width:'auto+50px',height:'auto' - + else { + this.direction = 1; + this.LoadCategory(); } - ); -// this.matdialog.open(ChangePassComponent,{ - -// width: '60%' -// }); + } -} + onTableDataChange(event: any) { -editCategory(categoryId:any) { + this.service.CatPageAdmin(this.page, this.tableSize, this.sort, this.direction).subscribe(result => { + this.result = result.content; + this.count = result.totalElements + this.data = this.result; + this.categorydata = this.result; + }) + } - localStorage.setItem('categoryId',categoryId); - this.dialog.open(CategoryComponent, - { - closeOnNavigation: true, - width:'auto',height:'auto' + openDialog() { - } + + this.dialog.open(CategoryComponent, + { + // width:'25%',height:'35%' + width: 'auto+50px', height: 'auto' + + } ); - this.router.events - .subscribe(() => { - this.dialog.closeAll(); - }); -} + } + editCategory(categoryId: any) { + localStorage.setItem('categoryId', categoryId); -deleteCategory(category:any): void{ - if(confirm('Are you sure want to delete?')) - { - - console.log("catid=",category); - this.service.delete(category.categoryId).subscribe({next:(res)=>{ - - this.toast.error({detail:'Success',summary:'The Category '+category.categoryName+' Deleted',duration:5000}); - setTimeout(() => { - window.location.reload() - }, 1500); - - }, - error:(msg)=>{} - }) - } - else{ - this.router.navigate(['/addcategory']) - } -} + this.dialog.open(CategoryComponent, + { + closeOnNavigation: true, + width: 'auto', height: 'auto' + } + + ); + this.LoadCategory(); + // this.ngOnInit(); + + } + deleteCategory(category: any): void { + if (confirm('Are you sure want to delete?')) { + this.service.delete(category.categoryId).subscribe({ + next: (res) => { + this.toast.error({ detail: 'Success', summary: 'The Category ' + category.categoryName + ' Deleted', duration: 5000 }); + this.LoadCategory() - } + }, + error: (msg) => { } + }) + } + else { + this.router.navigate(['/addcategory']) + } + } +} diff --git a/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.css b/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.css index 87b7c653..718ed5e8 100644 --- a/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.css +++ b/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.css @@ -1,3 +1,112 @@ + + + + +* { + box-sizing: border-box; +} + +.menu { + float: left; + width: 20%; + text-align: center; +} + +.menu a { + background-color: #e5e5e5; + padding: 8px; + margin-top: 7px; + display: block; + width: 100%; + color: black; +} + +.main { + float: left; + width: 60%; + padding: 0 20px; +} + +.right { + /* background-color: #e5e5e5; */ + float: right; + /* width: 20%; */ + /* padding: 10px; */ + margin-right: 7px; + /* text-align: center; */ +} + +@media only screen and (max-width: 620px) { + /* For mobile phones: */ + .menu, .main { + width: 100%; + } + + .nav-mobile li{ + width:75%; + float:right; + text-align: center; +} + +} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + body, html { /* fixed */ position: relative; diff --git a/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.html b/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.html index 52748234..1f142356 100644 --- a/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.html +++ b/FrontEnd/Library/src/app/admin-navbar/admin-navbar.component.html @@ -1,57 +1,6 @@ - - - - +
+
-
- +
+ + + \ No newline at end of file diff --git a/FrontEnd/Library/src/app/booksdisplay/booksdisplay.component.ts b/FrontEnd/Library/src/app/booksdisplay/booksdisplay.component.ts index 3d1c5636..e2cadc46 100644 --- a/FrontEnd/Library/src/app/booksdisplay/booksdisplay.component.ts +++ b/FrontEnd/Library/src/app/booksdisplay/booksdisplay.component.ts @@ -1,5 +1,6 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; +import { NgToastService } from 'ng-angular-popup'; import { BooksService } from '../books.service'; import { BorrowService } from '../borrow.service'; import { CategoryService } from '../category.service'; @@ -10,7 +11,7 @@ import { CategoryService } from '../category.service'; styleUrls: ['./booksdisplay.component.css'] }) export class BooksdisplayComponent implements OnInit { - + //booksdata:any; // categoryList: any[]; categoryId:any; @@ -41,7 +42,7 @@ result: any; direction=-1; - constructor(private router:Router ,private booksservice:BooksService,private service:CategoryService,private borrowservice:BorrowService) { + constructor(private router:Router ,private booksservice:BooksService,private service:CategoryService,private borrowservice:BorrowService,private toast:NgToastService) { // this.booksList=[]; // this.categoryList=[]; } @@ -128,8 +129,10 @@ onTableDataChange(event:any) { this.borrowservice.add(data).subscribe({ next:(res)=>{ this.booksId=res.booksId; - console.log(res); - alert("Book request successfull") + console.log(res); + + // alert("Book request successfull") + this.toast.info({summary:'Booking Successfull',duration:5000}); this.router.navigate(['/borrowhistory']) }, error:(msg)=>{} diff --git a/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.css b/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.css index a96ee23b..fd9810c9 100644 --- a/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.css +++ b/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.css @@ -1,24 +1,10 @@ -p{ - padding: 0px 0px 30px 1000px; - margin: 0px; - background-color: rgb(0, 0, 0); - /* background-image: url('../../../a.png'); */ - -} -.btnhome{ - margin-top: 20px; - margin-bottom: 10px; - padding: 7; - border-color: rgb(124, 241, 134); - background-color: rgba(83, 254, 3, 0.853); - font-size: 13px; - border-radius: 25px; - -} + table{ border: none; width: 35%; + margin-top:2%; + /* text-align: left; */ } diff --git a/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.html b/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.html index 262dcb4e..6bc9316b 100644 --- a/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.html +++ b/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.html @@ -1,16 +1,16 @@
-
+

-

Borrow Details

+

Borrow Details

- +
- + diff --git a/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.ts b/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.ts index d4b9f304..8c77cd0e 100644 --- a/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.ts +++ b/FrontEnd/Library/src/app/borrow-detail-view/borrow-detail-view.component.ts @@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; import { BooksService } from '../books.service'; import { BorrowService } from '../borrow.service'; +import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'app-borrow-detail-view', @@ -14,12 +15,15 @@ export class BorrowDetailViewComponent implements OnInit { borrowdata:any; booksdata:any; - constructor(private router:Router ,private service:BorrowService,private booksService:BooksService) { + constructor(private router:Router , + private route: ActivatedRoute, + private service:BorrowService, + private booksService:BooksService) { } ngOnInit(): void { - //sessionStorage.clear() + this.borrowId = this.route.snapshot.params['id']; this.LoadBorrow(this.borrowId) } @@ -27,7 +31,8 @@ export class BorrowDetailViewComponent implements OnInit { LoadBorrow(borrow:any){ this.service.LoadBorrowDetailView(borrow).subscribe((data)=>{ this.borrowdata=data; - console.log(this.borrowdata);}); + + ;}); } diff --git a/FrontEnd/Library/src/app/borrow.service.ts b/FrontEnd/Library/src/app/borrow.service.ts index 1fc20259..3d06d5dc 100644 --- a/FrontEnd/Library/src/app/borrow.service.ts +++ b/FrontEnd/Library/src/app/borrow.service.ts @@ -3,8 +3,9 @@ import { Injectable } from '@angular/core'; import { catchError, Observable } from 'rxjs'; import { HttpErrorResponse } from '@angular/common/http'; import { Router } from '@angular/router'; +import { environment } from 'src/environments/environment'; + function _window() : any { - // return the global native browser window object return window; } @@ -16,191 +17,158 @@ export class BorrowService { get nativeWindow() : any { return _window(); } - - - apiurl='http://localhost:8080'; - accesstocken:any + baseUrl=environment.apiUrl; constructor(private http:HttpClient,private router:Router) { } - //////////////////////////////////////////////// - -handleError(err: HttpErrorResponse): any { - console.log('hhhii'); - if ( err.status === 403) { - alert("UNAUTHORIZED ACCESS DETECTED") - sessionStorage.clear() - localStorage.clear() - this.router.navigateByUrl(`/login`); } -} - - - - ////////////////////////////////////////////// export(): Observable { - return this.http.get('http://localhost:8080/borrow/admin/export', { responseType: 'blob' }); + return this.http.get(this.baseUrl+'/borrow/admin/export', { responseType: 'blob' }); } chartbar():Observable{ - return this.http.get('http://localhost:8080/borrow/admin/chart') + return this.http.get(this.baseUrl+'/borrow/admin/chart') } sendMail(userId: any):Observable { console.log("inservice"+userId) - return this.http.post('http://localhost:8080/email/emailsent/'+userId,userId).pipe((catchError(err => this.handleError(err)))); + return this.http.post(this.baseUrl+'/email/emailsent/'+userId,userId) + } add(data:any):Observable{ - return this.http.post('http://localhost:8080/borrow',data).pipe((catchError(err => this.handleError(err)))) + return this.http.post(this.baseUrl+'/borrow',data) + } borrowHistoryPagination(page:any,tableSize:any,sort:any){ - return this.http.get("http://localhost:8080/borrow/userBorrow/pagenated/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort).pipe((catchError(err => this.handleError(err)))) + return this.http.get(this.baseUrl+"/borrow/userBorrow/pagenated/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort) + } borrowPagination(page:any,tableSize:any,sort:any,direction:any):Observable{ - return this.http.get("http://localhost:8080/borrow/admin/pagenated/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction).pipe((catchError(err => this.handleError(err)))) + return this.http.get(this.baseUrl+"/borrow/admin/pagenated/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction) + + } + + + finePagination(page:any,tableSize:any,sort:any,direction:any):Observable{ + return this.http.get(this.baseUrl+"/borrow/admin/fine/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction) + } filterBorrowPagination(date1:any,date2:any,page:any,tableSize:any,sort:any,direction:any):Observable{ console.log(date1,' to ',date2) - return this.http.get(this.apiurl + "/borrow/admin/"+date1+"/"+date2+"/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction).pipe((catchError(err => this.handleError(err)))) + return this.http.get(this.baseUrl+"/borrow/admin/"+date1+"/"+date2+"/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction) + } // user filer filterBorrowPagination2(date1:any,date2:any,page:any,tableSize:any,sort:any){ console.log(date1) - return this.http.get(this.apiurl + "/borrow/user/"+date1+"/"+date2+"?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort) + return this.http.get(this.baseUrl+"/borrow/user/loadByIssueDate/"+date1+"/"+date2) } - ////////////// + statusfilterBor(page:any,tableSize:any,sort:any,direction:any,status:any):Observable{ - return this.http.get("http://localhost:8080/borrow/user/statusFilter/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction+"&status="+status) - // return this.http.get(this.apiurl + "/borrow/user/statusFilter?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction+"&status="+status) - } - - // return this.http.get(this.apiurl + `/users/fetching/${type}/${date1}/${date2}`, httpOptions) + return this.http.get(this.baseUrl+"/borrow/user/statusFilter/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction+"&status="+status) + + } + + AdminStatusfilterBorrow(page:any,tableSize:any,sort:any,direction:any,status:any):Observable{ + return this.http.get(this.baseUrl+"/borrow/admin/statusFilter/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction+"&status="+status) + + } + LoadByIssueDate(date1:any,date2:any){ - return this.http.get(this.apiurl + "/borrow/loadByIssueDate/"+date1+"/"+date2).pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+ "/borrow/loadByIssueDate/"+date1+"/"+date2); } //user LoadByIssueDateUser(date1:any,date2:any){ - return this.http.get(this.apiurl + "/borrow/user/loadByIssueDateUser/"+date1+"/"+date2); - } - + return this.http.get(this.baseUrl+"/borrow/user/loadByIssueDateUser/"+date1+"/"+date2); + } Load(){ - return this.http.get('http://localhost:8080/borrow').pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+'/borrow') + } - LoadBorrowDetailView(id: any){ - return this.http.get('http://localhost:8080/borrow/'+ sessionStorage.getItem('borrowId')).pipe((catchError(err => this.handleError(err)))); + LoadBorrowDetailView(borrowId: any){ + return this.http.get(this.baseUrl+'/borrow/'+ borrowId) + } borrowBlock(){ - return this.http.get('http://localhost:8080/borrow/borrowBlock'); + return this.http.get(this.baseUrl+'/borrow/borrowBlock'); } - LoadDue(){ - return this.http.get('http://localhost:8080/borrow/due').pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+'/borrow/due') + } LoadFine(){ - return this.http.get('http://localhost:8080/borrow/admin/fine').pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+'/borrow/admin/fine') + } //user LoadDueByUser(){ - return this.http.get('http://localhost:8080/borrow/user/dueByUser').pipe((catchError(err => this.handleError(err)))); - } - + return this.http.get(this.baseUrl+'/borrow/user/dueByUser') + } LoadUserList(){ - return this.http.get('http://localhost:8080/borrow/list/user').pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+'/borrow/list/user') + } LoadNotification(){ - return this.http.get('http://localhost:8080/borrow/user/notification').pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+'/borrow/user/notification') + } LoadUserNotification(){ - return this.http.get('http://localhost:8080/borrow/user/UserNotification').pipe((catchError(err => this.handleError(err)))); - } - - + return this.http.get(this.baseUrl+'/borrow/user/UserNotification') - + } + getBorrowID(borrowId:any){ - return this.http.get('http://localhost:8080/borrow'+borrowId); + return this.http.get(this.baseUrl+'/borrow'+borrowId); } payment(id: any) { - return this.http.put(this.apiurl + "/borrow/user/paymentStatus/" + id,{headers:Headers}); + return this.http.put(this.baseUrl+ "/borrow/user/paymentStatus/" + id,{headers:Headers}); } - - - - - - - - - - - - - - - - - - - - - - - - - + delete(booksId:any):Observable{ let tocken=localStorage.getItem('accesstoken') let head_obj=new HttpHeaders({"Authorization":"library " + tocken}) - return this.http.delete(this.apiurl+'/borrow/'+booksId,{headers:head_obj}); + return this.http.delete(this.baseUrl+'/borrow/'+booksId,{headers:head_obj}); } - - // update(id: any, data: any) { - // const httpOptions = { - // headers: new HttpHeaders({ - // 'Content-Type': 'application/json', - // 'Authorization': 'library ' + localStorage.getItem('accessToken') - // }) - // } - // return this.http.put(this.apiurl + "/borrow/" + id, data, httpOptions) - // } + update(id: any, data: any) { - return this.http.put(this.apiurl + "/borrow/admin/accept/" + sessionStorage.getItem('borrowId'), data).pipe((catchError(err => this.handleError(err)))); + return this.http.put(this.baseUrl + "/borrow/admin/accept/" + localStorage.getItem('borrowId'), data) + } - // updateReject(id: any, data:any) { - // return this.http.put(this.apiurl + "/borrow/reject/" + id,{headers:Headers}); - // } updateReject(id: any, data:any) { - return this.http.put(this.apiurl + "/borrow/admin/reject/" + sessionStorage.getItem('borrowId'), data).pipe((catchError(err => this.handleError(err)))); + return this.http.put(this.baseUrl + "/borrow/admin/reject/" + localStorage.getItem('borrowId'), data) + } bookReturn(id: any) { - return this.http.put(this.apiurl + "/borrow/admin/return/" + id,{headers:Headers}).pipe((catchError(err => this.handleError(err)))); + return this.http.put(this.baseUrl + "/borrow/admin/return/" + id,{headers:Headers}) + } undo(id: any) { - return this.http.put(this.apiurl + "/borrow/admin/undo/" + id,{headers:Headers}).pipe((catchError(err => this.handleError(err)))); + return this.http.put(this.baseUrl + "/borrow/admin/undo/" + id,{headers:Headers}) + } @@ -208,7 +176,8 @@ handleError(err: HttpErrorResponse): any { edit(booksId:any): Observable{ let tocken=localStorage.getItem('accesstoken') let head_obj=new HttpHeaders({"Authorization":"library " + tocken}) - return this.http.get(this.apiurl + '/borrow/'+ booksId,{headers:head_obj}).pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl + '/borrow/'+ booksId,{headers:head_obj}) + } } diff --git a/FrontEnd/Library/src/app/borrow/borrow.component.css b/FrontEnd/Library/src/app/borrow/borrow.component.css index 6b980aff..c736d688 100644 --- a/FrontEnd/Library/src/app/borrow/borrow.component.css +++ b/FrontEnd/Library/src/app/borrow/borrow.component.css @@ -1,4 +1,30 @@ +* { +box-sizing: border-box; +} + +@media only screen and (max-width: 620px) { +/* For mobile phones: */ +.right { + width: 57%; +} + + +.table-responsive{ + overflow-x: auto; +} + +} + + + + + + + + + + .split { height: 100%; /* width: 50%; */ diff --git a/FrontEnd/Library/src/app/borrow/borrow.component.html b/FrontEnd/Library/src/app/borrow/borrow.component.html index 662750fd..6b0998a6 100644 --- a/FrontEnd/Library/src/app/borrow/borrow.component.html +++ b/FrontEnd/Library/src/app/borrow/borrow.component.html @@ -2,28 +2,6 @@

- - Borrow - - - - @@ -56,7 +34,7 @@

Borrow Details

NAME : {{this.borrowdata.user.firstName}}
BOOK NAME : {{this.borrowdata.books.booksName}}
ISSUE DATE : {{this.borrowdata.issueDate| date:'dd/MM/yyyy'}}
- + @@ -70,7 +48,7 @@

Borrow Details

- diff --git a/FrontEnd/Library/src/app/borrow/borrow.component.ts b/FrontEnd/Library/src/app/borrow/borrow.component.ts index 16854109..990f4607 100644 --- a/FrontEnd/Library/src/app/borrow/borrow.component.ts +++ b/FrontEnd/Library/src/app/borrow/borrow.component.ts @@ -1,11 +1,8 @@ import { DatePipe } from '@angular/common'; import { Component, OnInit } from '@angular/core'; import { FormGroup, FormControl, Validators } from '@angular/forms'; -import {MatSort,Sort} from '@angular/material/sort'; import { Router } from '@angular/router'; -import { BooksService } from '../books.service'; import { BorrowService } from '../borrow.service'; -import { CategoryService } from '../category.service'; import { saveAs } from 'file-saver'; import { NgToastService } from 'ng-angular-popup'; @@ -21,38 +18,31 @@ export class BorrowComponent implements OnInit { myDate:any; filename: any; data1:number=0; - borrowId:any; borrowdata:any; booksdata:any; d1:number=0; - date:any; data: any; page:number=1; count: any; tableSize: number = 5; - ProdData: any; - sortedData: any; a:any; b:any; - searchResult:any - searchData:any sort1:string="borrowId"; sort:string="borrow_id"; - len: any; flag:number=0; result: any; direction=1; direction1=-1; - //borrow_id:any; + status=1; + selectedGroup: any; + selected="status"; constructor(private router:Router , private datePipe:DatePipe, private service:BorrowService, - private toast : NgToastService, - private booksService:BooksService) { + private toast : NgToastService) { - // this.borrowList=[]; this.date=new Date(); } @@ -60,9 +50,9 @@ export class BorrowComponent implements OnInit { ngOnInit(): void { this.date = new Date(); - console.log("today-",this.date) - sessionStorage.clear() + sessionStorage.clear(); + localStorage.removeItem('borrowId'); this.LoadData(); } @@ -71,7 +61,6 @@ export class BorrowComponent implements OnInit { this.service.borrowPagination(this.page,this.tableSize,this.sort1,this.direction).subscribe(result=>{ this.result=result.content; this.count=result.totalElements - console.log(this.result); this.data=this.result; }); } @@ -81,23 +70,88 @@ export class BorrowComponent implements OnInit { date1:new FormControl('',[Validators.required]), date2:new FormControl('',[Validators.required]), + } ) + + + filter:FormGroup = new FormGroup({ + status:new FormControl('',[Validators.required]) + + }) + + + + + + + + + + + + disp1() { + // this.status=1; + console.log('stat-------------------=',this.status) + if(this.filter.controls['status'].value==1){ + console.log('/////------------=',this.status) + this.service.AdminStatusfilterBorrow(this.page,this.tableSize,this.sort,this.direction,1).subscribe(response=>{ + this.result=response.content; + this.count=response.totalElements + console.log('in approved',this.result); + this.data=this.result; + }); + } + else if(this.filter.controls['status'].value==2){ + console.log('>>>>>>>>>>>>>>>>>>>>>>>>>>',this.status) + this.service.AdminStatusfilterBorrow(this.page,this.tableSize,this.sort,this.direction,2).subscribe(response=>{ + this.result=response.content; + this.count=response.totalElements + console.log(this.result); + this.data=this.result; + }); } - ) + + else if(this.filter.controls['status'].value==3){ + + this.service.AdminStatusfilterBorrow(this.page,this.tableSize,this.sort,this.direction,3).subscribe(response=>{ + this.result=response.content; + this.count=response.totalElements + console.log(this.result); + this.data=this.result; + }); + } + + else if(this.filter.controls['status'].value==4){ + + this.service.AdminStatusfilterBorrow(this.page,this.tableSize,this.sort,this.direction,4).subscribe(response=>{ + this.result=response.content; + this.count=response.totalElements + console.log(this.result); + this.data=this.result; + }); + } + else{ + + } + + } + + + + + + + + + + dwn() { - // if(this.key==""){ + this.myDate=this.datePipe.transform(this.curDate,'yyyy-MM-dd'); this.filename="DataExport_"+this.myDate; this.service.export().subscribe((blob:any)=>saveAs(blob,this.filename)) - // } - // else{ - // this.myDate=this.datePipe.transform(this.curDate,'yyyy-MM-dd'); - // this.filename="DataExport_"+this.myDate; - // this.service.exportSearch(this.search.controls['inp'].value).subscribe((blob:any)=>saveAs(blob,this.filename)) - // } - - // throw new Error('Method not implemented.'); + } @@ -112,13 +166,11 @@ export class BorrowComponent implements OnInit { if(this.direction==1){ this.direction=-1; - console.log("DIR -----1",this.direction) this.ngOnInit(); } else{ this.direction=1; - console.log("dir -1",this.direction) this.ngOnInit(); } @@ -133,13 +185,11 @@ export class BorrowComponent implements OnInit { if(this.direction1==1){ this.direction1=-1; - console.log("DIR -----1",this.direction1) this.getFilter(); } else{ this.direction1=1; - console.log("dir -1",this.direction1) this.getFilter(); } } @@ -147,22 +197,19 @@ export class BorrowComponent implements OnInit { getFilter() { if(this.d1==2){ -console.log("d=",this.ObjSampleForm.controls['date1'].value) this.flag=1; this.service.filterBorrowPagination(this.ObjSampleForm.controls['date1'].value,this.ObjSampleForm.controls['date2'].value,this.page,this.tableSize,this.sort,this.direction1).subscribe(response=>{ this.result=response.content; this.count=response.totalElements - console.log(this.result); this.data=this.result; - console.log("len>",this.result.length); if(this.result.length!==0){ this.data1=0; } else if(this.result.length==0){ this.data1=1; - console.log("else>",this.data1); + } @@ -171,8 +218,7 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) } else this.toast.warning({detail:'Warning',summary:'Choose start and end dates ',duration:5000}); - // this.d1=0; - console.log("d11==",this.d1) + } @@ -184,77 +230,53 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) onTableDataChange(event: any) { - console.log(event) + if(this.flag==0){ - console.log('flag=',this.flag) + this.service.borrowPagination(this.page,this.tableSize,this.sort1,this.direction).subscribe(result=>{ this.result=result.content; this.count=result.totalElements - console.log(this.result); + this.data=this.result; }); } else if(this.flag==1){ - console.log('flag=',this.flag) + this.service.filterBorrowPagination(this.ObjSampleForm.controls['date1'].value,this.ObjSampleForm.controls['date2'].value,this.page,this.tableSize,this.sort,this.direction1).subscribe(response=>{ this.result=response.content; this.count=response.totalElements - console.log(this.result); + this.data=this.result; }); } } - - - - - ///////////////////////////////////////////////- C R U D -//////////////////////////////////////////////////// - - home() - { - this.router.navigate(['/sidenav']) - } - LogOut(){ - sessionStorage.clear() - localStorage.clear() - this.router.navigate(['/login']) - } - acceptRequest(borrow:any) { - console.log("in borrow"); - console.log(borrow); - console.log(borrow.borrowId); - - sessionStorage.setItem('borrowId',borrow.borrowId) + + localStorage.setItem('borrowId',borrow.borrowId) this.router.navigate(['/acceptrequest']) } rejectRequest(borrow:any){ - console.log("in borrow"); - console.log(borrow); - console.log(borrow.borrowId); - - sessionStorage.setItem('borrowId',borrow.borrowId) + localStorage.setItem('borrowId',borrow.borrowId) this.router.navigate(['/rejectrequest']) } bookReturn(borrow: any) { - console.log(borrow) + if(borrow.paymentStatus=="UNPAID"){ alert("FINE IS NOT PAIDED") } else{ this.service.bookReturn(borrow.borrowId).subscribe({ next: (Response: any) => { - console.log(Response); - // alert(" Book Returned") + this.toast.success({detail:'Book Returned',summary:'Book '+borrow.books.booksName+' Returned by '+borrow.user.firstName,duration:5000}); setTimeout(() => { @@ -262,7 +284,6 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) }, 2500); }, error: (Response: any) => { - console.log(Response) alert("invalid Borrow details") } }) @@ -271,11 +292,11 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) } datas(){ this.val=this.ObjSampleForm.controls['date1'].value; - console.log("date=",this.val) + if(this.d1==0){ this.d1=1; - console.log("d1=",this.d1) + } else if(this.d1==1){ this.d1=2; @@ -291,16 +312,12 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) if(this.d1==1){ this.d1=2; - console.log("d1=",this.d1) + } else if(this.d1==0){ this.d1=1; } - // if(this.ObjSampleForm.controls['date2'].value!=null){ - // this.d1=1; - // } - } @@ -309,13 +326,11 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) alert(" Are you want to undo last change?") this.service.undo(borrow.borrowId).subscribe({ next: (Response: any) => { - console.log(Response); alert(" Book Returned status revoked") window.location.reload() }, error: (Response: any) => { - console.log(Response) - alert("invalid Borrow details") + alert("invalid Borrow details") } }) this.router.navigate(['/borrow']) @@ -324,12 +339,8 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) DetailView(borrow: any) { - console.log("in borrow"); - console.log(borrow); - console.log(borrow.borrowId); - - sessionStorage.setItem('borrowId',borrow.borrowId) - this.router.navigate(['/borrow-detail-view']) + localStorage.setItem('borrowId',borrow.borrowId) + this.router.navigate(['/borrow-detail-view',borrow.borrowId]) } @@ -345,6 +356,3 @@ console.log("d=",this.ObjSampleForm.controls['date1'].value) - function compare(a: number | string, b: number | string, isAsc: boolean) { - return (a < b ? -1 : 1) * (isAsc ? 1 : -1); - } diff --git a/FrontEnd/Library/src/app/borrowhistory/borrowhistory.component.ts b/FrontEnd/Library/src/app/borrowhistory/borrowhistory.component.ts index 004d0726..f6ba1370 100644 --- a/FrontEnd/Library/src/app/borrowhistory/borrowhistory.component.ts +++ b/FrontEnd/Library/src/app/borrowhistory/borrowhistory.component.ts @@ -11,7 +11,8 @@ import { UserserviceService } from '../userservice.service'; styleUrls: ['./borrowhistory.component.css'] }) export class BorrowhistoryComponent implements OnInit { - + + // borrowList: any[]; borrowId: any; @@ -194,25 +195,14 @@ export class BorrowhistoryComponent implements OnInit { console.log('1111',this.sort); }) - // if (this.searchData == null || this.searchData == "") { - - // // this.sort="borrow_id"; this.service.filterBorrowPagination2(this.ObjSampleForm.controls['date1'].value, this.ObjSampleForm.controls['date2'].value, this.page, this.tableSize, this.sort).subscribe({ next: (res: any) => { - - //console.log("--------") console.log('filter',res); console.log(this.ObjSampleForm.controls['date1'].value); this.data = res; }, }); - - // } - // else { - - // this.data = this.searchData - // } } display(){ diff --git a/FrontEnd/Library/src/app/category.service.ts b/FrontEnd/Library/src/app/category.service.ts index b6ba9005..31bdfacd 100644 --- a/FrontEnd/Library/src/app/category.service.ts +++ b/FrontEnd/Library/src/app/category.service.ts @@ -3,58 +3,54 @@ import { Injectable } from '@angular/core'; import { catchError, Observable } from 'rxjs'; import { HttpErrorResponse } from '@angular/common/http'; import { Router } from '@angular/router'; +import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' }) export class CategoryService { - apiurl='http://localhost:8080'; - accesstocken:any - tocken:any; + + + baseUrl=environment.apiUrl; + constructor(private http:HttpClient,private router:Router) { } - //error handling - handleError(err: HttpErrorResponse): any { - console.log('hhhii'); - if ( err.status === 403) { - alert("UNAUTHORIZED ACCESS DETECTED") - sessionStorage.clear() - localStorage.clear() - this.router.navigateByUrl(`/login`); } - } -//////////////////////////////////////////////////////// addCategory(data:any):Observable{ - return this.http.post('http://localhost:8080/category',data).pipe((catchError(err => this.handleError(err)))); + return this.http.post(this.baseUrl+'/category',data); + } LoadCategory(){ - return this.http.get('http://localhost:8080/category/admin').pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+'/category/admin'); + } CatPageAdmin(page:any,tableSize:any,sort:any,direction:any):Observable{ - return this.http.get("http://localhost:8080/category/admin/pagenated/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction).pipe((catchError(err => this.handleError(err)))) + return this.http.get(this.baseUrl+"/category/admin/pagenated/?pageNo="+page+"&pageSize="+tableSize+"&sortBy="+sort+"&direction="+direction); + } LoadCategoryForUser(){ - return this.http.get('http://localhost:8080/category/user').pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl+'/category/user'); + } delete(categoryId:any):Observable{ - return this.http.delete(this.apiurl+'/category/'+categoryId); + return this.http.delete(this.baseUrl+'/category/'+categoryId); } update(id: any, data: any) { - return this.http.put(this.apiurl + "/category/" + id, data).pipe((catchError(err => this.handleError(err)))); + return this.http.put(this.baseUrl + "/category/" + id, data); } editCategory(categoryId:any): Observable{ - return this.http.get(this.apiurl + '/category/'+ categoryId).pipe((catchError(err => this.handleError(err)))); + return this.http.get(this.baseUrl + '/category/'+ categoryId); } } diff --git a/FrontEnd/Library/src/app/category/category.component.ts b/FrontEnd/Library/src/app/category/category.component.ts index 354c79c7..84e58fa5 100644 --- a/FrontEnd/Library/src/app/category/category.component.ts +++ b/FrontEnd/Library/src/app/category/category.component.ts @@ -2,13 +2,13 @@ import { Component, OnInit } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; import { Router } from '@angular/router'; import { CategoryService } from '../category.service'; -import {MatDialog, MAT_DIALOG_DATA, MatDialogRef} from '@angular/material/dialog'; +import { MatDialog, MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; import { NgToastService } from 'ng-angular-popup'; -export interface DialogData { -categoryName:string; +export interface DialogData { + categoryName: string; } @Component({ @@ -20,117 +20,130 @@ export class CategoryComponent implements OnInit { -categoryId:any; -categoryName:any; -data: any; -test:any; + categoryId: any; + categoryName: any; + data: any; + test: any; -ObjSampleForm:FormGroup; + ObjSampleForm: FormGroup; constructor( - private router:Router , - private service:CategoryService, - private toast : NgToastService, - ) - { - this.ObjSampleForm=new FormGroup( - { - categoryName:new FormControl('',[Validators.required]), - } - ); - } + private router: Router, + private service: CategoryService, + private toast: NgToastService, + private dialog: MatDialog, + ) { + this.ObjSampleForm = new FormGroup( + { + categoryName: new FormControl('', [Validators.required]), + } + ); + } ngOnInit(): void { -this.LoadEdit() + this.LoadEdit() } - -LoadEdit(){ - let categoryId=localStorage.getItem("categoryId") - //set edit data to fields - - if(categoryId!=null){ - this.service.editCategory(categoryId).subscribe({ - next:(res)=>{ - this.categoryId=res.categoryId; - this.ObjSampleForm.controls['categoryName'].setValue(res.categoryName) - console.log(res); - - }, - error:(msg)=>{} - }) -} -} + LoadEdit() { + let categoryId = localStorage.getItem("categoryId") - categorydata:any; + if (categoryId != null) { + this.service.editCategory(categoryId).subscribe({ + next: (res) => { + this.categoryId = res.categoryId; + this.ObjSampleForm.controls['categoryName'].setValue(res.categoryName) + }, + error: (msg) => { } + }) + } -onSubmit(){ + } - let categoryId=localStorage.getItem("categoryId") + categorydata: any; - if(categoryId!=undefined){ - this.updateCategory(categoryId) - }else{ - this.addCategory() + onSubmit() { - } + let categoryId = localStorage.getItem("categoryId") -} - addCategory(){ - this.service.addCategory(this.ObjSampleForm.value).subscribe(result=>{ - - console.log(result); - if(result.categoryId){ - console.log(result); - this.toast.success({detail:'Success',summary:'The Category '+result.categoryName+' Added',duration:5000}); - this.router.navigate(['/addCategory']) - setTimeout(() => { - window.location.reload() - }, 1500); - - - } - else{ - alert("category Not added"); - } - }) - } + if (categoryId != undefined) { + this.updateCategory(categoryId) + } else { + this.addCategory() + } -updateCategory(categoryId:any){ - let body={ - categoryName: this.ObjSampleForm.controls['categoryName'].value } + + addCategory() { + this.service.addCategory(this.ObjSampleForm.value).subscribe({ + next: (result: any) => { + - console.log(body) - this.service.update(categoryId, body).subscribe({ - next: (Response: any) => { - console.log(Response); - // alert(" Edited successfully") - this.toast.success({detail:'Success',summary:'The Category - '+Response.categoryName+' Edited',duration:5000}); - setTimeout(() => { - window.location.reload() - }, 1500); - // window.location.reload() + if (result.categoryId) { + this.toast.success({ detail: 'Success', summary: 'The Category ' + result.categoryName + ' Added', duration: 5000 }); + + setTimeout(() => { + this.router.navigate(['/addcategory']) + this.dialog.closeAll(); + window.location.reload(); + }, 1000); + + } + + }, error: (Response: any) => { console.log(Response) - alert("invalid Category credentials") + if (Response.status == 400) { + this.toast.warning({ detail: 'Failed', summary: 'Please Fill up the fields', duration: 10000, position: 'tr' }) + } + else if (Response.status == 500) { + this.toast.warning({ detail: 'FAILED to add Category', summary: 'INTERNAL SERVER ERROR', duration: 5000, position: 'tr' }) + } + } }) - localStorage.removeItem('categoryId'); - // localStorage.removeItem("categoryId") - } - clear() { - localStorage.removeItem('categoryId'); - window.location.reload() } + + + updateCategory(categoryId: any) { + let body = { + categoryName: this.ObjSampleForm.controls['categoryName'].value + } + + this.service.update(categoryId, body).subscribe({ + next: (Response: any) => { + + this.toast.success({ detail: 'Success', summary: 'The Category - ' + Response.categoryName + ' Edited', duration: 5000 }); + setTimeout(() => { + + this.router.navigate(['/addcategory']) + this.dialog.closeAll(); + window.location.reload(); + }, 1000); + + }, + error: (Response: any) => { + console.log(Response) + alert("invalid Category credentials") + } + }) + + localStorage.removeItem('categoryId'); + + + } + clear() { + localStorage.removeItem('categoryId'); + this.ObjSampleForm.reset() + } + + - } diff --git a/FrontEnd/Library/src/app/email.service.ts b/FrontEnd/Library/src/app/email.service.ts index 6257e222..bf9ec2de 100644 --- a/FrontEnd/Library/src/app/email.service.ts +++ b/FrontEnd/Library/src/app/email.service.ts @@ -1,13 +1,14 @@ import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; +import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' }) export class EmailService { - private baseUrl="http://localhost:8080"; + baseUrl=environment.apiUrl; constructor( private http: HttpClient, ) @@ -15,10 +16,15 @@ export class EmailService { sendotp(data:any):Observable{ - return this.http.post('http://localhost:8080/email/emailsentotp',data) + return this.http.post(this.baseUrl+'/email/emailsentotp',data) } verify(data:any):Observable{ - return this.http.post('http://localhost:8080/email/verify',data) + return this.http.post(this.baseUrl+'/email/verify',data) + } + + + verifyPassword(data:any):Observable{ + return this.http.post(this.baseUrl+'/email/verifyPassword',data) } } diff --git a/FrontEnd/Library/src/app/findby-category/findby-category.component.css b/FrontEnd/Library/src/app/findby-category/findby-category.component.css index 6103feba..aea931c0 100644 --- a/FrontEnd/Library/src/app/findby-category/findby-category.component.css +++ b/FrontEnd/Library/src/app/findby-category/findby-category.component.css @@ -54,15 +54,15 @@ p{ border: 1px solid; } th { - background-color: #232524; - color: white; + background-color: white; + color:black; width: 15%; text-align: center; border: none; } td { - background-color: #a7bdb08f; - color: rgb(0, 0, 0); + background-color: white; + color: black; width: 15%; text-align: center; margin-top: auto; @@ -80,3 +80,7 @@ th { color: rgb(255, 255, 255); border-radius: 3px; } +.btnn2{ + background-color: black; + color: white; +} \ No newline at end of file diff --git a/FrontEnd/Library/src/app/findby-category/findby-category.component.html b/FrontEnd/Library/src/app/findby-category/findby-category.component.html index 66c95cf2..ee2673a0 100644 --- a/FrontEnd/Library/src/app/findby-category/findby-category.component.html +++ b/FrontEnd/Library/src/app/findby-category/findby-category.component.html @@ -1,60 +1,75 @@ - -
-
-
-
Issue Date - + Due Date @@ -82,9 +60,22 @@

Borrow Details

Status + + + + + +
+ + + + + +
+
+ +

- - -
-
- -
-
-
-
-
-
NO BOOKS FOUND!!!
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Book NameCategory-NamePublicationAutherBook CopiesBook CoverAction
{{books.booksName}}{{books.category.categoryName}}{{books.publication}}{{books.auther}}{{books.booksCopies}} - - - -
\ No newline at end of file +
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Book NameCategory-NamePublicationAuthorBook CopiesBook CoverAction
{{books.booksName}}{{books.category.categoryName}}{{books.publication}}{{books.auther}}{{books.booksCopies}} + + + +
+
\ No newline at end of file diff --git a/FrontEnd/Library/src/app/findby-category/findby-category.component.ts b/FrontEnd/Library/src/app/findby-category/findby-category.component.ts index 2fcb6ea4..5ae35029 100644 --- a/FrontEnd/Library/src/app/findby-category/findby-category.component.ts +++ b/FrontEnd/Library/src/app/findby-category/findby-category.component.ts @@ -13,76 +13,60 @@ import { CategoryService } from '../category.service'; export class FindbyCategoryComponent implements OnInit { categoryList: any[]; - categoryId:any; + categoryId: any; booksList: any[]; books: any; booksId: any; - selectedGroup:any; + selectedGroup: any; - categorydata:any; - booksdata:any; + categorydata: any; + booksdata: any; catdata: any; - ObjSampleForm:FormGroup=new FormGroup( - { - categoryId:new FormControl('',[Validators.required]) + ObjSampleForm: FormGroup = new FormGroup( + { + categoryId: new FormControl('', [Validators.required]) }) - - constructor(private router:Router ,private booksService:BooksService,private service:CategoryService,private borrowservice:BorrowService) { - this.booksList=[]; - this.categoryList=[];} - ngOnInit(): void { + constructor(private router: Router, private booksService: BooksService, private service: CategoryService, private borrowservice: BorrowService) { + this.booksList = []; + this.categoryList = []; + } - - this.service.LoadCategoryForUser().subscribe((data: any)=>{ - this.catdata=data; - console.log(this.catdata) + ngOnInit(): void { + this.service.LoadCategoryForUser().subscribe((data: any) => { + this.catdata = data; + console.log(this.catdata) }); + } - - } - - - home() - { + home() { this.router.navigate(['/userbody']) } + disp() { + console.log(this.selectedGroup); + this.booksService.LoadbyCategory(this.selectedGroup).subscribe((data: any) => { + if (data.length>0) { + this.booksdata = data; + console.log(data) + } else{ + this.booksdata=null + } - disp(){ - - console.log(this.selectedGroup); - // console.log(this.selectedGroup.categoryId); - // console.log(this.categoryId) - //this.LoadbyCategory(); - this.booksService.LoadbyCategory(this.selectedGroup).subscribe((data: any)=>{ - console.log(data) - this.booksdata=data; - }); - } - - - - - requestBook(booksId: any) { - console.log(booksId) - let data=booksId - this.borrowservice.add(data).subscribe({ - next:(res)=>{ - this.booksId=res.booksId; - console.log(res); - alert("Book request successfull") + }); + } +requestBook(booksId: any) { + console.log(booksId) + let data = booksId + this.borrowservice.add(data).subscribe({ + next: (res) => { + this.booksId = res.booksId; + console.log(res); + alert("Book request successfull") this.router.navigate(['/borrowhistory']) - }, - error:(msg)=>{} - }) - } - - // LoadbyCategory() { - // this.booksService.LoadbyCategory().subscribe((data: any)=>{ - // console.log(data) - // this.booksdata=data; - // }); } - -} + }, + error: (msg) => { } + }) + } +} \ No newline at end of file diff --git a/FrontEnd/Library/src/app/fine/fine.component.css b/FrontEnd/Library/src/app/fine/fine.component.css index b68c2589..03948260 100644 --- a/FrontEnd/Library/src/app/fine/fine.component.css +++ b/FrontEnd/Library/src/app/fine/fine.component.css @@ -1,3 +1,44 @@ +* { + box-sizing: border-box; +} + + + +@media only screen and (max-width: 620px) { + /* For mobile phones: */ + .menu, .main, .right { + width: 100%; + } + .right { +right: 0; +width: 100%; +float: left; +background-color: rgb(255, 255, 255); +} + +table{ +width: 55%; +border: none; +text-align: center; +position:relative; +overflow-x: scroll; +overflow-x: visible; +font-size: 0.675em; +/* overflow-x: scroll; +overflow:visible; */ +} + + +} + + + + + + + + + .split { height: 100%; /* width: 50%; */ @@ -40,14 +81,14 @@ table{ width: 90%; border: none; - text-align: center; + text-align: left; position:relative; } th { background-color: #ffffff; color: rgb(0, 0, 0); - text-align: center; + text-align: left; border: none; position:relative; @@ -55,7 +96,7 @@ table{ td { border: none; padding-top: 16px;padding-bottom: 6px; - text-align: center; + text-align: left; position:relative; } diff --git a/FrontEnd/Library/src/app/fine/fine.component.html b/FrontEnd/Library/src/app/fine/fine.component.html index 77f65c81..16a3cf32 100644 --- a/FrontEnd/Library/src/app/fine/fine.component.html +++ b/FrontEnd/Library/src/app/fine/fine.component.html @@ -3,71 +3,9 @@ - - - -
@@ -93,7 +31,14 @@

OUTSTANDING FINE DETAILS

- + {{borrow.user.firstName}} {{borrow.books.booksName}} @@ -103,15 +48,15 @@

OUTSTANDING FINE DETAILS

{{borrow.fine}} - - NO RECORDS FOUND - - + - +
+ + +
diff --git a/FrontEnd/Library/src/app/fine/fine.component.ts b/FrontEnd/Library/src/app/fine/fine.component.ts index bb50d13b..771836b6 100644 --- a/FrontEnd/Library/src/app/fine/fine.component.ts +++ b/FrontEnd/Library/src/app/fine/fine.component.ts @@ -1,6 +1,5 @@ import { Component, OnInit } from '@angular/core'; import { Router } from '@angular/router'; -import { elementAt } from 'rxjs'; import { BooksService } from '../books.service'; import { BorrowService } from '../borrow.service'; @@ -11,104 +10,88 @@ import { BorrowService } from '../borrow.service'; }) export class FineComponent implements OnInit { - - borrowList: any[]; borrowId:any; borrowdata:any; booksdata:any; data:number=1; + + + + +page:number=1; +count: any; +tableSize: number = 10; +a:any; +b:any; +sort:string="borrow_id"; +len: any; +result: any; +booksCount: any; +direction=-1; + constructor(private router:Router ,private service:BorrowService,private booksService:BooksService) { - this.borrowList=[]; } ngOnInit(): void { - sessionStorage.clear() + this.LoadBorrow() } LoadBorrow(){ - this.service.LoadFine().subscribe((data: any)=>{ - this.borrowdata=data; - console.log(data); - console.log("9999",data.length) - - - - if(data.length!==0){ - this.data=0; + this.service.finePagination(this.page,this.tableSize,this.sort,this.direction).subscribe(result=>{ + this.result=result.content; + this.count=result.totalElements + this.data=this.result; + this.borrowdata=this.result; + + + // if(result.length!==0){ + // this.data=0; - } - else if(data.length==0){ - this.data=1; - } + // } + // else if(result.length==0){ + // this.data=1; + // } + }); - } - - - - - // acceptRequest(borrow:any) - // { - // console.log("in borrow"); - // console.log(borrow); - // console.log(borrow.borrowId); - // sessionStorage.setItem('borrowId',borrow.borrowId) - // this.router.navigate(['/acceptrequest']) - // } + sortfn(a:any){ + this.sort=a; + this.page=this.page; + this.tableSize; + + if(this.direction==1){ + this.direction=-1; + this.ngOnInit(); + } + + else{ + this.direction=1; + this.ngOnInit(); + } + + } + onTableDataChange(event:any) { + - // rejectRequest(borrow:any){ + this.service.finePagination(this.page,this.tableSize,this.sort,this.direction).subscribe(result=>{ + this.result=result.content; + this.count=result.totalElements + this.data=this.result; + this.borrowdata=this.result; + }) + } - // console.log("in borrow"); - // console.log(borrow); - // console.log(borrow.borrowId); - // sessionStorage.setItem('borrowId',borrow.borrowId) - // this.router.navigate(['/rejectrequest']) - - // } - - // bookReturn(borrow: any) { - // this.service.bookReturn(borrow.borrowId).subscribe({ - // next: (Response: any) => { - // console.log(Response); - // alert(" Book Returned") - // window.location.reload() - // }, - // error: (Response: any) => { - // console.log(Response) - // alert("invalid Borrow details") - // } - // }) - // this.router.navigate(['/borrow']) - // } - - - // undo(borrow: any) { - - // this.service.undo(borrow.borrowId).subscribe({ - // next: (Response: any) => { - // console.log(Response); - // alert(" Book Returned status revoked") - // window.location.reload() - // }, - // error: (Response: any) => { - // console.log(Response) - // alert("invalid Borrow details") - // } - // }) - // this.router.navigate(['/borrow']) - // } - } \ No newline at end of file diff --git a/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.css b/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.css index b31ab8ff..347555cf 100644 --- a/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.css +++ b/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.css @@ -60,4 +60,62 @@ body, html { } .button:hover {color: #ffffff} - \ No newline at end of file + + .email{ + + width: 25%; + height: auto; + padding: 8px 2px; + margin: 0px; + box-sizing: border-box; + border: 1px ; + background-color: #a7bdb08f; + color: rgb(0, 0, 0); + border-radius: 7px; + +} + +input::-webkit-outer-spin-button, +input::-webkit-inner-spin-button { + -webkit-appearance: none; + margin: 0; +} +input[type=number] { + -moz-appearance: textfield; +} + +input { + text-align: center; +} + +::-webkit-input-placeholder { + text-align: center; +} + + + +/* spinner css */ + +.loader { + border: 7px solid #f3f3f3; + border-radius: 50%; + border-top: 7px solid #3498db; + width: 60px; + height: 60px; + -webkit-animation: spin 2s linear infinite; /* Safari */ + animation: spin 2s linear infinite; + z-index: 1; + margin-left: 47%; + +} + +/* Safari */ +@-webkit-keyframes spin { + 0% { -webkit-transform: rotate(0deg); } + 100% { -webkit-transform: rotate(360deg); } +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} diff --git a/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.html b/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.html index 273f2963..578a76f4 100644 --- a/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.html +++ b/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.html @@ -2,11 +2,9 @@ @@ -15,12 +13,13 @@



-
+


-

- + +

+ +
@@ -32,30 +31,60 @@ -
diff --git a/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.ts b/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.ts index 24b45b14..c8116dd5 100644 --- a/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.ts +++ b/FrontEnd/Library/src/app/forgotpassword/forgotpassword.component.ts @@ -11,109 +11,150 @@ import { EmailService } from '../email.service'; }) export class ForgotpasswordComponent implements OnInit { displayStyle: any; - result:any; - rslt=0; + result: any; + rslt = 0; + val = 0; + spin = 0; - - ObjForm:FormGroup=new FormGroup({ - sentto:new FormControl('',[Validators.maxLength(50),Validators.required]), + ObjForm: FormGroup = new FormGroup({ + sentto: new FormControl('', [Validators.maxLength(50), Validators.required]), }) - ObjForgetForm:FormGroup=new FormGroup({ - otp:new FormControl('',[Validators.maxLength(50),Validators.required]), - newPassword:new FormControl('',[Validators.maxLength(50),Validators.required]), - cnewPassword:new FormControl('',[Validators.maxLength(50),Validators.required]), - email:new FormControl() + ObjForgetForm: FormGroup = new FormGroup({ + otp: new FormControl('', [Validators.maxLength(50), Validators.required]), + newPassword: new FormControl('', [Validators.maxLength(50), Validators.required]), + cnewPassword: new FormControl('', [Validators.maxLength(50), Validators.required]), + email: new FormControl() }) email: any; - - constructor( private emails:EmailService, - private toast:NgToastService, - private router:Router) { } + constructor(private emails: EmailService, + private toast: NgToastService, + private router: Router) { } + + ngOnInit(): void { + + this.ObjForgetForm.reset() + this.spin = 0; - ngOnInit(): void { - // this.ObjForgetForm.controls['otp'].value.reset() - console.log('rslt=',this.rslt) - if(this.rslt==1){ - this.toast.error({detail:'OTP Sent Failed :(',summary:'Unregistered Email Detected ', duration:5000,position:'tr'}) + if (this.rslt == 1) { + this.toast.error({ detail: 'OTP Sent Failed :(', summary: 'Unregistered Email Detected ', duration: 5000, position: 'tr' }) setTimeout(() => { - window.location.reload() - }, 3000); - // this.rslt=0; + this.ObjForm.reset() + this.rslt = 0; + this.val = 0; + }, 3000); + + } - + } - Login() - { + Login() { this.router.navigate(['/login']) } - + closePopup() { + this.displayStyle = "none"; + this.ObjForgetForm.reset() + } -//verify otp - SaveData() { + openSuccess() { + this.toast.success({ detail: 'OTP Sent Success', summary: 'OTP Has been Sent to your mail', duration: 5000, position: 'tr' }) + } - // this.toast.success({detail:'OTP Sent',summary:'Please verify the OTP', duration:10000,position:'tr'}) - this.ObjForgetForm.value.email=this.email; - console.log(this.ObjForgetForm.value.email); - if(this.ObjForgetForm.value.newPassword==this.ObjForgetForm.value.cnewPassword){ - - this.emails.verify(this.ObjForgetForm.value).subscribe(result=>{ + openPopup() { - if(result){ - this.toast.success({detail:'password changed',summary:'Please Login', duration:10000,position:'tr'}) - this.router.navigate(['/login']) - } - else{ - this.toast.warning({detail:'Failed',summary:'Please Enter valid OTP', duration:10000,position:'tr'}) - } + this.val = 1; + this.spin = 1; + this.email = this.ObjForm.value.sentto; + this.emails.sendotp(this.ObjForm.value).subscribe((result => { + this.rslt = 2; + this.spin = 0; + this.openSuccess(); + }), + (error) => { + if (error.status == 406) { + this.toast.error({ detail: 'OTP Sent Failed :(', summary: 'Fill the fields', duration: 5000, position: 'tr' }) + this.spin = 0; + this.val = 0; + } - // alert("password has been Updated") - }) - } - else - this.toast.warning({detail:'Password Mismatch',summary:'Please Enter valid password', duration:10000,position:'tr'}) + else if (error.status == 400) { + this.rslt = 1; + this.spin = 0; + this.ngOnInit() + } - - } + else if (error.status == 417) { + this.toast.error({ detail: 'OTP Sent Failed :(', summary: 'Internal server error', duration: 5000, position: 'tr' }) + } - //send otp - openPopup() { - - this.email=this.ObjForm.value.sentto; - - this.emails.sendotp(this.ObjForm.value).subscribe(result=>{ - - console.log(result); - - if(result==null){ - // this.toast.error({detail:'OTP Not Sent',summary:'Unregistered Email Detected', duration:5000,position:'tr'}) - this.rslt=1; - console.log("reslt in if=",this.rslt) - // this.router.navigate(['/forgotpassword']) - this.ngOnInit() - } - - }) + }); - this.openSuccess(); this.displayStyle = "block"; - + } - closePopup() { - this.displayStyle = "none"; + + //verify otp + Otp() { + + this.ObjForgetForm.value.email = this.email; + this.emails.verify(this.ObjForgetForm.value).subscribe({ + next: (result: any) => { + this.val = 2; + this.toast.success({ detail: 'OTP', summary: 'Please Change Password', duration: 10000, position: 'tr' }) + + }, + error: (Response: any) => { + console.log("response-", Response.error) + if (Response.status == 400) { + this.toast.warning({ detail: 'Failed', summary: 'Please Fill in the fields', duration: 5000, position: 'tr' }) + } + else if (Response.status == 406) { + this.toast.error({ detail: 'Failed', summary: 'OTP VERIFICATION FAILED', duration: 5000, position: 'tr' }) + } + else if (Response.status == 504) { + this.toast.error({ detail: 'Failed', summary: 'OTP EXPIRED', duration: 5000, position: 'tr' }) + } + } + }) } - openSuccess(){ - this.toast.success({detail:'OTP Sent Success',summary:'OTP Has been Sent to your mail', duration:5000,position:'tr'}) - } + + + + ChangePassword() { + + this.ObjForgetForm.value.email = this.email; + this.emails.verifyPassword(this.ObjForgetForm.value).subscribe({ + next: (result: any) => { + console.log("log", result) + this.toast.success({ detail: 'Success', summary: 'Changed Password, please Login', duration: 10000, position: 'tr' }) + this.router.navigate(['/login']) + }, + error: (Response: any) => { + console.log(Response) + if (Response.status == 400) { + this.toast.warning({ detail: 'Failed', summary: 'Please Fill up the fields', duration: 10000, position: 'tr' }) + } + else if (Response.status == 502) { + this.toast.warning({ detail: 'Failed', summary: 'Password missmatch', duration: 10000, position: 'tr' }) + } + else if (Response.status == 500) { + this.toast.warning({ detail: 'Failed to change password', summary: 'INTERNAL SERVER ERROR', duration: 10000, position: 'tr' }) + } + + } + + }) + + } } diff --git a/FrontEnd/Library/src/app/imageupload.service.ts b/FrontEnd/Library/src/app/imageupload.service.ts index 206f0d77..0e14cd50 100644 --- a/FrontEnd/Library/src/app/imageupload.service.ts +++ b/FrontEnd/Library/src/app/imageupload.service.ts @@ -1,6 +1,8 @@ -import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; +import { HttpClient, HttpErrorResponse } from '@angular/common/http'; +import { Router } from '@angular/router'; +import { catchError, Observable } from 'rxjs'; +import { environment } from 'src/environments/environment'; @Injectable({ providedIn: 'root' @@ -12,27 +14,34 @@ export class ImageuploadService { } getId(){ return this.id; - console.log(this.id) - } - - private baseUrl="http://localhost:8080"; - //header: any; - - constructor(private http: HttpClient) { } + + } + + baseUrl=environment.apiUrl; + constructor(private http: HttpClient,private router:Router) { } + + handleError(err: HttpErrorResponse): any { + if ( err.status === 403) { + alert("UNAUTHORIZED ACCESS DETECTED") + sessionStorage.clear() + localStorage.clear() + this.router.navigateByUrl(`/login`); } + } + LoadBooks(): Observable { return this.http.get(this.baseUrl+'/books/admin') + } imageUpload(image:any,booksId:any):Observable{ - console.log("library") const formData: FormData = new FormData(); formData.append('image',image ); - - - return this.http.post(this.baseUrl+'/books/save/image/'+booksId,formData); + + return this.http.post(this.baseUrl+'/books/save/image/'+booksId,formData) + } } diff --git a/FrontEnd/Library/src/app/imageupload/imageupload.component.ts b/FrontEnd/Library/src/app/imageupload/imageupload.component.ts index becece12..4b6d44a5 100644 --- a/FrontEnd/Library/src/app/imageupload/imageupload.component.ts +++ b/FrontEnd/Library/src/app/imageupload/imageupload.component.ts @@ -24,7 +24,6 @@ export class ImageuploadComponent implements OnInit { ngOnInit(): void { this.service.LoadBooks().subscribe(data=>{ this.data=data - console.log(this.service.getId()); }) } @@ -40,12 +39,12 @@ export class ImageuploadComponent implements OnInit { if (file) { this.currentFile = file; } - console.log(this.data.booksId) + this.service.imageUpload(this.currentFile,this.service.getId()).subscribe( response =>{ this.toast.success({detail:'Success',summary:' Book cover uploaded',duration:5000}); this.router.navigate(['/addbooks']) - console.log(response) + if(response) { diff --git a/FrontEnd/Library/src/app/login/login.component.ts b/FrontEnd/Library/src/app/login/login.component.ts index 2f84b2c3..ccd9490b 100644 --- a/FrontEnd/Library/src/app/login/login.component.ts +++ b/FrontEnd/Library/src/app/login/login.component.ts @@ -27,6 +27,7 @@ export class LoginComponent implements OnInit { ) ngOnInit(): void { + localStorage. clear(); } @@ -36,8 +37,7 @@ export class LoginComponent implements OnInit { this.service.login(this.loginForm.value).subscribe(result=>{ if(result.userId){ this.responsedata=result - console.log("log=",result); - + if(result.role==2){ localStorage.setItem('token',this.responsedata.accessToken.value) this.toast.info({detail:'Hello User ',summary:'LogIn Successfull',duration:5000}); @@ -55,12 +55,12 @@ export class LoginComponent implements OnInit { } else{ - //alert("login not sucessful"); + this.toast.warning({detail:'success msg',summary:'LogIn failed',duration:5000}); } }, (error: any) =>{ this.toast.error({detail:'Login Failed',summary:'Invalid Credentials',duration:5000}); - console.log(error)}); + }); } diff --git a/FrontEnd/Library/src/app/notification/notification.component.css b/FrontEnd/Library/src/app/notification/notification.component.css index b354b8d1..e8a877b0 100644 --- a/FrontEnd/Library/src/app/notification/notification.component.css +++ b/FrontEnd/Library/src/app/notification/notification.component.css @@ -52,6 +52,8 @@ p{ } .table-bordered{ border: 1px solid; + margin-left: 70px; + margin-right: 20px; } th { background-color: #232524; diff --git a/FrontEnd/Library/src/app/notification/notification.component.html b/FrontEnd/Library/src/app/notification/notification.component.html index 7143bda0..0e27d003 100644 --- a/FrontEnd/Library/src/app/notification/notification.component.html +++ b/FrontEnd/Library/src/app/notification/notification.component.html @@ -2,12 +2,12 @@ -

+ Issue date : {{due.issueDate| date:'dd/MM/yyyy'}}
Due date : {{due.dueDate| date:'dd/MM/yyyy'}}
Status : {{due.status}}
Due days : {{due.dueDays}}
Fine : {{due.fine}}
- +
\ No newline at end of file diff --git a/FrontEnd/Library/src/app/notification/notification.component.ts b/FrontEnd/Library/src/app/notification/notification.component.ts index f0c3db42..a0f594eb 100644 --- a/FrontEnd/Library/src/app/notification/notification.component.ts +++ b/FrontEnd/Library/src/app/notification/notification.component.ts @@ -89,7 +89,7 @@ export class NotificationComponent implements OnInit { "currency": "INR", "name": "", "description": "Test Transaction", - "image": "../assets/BooksImage/item_pics/item_pics/sherlok.jpeg", + "image": "../../assets/BooksImage/item_pics/aadu.jpeg", "order_id": "", //This is a sample Order ID. Pass the `id` obtained in the response of Step 1 // "callback_url": "https://eneqd3r9zrjok.x.pipedream.net/", "handler": function (response: any) { @@ -105,7 +105,7 @@ export class NotificationComponent implements OnInit { "prefill": { "name": this.name, "email": this.email, - "contact": this.phone + "contact": this.phone, }, "notes": { "address": "Razorpay Corporate Office" @@ -114,11 +114,12 @@ export class NotificationComponent implements OnInit { "color": "#3399cc" } }; - pay(fine: number, bookname: string) { + pay(fine: number, bookname: string,BooksImage:string) { console.log(fine) this.tot = fine * 100; this.options.amount = this.tot; this.options.name = bookname; + this.options.image=BooksImage; this.service.LoadDueByUser().subscribe((data: any) => { this.duedata = data; this.borrow = data; @@ -129,9 +130,6 @@ export class NotificationComponent implements OnInit { this.rzp1 = new this.service.nativeWindow.Razorpay(this.options); this.rzp1.open(); this.rzp1.on('payment.failed', function (response: any) { - - // this.message ="Payment Failed" - console.log(response.console.error.code); } ); @@ -145,8 +143,9 @@ export class NotificationComponent implements OnInit { this.service.payment(this.duedata[0].borrowId).subscribe({ next: (Response: any) => { console.log(Response); - alert("Payment Success") - // window.location.reload() + // alert("Payment Success") + this.toast.info({summary:'payment Successfull',duration:5000}); + }, error: (Response: any) => { console.log(Response) diff --git a/FrontEnd/Library/src/app/page-notfound/page-notfound.component.css b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.css new file mode 100644 index 00000000..d1095a6f --- /dev/null +++ b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.css @@ -0,0 +1,34 @@ + +/*====================== + 404 page +=======================*/ + + +.page_404{ padding:40px 0; background:#fff; font-family: 'Arvo', serif; +} + +.page_404 img{ width:100%;} + +.four_zero_four_bg{ + + background-image: url(https://cdn.dribbble.com/users/285475/screenshots/2083086/dribbble_1.gif); + height: 400px; + background-position: center; + } + + + .four_zero_four_bg h1{ + font-size:80px; + } + + .four_zero_four_bg h3{ + font-size:80px; + } + + .link_404{ + color: #fff!important; + padding: 10px 20px; + background: #39ac31; + margin: 20px 0; + display: inline-block;} + .contant_box_404{ margin-top:-50px;} \ No newline at end of file diff --git a/FrontEnd/Library/src/app/page-notfound/page-notfound.component.html b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.html new file mode 100644 index 00000000..a10a9f2e --- /dev/null +++ b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.html @@ -0,0 +1,27 @@ + +
+
+
+
+
+
+

404

+ + +
+ +
+

+ Look like you're lost +

+ +

the page you are looking for not avaible!

+ + + +
+
+
+
+
+
\ No newline at end of file diff --git a/FrontEnd/Library/src/app/page-notfound/page-notfound.component.spec.ts b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.spec.ts new file mode 100644 index 00000000..fe933e7d --- /dev/null +++ b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.spec.ts @@ -0,0 +1,23 @@ +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { PageNotfoundComponent } from './page-notfound.component'; + +describe('PageNotfoundComponent', () => { + let component: PageNotfoundComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ PageNotfoundComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(PageNotfoundComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/FrontEnd/Library/src/app/page-notfound/page-notfound.component.ts b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.ts new file mode 100644 index 00000000..507d7af8 --- /dev/null +++ b/FrontEnd/Library/src/app/page-notfound/page-notfound.component.ts @@ -0,0 +1,23 @@ +import { Component, OnInit } from '@angular/core'; +import { Router } from '@angular/router'; +import {Location} from '@angular/common'; + +@Component({ + selector: 'app-page-notfound', + templateUrl: './page-notfound.component.html', + styleUrls: ['./page-notfound.component.css'] +}) +export class PageNotfoundComponent implements OnInit { + + + constructor(private router:Router,private _location: Location) { } + + ngOnInit(): void { + } + home() { + + this._location.back(); + + // this.router.navigate(['/body']) + } +} diff --git a/FrontEnd/Library/src/app/rejectrequest/rejectrequest.component.ts b/FrontEnd/Library/src/app/rejectrequest/rejectrequest.component.ts index 88bc1fcb..99499223 100644 --- a/FrontEnd/Library/src/app/rejectrequest/rejectrequest.component.ts +++ b/FrontEnd/Library/src/app/rejectrequest/rejectrequest.component.ts @@ -15,7 +15,6 @@ export class RejectrequestComponent implements OnInit { borrowId:any; constructor(private router:Router ,private booksService:BooksService,private borrowService:BorrowService) { - // this.booksList=[]; this.borrowList=[]; } ngOnInit(): void { @@ -36,62 +35,22 @@ onSubmit(){ } rejectRequest(borrowId:any){ - console.log("hi") - console.log(borrowId) let body={ reason: this.ObjSampleForm.controls['reason'].value } - console.log(body) - this.borrowService.updateReject(borrowId, body).subscribe({ next: (Response: any) => { - console.log(Response); alert(" Book Rejected") window.location.reload() }, error: (Response: any) => { - console.log(Response) - alert("invalid Borrow details") + alert("invalid Borrow details") } }) this.router.navigate(['/borrow']) } - - -// update(borrowId:any){ -// console.log("vjydsvajys") -// console.log(borrowId) -// let body={ -// issueDate: this.ObjSampleForm.controls['issueDate'].value, -// returnDate: this.ObjSampleForm.controls['returnDate'].value, -// dueDate: this.ObjSampleForm.controls['dueDate'].value - -// } - -// console.log(body) -// this.borrowService.update(borrowId, body).subscribe({ -// next: (Response: any) => { -// console.log(Response); -// alert(" Book approved") -// window.location.reload() -// }, -// error: (Response: any) => { -// console.log(Response) -// alert("invalid Borrow details") -// } -// }) -// this.router.navigate(['/borrow']) - -// } - - home() - { - this.router.navigate(['/sidenav']) - } - - -} +} \ No newline at end of file diff --git a/FrontEnd/Library/src/app/sidenav/sidenav.component.css b/FrontEnd/Library/src/app/sidenav/sidenav.component.css index e014a963..d3174a9d 100644 --- a/FrontEnd/Library/src/app/sidenav/sidenav.component.css +++ b/FrontEnd/Library/src/app/sidenav/sidenav.component.css @@ -119,4 +119,65 @@ font-weight: 300; src: local('Titillium WebLight'), local('TitilliumWeb-Light'), url(http://themes.googleusercontent.com/static/fonts/titilliumweb/v2/anMUvcNT0H1YN4FII8wpr24bNCNEoFTpS2BTjF6FB5E.woff) format('woff'); } + + + + + + + + + * { + box-sizing: border-box; + } + + .menu { + float: left; + width: 20%; + text-align: center; + } + + .menu a { + background-color: #e5e5e5; + padding: 8px; + margin-top: 7px; + display: block; + width: 100%; + color: black; + } + + .main { + float: left; + width: 60%; + padding: 0 20px; + } + + .right { + background-color: #e5e5e5; + float: left; + width: 20%; + padding: 15px; + margin-top: 7px; + text-align: center; + } + + @media only screen and (max-width: 620px) { + /* For mobile phones: */ + .menu, .main, .right { + width: 100%; + } + .nav-text{ + visibility: hidden; + } + .main-menu{ + width:11%; + } + + .fa{ + width: 50%; + } + + + + } \ No newline at end of file diff --git a/FrontEnd/Library/src/app/sidenav/sidenav.component.html b/FrontEnd/Library/src/app/sidenav/sidenav.component.html index 93ac4e58..84971588 100644 --- a/FrontEnd/Library/src/app/sidenav/sidenav.component.html +++ b/FrontEnd/Library/src/app/sidenav/sidenav.component.html @@ -2,62 +2,7 @@ - - - -
@@ -66,7 +11,7 @@