Cleaned up exchange and account pages, and added custom site font.

This commit is contained in:
Andrew Lalis 2022-02-16 12:02:14 +01:00
parent cff73d9803
commit f768d62342
18 changed files with 126 additions and 122 deletions

View File

@ -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;

View File

@ -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
) {
}

View File

@ -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(

View File

@ -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(),

View File

@ -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);

View File

@ -8,50 +8,53 @@
<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-body">
<h5 class="card-title">Overview</h5>
<dl class="row">
<dt class="col-sm-6">Number</dt>
<dd class="col-sm-6 monospace" th:text="${account.number()}"></dd>
<dt class="col-sm-6">Account Holder Name</dt>
<dd class="col-sm-6" th:text="${account.name()}"></dd>
<dt class="col-sm-6">Exchange</dt>
<dd class="col-sm-6">
<a class="colored-link" th:href="@{/exchanges/{id}(id=${account.exchange().id()})}" th:text="${account.exchange().name()}"></a>
</dd>
<dt class="col-sm-6">Total Value</dt>
<dd class="col-sm-6">
<span class="monospace" th:text="${account.totalBalance()}"></span>&nbsp;<span th:text="${account.exchange().primaryTradeable()}"></span>
</dd>
</dl>
<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 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">
<dt class="col-sm-6">Number</dt>
<dd class="col-sm-6 monospace" th:text="${account.number()}"></dd>
<dt class="col-sm-6">Account Holder Name</dt>
<dd class="col-sm-6" th:text="${account.name()}"></dd>
<dt class="col-sm-6">Exchange</dt>
<dd class="col-sm-6">
<a class="colored-link" th:href="@{/exchanges/{id}(id=${account.exchange().id()})}" th:text="${account.exchange().name()}"></a>
</dd>
<dt class="col-sm-6">Total Value</dt>
<dd class="col-sm-6">
<span class="monospace" th:text="${account.totalBalance()}"></span>&nbsp;<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>
<div class="card text-white bg-dark mb-3">
<div class="card-body">
<h5 class="card-title">Tradeable Assets</h5>
<table class="table table-dark">
<thead>
<tr>
<th>Asset</th>
<th>Type</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<tr th:each="bal : ${account.balances()}">
<td>
<a class="colored-link" th:href="@{/tradeables/{tId}(tId=${bal.id()})}" th:text="${bal.symbol()}"></a>
</td>
<td th:text="${bal.type()}"></td>
<td class="monospace" th:text="${bal.amount()}"></td>
</tr>
</tbody>
</table>
<div class="card text-white bg-dark">
<div class="card-body">
<h5 class="card-title">Tradeable Assets</h5>
<table class="table table-dark">
<thead class="d-block">
<tr>
<th>Asset</th>
<th>Type</th>
<th>Balance</th>
</tr>
</thead>
<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>
</td>
<td th:text="${bal.type()}"></td>
<td class="monospace" th:text="${bal.amount()}"></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

View File

@ -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>&nbsp;
<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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>