Fakultas Ilmu Komputer UI

Commit 108b9123 authored by RYAN PUTRA BUDIANTO's avatar RYAN PUTRA BUDIANTO
Browse files

improve ui

parent 1bb91b17
Pipeline #134301 failed with stages
in 24 minutes and 17 seconds
......@@ -39,7 +39,7 @@ public class CartController {
var cart = cartService.findCartByUsername(username);
cartService.updateCart(cart);
model.addAttribute("cart", cart);
model.addAttribute("bookorders", cartService.getAllBookOrders(userService.getUserByName(principal.getName())));
model.addAttribute("bookorders", cartService.getAllBookOrders(userService.getUserByName(username)));
return "cart";
}
......@@ -81,7 +81,7 @@ public class CartController {
var user = userService.getUserByName(username);
cartService.updateCart(cart);
model.addAttribute("cart", cart);
model.addAttribute("bookorders", cartService.getAllBookOrders(userService.getUserByName(principal.getName())));
model.addAttribute("bookorders", cartService.getAllBookOrders(userService.getUserByName(username)));
model.addAttribute("payments", userService.getPaymentMethods(user));
return "purchase";
}
......
......@@ -40,6 +40,7 @@ public class PaymentController {
@GetMapping(path="/payment-methods")
public String paymentList(Model model, Principal principal){
paymentService.getUserPayments();
model.addAttribute("username", (principal != null) ? principal.getName() : "");
model.addAttribute("payments", paymentService.getUserPayments());
model.addAttribute("user", userService.getUserByName(principal.getName()));
......
......@@ -41,7 +41,8 @@ public class ProfileController {
}
@GetMapping(path="/create-address")
public String createAddress(Model model){
public String createAddress(Principal principal, Model model){
model.addAttribute("username", (principal != null) ? principal.getName() : "");
model.addAttribute("form", new CreateAddressForm());
return "address-create";
}
......@@ -55,12 +56,13 @@ public class ProfileController {
}
@GetMapping(path="/update-address/{id}")
public String updateAddress(Model model, @PathVariable Long id){
public String updateAddress(Principal principal, Model model, @PathVariable Long id){
var form = new CreateAddressForm();
AddressModel address = addressRepository.getAddressFromId(id);
form.setDescription(address.getDescription());
form.setCity(address.getCity());
form.setPostalCode(address.getPostalCode());
model.addAttribute("username", (principal != null) ? principal.getName() : "");
model.addAttribute("form", form);
return "address-update";
}
......@@ -85,7 +87,8 @@ public class ProfileController {
}
@GetMapping(path="/edit-profile")
public String editProfile(Model model){
public String editProfile(Principal principal, Model model){
model.addAttribute("user", userService.getUserByName(principal.getName()));
model.addAttribute("form", new EditProfileForm());
return "profile-edit";
}
......
......@@ -18,7 +18,7 @@ public class Wishlist {
@Column(name = "wishlist_id")
private Long wishlistId;
@OneToMany(cascade = CascadeType.ALL)
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(
name= "wishlist_item",
joinColumns = @JoinColumn(name = "wishlist_id"),
......
......@@ -44,7 +44,7 @@ public class BookServiceImpl implements BookService {
throw new InvalidStockException(form.getTitle(), form.getStock());
}
if(file != null){
if(file != null && !file.isEmpty()){
try{
book.setImg(ImageConverter.getInstance().getString(file.getBytes()));
} catch (Exception e){
......
......@@ -10,6 +10,7 @@ import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Objects;
@Service
public class WishlistServiceImpl implements WishlistService {
......@@ -35,7 +36,7 @@ public class WishlistServiceImpl implements WishlistService {
if(tempBooks.isEmpty()) {
tempBooks.add(book);}
else{
if(tempBooks.stream().anyMatch(b -> b.getBookId() == book.getBookId())){
if(tempBooks.stream().anyMatch(b -> Objects.equals(b.getBookId(), book.getBookId()))){
return tempBooks;
}
......@@ -44,13 +45,6 @@ public class WishlistServiceImpl implements WishlistService {
}
if (wishlist == null) {
wishlist = new Wishlist();
wishlist.setUser(user);
wishlist.setWishlistItems(tempBooks);
wishlistRepository.save(wishlist);
wishlistRepository.insertUser(user.getUserId(), wishlist.getWishlistId());
}
wishlist.setWishlistItems(tempBooks);
wishlistRepository.save(wishlist);
......
......@@ -6,8 +6,75 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>body{
background-color: #F2FCFD;
background-image: url("https://i.imgur.com/BnSpO0s.png");
height: 100%;
background-position: center;
background-repeat: repeat-y;
background-size: cover;
}
.header {
padding-bottom: 10px;
display:flex;
flex-direction: row;
align-items: center;
text-align: left;
background: #448498;
color: white;
font-size: 25px;
font-family: "Helvetica",serif;
}
/* Style the search box inside the navigation bar */
.search[type=text] {
float: left;
width: 80%;
padding: 6px;
border: none;
margin-right: 10px;
padding-left: 10px;
font-size: 17px;
}
.sign-in-text{
padding-top: 5px;
min-width: 150px;
}
.forminput{
width:100%;
}
.submit-button{
background: #448498;
border:0px;
height:40px;
width:50px;
}
</style>
</head>
<body>
<div class="header mb-4">
<div style="width: 1%"></div>
<a href="/"><img src="https://i.imgur.com/cyBT3sP.png" alt="RBS" width="100" height="100" style="padding-left: 5px"></a>
<a href="/"><img src="https://i.imgur.com/aREsEE8.png" alt="Ryan's Book Store" height="100"></a>
<div style="width: 1%"></div>
<div class="forminput">
<form id="search-form" th:action="@{/book/search/}" method="get">
<input id = "bookTitle" class="search" type="text" placeholder="Search by title..">
<button type="submit" class = "submit-button">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
</button>
</form>
</div>
<div style="width: 3%"></div>
<a href="/wishlist"><img src="https://i.imgur.com/HwTZHG8.png" class = "wishlist-button" alt="wishlist" height="40"></a>
<div style="width: 3%"></div>
<a href="/cart"><img src="https://i.imgur.com/EPveDOI.png" class = "cart-button" alt="cart" height="40"></a>
<div style="width: 3%"></div>
<a th:href ="${username.isBlank() ? '/login' : '/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${username.isBlank() ? '/login' : '/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${username.isBlank()} ? 'Sign In' : ${username}"></a>
</div>
<div class="container">
<form action="" th:action="@{/create-address}" th:object="${form}" method="post" id="input-form">
<div class="form-group">
......
......@@ -6,8 +6,75 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>body{
background-color: #F2FCFD;
background-image: url("https://i.imgur.com/BnSpO0s.png");
height: 100%;
background-position: center;
background-repeat: repeat-y;
background-size: cover;
}
.header {
padding-bottom: 10px;
display:flex;
flex-direction: row;
align-items: center;
text-align: left;
background: #448498;
color: white;
font-size: 25px;
font-family: "Helvetica",serif;
}
/* Style the search box inside the navigation bar */
.search[type=text] {
float: left;
width: 80%;
padding: 6px;
border: none;
margin-right: 10px;
padding-left: 10px;
font-size: 17px;
}
.sign-in-text{
padding-top: 5px;
min-width: 150px;
}
.forminput{
width:100%;
}
.submit-button{
background: #448498;
border:0px;
height:40px;
width:50px;
}
</style>
</head>
<body>
<div class="header mb-4">
<div style="width: 1%"></div>
<a href="/"><img src="https://i.imgur.com/cyBT3sP.png" alt="RBS" width="100" height="100" style="padding-left: 5px"></a>
<a href="/"><img src="https://i.imgur.com/aREsEE8.png" alt="Ryan's Book Store" height="100"></a>
<div style="width: 1%"></div>
<div class="forminput">
<form id="search-form" th:action="@{/book/search/}" method="get">
<input id = "bookTitle" class="search" type="text" placeholder="Search by title..">
<button type="submit" class = "submit-button">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
</button>
</form>
</div>
<div style="width: 3%"></div>
<a href="/wishlist"><img src="https://i.imgur.com/HwTZHG8.png" class = "wishlist-button" alt="wishlist" height="40"></a>
<div style="width: 3%"></div>
<a href="/cart"><img src="https://i.imgur.com/EPveDOI.png" class = "cart-button" alt="cart" height="40"></a>
<div style="width: 3%"></div>
<a th:href ="${username.isBlank() ? '/login' : '/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${username.isBlank() ? '/login' : '/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${username.isBlank()} ? 'Sign In' : ${username}"></a>
</div>
<div class="container">
<form action="" th:action="@{/update-address}" th:object="${form}" method="post" id="input-form">
......
......@@ -45,6 +45,13 @@
.forminput{
width:100%;
}
.submit-button{
background: #448498;
border:0px;
height:40px;
width:50px;
}
</style>
</head>
<body>
......@@ -56,7 +63,7 @@
<div class="forminput">
<form id="search-form" th:action="@{/book/search/}" method="get">
<input id = "bookTitle" class="search" type="text" placeholder="Search by title..">
<button type="submit">
<button type="submit" class = "submit-button">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
</button>
</form>
......@@ -66,8 +73,8 @@
<div style="width: 3%"></div>
<a href="/cart"><img src="https://i.imgur.com/EPveDOI.png" class = "cart-button" alt="cart" height="40"></a>
<div style="width: 3%"></div>
<a href ="/profile"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" height="40" style="padding-right: 10px"></a>
<a href ="/profile" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${user.username}"></a>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${user.username.isBlank()} ? 'Sign In' : ${user.username}"></a>
</div>
<div class = "container">
......
......@@ -31,11 +31,11 @@
/* Style the search box inside the navigation bar */
.search[type=text] {
float: right;
width: 50%;
float: left;
width: 80%;
padding: 6px;
border: none;
margin-right: 2px;
margin-right: 10px;
padding-left: 10px;
font-size: 17px;
}
......@@ -43,27 +43,40 @@
padding-top: 5px;
min-width: 150px;
}
</style>
.forminput{
width:100%;
}
.submit-button{
background: #448498;
border:0px;
height:40px;
width:50px;
}
</style>
</head>
<body>
<div class="header">
<div class="header mb-4">
<div style="width: 1%"></div>
<img src="https://i.imgur.com/cyBT3sP.png" alt="RBS" width="100" height="100" style="padding-left: 5px">
<img src="https://i.imgur.com/aREsEE8.png" alt="Ryan's Book Store" height="100">
<a href="/"><img src="https://i.imgur.com/cyBT3sP.png" alt="RBS" width="100" height="100" style="padding-left: 5px"></a>
<a href="/"><img src="https://i.imgur.com/aREsEE8.png" alt="Ryan's Book Store" height="100"></a>
<div style="width: 1%"></div>
<input class="search" type="text" placeholder="Search by title..">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
<div class="forminput">
<form id="search-form" th:action="@{/book/search/}" method="get">
<input id = "bookTitle" class="search" type="text" placeholder="Search by title..">
<button type="submit" class = "submit-button">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
</button>
</form>
</div>
<div style="width: 3%"></div>
<a href="/wishlist"><img src="https://i.imgur.com/HwTZHG8.png" class = "wishlist-button" alt="wishlist" height="40"></a>
<div style="width: 3%"></div>
<a href="/cart"><img src="https://i.imgur.com/EPveDOI.png" class = "cart-button" alt="cart" height="40"></a>
<div style="width: 3%"></div>
<a th:href ="${'/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${'/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" >Sign In</a>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${user.username.isBlank()} ? 'Sign In' : ${user.username}"></a>
</div>
<body>
<div class = "container">
<ul class="nav nav-tabs">
<li class="nav-item">
......
......@@ -16,16 +16,16 @@
}
.header {
padding-bottom: 10px;
display:flex;
flex-direction: row;
align-items: center;
text-align: left;
background: #448498;
color: white;
font-size: 25px;
font-family: "Helvetica",serif;
}
padding-bottom: 10px;
display:flex;
flex-direction: row;
align-items: center;
text-align: left;
background: #448498;
color: white;
font-size: 25px;
font-family: "Helvetica",serif;
}
/* Style the search box inside the navigation bar */
.search[type=text] {
......@@ -44,8 +44,14 @@
.forminput{
width:100%;
}
</style>
.submit-button{
background: #448498;
border:0px;
height:40px;
width:50px;
}
</style>
</head>
<body>
<div class="header mb-4">
......@@ -56,7 +62,7 @@
<div class="forminput">
<form id="search-form" th:action="@{/book/search/}" method="get">
<input id = "bookTitle" class="search" type="text" placeholder="Search by title..">
<button type="submit">
<button type="submit" class = "submit-button">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
</button>
</form>
......@@ -66,8 +72,8 @@
<div style="width: 3%"></div>
<a href="/cart"><img src="https://i.imgur.com/EPveDOI.png" class = "cart-button" alt="cart" height="40"></a>
<div style="width: 3%"></div>
<a href ="/profile"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" height="40" style="padding-right: 10px"></a>
<a href ="/profile" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${user.username}"></a>
<a th:href ="${username.isBlank() ? '/login' : '/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${username.isBlank() ? '/login' : '/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${username.isBlank()} ? 'Sign In' : ${username}"></a>
</div>
<div class = "container">
......
......@@ -6,8 +6,76 @@
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta3/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<style>
body{
background-color: #F2FCFD;
background-image: url("https://i.imgur.com/BnSpO0s.png");
height: 100%;
background-position: center;
background-repeat: repeat-y;
background-size: cover;
}
.header {
padding-bottom: 10px;
display:flex;
flex-direction: row;
align-items: center;
text-align: left;
background: #448498;
color: white;
font-size: 25px;
font-family: "Helvetica",serif;
}
/* Style the search box inside the navigation bar */
.search[type=text] {
float: left;
width: 80%;
padding: 6px;
border: none;
margin-right: 10px;
padding-left: 10px;
font-size: 17px;
}
.sign-in-text{
padding-top: 5px;
min-width: 150px;
}
.forminput{
width:100%;
}
.submit-button{
background: #448498;
border:0px;
height:40px;
width:50px;
}
</style>
</head>
<body>
<div class="header mb-4">
<div style="width: 1%"></div>
<a href="/"><img src="https://i.imgur.com/cyBT3sP.png" alt="RBS" width="100" height="100" style="padding-left: 5px"></a>
<a href="/"><img src="https://i.imgur.com/aREsEE8.png" alt="Ryan's Book Store" height="100"></a>
<div style="width: 1%"></div>
<div class="forminput">
<form id="search-form" th:action="@{/book/search/}" method="get">
<input id = "bookTitle" class="search" type="text" placeholder="Search by title..">
<button type="submit" class = "submit-button">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
</button>
</form>
</div>
<div style="width: 3%"></div>
<a href="/wishlist"><img src="https://i.imgur.com/HwTZHG8.png" class = "wishlist-button" alt="wishlist" height="40"></a>
<div style="width: 3%"></div>
<a href="/cart"><img src="https://i.imgur.com/EPveDOI.png" class = "cart-button" alt="cart" height="40"></a>
<div style="width: 3%"></div>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${user.username.isBlank()} ? 'Sign In' : ${user.username}"></a>
</div>
<div class="container">
<form action="" th:action="@{/edit-profile}" th:object="${form}" method="post" id="input-form">
<div class="form-group">
......
......@@ -54,7 +54,6 @@
}
</style>
</head>
<body>
<div class="header mb-4">
......@@ -65,7 +64,7 @@
<div class="forminput">
<form id="search-form" th:action="@{/book/search/}" method="get">
<input id = "bookTitle" class="search" type="text" placeholder="Search by title..">
<button class="submit-button" type="submit">
<button type="submit" class = "submit-button">
<img src="https://i.imgur.com/WWk7FEt.png" class = "search-button" alt="search" height="40">
</button>
</form>
......@@ -75,8 +74,8 @@
<div style="width: 3%"></div>
<a href="/cart"><img src="https://i.imgur.com/EPveDOI.png" class = "cart-button" alt="cart" height="40"></a>
<div style="width: 3%"></div>
<a href ="/profile"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" height="40" style="padding-right: 10px"></a>
<a href ="/profile" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${user.username}"></a>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}"><img src="https://i.imgur.com/KxpWso4.png" class = "signin-button" alt="sign in" height="40" style="padding-right: 10px"></a>
<a th:href ="${user.username.isBlank() ? '/login' : '/profile'}" class="sign-in-text" style="text-decoration: none; color: inherit" th:text="${user.username.isBlank()} ? 'Sign In' : ${user.username}"></a>
</div>
<div class = "container">
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment