cleaning up a bit

htmx
lza_menace 1 year ago
parent 1921691040
commit e0c8e786f1

@ -18,15 +18,6 @@ from lws import config
# webhook_delete_uuid: {"event_ids": [...]}
# webhook_list: {}
def get_height() -> int:
try:
r = requests.get(f"{config.MONEROD_URL}/get_info")
print(r.content)
return int(r.json()["height"])
except Exception as e:
print(e)
return 0
class LWS:
def __init__(self):
pass

@ -23,11 +23,13 @@ async def create_wallet():
svk=seed.secret_view_key()
)
@bp.route("/import_wallet")
async def import_wallet():
"""Importing an existing wallet"""
return await render_template("htmx/import_wallet.html")
@bp.route("/label_wallet")
async def label_wallet():
"""Changing the label on a stored wallet"""
@ -39,6 +41,7 @@ async def label_wallet():
label=label
)
@bp.route("/set_height")
async def set_height():
"""Setting a new height to scan from"""
@ -50,6 +53,7 @@ async def set_height():
height=height
)
@bp.route("/show_wallets")
@login_required
async def show_wallets():
@ -73,4 +77,4 @@ async def show_wallets():
"htmx/show_wallets.html",
accounts=accounts,
requests=requests
)
)

@ -1,7 +1,7 @@
import monero.address
from monero.seed import Seed
from quart import Blueprint, render_template, request, flash, redirect, url_for
from quart_auth import login_required, current_user
from quart import Blueprint, request, flash, redirect, url_for
from quart_auth import login_required
from lws.helpers import lws
from lws.models import Wallet, get_random_words
@ -15,7 +15,6 @@ bp = Blueprint("wallet", "wallet")
async def add():
form = await request.form
if form:
address = None
label = form.get("label")
seed = form.get("seed")
restore_height = form.get("restore_height", None)
@ -29,7 +28,7 @@ async def add():
svk = str(seed.secret_view_key())
lws.add_wallet(address, svk)
if restore_height != "-1":
lws.rescan(address, str(restore_height))
lws.rescan(address, int(restore_height))
w = Wallet(
address=seed.public_address(),
label=label if label else get_random_words()

@ -11,8 +11,8 @@
<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 type="submit">Create</button>
<button onclick="cancelCreate()">Cancel</button>
<button onsubmit="cancelCreate()" type="submit">Create</button>
</form>
<script>
function cancelCreate() {

@ -7,8 +7,8 @@
<input type="password" name="seed" />
<label for="restore_height">Restore Height</label>
<input type="number" name="restore_height" value="-1" />
<button type="submit">Import</button>
<button onclick="cancelImport()">Cancel</button>
<button onsubmit="cancelImport()" type="submit">Import</button>
</form>
<script>
function cancelImport() {

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

@ -1,14 +1,16 @@
<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');
<div>
<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>
document.getElementById('height-input-{{ address }}').focus();
</script>
</div>

@ -19,7 +19,6 @@
</span>
</td>
<td>
<!-- <a hx-get="/htmx/import_wallet" hx-target="#walletForm" class="button primary outline"></a> -->
<button class="button primary" hx-target="#show_wallets" hx-get="{{ url_for('wallet.accept', address=request['address']) }}" hx-swap="innerHTML">Accept</button>
<button class="button error" hx-target="#show_wallets" hx-get="{{ url_for('wallet.reject', address=request['address']) }}" hx-swap="innerHTML">Reject</button>
</td>
@ -53,7 +52,6 @@
<td>
<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>

Loading…
Cancel
Save