From 6de3345c85dc5fe6e01911914aff08c26923e838 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 3 May 2023 15:53:28 -0700 Subject: [PATCH] start dashboard --- lws-web/lws/app.py | 14 +++++++++++- lws-web/lws/templates/includes/base.html | 2 +- lws-web/lws/templates/index.html | 12 +++++----- lws-web/lws/templates/wallet/list.html | 15 +++++++++++++ lws-web/lws/templates/wallet/show.html | 28 +++++++++++++++++------- 5 files changed, 56 insertions(+), 15 deletions(-) create mode 100644 lws-web/lws/templates/wallet/list.html diff --git a/lws-web/lws/app.py b/lws-web/lws/app.py index 062af1e..59c91c9 100644 --- a/lws-web/lws/app.py +++ b/lws-web/lws/app.py @@ -31,7 +31,12 @@ async def index(): admin_exists = User.select().first() if not admin_exists: return redirect("/setup") - return await render_template("index.html") + wallets = Wallet.select().order_by(Wallet.date.desc()) + return await render_template( + "index.html", + config=config, + wallets=wallets + ) @app.route("/debug") async def debug(): @@ -126,7 +131,14 @@ async def setup(): return await render_template("setup.html") +@app.route("/wallets") +@login_required +async def wallets(): + wallets = Wallet.select().order_by(Wallet.id.asc()) + return await render_template("wallet/list.html", wallets=wallets) + @app.route("/wallet/add", methods=["GET", "POST"]) +@login_required async def wallet_add(): form = await request.form if form: diff --git a/lws-web/lws/templates/includes/base.html b/lws-web/lws/templates/includes/base.html index c2999a9..f13f249 100644 --- a/lws-web/lws/templates/includes/base.html +++ b/lws-web/lws/templates/includes/base.html @@ -36,7 +36,7 @@ --> diff --git a/lws-web/lws/templates/index.html b/lws-web/lws/templates/index.html index e96f22c..2ebfca2 100644 --- a/lws-web/lws/templates/index.html +++ b/lws-web/lws/templates/index.html @@ -1,10 +1,12 @@ {% extends 'includes/base.html' %} {% block content %} -{% if current_user.is_authenticated %} -

hi {{ current_user.username }}

-{% else %} -

hi anon

-{% endif %} +
+

LWS Web

+

LWS Admin: {{ config.LWS_ADMIN_URL }}

+

LWS RPC: {{ config.LWS_URL }}

+

{{ wallets.count() }} wallet{% if wallets.count() > 1 %}s{% endif %} being tracked

+ Manage Wallets +
{% endblock %} diff --git a/lws-web/lws/templates/wallet/list.html b/lws-web/lws/templates/wallet/list.html new file mode 100644 index 0000000..203baf0 --- /dev/null +++ b/lws-web/lws/templates/wallet/list.html @@ -0,0 +1,15 @@ +{% extends 'includes/base.html' %} + +{% block content %} +Add a Wallet +
+ {% for wallet in wallets %} +

{{ wallet.id }} - {{ wallet.name }} - {{ wallet.description }} - {{ wallet.date }}

+ {% endfor %} +
+ +{% endblock %} \ No newline at end of file diff --git a/lws-web/lws/templates/wallet/show.html b/lws-web/lws/templates/wallet/show.html index d80f3fa..fc6aba0 100644 --- a/lws-web/lws/templates/wallet/show.html +++ b/lws-web/lws/templates/wallet/show.html @@ -1,14 +1,26 @@ {% extends 'includes/base.html' %} {% block content %} -

{{ wallet.name }}

-

{{ wallet.description }}

-

{{ wallet.date }}

-

{{ wallet.restore_height }}

-

{{ wallet.address }}

-
-    {{ wallet.get_wallet_info() }}
-
+{% set info = wallet.get_wallet_info() %} +

{{ wallet.name }}

+
{{ wallet.description }}
+
{{ wallet.date }}
+

Restore Height: {{ wallet.restore_height }}

+

Address: {{ wallet.address }}

+

Locked: {{ info['locked_funds'] }}

+

Received: {{ info['total_received'] }}

+

Sent: {{ info['total_sent'] }}

+

Scanned Height: {{ info['scanned_height'] }} ({{ info['blockchain_height'] - info['scanned_height'] }} blocks away from top)

+

Spent Outputs: {{ info['spent_outputs'] | length }}

+ {% endblock %} \ No newline at end of file