From 9119fe57f34c5f2abbbf258337e76932a8f36762 Mon Sep 17 00:00:00 2001 From: Rohan Sircar Date: Fri, 24 Jul 2020 12:00:56 +0530 Subject: [PATCH] Added basic admin user profile page --- .../chatto/controller/AdminController.java | 18 ++++ .../templates/admin/user-profile.html | 88 +++++++++++++++++++ 2 files changed, 106 insertions(+) create mode 100644 src/main/resources/templates/admin/user-profile.html diff --git a/src/main/java/org/ros/chatto/controller/AdminController.java b/src/main/java/org/ros/chatto/controller/AdminController.java index 51621d3..da79f87 100644 --- a/src/main/java/org/ros/chatto/controller/AdminController.java +++ b/src/main/java/org/ros/chatto/controller/AdminController.java @@ -1,16 +1,24 @@ package org.ros.chatto.controller; +import java.util.Optional; + +import org.ros.chatto.model.ChatUser; import org.ros.chatto.service.UserService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.server.ResponseStatusException; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; @Controller @RequestMapping("/admin") +@Slf4j @RequiredArgsConstructor public class AdminController { @@ -32,4 +40,14 @@ public class AdminController { public String usersPage() { return "admin/users"; } + + @GetMapping("/users/{userName}") + public String userProfile(@PathVariable String userName) { + Optional maybeUser = userService.getUser(userName); + if (!maybeUser.isPresent()) { + throw new ResponseStatusException(HttpStatus.NOT_FOUND, + "Requested user does not exist"); + } + return "admin/user-profile"; + } } diff --git a/src/main/resources/templates/admin/user-profile.html b/src/main/resources/templates/admin/user-profile.html new file mode 100644 index 0000000..6dc9626 --- /dev/null +++ b/src/main/resources/templates/admin/user-profile.html @@ -0,0 +1,88 @@ + + + + +
+ User Profile +
+ + + + + + + + + + + + + +
+ + +
+ + +
+ + +
+ +
+ + +
+ + +
+

Dashboard

+ Generate Report +
+ + +
+ +
+ + +
+
+
Development Approach
+
+
+
John
+
+
+ +
+
+ +
+ + +
+ + +
+ +
+ + +
+ + + +
+ +
+ + + + \ No newline at end of file