done
This commit is contained in:
50
templates/base.html
Normal file
50
templates/base.html
Normal file
@ -0,0 +1,50 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>DWSFi</title>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/js/tabler.min.js"></script>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/css/tabler.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/css/tabler-flags.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/css/tabler-payments.min.css">
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/css/tabler-vendors.min.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="page">
|
||||
<header class="navbar navbar-expand-sm navbar-light d-print-none">
|
||||
<div class="container-xl">
|
||||
<h1 class="navbar-brand navbar-brand-autodark d-none-navbar-horizontal pe-0 pe-md-3">
|
||||
<a href="#">
|
||||
<img src="https://images.rawpixel.com/image_png_800/czNmcy1wcml2YXRlL3Jhd3BpeGVsX2ltYWdlcy93ZWJzaXRlX2NvbnRlbnQvbHIvdjEwNDktMjIucG5n.png" width="110" height="32" alt="Tabler" class="navbar-brand-image" />
|
||||
</a>
|
||||
<span>DWSFi</span>
|
||||
</h1>
|
||||
|
||||
<div class="navbar-nav flex-row order-md-last">
|
||||
<div class="nav-item">
|
||||
<a href="/logout" class="nav-link d-flex lh-1 text-reset">
|
||||
<div class="d-xl-block ps-2">
|
||||
{% if userid is not none %}
|
||||
<div>{{userid}} - Logout</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
<div class="page-wrapper">
|
||||
<div class="page-body">
|
||||
<div class="container-xl">
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
220
templates/index.html
Normal file
220
templates/index.html
Normal file
@ -0,0 +1,220 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="row row-deck row-cards">
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<div class="d-flex align-items-center">
|
||||
<div class="subheader">Account Balance</div>
|
||||
<div class="ms-auto lh-1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="d-flex align-items-baseline">
|
||||
<div class="h1 mb-0 me-2">${{balance}}</div>
|
||||
<div class="me-auto">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-lg-12">
|
||||
<div class="card">
|
||||
<div class="card-header border-0">
|
||||
<div class="card-title">Treasury Yields</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<div id="chart-yields" class="chart-lg"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Transactions</h3>
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table card-table table-vcenter text-nowrap datatable">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Term</th>
|
||||
<th>Quantity</th>
|
||||
<th>Date</th>
|
||||
<th>Side</th>
|
||||
<th>Rate</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="txbody">
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Buy/Sell</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<div class="form-label">Term</div>
|
||||
<select class="form-select" id="term">
|
||||
<option value="1 Mo">1 Mo</option>
|
||||
<option value="2 Mo">2 Mo</option>
|
||||
<option value="3 Mo">3 Mo</option>
|
||||
<option value="4 Mo">4 Mo</option>
|
||||
<option value="6 Mo">6 Mo</option>
|
||||
<option value="1 Yr">1 Yr</option>
|
||||
<option value="2 Yr">2 Yr</option>
|
||||
<option value="3 Yr">3 Yr</option>
|
||||
<option value="5 Yr">5 Yr</option>
|
||||
<option value="7 Yr">7 Yr</option>
|
||||
<option value="10 Yr">10 Yr</option>
|
||||
<option value="12 Yr">12 Yr</option>
|
||||
<option value="30 Yr">30 Yr</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Quantity</label>
|
||||
<input type="number" class="form-control" name="quantity" id="quantity" placeholder="100" />
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Side</label>
|
||||
<select class="form-select">
|
||||
<option value="BUY">Buy</option>
|
||||
<option value="SELL">Sell</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button id="buybtn" class="btn btn-primary ms-auto">Submit Order</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/@tabler/core@1.0.0-beta17/dist/libs/apexcharts/dist/apexcharts.min.js" defer></script>
|
||||
<script>
|
||||
|
||||
document.getElementById("buybtn").addEventListener('click', () => {
|
||||
var r = new XMLHttpRequest();
|
||||
r.open("POST", "/api/buy", true);
|
||||
r.onload = function () {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
r.setRequestHeader("Content-Type", "application/json")
|
||||
// Send data in below way from JS
|
||||
r.send(JSON.stringify({
|
||||
"quantity": document.getElementById('quantity').value,
|
||||
"instrument": document.getElementById("term").value,
|
||||
"user_id": "{{userid}}"
|
||||
}));
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
|
||||
window.ApexCharts && (new ApexCharts(document.getElementById('chart-yields'), {
|
||||
chart: {
|
||||
type: "line",
|
||||
fontFamily: 'inherit',
|
||||
parentHeightOffset: 0,
|
||||
height: 512,
|
||||
toolbar: {
|
||||
show: true,
|
||||
},
|
||||
animations: {
|
||||
enabled: false
|
||||
},
|
||||
},
|
||||
fill: {
|
||||
opacity: 1,
|
||||
},
|
||||
stroke: {
|
||||
width: 2,
|
||||
lineCap: "round",
|
||||
curve: "straight",
|
||||
},
|
||||
series: [
|
||||
{% for rate in rates %}
|
||||
{% for name, data in rate.items() %}
|
||||
{
|
||||
name: "{{name}}",
|
||||
data: {{data}}
|
||||
},
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
],
|
||||
tooltip: {
|
||||
theme: 'dark'
|
||||
},
|
||||
grid: {
|
||||
padding: {
|
||||
top: -20,
|
||||
right: 0,
|
||||
left: -4,
|
||||
bottom: -4
|
||||
},
|
||||
strokeDashArray: 4,
|
||||
},
|
||||
xaxis: {
|
||||
labels: {
|
||||
padding: 0,
|
||||
},
|
||||
tooltip: {
|
||||
enabled: false
|
||||
},
|
||||
type: 'datetime',
|
||||
},
|
||||
yaxis: {
|
||||
labels: {
|
||||
padding: 4
|
||||
},
|
||||
},
|
||||
labels: [
|
||||
{% for each in dates %}
|
||||
"{{each}}",
|
||||
{% endfor %}
|
||||
],
|
||||
|
||||
legend: {
|
||||
show: true,
|
||||
position: 'bottom',
|
||||
offsetY: 12,
|
||||
markers: {
|
||||
width: 10,
|
||||
height: 10,
|
||||
radius: 100,
|
||||
},
|
||||
itemMargin: {
|
||||
horizontal: 8,
|
||||
vertical: 8
|
||||
},
|
||||
},
|
||||
})).render();
|
||||
|
||||
let xhr = new XMLHttpRequest();
|
||||
xhr.withCredentials = true;
|
||||
xhr.open('GET', 'http://localhost:8008/api/transactions/{{userid}}');
|
||||
|
||||
xhr.onload = function() {
|
||||
console.log(xhr.response);
|
||||
var jsonResponse = JSON.parse(xhr.response);
|
||||
for (let i = 0; i < jsonResponse.length; i++) {
|
||||
var newRow="<tr><td>"+ jsonResponse[i].term + "</td><td>" + jsonResponse[i].quantity + "</td><td>" + jsonResponse[i].date + "</td><td>" + jsonResponse[i].side + "</td><td>"+ jsonResponse[i].rate +"</td></tr>";
|
||||
document.getElementById('txbody').innerHTML += newRow;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
xhr.send();
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
{% endblock %}
|
64
templates/register.html
Normal file
64
templates/register.html
Normal file
@ -0,0 +1,64 @@
|
||||
|
||||
{% extends 'base.html' %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div class="row row-deck row-cards">
|
||||
<h1>Registration</h1>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>Registration will assign you a UUID, please remember this UUID to login!</h4>
|
||||
|
||||
<button id="regbtn" class="btn btn-primary ms-auto">Register</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-sm-6 col-lg-3">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<h4>If you already have a UUID, enter it below to login</h4>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Enter ID</label>
|
||||
<input type="text" class="form-control" placeholder="User ID" id="uuidid" />
|
||||
</div>
|
||||
|
||||
<button id="loginbtn" class="btn btn-primary ms-auto">Login</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById("regbtn").addEventListener('click', () => {
|
||||
var r = new XMLHttpRequest();
|
||||
r.open("POST", "/api/createuser", true);
|
||||
r.onreadystatechange = function () {
|
||||
r.onload = function () {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
r.setRequestHeader("Content-Type", "application/json")
|
||||
// Send data in below way from JS
|
||||
r.send();
|
||||
});
|
||||
|
||||
document.getElementById("loginbtn").addEventListener('click', () => {
|
||||
var r = new XMLHttpRequest();
|
||||
r.open("POST", "/api/login", true);
|
||||
r.onreadystatechange = function () {
|
||||
r.onload = function () {
|
||||
window.location.reload();
|
||||
}
|
||||
};
|
||||
|
||||
r.setRequestHeader("Content-Type", "application/json")
|
||||
// Send data in below way from JS
|
||||
r.send(JSON.stringify({
|
||||
"id": document.getElementById('uuidid').value
|
||||
}));
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
Reference in New Issue
Block a user