improvements to web admin

master
lza_menace 12 months ago
parent 36da130b7d
commit 8683d71155

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

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

@ -21,15 +21,15 @@
{% set _data = data[address] %}
<tr>
<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 }}
</button>
</span>
</td>
<td>
{% if _data['wallet'] %}
<a href="/wallet/{{ data[address]['wallet'].id }}">{{ data[address]['wallet'].name }}</a>
{% else %}
<a href="/wallet/add?address={{ address }}">add</a>
<a href="/wallet/add?address={{ address }}" class="button">ADD</a>
{% endif %}
</td>
<td>{{ address | shorten }}</td>

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