Adding frontend page
This commit is contained in:
parent
f4439974e4
commit
69c7cdb49f
7 changed files with 85 additions and 29 deletions
|
|
@ -10,8 +10,8 @@ async def create_gerty(wallet_id: str, data: Gerty) -> Gerty:
|
|||
gerty_id = urlsafe_short_hash()
|
||||
await db.execute(
|
||||
"""
|
||||
INSERT INTO gerty.gertys (id, name, wallet, lnbits_wallets, sats_quote, exchange, onchain_sats, ln_stats)
|
||||
VALUES (?, ?, ?, ?, ?, ?)
|
||||
INSERT INTO gerty.gertys (id, name, wallet, lnbits_wallets, sats_quote, exchange, onchain_stats, ln_stats)
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
||||
""",
|
||||
(
|
||||
gerty_id,
|
||||
|
|
|
|||
|
|
@ -6,12 +6,13 @@ async def m001_initial(db):
|
|||
"""
|
||||
CREATE TABLE gerty.gertys (
|
||||
id TEXT PRIMARY KEY,
|
||||
name TEXT NOT NULL,
|
||||
wallet TEXT NOT NULL,
|
||||
lnbits_wallets TEXT NOT NULL,
|
||||
sats_quote BOOL NOT NULL,
|
||||
exchange TEXT NOT NULL,
|
||||
onchain_sats BOOL NOT NULL,
|
||||
ln_stats BOOL NOT NULL
|
||||
lnbits_wallets TEXT,
|
||||
sats_quote BOOL,
|
||||
exchange TEXT,
|
||||
onchain_stats BOOL,
|
||||
ln_stats BOOL
|
||||
);
|
||||
"""
|
||||
)
|
||||
|
|
@ -7,10 +7,10 @@ from pydantic import BaseModel
|
|||
|
||||
|
||||
class Gerty(BaseModel):
|
||||
id: str
|
||||
id: str = Query(None)
|
||||
name: str
|
||||
wallet: str
|
||||
lnbits_wallets: str # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"}
|
||||
lnbits_wallets: str = Query(None) # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"}
|
||||
sats_quote: bool = Query(False) # Fetch Satoshi quotes
|
||||
exchange: str = Query(None) # BTC <-> Fiat exchange rate to pull ie "USD", in 0.0001 and sats
|
||||
onchain_sats: bool = Query(False) # Onchain stats
|
||||
|
|
|
|||
54
lnbits/extensions/gerty/templates/gerty/gerty.html
Normal file
54
lnbits/extensions/gerty/templates/gerty/gerty.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
{% extends "public.html" %} {% block page %}
|
||||
<div class="row q-col-gutter-md justify-center">
|
||||
<div class="col-12 col-sm-6 col-md-5 col-lg-4">
|
||||
<q-card class="q-pa-lg">
|
||||
<q-card-section class="q-pa-none">
|
||||
<div class="text-center">
|
||||
<a href="lightning:{{ lnurl }}">
|
||||
<q-responsive :ratio="1" class="q-mx-md">
|
||||
<qrcode
|
||||
value="{{ lnurl }}"
|
||||
:options="{width: 800}"
|
||||
class="rounded-borders"
|
||||
></qrcode>
|
||||
</q-responsive>
|
||||
</a>
|
||||
</div>
|
||||
<div class="row q-mt-lg q-gutter-sm">
|
||||
<q-btn outline color="grey" @click="copyText('{{ lnurl }}')"
|
||||
>Copy LNURL</q-btn
|
||||
>
|
||||
<q-btn
|
||||
outline
|
||||
color="grey"
|
||||
icon="nfc"
|
||||
@click="writeNfcTag(' {{ lnurl }} ')"
|
||||
:disable="nfcTagWriting"
|
||||
></q-btn>
|
||||
</div>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
<div class="col-12 col-sm-6 col-md-5 col-lg-4 q-gutter-y-md">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<h6 class="text-subtitle1 q-mb-sm q-mt-none">Gerty</h6>
|
||||
<p class="q-my-none">Use an LNURL compatible bitcoin wallet to pay.</p>
|
||||
</q-card-section>
|
||||
<q-card-section class="q-pa-none">
|
||||
<q-separator></q-separator>
|
||||
<q-list> {% include "lnurlp/_lnurl.html" %} </q-list>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %} {% block scripts %}
|
||||
<script>
|
||||
Vue.component(VueQrcode.name, VueQrcode)
|
||||
|
||||
new Vue({
|
||||
el: '#vue',
|
||||
mixins: [windowMixin]
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
@ -9,7 +9,6 @@
|
|||
>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<div class="row items-center no-wrap q-mb-md">
|
||||
|
|
@ -137,7 +136,7 @@
|
|||
<q-btn
|
||||
unelevated
|
||||
color="primary"
|
||||
:disable="formDialog.data.walletOptions == null || formDialog.data.name == null"
|
||||
:disable="formDialog.data.wallet == null || formDialog.data.name == null"
|
||||
type="submit"
|
||||
>Create Gerty</q-btn
|
||||
>
|
||||
|
|
@ -383,7 +382,7 @@
|
|||
formDialog: {
|
||||
show: false,
|
||||
data: {sats_quote: false,
|
||||
onchain_sats: false,
|
||||
onchain_stats: false,
|
||||
ln_stats: false}
|
||||
}
|
||||
}
|
||||
|
|
@ -396,11 +395,10 @@
|
|||
},
|
||||
getGertys: function () {
|
||||
var self = this
|
||||
|
||||
LNbits.api
|
||||
.request(
|
||||
'GET',
|
||||
'/gerty/api/v1/gertys?all_wallets=true',
|
||||
'/gerty/api/v1/gerty?all_wallets=true',
|
||||
this.g.user.wallets[0].inkey
|
||||
)
|
||||
.then(function (response) {
|
||||
|
|
@ -412,20 +410,19 @@
|
|||
createGerty: function () {
|
||||
var data = {
|
||||
name: this.formDialog.data.name,
|
||||
currency: this.formDialog.data.currency,
|
||||
tip_options: this.formDialog.data.tip_options
|
||||
? JSON.stringify(
|
||||
this.formDialog.data.tip_options.map(str => parseInt(str))
|
||||
)
|
||||
: JSON.stringify([]),
|
||||
tip_wallet: this.formDialog.data.tip_wallet || ''
|
||||
wallet: this.formDialog.data.wallet,
|
||||
lnbits_wallets: this.formDialog.data.lnbits_wallets,
|
||||
sats_quote: this.formDialog.data.sats_quote,
|
||||
exchange: this.formDialog.data.exchange,
|
||||
onchain_sats: this.formDialog.data.onchain_sats,
|
||||
ln_stats: this.formDialog.data.ln_stats
|
||||
}
|
||||
var self = this
|
||||
|
||||
LNbits.api
|
||||
.request(
|
||||
'POST',
|
||||
'/gerty/api/v1/gertys',
|
||||
'/gerty/api/v1/gerty',
|
||||
_.findWhere(this.g.user.wallets, {id: this.formDialog.data.wallet})
|
||||
.inkey,
|
||||
data
|
||||
|
|
@ -448,7 +445,7 @@
|
|||
LNbits.api
|
||||
.request(
|
||||
'DELETE',
|
||||
'/gerty/api/v1/gertys/' + gertyId,
|
||||
'/gerty/api/v1/gerty/' + gertyId,
|
||||
_.findWhere(self.g.user.wallets, {id: gerty.wallet}).adminkey
|
||||
)
|
||||
.then(function (response) {
|
||||
|
|
|
|||
|
|
@ -21,3 +21,11 @@ async def index(request: Request, user: User = Depends(check_user_exists)):
|
|||
"gerty/index.html", {"request": request, "user": user.dict()}
|
||||
)
|
||||
|
||||
@gerty_ext.get("/{gerty_id}", response_class=HTMLResponse)
|
||||
async def display(request: Request, gerty_id):
|
||||
gerty = await get_gerty(gerty_id)
|
||||
if not gerty:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Gerty does not exist."
|
||||
)
|
||||
return lnurlp_renderer().TemplateResponse("gerty/gerty.html", ctx)
|
||||
|
|
@ -91,18 +91,14 @@ async def api_gerty_satoshi():
|
|||
|
||||
@gerty_ext.get("/api/v1/gerty/{gerty_id}")
|
||||
async def api_gerty_json(
|
||||
gerty_id: str, wallet: WalletTypeInfo = Depends(require_admin_key)
|
||||
gerty_id: str
|
||||
):
|
||||
gerty = await get_gerty(gerty_id)
|
||||
logger.debug(gerty.wallet)
|
||||
if not gerty:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.NOT_FOUND, detail="Gerty does not exist."
|
||||
)
|
||||
if gerty.wallet != wallet.wallet.id:
|
||||
raise HTTPException(
|
||||
status_code=HTTPStatus.FORBIDDEN,
|
||||
detail="Come on, seriously, this isn't your Gerty!",
|
||||
)
|
||||
gertyReturn = []
|
||||
if gerty.lnbits_wallets != "":
|
||||
gertyReturn.append(gerty.lnbitsWallets)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue