From 74396ccd6893513e7b33acf141faf6036555be26 Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Wed, 13 Nov 2019 19:40:02 +0530 Subject: [PATCH] added thymeleaf template logic for active users in chat page --- .../controller/ChatMessageController.java | 6 ++++++ .../java/org/ros/chatto/controller/Home.java | 2 +- chatto/src/main/resources/static/css/chat.css | 2 +- chatto/src/main/resources/templates/chat.html | 21 +++++++++++++++---- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/chatto/src/main/java/org/ros/chatto/controller/ChatMessageController.java b/chatto/src/main/java/org/ros/chatto/controller/ChatMessageController.java index dea8e60..ae80fc1 100644 --- a/chatto/src/main/java/org/ros/chatto/controller/ChatMessageController.java +++ b/chatto/src/main/java/org/ros/chatto/controller/ChatMessageController.java @@ -10,6 +10,7 @@ import java.util.stream.Collectors; import javax.validation.Valid; +import org.ros.chatto.dto.ActiveUserDTO; import org.ros.chatto.dto.ChatMessageDTO; import org.ros.chatto.dto.MessageCipherDTO; import org.ros.chatto.error.ErrorModel; @@ -130,6 +131,11 @@ public class ChatMessageController { public List getAllOtherUsers(Principal principal) { return userService.findAllOtherUsers(principal.getName()); } + + @GetMapping("/get/active-users") + public List getAllOtherActiveUsers(Principal principal) { + return userService.getOtherActiveUsers(principal.getName()); + } } //public ResponseEntity> getMessages(@PathVariable String userName, Principal principal) { diff --git a/chatto/src/main/java/org/ros/chatto/controller/Home.java b/chatto/src/main/java/org/ros/chatto/controller/Home.java index 0a0a789..2e24671 100644 --- a/chatto/src/main/java/org/ros/chatto/controller/Home.java +++ b/chatto/src/main/java/org/ros/chatto/controller/Home.java @@ -83,7 +83,7 @@ public class Home { boolean isAdmin = authentication.getAuthorities().stream() .anyMatch(r -> r.getAuthority().equals("ROLE_ADMIN") || r.getAuthority().equals("ROLE_SUPER_USER")); System.out.println("Is admin? " + isAdmin); - modelAndView.addObject("userNames", userService.findAllOtherUsers(principal.getName())); + modelAndView.addObject("activeUsers", userService.getOtherActiveUsers(principal.getName())); return modelAndView; } // public String showHome(Model model) diff --git a/chatto/src/main/resources/static/css/chat.css b/chatto/src/main/resources/static/css/chat.css index f238c29..23841e6 100644 --- a/chatto/src/main/resources/static/css/chat.css +++ b/chatto/src/main/resources/static/css/chat.css @@ -175,7 +175,7 @@ html { color: white; } -.user_info p { +.user_info p, .user_info p span { font-size: 10px; color: rgba(255, 255, 255, 0.6); } diff --git a/chatto/src/main/resources/templates/chat.html b/chatto/src/main/resources/templates/chat.html index c141e0a..c7bf5bb 100644 --- a/chatto/src/main/resources/templates/chat.html +++ b/chatto/src/main/resources/templates/chat.html @@ -73,16 +73,29 @@ - +
  • - +
    Dec 25