improvements to web admin

master
lza_menace 2 years ago
parent 36da130b7d
commit 8683d71155

@ -10,7 +10,7 @@ HOST = env.get("HOST", "127.0.0.1")
TEMPLATES_AUTO_RELOAD = True TEMPLATES_AUTO_RELOAD = True
QUART_ENV = env.get("QUART_ENV", "development") QUART_ENV = env.get("QUART_ENV", "development")
SECRET_KEY = env.get("SECRET_KEY", token_urlsafe(12)) 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
LWS_URL = env.get("LWS_URL", "http://127.0.0.1:8080") LWS_URL = env.get("LWS_URL", "http://127.0.0.1:8080")

@ -13,6 +13,9 @@ bp = Blueprint("meta", "meta")
@login_required @login_required
async def index(): async def index():
admin = User.select().first() admin = User.select().first()
if not admin:
await flash("must setup admin first")
return redirect("/setup")
lws = LWS(admin.view_key) lws = LWS(admin.view_key)
accounts = lws.list_accounts() accounts = lws.list_accounts()
data = {} data = {}
@ -20,7 +23,7 @@ async def index():
if status == "hidden": if status == "hidden":
continue continue
for account in accounts[status]: 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 account["status"] = status
data[account["address"]] = account data[account["address"]] = account
return await render_template( return await render_template(

@ -21,15 +21,15 @@
{% set _data = data[address] %} {% set _data = data[address] %}
<tr> <tr>
<td> <td>
<button class="button {% if _data['status'] == 'active' %}success{% else %}error{% endif %}"> <span class="tag text-white {% if _data['status'] == 'active' %}bg-success{% else %}bg-error{% endif %}">
{{ _data['status'] | upper }} {{ _data['status'] | upper }}
</button> </span>
</td> </td>
<td> <td>
{% if _data['wallet'] %} {% if _data['wallet'] %}
<a href="/wallet/{{ data[address]['wallet'].id }}">{{ data[address]['wallet'].name }}</a> <a href="/wallet/{{ data[address]['wallet'].id }}">{{ data[address]['wallet'].name }}</a>
{% else %} {% else %}
<a href="/wallet/add?address={{ address }}">add</a> <a href="/wallet/add?address={{ address }}" class="button">ADD</a>
{% endif %} {% endif %}
</td> </td>
<td>{{ address | shorten }}</td> <td>{{ address | shorten }}</td>

@ -8,20 +8,24 @@
<h6>{{ wallet.date }}</h6> <h6>{{ wallet.date }}</h6>
<p>Restore Height: {{ wallet.restore_height }}</p> <p>Restore Height: {{ wallet.restore_height }}</p>
<p>Address: <span class="key">{{ wallet.address }}</span></p> <p>Address: <span class="key">{{ wallet.address }}</span></p>
<p>Scanned Height: {{ info['scanned_height'] }} <span class="smol">({{ info['blockchain_height'] - info['scanned_height'] }} blocks away from top)</span></p> {% if info %}
<p>Chain Height: {{ info['blockchain_height'] }}</p> <p>Scanned Height: {{ info['scanned_height'] }} <span class="smol">({{ info['blockchain_height'] - info['scanned_height'] }} blocks away from top)</span></p>
<p>Spent Outputs: {{ info['spent_outputs'] | length }}</p> <p>Chain Height: {{ info['blockchain_height'] }}</p>
{% if wallet.is_active() %} <p>Spent Outputs: {{ info['spent_outputs'] | length }}</p>
{% if wallet.is_active() %}
<p>Status: active</p> <p>Status: active</p>
{% else %} {% else %}
<p>Status: inactive</p> <p>Status: inactive</p>
{% endif %} {% endif %}
<a href="{{ url_for('wallet.rescan', id=wallet.id) }}" class="button dark outline">rescan</a> <a href="{{ url_for('wallet.rescan', id=wallet.id) }}" class="button dark outline">rescan</a>
{% if wallet.is_active() %} {% if wallet.is_active() %}
<a href="{{ url_for('wallet.disable', id=wallet.id) }}" class="button error">disable</a> <a href="{{ url_for('wallet.disable', id=wallet.id) }}" class="button error">disable</a>
{% else %} {% else %}
<a href="{{ url_for('wallet.enable', id=wallet.id) }}" class="button primary">enable</a> <a href="{{ url_for('wallet.enable', id=wallet.id) }}" class="button primary">enable</a>
{% endif %}
{% else %}
<p>not connected to lws</p>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
Loading…
Cancel
Save