Cleaned up exchange and account pages, and added custom site font.
This commit is contained in:
parent
cff73d9803
commit
f768d62342
|
@ -1,7 +1,6 @@
|
|||
package nl.andrewl.coyotecredit.ctl;
|
||||
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import nl.andrewl.coyotecredit.ctl.dto.AddAccountPayload;
|
||||
import nl.andrewl.coyotecredit.ctl.dto.EditExchangePayload;
|
||||
import nl.andrewl.coyotecredit.ctl.dto.InviteUserPayload;
|
||||
import nl.andrewl.coyotecredit.model.User;
|
||||
|
|
|
@ -3,6 +3,8 @@ package nl.andrewl.coyotecredit.ctl.dto;
|
|||
public record ExchangeData(
|
||||
long id,
|
||||
String name,
|
||||
String primaryTradeable
|
||||
String description,
|
||||
String primaryTradeable,
|
||||
long primaryTradeableId
|
||||
) {
|
||||
}
|
||||
|
|
|
@ -127,7 +127,9 @@ public class AccountService {
|
|||
new ExchangeData(
|
||||
account.getExchange().getId(),
|
||||
account.getExchange().getName(),
|
||||
account.getExchange().getPrimaryTradeable().getSymbol()
|
||||
account.getExchange().getDescription(),
|
||||
account.getExchange().getPrimaryTradeable().getSymbol(),
|
||||
account.getExchange().getPrimaryTradeable().getId()
|
||||
),
|
||||
account.getBalances().stream()
|
||||
.map(b -> new BalanceData(
|
||||
|
|
|
@ -106,29 +106,6 @@ public class ExchangeService {
|
|||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public long addAccount(long exchangeId, User user, AddAccountPayload payload) {
|
||||
Exchange exchange = exchangeRepository.findById(exchangeId)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
|
||||
Account account = accountRepository.findByUserAndExchange(user, exchange)
|
||||
.orElseThrow(() -> new ResponseStatusException(HttpStatus.NOT_FOUND));
|
||||
if (!account.isAdmin()) {
|
||||
throw new ResponseStatusException(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
User u = userRepository.save(new User(payload.username(), passwordEncoder.encode(payload.password()), payload.email()));
|
||||
Account a = accountRepository.save(new Account(
|
||||
AccountNumberUtils.generate(),
|
||||
u,
|
||||
payload.name(),
|
||||
exchange
|
||||
));
|
||||
for (var t : exchange.getAllTradeables()) {
|
||||
a.getBalances().add(new Balance(a, t, BigDecimal.ZERO));
|
||||
}
|
||||
a = accountRepository.save(a);
|
||||
return a.getId();
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void removeAccount(long exchangeId, long accountId, User user) {
|
||||
Exchange exchange = exchangeRepository.findById(exchangeId)
|
||||
|
@ -217,7 +194,13 @@ public class ExchangeService {
|
|||
public List<ExchangeAccountData> getExchanges(User user) {
|
||||
return accountRepository.findAllByUser(user).stream()
|
||||
.map(a -> new ExchangeAccountData(
|
||||
new ExchangeData(a.getExchange().getId(), a.getExchange().getName(), a.getExchange().getPrimaryTradeable().getSymbol()),
|
||||
new ExchangeData(
|
||||
a.getExchange().getId(),
|
||||
a.getExchange().getName(),
|
||||
a.getExchange().getDescription(),
|
||||
a.getExchange().getPrimaryTradeable().getSymbol(),
|
||||
a.getExchange().getPrimaryTradeable().getId()
|
||||
),
|
||||
new SimpleAccountData(
|
||||
a.getId(),
|
||||
user.getId(),
|
||||
|
|
|
@ -1,29 +1,38 @@
|
|||
@font-face {
|
||||
font-family: SpaceMono;
|
||||
src: url("/static/font/SpaceMono-Regular.ttf");
|
||||
src: url("/static/font/spacemono/SpaceMono-Regular.ttf");
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: SpaceMono;
|
||||
src: url("/static/font/spacemono/SpaceMono-Italic.ttf");
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
@font-face {
|
||||
font-family: SpaceMono;
|
||||
src: url("/static/font/spacemono/SpaceMono-Bold.ttf");
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
@font-face {
|
||||
font-family: SpaceMono;
|
||||
src: url("/static/font/spacemono/SpaceMono-BoldItalic.ttf");
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: Pacifico;
|
||||
src: url("/static/font/pacifico/Pacifico-Regular.ttf");
|
||||
font-style: normal;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: SpaceMono;
|
||||
src: url("/static/font/SpaceMono-Italic.ttf");
|
||||
font-style: italic;
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: SpaceMono;
|
||||
src: url("/static/font/SpaceMono-Bold.ttf");
|
||||
font-style: normal;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
@font-face {
|
||||
font-family: SpaceMono;
|
||||
src: url("/static/font/SpaceMono-BoldItalic.ttf");
|
||||
font-style: italic;
|
||||
font-weight: bold;
|
||||
font-family: Josefin Sans;
|
||||
src: url("/static/font/josefin-sans/JosefinSans-VariableFont_wght.ttf") format("truetype-variations");
|
||||
}
|
||||
|
||||
:root {
|
||||
|
@ -37,12 +46,17 @@
|
|||
body{
|
||||
background-color: black;
|
||||
color: white;
|
||||
font-family: "Josefin Sans", sans-serif;
|
||||
}
|
||||
|
||||
.monospace {
|
||||
font-family: SpaceMono, monospace;
|
||||
}
|
||||
|
||||
.font-pacifico {
|
||||
font-family: Pacifico, serif;
|
||||
}
|
||||
|
||||
.header-bar {
|
||||
--bs-bg-opacity: 1;
|
||||
background-color: var(--color-faded-blue);
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -8,7 +8,8 @@
|
|||
<div id="content" class="container">
|
||||
<h1 class="display-4">Account <span th:text="${account.number()}"></span></h1>
|
||||
|
||||
<div class="card text-white bg-dark mb-3">
|
||||
<div class="card-group mb-3">
|
||||
<div class="card text-white bg-dark">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Overview</h5>
|
||||
<dl class="row">
|
||||
|
@ -25,24 +26,25 @@
|
|||
<span class="monospace" th:text="${account.totalBalance()}"></span> <span th:text="${account.exchange().primaryTradeable()}"></span>
|
||||
</dd>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a class="btn btn-success" th:href="@{/trade/{account}(account=${account.id()})}">Trade</a>
|
||||
<a class="btn btn-success" th:href="@{/accounts/{aId}/transfer(aId=${account.id()})}">Transfer</a>
|
||||
<a class="btn btn-primary" th:if="${account.userAdmin()}" th:href="@{/accounts/{aId}/editBalances(aId=${account.id()})}">Edit Balances</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card text-white bg-dark mb-3">
|
||||
<div class="card text-white bg-dark">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Tradeable Assets</h5>
|
||||
<table class="table table-dark">
|
||||
<thead>
|
||||
<thead class="d-block">
|
||||
<tr>
|
||||
<th>Asset</th>
|
||||
<th>Type</th>
|
||||
<th>Balance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tbody class="d-block" style="height: 300px; overflow-y: scroll;">
|
||||
<tr th:each="bal : ${account.balances()}">
|
||||
<td>
|
||||
<a class="colored-link" th:href="@{/tradeables/{tId}(tId=${bal.id()})}" th:text="${bal.symbol()}"></a>
|
||||
|
@ -54,6 +56,7 @@
|
|||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card text-white bg-dark mb-3" th:if="${!account.recentTransactions().isEmpty()}">
|
||||
<div class="card-body">
|
||||
|
|
|
@ -6,29 +6,28 @@
|
|||
>
|
||||
<div id="content" class="container">
|
||||
<h1 class="display-4">Exchanges</h1>
|
||||
<table class="table table-dark">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Primary Asset</th>
|
||||
<th>Account</th>
|
||||
<th>Estimated Balance</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr th:each="ed : ${exchangeData}">
|
||||
<td>
|
||||
<a class="colored-link" th:text="${ed.exchange().name()}" th:href="@{/exchanges/{eId}(eId=${ed.exchange().id()})}"></a>
|
||||
</td>
|
||||
<td th:text="${ed.exchange().primaryTradeable()}"></td>
|
||||
<td>
|
||||
<a class="colored-link" th:text="${ed.account().number()}" th:href="@{/accounts/{aId}(aId=${ed.account().id()})}"></a>
|
||||
</td>
|
||||
<td class="monospace" th:text="${ed.account().totalBalance()}"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<p>
|
||||
|
||||
<div class="row row-cols-1 row-cols-sm-3 g-4">
|
||||
<div class="col" th:each="exchange: ${exchangeData}">
|
||||
<div class="card text-white bg-dark">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">
|
||||
<a class="colored-link" th:href="@{/exchanges/{eId}(eId=${exchange.exchange().id()})}" th:text="${exchange.exchange().name()}"></a>
|
||||
</h5>
|
||||
<h6 class="card-subtitle text-muted mb-2">
|
||||
Est. Account Balance:
|
||||
<span class="badge bg-secondary">
|
||||
<span class="font-monospace" th:text="${exchange.account().totalBalance()}"></span>
|
||||
<a class="colored-link" th:text="${exchange.exchange().primaryTradeable()}" th:href="@{/tradeables/{tId}(tId=${exchange.exchange().primaryTradeableId()})}"></a>
|
||||
</span>
|
||||
</h6>
|
||||
<p class="card-text" th:if="${exchange.exchange().description() != null}" th:text="${exchange.exchange().description()}"></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-3">
|
||||
Use this page to view a list of all exchanges you're participating in. Click on the <strong>name</strong> of the exchange to view its page, and click on your <strong>account</strong> number to view your account information for a given exchange. The <strong>estimated balance</strong> shown in this overview may not be completely accurate. Navigate to your account page for a complete overview of your current account balances for stocks, fiat currencies, and more.
|
||||
</p>
|
||||
</div>
|
|
@ -9,11 +9,11 @@
|
|||
</head>
|
||||
<body>
|
||||
|
||||
<nav th:fragment="header" class="navbar navbar-expand-lg navbar-dark header-bar">
|
||||
<nav th:fragment="header" class="navbar navbar-expand-lg navbar-dark header-bar mb-3">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand" href="/">
|
||||
<img src="/static/images/icon_256.png" alt="Coyote Credit" height="24" class="d-inline-block align-text-top"/>
|
||||
Coyote Credit
|
||||
<span class="font-pacifico">Coyote Credit</span>
|
||||
</a>
|
||||
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
|
|
|
@ -6,10 +6,11 @@
|
|||
>
|
||||
<div id="content" class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-4">
|
||||
|
||||
|
||||
<h1>Login</h1>
|
||||
<div class="col-lg-5">
|
||||
<div class="text-center">
|
||||
<img src="/static/images/icon_256.png" alt="Coyote Credit Logo" width="256"/>
|
||||
</div>
|
||||
<h1 class="text-center font-pacifico">Coyote Credit</h1>
|
||||
<form th:action="@{/login/processing}" th:method="post">
|
||||
<div class="mb-3">
|
||||
<label for="usernameInput" class="form-label">Username</label>
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<div id="content" class="container">
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-lg-4">
|
||||
<h1>Register</h1>
|
||||
<h1 class="display-4">Register</h1>
|
||||
<form th:action="@{/register}" th:method="post">
|
||||
<div class="mb-3">
|
||||
<label for="usernameInput" class="form-label">Username</label>
|
||||
|
@ -44,8 +44,9 @@
|
|||
<input type="submit" class="btn btn-primary mb-3" value="Register">
|
||||
|
||||
<p class="alert alert-dark">
|
||||
After registering, you will receive an email with a verification link. Please
|
||||
click that link to verify your account before attempting to log in.
|
||||
<strong>Note!</strong> After registering, you will receive an email with a
|
||||
verification link. Please click that link to verify your account before
|
||||
attempting to log in.
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="card text-white bg-dark mb-3">
|
||||
<div class="card text-white bg-dark mb-3" th:if="${!user.exchangeInvitations().isEmpty()}">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">Exchange Invitations</h5>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue