saving progress

htmx
lza_menace 1 year ago
parent e969518e15
commit b721a14402

@ -36,6 +36,16 @@ async def label_wallet():
label=label
)
@bp.route("/set_height")
async def set_height():
address = request.args.get("address")
height = request.args.get("height")
return await render_template(
"htmx/set_height.html",
address=address,
height=height
)
@bp.route("/show_wallets")
@login_required
async def show_wallets():
@ -46,7 +56,6 @@ async def show_wallets():
del accounts["hidden"]
# make wallets if they don't exist
for status in accounts:
print(status)
for account in accounts[status]:
w = Wallet.select().where(Wallet.address == account["address"]).first()
if not w:

@ -49,19 +49,11 @@ async def add():
return ""
@bp.route("/wallet/rescan")
@bp.route("/wallet/<address>/rescan/<height>")
@login_required
async def rescan():
address = request.args.get("address")
height = request.args.get("height")
if not address or not height:
await flash("you need to provide both address and height")
return redirect("/")
if lws.rescan(address, int(height)):
await flash(f"rescanning {address} from block {height}")
else:
await flash("probz")
return redirect(f"/")
async def rescan(address, height):
lws.rescan(address, int(height))
return redirect(url_for("htmx.show_wallets"))
@bp.route("/wallet/<address>/<status>")

@ -35,4 +35,18 @@ input {
.htmx-request.indicator{
display:inline;
}
.underline {
text-decoration: underline dotted;
}
#show_wallets {
animation-name: example;
animation-duration: 4s;
}
@keyframes example {
from {background-color: red;}
to {background-color: yellow;}
}

@ -1,8 +1,9 @@
<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="label">Label</label>
<input type="text" name="label" />
<label for="seed">Mnemonic Seed</label>
<p class="subtext">12, 13, or 25 word seeds</p>
<input type="password" name="seed" />
<label for="restore_height">Restore Height</label>
<input type="number" name="restore_height" />
<button onclick="document.getElementById('import_wallet').innerHTML = ''">Cancel</button>

@ -0,0 +1,14 @@
<form action="#" onsubmit="updateHeight(event)">
<input type="text" name="label" onkeyup="updateHeight(event)" value="{{ height }}" id="height-input-{{ address }}" onfocusout="updateHeight(event)">
</form>
<script>
function updateHeight(e) {
e.preventDefault();
if (e.keyCode === 13) {
htmx.ajax('GET', `/wallet/{{ address }}/rescan/${e.target.value}`, '#show_wallets');
} else if (e.keyCode === 27 || e.type == "focusout") {
htmx.ajax('GET', '{{ url_for("htmx.show_wallets") }}', '#show_wallets');
}
}
document.getElementById('height-input-{{ address }}').focus();
</script>

@ -33,12 +33,12 @@
<tr>
<td>
<div hx-get="/htmx/label_wallet" hx-target="this" hx-swap="outerHTML" hx-vals='{"address": "{{ account['address'] }}", "label": "{{ account['address'] | find_label }}"}'>
{{ account['address'] | find_label }} <i class="fa-regular fa-pen-to-square"></i>
<span class="underline">{{ account['address'] | find_label }}</span> <i class="fa-regular fa-pen-to-square"></i>
</div>
</td>
<td>
<span class="tag {% if status == 'active' %}text-primary{% else %}text-error{% endif %}">
{{ status | upper }}
{{ status | capitalize }}
</span>
</td>
<td>
@ -50,7 +50,11 @@
</td>
<td>{{ account['address'] | shorten }}</td>
<td>
<i class="fa-sharp fa-solid fa-spinner fa-spin"></i> {{ account['scan_height'] }}
<div hx-get="/htmx/set_height" hx-target="this" hx-swap="outerHTML" hx-vals='{"address": "{{ account['address'] }}", "height": "{{ account['scan_height'] }}"}'>
<span class="underline">{{ account['scan_height'] }}</span>
<!-- <i class="fa-sharp fa-solid fa-spinner fa-spin"></i> -->
<i class="fa-regular fa-pen-to-square"></i>
</div>
</td>
</tr>
{% endfor %}

Loading…
Cancel
Save