Changes to error model and login/registration cards

Added json property names to error model
Switched to grid offset instead of changing card width using CSS
This commit is contained in:
Rohan Sircar 2019-10-26 18:55:10 +05:30
parent d3ac95e8f4
commit febfaeec9a
10 changed files with 62 additions and 67 deletions

View File

@ -17,7 +17,6 @@ import org.ros.chatto.error.ErrorResponse;
import org.ros.chatto.service.ChatService; import org.ros.chatto.service.ChatService;
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.HttpHeaders;
import org.springframework.http.HttpStatus; import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
@ -45,19 +44,18 @@ public class ChatMessageController {
@PostMapping(value = "/post/message", consumes = { "application/json" }) @PostMapping(value = "/post/message", consumes = { "application/json" })
@ResponseBody @ResponseBody
public ResponseEntity<?> newMessage(@RequestBody @Valid ChatMessageDTO chatMessageDTO, public ResponseEntity<?> newMessage(@RequestBody @Valid ChatMessageDTO chatMessageDTO,
Principal principal) { BindingResult bindingResult, Principal principal) {
// if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
//
//// return new ResponseEntity<List<FieldError>>(bindingResult.getFieldErrors(),HttpStatus.BAD_REQUEST); // return new ResponseEntity<List<FieldError>>(bindingResult.getFieldErrors(),HttpStatus.BAD_REQUEST);
// return new ResponseEntity<ErrorResponse>(handleException(bindingResult), HttpStatus.BAD_REQUEST); return new ResponseEntity<ErrorResponse>(handleException(bindingResult), HttpStatus.BAD_REQUEST);
// } }
MessageCipherDTO messageCipher = chatMessageDTO.getMessageCipher(); MessageCipherDTO messageCipher = chatMessageDTO.getMessageCipher();
String fromUser = principal.getName(); String fromUser = principal.getName();
String toUser = chatMessageDTO.getToUser(); String toUser = chatMessageDTO.getToUser();
System.out.println("Message cipher = " + messageCipher); System.out.println("Message cipher = " + messageCipher);
chatMessageDTO = chatService.saveNewMessage(fromUser, toUser, messageCipher); chatMessageDTO = chatService.saveNewMessage(fromUser, toUser, messageCipher);
HttpHeaders responseHeader = new HttpHeaders(); return new ResponseEntity<ChatMessageDTO>(chatMessageDTO, HttpStatus.CREATED);
return new ResponseEntity<ChatMessageDTO>(chatMessageDTO, responseHeader, HttpStatus.CREATED);
} }
/** /**

View File

@ -1,5 +1,7 @@
package org.ros.chatto.error; package org.ros.chatto.error;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
@ -8,8 +10,11 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ErrorModel{ public class ErrorModel{
@JsonProperty("field_name")
private String fieldName; private String fieldName;
@JsonProperty("rejected_value")
private Object rejectedValue; private Object rejectedValue;
@JsonProperty("error_message")
private String messageError; private String messageError;

View File

@ -2,6 +2,8 @@ package org.ros.chatto.error;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
@ -12,6 +14,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class ErrorResponse { public class ErrorResponse {
@JsonProperty("errors")
private List<ErrorModel> errorMessage; private List<ErrorModel> errorMessage;
} }

View File

@ -8,7 +8,6 @@ import javax.validation.Valid;
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.dto.ReencryptionDTO; import org.ros.chatto.dto.ReencryptionDTO;
import org.ros.chatto.model.ChatMessage;
import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.PageRequest;
public interface ChatService { public interface ChatService {

View File

@ -109,18 +109,13 @@ textarea {
width: 80%; width: 80%;
} }
#login-card {
/* #login-card {
width: 40%; width: 40%;
/* margin: 0 auto; */ } */
/* Added */
/* float: none; */
/* Added */
/* margin-bottom: 10px; */
/* Added */
}
@media only screen and (max-width: 600px) { @media only screen and (max-width: 600px) {
#login-card { /* #login-card {
width: 90%; width: 90%;
} } */
} }

View File

@ -84,8 +84,8 @@
<label for="passphrase">Passphrase: </label> <label for="passphrase">Passphrase: </label>
<input class="form-control" type="password" id="passphrase" required> <input class="form-control" type="password" id="passphrase" required>
</div> </div>
<div class="form-group"> <div class="form-group text-center">
<button class="btn btn-secondary">Submit</button> <button class="btn btn-secondary mx-auto">Submit</button>
</div> </div>
</div> </div>
</div> </div>

View File

@ -29,7 +29,7 @@
<!-- <div class="jumbotron bg-primary"> --> <!-- <div class="jumbotron bg-primary"> -->
<div class="d-flex rounded"> <div class="d-flex rounded">
<div class="p-4 align-self-end"> <div class="">
<h1 class="display-4">Chatto - Self Hosted, Minimal E2E Chat</h1> <h1 class="display-4">Chatto - Self Hosted, Minimal E2E Chat</h1>
<!-- <p th:if="${chatUser}" th:text="'username: ' + ${chatUser.userName}">You need to login</p> <!-- <p th:if="${chatUser}" th:text="'username: ' + ${chatUser.userName}">You need to login</p>
<th:block th:each="userName: ${userNames}"> <th:block th:each="userName: ${userNames}">

View File

@ -38,7 +38,7 @@
<header> <header>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-sm py-5"> <div class=" col-lg-5 offset-lg-3 py-5">
<!-- <h4 class="display-4 text-center py-2">Chat</h4> --> <!-- <h4 class="display-4 text-center py-2">Chat</h4> -->
<div class="card text-white bg-primary mb-3 text-center card-form rounded mx-auto" id="login-card"> <div class="card text-white bg-primary mb-3 text-center card-form rounded mx-auto" id="login-card">

View File

@ -15,9 +15,9 @@
<header> <header>
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class="col-sm py-5"> <div class="col-lg-5 offset-lg-3 py-5">
<!-- <h4 class="display-4 text-center py-2">Chat</h4> --> <!-- <h4 class="display-4 text-center py-2">Chat</h4> -->
<div class="card text-white bg-primary mb-3 card-form rounded mx-auto" id="login-card"> <div class="card text-white bg-primary mb-3 card-form rounded mx-auto" id="registration-card">
<div class="card-body rounded"> <div class="card-body rounded">
<!-- <h4 class="card-title">Chat</h4> --> <!-- <h4 class="card-title">Chat</h4> -->

View File

@ -6,13 +6,9 @@
<title id="pageTitle">User Home</title> <title id="pageTitle">User Home</title>
</div> </div>
<script src="https://code.jquery.com/jquery-2.1.4.min.js" th:if="false"></script> <script src="https://code.jquery.com/jquery-2.1.4.min.js" th:if="false"></script>
<script <script src="http://blackpeppersoftware.github.io/thymeleaf-fragment.js/thymeleaf-fragment.js" data-template-prefix="../" defer="defer" th:if="false"></script>
src="http://blackpeppersoftware.github.io/thymeleaf-fragment.js/thymeleaf-fragment.js" <link th:href="@{/css/master.css}" href="../../static/css/master.css" rel="stylesheet" th:if="false">
data-template-prefix="../" defer="defer" th:if="false"></script> <link th:href="@{/css/colors.css}" href="../../static/css/colors.css" rel="stylesheet" th:if="false">
<link th:href="@{/css/master.css}" href="../../static/css/master.css"
rel="stylesheet" th:if="false">
<link th:href="@{/css/colors.css}" href="../../static/css/colors.css"
rel="stylesheet" th:if="false">
</head> </head>
<body> <body>
@ -24,8 +20,7 @@
<div class="col-sm py-5"> <div class="col-sm py-5">
<!-- <h4 class="display-4 text-center py-2">Chat</h4> --> <!-- <h4 class="display-4 text-center py-2">Chat</h4> -->
<div <div class="card text-white bg-primary mb-3 text-center card-form rounded mx-auto">
class="card text-white bg-primary mb-3 text-center card-form rounded mx-auto">
<h1 class="display-4">User Page</h1> <h1 class="display-4">User Page</h1>
<div class="card-body rounded"> <div class="card-body rounded">
<!-- <h4 class="card-title">Chat</h4> --> <!-- <h4 class="card-title">Chat</h4> -->