Browse Source

Add bootstrap theme; Add return buttons; Confirm book deletion; Suppress

favicon.ico requests
Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.1-alpha
Pekka Helenius 4 years ago
parent
commit
597a6c0a48
6 changed files with 102 additions and 54 deletions
  1. +14
    -0
      bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java
  2. +7
    -0
      bookstore/src/main/resources/static/css/bootstrap.min.css
  3. +1
    -0
      bookstore/src/main/resources/static/css/bootstrap.min.css.map
  4. +24
    -13
      bookstore/src/main/resources/templates/bookadd.html
  5. +28
    -18
      bookstore/src/main/resources/templates/bookedit.html
  6. +28
    -23
      bookstore/src/main/resources/templates/booklist.html

+ 14
- 0
bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java View File

@ -8,6 +8,7 @@ import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ResponseStatus;
@ -165,5 +166,18 @@ public class BookController {
public String errorWebForm(HttpServletRequest requestData) {
return httpExceptionHandler.notFoundErrorHandler(requestData);
}
@RequestMapping(
value = "favicon.ico",
method = RequestMethod.GET
)
@ResponseBody
public void faviconRequest() {
/*
* We do not offer favicon for this website.
* Avoid HTTP status 404, and return nothing
* in server response when client requests the icon file.
*/
}
}

+ 7
- 0
bookstore/src/main/resources/static/css/bootstrap.min.css
File diff suppressed because it is too large
View File


+ 1
- 0
bookstore/src/main/resources/static/css/bootstrap.min.css.map
File diff suppressed because it is too large
View File


+ 24
- 13
bookstore/src/main/resources/templates/bookadd.html View File

@ -2,36 +2,47 @@
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" />
<title>Add new book</title>
</head>
<body>
<div class="col-md-4 mb-3">
<h1>Add new book</h1>
<div>
<form th:object="${book}" th:action="@{bookadd}" action="#" method="post">
<div>
<div class="form-group">
<label for="fname">Author</label>
<input type="text" th:field="*{author}" />
<input class="form-control" type="text" th:field="*{author}" placeholder="Book author"/>
<small class="form-text text-muted">Set book author name</small>
</div>
<div>
<div class="form-group">
<label for="fname">Title</label>
<input type="text" th:field="*{title}" />
<input class="form-control" type="text" th:field="*{title}" placeholder="Book title"/>
<small class="form-text text-muted">Set book primary title</small>
</div>
<div>
<div class="form-group">
<label for="fname">ISBN</label>
<input type="text" th:field="*{isbn}" />
<input class="form-control" type="text" th:field="*{isbn}" placeholder="Book ISBN code"/>
<small class="form-text text-muted">Set book ISBN code</small>
</div>
<div>
<div class="form-group">
<label for="fname">Year</label>
<input type="text" th:field="*{year}" />
<input class="form-control" type="text" th:field="*{year}" placeholder="Book publication year (YYYY)"/>
<small class="form-text text-muted">Set book publication year</small>
</div>
<div>
<div class="form-group">
<label for="fname">Price</label>
<input type="text" th:field="*{price}" />
<input class="form-control" type="text" th:field="*{price}" placeholder="Book price"/>
<small class="form-text text-muted">Set book price</small>
</div>
<input type="submit" value="Save book"></input>
<button class="btn btn-primary" type="submit">Add book</button>
</form>
<br>
<form action="#" th:action="@{/booklist}" method="get">
<button class="btn btn-success" type="submit">Return to book list page</button>
</form>
</div>


+ 28
- 18
bookstore/src/main/resources/templates/bookedit.html View File

@ -2,36 +2,46 @@
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="/css/bootstrap.min.css" th:href="@{/css/bootstrap.min.css}" />
<title>Update existing book</title>
</head>
<body>
<h1>Update existing book</h1>
<div>
<div class="col-md-4 mb-3">
<h1>Update existing book</h1>
<form th:object="${book}" th:action="@{/bookedit/{id}(id=${book.id})}" action="#" method="post">
<div>
<label for="fname">Author</label>
<input type="text" th:field="*{author}" />
<div class="form-group">
<label for="BookAuthor">Author</label><br>
<input class="form-control" type="text" th:field="*{author}" placeholder="Book author"/>
<small class="form-text text-muted">Set book author name</small>
</div>
<div>
<label for="fname">Title</label>
<input type="text" th:field="*{title}" />
<div class="form-group">
<label for="BookName">Title</label><br>
<input class="form-control" type="text" th:field="*{title}" placeholder="Book title"/>
<small class="form-text text-muted">Set book primary title</small>
</div>
<div>
<label for="fname">ISBN</label>
<input type="text" th:field="*{isbn}" />
<div class="form-group">
<label for="BookISBN">ISBN</label><br>
<input class="form-control" type="text" th:field="*{isbn}" placeholder="Book ISBN code"/>
<small class="form-text text-muted">Set book ISBN code</small>
</div>
<div>
<label for="fname">Year</label>
<input type="text" th:field="*{year}" />
<div class="form-group">
<label for="BookYear">Year</label><br>
<input class="form-control" type="text" th:field="*{year}" placeholder="Book publication year (YYYY)"/>
<small class="form-text text-muted">Set book publication year</small>
</div>
<div>
<label for="fname">Price</label>
<input type="text" th:field="*{price}" />
<div class="form-group">
<label for="BookPrice">Price</label><br>
<input class="form-control" type="text" th:field="*{price}" placeholder="Book price"/>
<small class="form-text text-muted">Set book price</small>
</div>
<input type="submit" value="Update book"></input>
<button class="btn btn-primary" type="submit">Update book</button>
</form>
<br>
<form action="#" th:action="@{/booklist}" method="get">
<button class="btn btn-success" type="submit">Return to book list page</button>
</form>
</div>


+ 28
- 23
bookstore/src/main/resources/templates/booklist.html View File

@ -2,33 +2,38 @@
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link type="text/css" rel="stylesheet" href="/css/bootstrap.min.css"
th:href="@{/css/bootstrap.min.css}" />
<title>Bookstore page</title>
</head>
<body>
<h1>Books</h1>
<table>
<tr>
<th>Author</th>
<th>Title</th>
<th>ISBN</th>
<th>Year</th>
</tr>
<tr th:each="book : ${books}">
<td th:text="${book.author}"></td>
<td th:text="${book.title}"></td>
<td th:text="${book.isbn}"></td>
<td th:text="${book.year}"></td>
<td>
<a th:href="@{/bookdelete/{id}(id=${book.id})}">Delete</a>
</td>
<td>
<a th:href="@{/bookedit/{id}(id=${book.id})}">Edit</a>
</td>
</tr>
</table>
<div>
<a href="/bookadd">Add Book</a>
<h1>Books</h1>
<table class="table table-striped">
<tr>
<th>Author</th>
<th>Title</th>
<th>ISBN</th>
<th>Year</th>
<th>Actions</th>
<th></th>
</tr>
<tr th:each="book : ${books}">
<td th:text="${book.author}"></td>
<td th:text="${book.title}"></td>
<td th:text="${book.isbn}"></td>
<td th:text="${book.year}"></td>
<td><a class="btn btn-danger"
th:attr="onclick='return confirm(\'' + 'Delete book: ' + ${book.title} + '?' + '\');'"
th:href="@{/bookdelete/{id}(id=${book.id})}">Delete</a></td>
<td><a class="btn btn-warning"
th:href="@{/bookedit/{id}(id=${book.id})}">Edit</a></td>
</tr>
</table>
<div>
<a class="btn btn-success" href="/bookadd">Add Book</a>
</div>
</div>
</body>
</html>

Loading…
Cancel
Save