From 8683d71155764acebd6a9e788fd633fa6510b860 Mon Sep 17 00:00:00 2001 From: lza_menace Date: Wed, 24 May 2023 09:00:05 -0700 Subject: [PATCH] improvements to web admin --- lws-web/lws/config.py | 2 +- lws-web/lws/routes/meta.py | 5 ++++- lws-web/lws/templates/index.html | 6 +++--- lws-web/lws/templates/wallet/show.html | 28 +++++++++++++++----------- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/lws-web/lws/config.py b/lws-web/lws/config.py index 7a3da44..db7a9a4 100644 --- a/lws-web/lws/config.py +++ b/lws-web/lws/config.py @@ -10,7 +10,7 @@ HOST = env.get("HOST", "127.0.0.1") TEMPLATES_AUTO_RELOAD = True QUART_ENV = env.get("QUART_ENV", "development") SECRET_KEY = env.get("SECRET_KEY", token_urlsafe(12)) -QUART_AUTH_DURATION = 60 * 60 # 1 hour +QUART_AUTH_DURATION = int(env.get('QUART_AUTH_DURATION', 60 * 60)) # 1 hour # LWS LWS_URL = env.get("LWS_URL", "http://127.0.0.1:8080") diff --git a/lws-web/lws/routes/meta.py b/lws-web/lws/routes/meta.py index c473a5c..07fb901 100644 --- a/lws-web/lws/routes/meta.py +++ b/lws-web/lws/routes/meta.py @@ -13,6 +13,9 @@ bp = Blueprint("meta", "meta") @login_required async def index(): admin = User.select().first() + if not admin: + await flash("must setup admin first") + return redirect("/setup") lws = LWS(admin.view_key) accounts = lws.list_accounts() data = {} @@ -20,7 +23,7 @@ async def index(): if status == "hidden": continue for account in accounts[status]: - account["wallet"] = Wallet.select().where(Wallet.address ** account["address"]).first() + account["wallet"] = Wallet.select().where(Wallet.address ** account["address"]).order_by(Wallet.date.asc()).first() account["status"] = status data[account["address"]] = account return await render_template( diff --git a/lws-web/lws/templates/index.html b/lws-web/lws/templates/index.html index c5eb6f6..c0763c7 100644 --- a/lws-web/lws/templates/index.html +++ b/lws-web/lws/templates/index.html @@ -21,15 +21,15 @@ {% set _data = data[address] %} - + {% if _data['wallet'] %} {{ data[address]['wallet'].name }} {% else %} - add + ADD {% endif %} {{ address | shorten }} diff --git a/lws-web/lws/templates/wallet/show.html b/lws-web/lws/templates/wallet/show.html index 75d78e6..e200071 100644 --- a/lws-web/lws/templates/wallet/show.html +++ b/lws-web/lws/templates/wallet/show.html @@ -8,20 +8,24 @@
{{ wallet.date }}

Restore Height: {{ wallet.restore_height }}

Address: {{ wallet.address }}

-

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

-

Chain Height: {{ info['blockchain_height'] }}

-

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

-{% if wallet.is_active() %} -

Status: active

-{% else %} -

Status: inactive

-{% endif %} +{% if info %} +

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

+

Chain Height: {{ info['blockchain_height'] }}

+

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

+ {% if wallet.is_active() %} +

Status: active

+ {% else %} +

Status: inactive

+ {% endif %} -rescan -{% if wallet.is_active() %} - disable + rescan + {% if wallet.is_active() %} + disable + {% else %} + enable + {% endif %} {% else %} - enable +

not connected to lws

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