Fakultas Ilmu Komputer UI

Commit 9883e969 authored by FIRLANDI ALTHAF RIZQI ANSYARI's avatar FIRLANDI ALTHAF RIZQI ANSYARI
Browse files

Merge branch 'firlandi' into 'staging'

Add unique tabs for each role

See merge request !25
parents fab3526f f44fc1d3
Pipeline #134282 failed with stages
in 18 minutes and 26 seconds
......@@ -66,7 +66,8 @@ public class AdminController {
@GetMapping(path="/list-payment")
@Timed("allpayments")
public String paymentList(Model model){
public String paymentList(Model model, Principal principal){
model.addAttribute("user", userService.getUserByName(principal.getName()));
model.addAttribute("payments", paymentService.getAllPayments());
return "admin-payment-list";
}
......
......@@ -3,6 +3,7 @@ package id.ac.ui.cs.advprog.landiandfriends.controller;
import id.ac.ui.cs.advprog.landiandfriends.forms.AddPaymentForm;
import id.ac.ui.cs.advprog.landiandfriends.model.PaymentModel;
import id.ac.ui.cs.advprog.landiandfriends.service.PaymentServiceImpl;
import id.ac.ui.cs.advprog.landiandfriends.service.UserServiceImpl;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -10,13 +11,17 @@ import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.security.Principal;
@Controller
public class PaymentController {
private final PaymentServiceImpl paymentService;
private final UserServiceImpl userService;
public PaymentController(PaymentServiceImpl paymentService) {
public PaymentController(PaymentServiceImpl paymentService, UserServiceImpl userService) {
this.paymentService = paymentService;
this.userService = userService;
}
@GetMapping(path={"/add-card"})
......@@ -33,9 +38,10 @@ public class PaymentController {
}
@GetMapping(path="/payment-methods")
public String paymentList(Model model){
public String paymentList(Model model, Principal principal){
paymentService.getUserPayments();
model.addAttribute("payments", paymentService.getUserPayments());
model.addAttribute("user", userService.getUserByName(principal.getName()));
return "payment-methods";
}
......
......@@ -34,7 +34,8 @@ public class ProfileController {
}
@GetMapping(path = "/delivery-address")
public String addressList(Model model) {
public String addressList(Model model, Principal principal) {
model.addAttribute("user", userService.getUserByName(principal.getName()));
model.addAttribute("address", addressService.getAddress());
return "my-address";
}
......
......@@ -30,11 +30,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;
}
......@@ -42,12 +42,55 @@
padding-top: 5px;
min-width: 150px;
}
.forminput{
width:100%;
}
</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">
<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 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>
</div>
<div class = "container">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link " href="/profile">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/delivery-address">Delivery Address</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('USER')}">
<a class="nav-link" href="/payment-methods">Payment Method</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('ADMIN')}">
<a class="nav-link" href="/admin/list-payment">Admin Payment Methods</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('CURATOR')}">
<a class="nav-link" href="/curator">Curator</a>
</li>
</ul>
</div>
<div class="container">
<h2 class="subtitle">Payment Methods</h2>
<button class="btn btn-outline-primary" th:onclick="|window.location.href='/admin/admin-add-card'|">Add Card</button>
<div class="row">
<div class="col-md-4">
<div th:each="payment : ${payments}" >
......
......@@ -65,17 +65,23 @@
<body>
<div class = "container">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link" href="/profile">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/delivery-address">Delivery Address</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/payment-methods">Payment Method</a>
</li>
</ul>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link " href="/profile">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/delivery-address">Delivery Address</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('USER')}">
<a class="nav-link" href="/payment-methods">Payment Method</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('ADMIN')}">
<a class="nav-link" href="/admin/list-payment">Admin Payment Methods</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('CURATOR')}">
<a class="nav-link" href="/curator">Curator</a>
</li>
</ul>
</div>
<div class="container">
......
......@@ -29,11 +29,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;
}
......@@ -41,27 +41,36 @@
padding-top: 5px;
min-width: 150px;
}
.forminput{
width:100%;
}
</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">
<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 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>
</div>
<div class = "container">
<body>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link " href="/profile">Profile</a>
......@@ -69,8 +78,14 @@
<li class="nav-item">
<a class="nav-link" href="/delivery-address">Delivery Address</a>
</li>
<li class="nav-item">
<a class="nav-link active" href="/payment-methods">Payment Method</a>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('USER')}">
<a class="nav-link" href="/payment-methods">Payment Method</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('ADMIN')}">
<a class="nav-link" href="/admin/list-payment">Admin Payment Methods</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('CURATOR')}">
<a class="nav-link" href="/curator">Curator</a>
</li>
</ul>
</div>
......
......@@ -80,17 +80,23 @@
</div>
<div class = "container">
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link active" href="#">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/delivery-address">Delivery Address</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/payment-methods">Payment Method</a>
</li>
</ul>
<ul class="nav nav-tabs">
<li class="nav-item">
<a class="nav-link " href="/profile">Profile</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/delivery-address">Delivery Address</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('USER')}">
<a class="nav-link" href="/payment-methods">Payment Method</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('ADMIN')}">
<a class="nav-link" href="/admin/list-payment">Admin Payment Methods</a>
</li>
<li class="nav-item" th:if="${user.getRoles() != null && user.getRoles().getName().equals('CURATOR')}">
<a class="nav-link" href="/curator">Curator</a>
</li>
</ul>
</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