Added basic admin user profile page

This commit is contained in:
Rohan Sircar 2020-07-24 12:00:56 +05:30
parent e569420ca5
commit 9119fe57f3
2 changed files with 106 additions and 0 deletions

View File

@ -1,16 +1,24 @@
package org.ros.chatto.controller; package org.ros.chatto.controller;
import java.util.Optional;
import org.ros.chatto.model.ChatUser;
import org.ros.chatto.service.UserService; import org.ros.chatto.service.UserService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.ui.Model; import org.springframework.ui.Model;
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.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.server.ResponseStatusException;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@Controller @Controller
@RequestMapping("/admin") @RequestMapping("/admin")
@Slf4j
@RequiredArgsConstructor @RequiredArgsConstructor
public class AdminController { public class AdminController {
@ -32,4 +40,14 @@ public class AdminController {
public String usersPage() { public String usersPage() {
return "admin/users"; return "admin/users";
} }
@GetMapping("/users/{userName}")
public String userProfile(@PathVariable String userName) {
Optional<ChatUser> maybeUser = userService.getUser(userName);
if (!maybeUser.isPresent()) {
throw new ResponseStatusException(HttpStatus.NOT_FOUND,
"Requested user does not exist");
}
return "admin/user-profile";
}
} }

View File

@ -0,0 +1,88 @@
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<div th:replace="fragments/head :: headFragment">
<title id="pageTitle" th:text="${userName}">User Profile</title>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js" th:if="false"></script>
<script src="http://blackpeppersoftware.github.io/thymeleaf-fragment.js/thymeleaf-fragment.js"
data-template-prefix="../" defer="defer" th:if="false"></script>
<th:block th:include="fragments/admin :: headFragment"></th:block>
</head>
<!-- TODO
Make user admin / remove user from admin
Change E2E passphrase
Delete Messages
-->
<!-- <div th:include="fragments/admin :: admin-sidebar"></div> -->
<body id="page-top">
<!-- Page Wrapper -->
<div id="wrapper">
<div th:include="fragments/admin :: sidebar-fragment"></div>
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column" style="background-color: #333;">
<!-- Main Content -->
<div id="content">
<div th:include="fragments/admin :: topbar-fragment"></div>
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<div class="d-sm-flex align-items-center justify-content-between mb-4">
<h1 class="h3 mb-0 text-light">Dashboard</h1>
<a href="#" class="d-none d-sm-inline-block btn btn-sm btn-primary shadow-sm"><i
class="fas fa-download fa-sm text-white-50"></i> Generate Report</a>
</div>
<!-- Content Row -->
<div class="row">
<div class="col-lg-4 mb-4 offset-lg-4">
<!-- Approach -->
<div class="card bg-dark border border-dark text-white shadow mb-4">
<div class="card-header bg-secondary border border-secondary py-3">
<h6 class="m-0 font-weight-bold text-white">Development Approach</h6>
</div>
<div class="card-body">
<div th:text="${userName}">John</div>
</div>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<div th:include="fragments/admin :: footer"></div>
</div>
<!-- End of Content Wrapper -->
</div>
<!-- End of Page Wrapper -->
<th:block th:include="fragments/admin :: modal"></th:block>
<div th:if="false">
<th:block th:include="admin :: modal"></th:block>
</div>
</body>
</html>