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_delete_uuid: {"event_ids": [...]}
# webhook_list: {} # 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: class LWS:
def __init__(self): def __init__(self):
pass pass

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

@ -1,7 +1,7 @@
import monero.address import monero.address
from monero.seed import Seed from monero.seed import Seed
from quart import Blueprint, render_template, request, flash, redirect, url_for from quart import Blueprint, request, flash, redirect, url_for
from quart_auth import login_required, current_user from quart_auth import login_required
from lws.helpers import lws from lws.helpers import lws
from lws.models import Wallet, get_random_words from lws.models import Wallet, get_random_words
@ -15,7 +15,6 @@ bp = Blueprint("wallet", "wallet")
async def add(): async def add():
form = await request.form form = await request.form
if form: if form:
address = None
label = form.get("label") label = form.get("label")
seed = form.get("seed") seed = form.get("seed")
restore_height = form.get("restore_height", None) restore_height = form.get("restore_height", None)
@ -29,7 +28,7 @@ async def add():
svk = str(seed.secret_view_key()) svk = str(seed.secret_view_key())
lws.add_wallet(address, svk) lws.add_wallet(address, svk)
if restore_height != "-1": if restore_height != "-1":
lws.rescan(address, str(restore_height)) lws.rescan(address, int(restore_height))
w = Wallet( w = Wallet(
address=seed.public_address(), address=seed.public_address(),
label=label if label else get_random_words() 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="address" value="{{ address }}" class="hidden" />
<input type="text" name="view_key" value="{{ svk }}" class="hidden" /> <input type="text" name="view_key" value="{{ svk }}" class="hidden" />
<input type="number" name="restore_height" value="-1" class="hidden" /> <input type="number" name="restore_height" value="-1" class="hidden" />
<button type="submit">Create</button>
<button onclick="cancelCreate()">Cancel</button> <button onclick="cancelCreate()">Cancel</button>
<button onsubmit="cancelCreate()" type="submit">Create</button>
</form> </form>
<script> <script>
function cancelCreate() { function cancelCreate() {

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

@ -1,7 +1,8 @@
<form action="#" onsubmit="updateLabel(event)"> <div>
<form action="#" onsubmit="updateLabel(event)">
<input type="text" name="label" onkeyup="updateLabel(event)" value="{{ label }}" id="label-input-{{ address }}" onfocusout="updateLabel(event)"> <input type="text" name="label" onkeyup="updateLabel(event)" value="{{ label }}" id="label-input-{{ address }}" onfocusout="updateLabel(event)">
</form> </form>
<script> <script>
function updateLabel(e) { function updateLabel(e) {
e.preventDefault(); e.preventDefault();
if (e.keyCode === 13) { if (e.keyCode === 13) {
@ -11,4 +12,5 @@
} }
} }
document.getElementById('label-input-{{ address }}').focus(); document.getElementById('label-input-{{ address }}').focus();
</script> </script>
</div>

@ -1,7 +1,8 @@
<form action="#" onsubmit="updateHeight(event)"> <div>
<form action="#" onsubmit="updateHeight(event)">
<input type="text" name="label" onkeyup="updateHeight(event)" value="{{ height }}" id="height-input-{{ address }}" onfocusout="updateHeight(event)"> <input type="text" name="label" onkeyup="updateHeight(event)" value="{{ height }}" id="height-input-{{ address }}" onfocusout="updateHeight(event)">
</form> </form>
<script> <script>
function updateHeight(e) { function updateHeight(e) {
e.preventDefault(); e.preventDefault();
if (e.keyCode === 13) { if (e.keyCode === 13) {
@ -11,4 +12,5 @@
} }
} }
document.getElementById('height-input-{{ address }}').focus(); document.getElementById('height-input-{{ address }}').focus();
</script> </script>
</div>

@ -19,7 +19,6 @@
</span> </span>
</td> </td>
<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 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> <button class="button error" hx-target="#show_wallets" hx-get="{{ url_for('wallet.reject', address=request['address']) }}" hx-swap="innerHTML">Reject</button>
</td> </td>
@ -53,7 +52,6 @@
<td> <td>
<div hx-get="/htmx/set_height" hx-target="this" hx-swap="outerHTML" hx-vals='{"address": "{{ account['address'] }}", "height": "{{ 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> <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> <i class="fa-regular fa-pen-to-square"></i>
</div> </div>
</td> </td>

Loading…
Cancel
Save