added thymeleaf template logic for active users in chat page
This commit is contained in:
parent
e85650d499
commit
74396ccd68
@ -10,6 +10,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
import org.ros.chatto.dto.ActiveUserDTO;
|
||||||
import org.ros.chatto.dto.ChatMessageDTO;
|
import org.ros.chatto.dto.ChatMessageDTO;
|
||||||
import org.ros.chatto.dto.MessageCipherDTO;
|
import org.ros.chatto.dto.MessageCipherDTO;
|
||||||
import org.ros.chatto.error.ErrorModel;
|
import org.ros.chatto.error.ErrorModel;
|
||||||
@ -130,6 +131,11 @@ public class ChatMessageController {
|
|||||||
public List<String> getAllOtherUsers(Principal principal) {
|
public List<String> getAllOtherUsers(Principal principal) {
|
||||||
return userService.findAllOtherUsers(principal.getName());
|
return userService.findAllOtherUsers(principal.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("/get/active-users")
|
||||||
|
public List<ActiveUserDTO> getAllOtherActiveUsers(Principal principal) {
|
||||||
|
return userService.getOtherActiveUsers(principal.getName());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public ResponseEntity<List<ChatMessage>> getMessages(@PathVariable String userName, Principal principal) {
|
//public ResponseEntity<List<ChatMessage>> getMessages(@PathVariable String userName, Principal principal) {
|
||||||
|
@ -83,7 +83,7 @@ public class Home {
|
|||||||
boolean isAdmin = authentication.getAuthorities().stream()
|
boolean isAdmin = authentication.getAuthorities().stream()
|
||||||
.anyMatch(r -> r.getAuthority().equals("ROLE_ADMIN") || r.getAuthority().equals("ROLE_SUPER_USER"));
|
.anyMatch(r -> r.getAuthority().equals("ROLE_ADMIN") || r.getAuthority().equals("ROLE_SUPER_USER"));
|
||||||
System.out.println("Is admin? " + isAdmin);
|
System.out.println("Is admin? " + isAdmin);
|
||||||
modelAndView.addObject("userNames", userService.findAllOtherUsers(principal.getName()));
|
modelAndView.addObject("activeUsers", userService.getOtherActiveUsers(principal.getName()));
|
||||||
return modelAndView;
|
return modelAndView;
|
||||||
}
|
}
|
||||||
// public String showHome(Model model)
|
// public String showHome(Model model)
|
||||||
|
@ -175,7 +175,7 @@ html {
|
|||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.user_info p {
|
.user_info p, .user_info p span {
|
||||||
font-size: 10px;
|
font-size: 10px;
|
||||||
color: rgba(255, 255, 255, 0.6);
|
color: rgba(255, 255, 255, 0.6);
|
||||||
}
|
}
|
||||||
|
@ -73,16 +73,29 @@
|
|||||||
</li>
|
</li>
|
||||||
</ui>
|
</ui>
|
||||||
<ui class="contacts">
|
<ui class="contacts">
|
||||||
<th:block th:each="userName: ${userNames}">
|
<th:block th:each="au: ${activeUsers}">
|
||||||
<li name="user-box" class="user-box">
|
<li name="user-box" class="user-box">
|
||||||
<div class="d-flex bd-highlight">
|
<div class="d-flex bd-highlight">
|
||||||
<div class="img_cont">
|
<div class="img_cont">
|
||||||
<img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg" class="rounded-circle user_img">
|
<img src="https://static.turbosquid.com/Preview/001292/481/WV/_D.jpg" class="rounded-circle user_img">
|
||||||
<span class="online_icon"></span>
|
<span th:if="${au.online == true}" class="online_icon"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="user_info">
|
<div class="user_info">
|
||||||
<span th:text="${userName}">Khalid</span>
|
<span th:text="${au.userName}">Khalid</span>
|
||||||
<p th:text="${userName} + ' is online'">Kalid is online</p>
|
<div th:switch="${au.online}">
|
||||||
|
<p th:case="true" th:text="${au.userName} + ' is online'">Khalid is online</p>
|
||||||
|
<th:block th:case="false">
|
||||||
|
<th:block th:if="${au.lastActive == null}" >
|
||||||
|
<p th:text="'User has not logged in yet'"></p>
|
||||||
|
</th:block>
|
||||||
|
<th:block th:if="${au.lastActive != null}">
|
||||||
|
<p th:text="'Last active = ' + ${au.lastActive}">Last active 3 hours ago</p>
|
||||||
|
</th:block>
|
||||||
|
<!-- <p th:case="${au.online == true}" th:text="${au.userName} + ' is online'">Khalid is online</p>
|
||||||
|
<p th:if="${au.online == false}" th:text="${au.userName} + ' is offline' + ' Last active = ' + ${au.lastActive}">Khalid is offline. -->
|
||||||
|
<!-- <span th:text="'Last active = ' + ${au.lastActive}"></span> -->
|
||||||
|
</th:block>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex flex-column ml-auto">
|
<div class="d-flex flex-column ml-auto">
|
||||||
<div class="text-right">Dec 25</div>
|
<div class="text-right">Dec 25</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user