implementing htmx
parent
6f6b971b9d
commit
1622c26d75
@ -0,0 +1,44 @@
|
||||
from quart import Blueprint, render_template
|
||||
from monero.seed import Seed
|
||||
from quart_auth import login_required
|
||||
|
||||
from lws.models import User
|
||||
from lws.helpers import lws
|
||||
from lws import config
|
||||
|
||||
bp = Blueprint('htmx', 'htmx', url_prefix="/htmx")
|
||||
|
||||
|
||||
@bp.route("/create_wallet")
|
||||
@login_required
|
||||
async def create_wallet():
|
||||
seed = Seed()
|
||||
return await render_template(
|
||||
"htmx/create_wallet.html",
|
||||
seed=seed.phrase,
|
||||
address=seed.public_address(),
|
||||
psk=seed.public_spend_key(),
|
||||
pvk=seed.public_view_key(),
|
||||
ssk=seed.secret_spend_key(),
|
||||
svk=seed.secret_view_key()
|
||||
)
|
||||
|
||||
@bp.route("/import_wallet")
|
||||
@login_required
|
||||
async def import_wallet():
|
||||
return await render_template("htmx/import_wallet.html")
|
||||
|
||||
@bp.route("/show_wallets")
|
||||
@login_required
|
||||
async def show_wallets():
|
||||
admin = User.select().first()
|
||||
lws.init(admin.view_key)
|
||||
accounts = lws.list_accounts()
|
||||
if 'hidden' in accounts:
|
||||
del accounts["hidden"]
|
||||
requests = lws.list_requests()
|
||||
return await render_template(
|
||||
"htmx/show_wallets.html",
|
||||
accounts=accounts,
|
||||
requests=requests
|
||||
)
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -0,0 +1,15 @@
|
||||
<div id="create_wallet">
|
||||
<p>Seed: <span class="key">{{ seed }}</span></p>
|
||||
<p>Public Address: <span class="key">{{ address }}</span></p>
|
||||
<p>Public Spend Key: <span class="key">{{ psk }}</span></p>
|
||||
<p>Public View Key: <span class="key">{{ pvk }}</span></p>
|
||||
<p>Secret Spend Key: <span class="key">{{ ssk }}</span></p>
|
||||
<p>Secret View Key: <span class="key">{{ svk }}</span></p>
|
||||
<form method="post" action="{{ url_for('wallet.add') }}" hx-confirm="Please confirm">
|
||||
<input type="text" name="address" value="{{ address }}" class="hidden" />
|
||||
<input type="text" name="view_key" value="{{ svk }}" class="hidden" />
|
||||
<input type="number" name="restore_height" value="-1" class="hidden" />
|
||||
<button onclick="document.getElementById('create_wallet').innerHTML = ''">Cancel</button>
|
||||
<button type="submit" >Create</button>
|
||||
</form>
|
||||
</div>
|
@ -0,0 +1,10 @@
|
||||
<form hx-post="{{ url_for('wallet.add') }}" id="import_wallet">
|
||||
<label for="address">Address</label>
|
||||
<input type="text" name="address" value="{{ request.args.get('address', '') }}" />
|
||||
<label for="view_key">Secret View Key</label>
|
||||
<input type="text" name="view_key" />
|
||||
<label for="restore_height">Restore Height</label>
|
||||
<input type="number" name="restore_height" />
|
||||
<button onclick="document.getElementById('import_wallet').innerHTML = ''">Cancel</button>
|
||||
<button type="submit">Import</button>
|
||||
</form>
|
@ -0,0 +1 @@
|
||||
<p>fug dat</p>
|
@ -0,0 +1,58 @@
|
||||
<table class="striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
<th>Address</th>
|
||||
<th>Height</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for status in accounts %}
|
||||
{% for account in accounts[status] %}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tag text-white {% if status == 'active' %}bg-success{% else %}bg-error{% endif %}">
|
||||
{{ status | upper }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if status == 'active' %}
|
||||
<a href="/wallet/{{ account['address'] }}/disable" class="">disable</a>
|
||||
{% else %}
|
||||
<a href="/wallet/{{ account['address'] }}/enable" class="">enable</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ account['address'] | shorten }}</td>
|
||||
<td>
|
||||
|
||||
<form method="get" action="{{ url_for('wallet.rescan') }}">
|
||||
{{ account['scan_height'] }}
|
||||
<input type="integer" name="height" style="width: 5em; display: inline;" />
|
||||
<input type="hidden" name="address" value="{{ account['address'] }}" />
|
||||
<button type="submit">Rescan</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% for status in requests %}
|
||||
{% for request in requests[status] %}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tag text-white bg-dark">
|
||||
PENDING
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/wallet/{{ request['address'] }}/accept" class="">approve</a> |
|
||||
<a href="/wallet/{{ request['address'] }}/reject" class="">reject</a>
|
||||
</td>
|
||||
<td>{{ request['address'] | shorten }}</td>
|
||||
<td>{{ request['start_height'] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
@ -1,68 +1,25 @@
|
||||
{% extends 'includes/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<h1>LWS Web Admin</h1>
|
||||
|
||||
<h1>Monero Lightwallet Server</h1>
|
||||
<p>LWS Admin: {{ config.LWS_ADMIN_URL }}</p>
|
||||
<p>LWS RPC: {{ config.LWS_URL }}</p>
|
||||
<h3>Accounts</h3>
|
||||
<a href="/wallet/add" class="button outline primary">Add Wallet</a>
|
||||
<table class="striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Status</th>
|
||||
<th>Action</th>
|
||||
<th>Address</th>
|
||||
<th>Height</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
{% for status in accounts %}
|
||||
{% for account in accounts[status] %}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tag text-white {% if status == 'active' %}bg-success{% else %}bg-error{% endif %}">
|
||||
{{ status | upper }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
{% if status == 'active' %}
|
||||
<a href="/wallet/{{ account['address'] }}/disable" class="">disable</a>
|
||||
{% else %}
|
||||
<a href="/wallet/{{ account['address'] }}/enable" class="">enable</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ account['address'] | shorten }}</td>
|
||||
<td>
|
||||
|
||||
<form method="get" action="{{ url_for('wallet.rescan') }}">
|
||||
{{ account['scan_height'] }}
|
||||
<input type="integer" name="height" style="width: 5em; display: inline;" />
|
||||
<input type="hidden" name="address" value="{{ account['address'] }}" />
|
||||
<button type="submit">Rescan</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% for status in requests %}
|
||||
{% for request in requests[status] %}
|
||||
<tr>
|
||||
<td>
|
||||
<span class="tag text-white bg-dark">
|
||||
PENDING
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<a href="/wallet/{{ request['address'] }}/accept" class="">approve</a> |
|
||||
<a href="/wallet/{{ request['address'] }}/reject" class="">reject</a>
|
||||
</td>
|
||||
<td>{{ request['address'] | shorten }}</td>
|
||||
<td>{{ request['start_height'] }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
<div>
|
||||
<a hx-get="/htmx/import_wallet" hx-target="#walletEvent" class="button primary outline">
|
||||
Import Wallet
|
||||
</a>
|
||||
<a hx-get="/htmx/create_wallet" hx-target="#walletEvent" class="button primary">
|
||||
Create Wallet
|
||||
</a>
|
||||
</div>
|
||||
<div class="" style="margin-top: 2em">
|
||||
<p id="walletEvent"></p>
|
||||
</div>
|
||||
|
||||
<div hx-trigger="every 15s" hx-get="/htmx/show_wallets" hx-target="#show_wallets"></div>
|
||||
<div hx-trigger="load" hx-get="/htmx/show_wallets" id="show_wallets"></div>
|
||||
|
||||
{% endblock %}
|
||||
|
@ -0,0 +1,15 @@
|
||||
{% extends 'includes/base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<a href="/">Go Back</a>
|
||||
<h1>Add a Wallet</h1>
|
||||
<form method="post">
|
||||
<label for="address">Address</label>
|
||||
<input type="text" name="address" value="{{ request.args.get('address', '') }}" />
|
||||
<label for="view_key">View Key</label>
|
||||
<input type="text" name="view_key" />
|
||||
<label for="restore_height">Restore Height</label>
|
||||
<input type="number" name="restore_height" />
|
||||
<button type="submit">Send</button>
|
||||
</form>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue