feat: code quality
format add ci fixup ci
This commit is contained in:
parent
09bb033f85
commit
42b5edaf5d
26 changed files with 3199 additions and 295 deletions
|
|
@ -1,3 +1,8 @@
|
|||
<q-expansion-item group="extras" icon="swap_vertical_circle" label="API info" :content-inset-level="0.5">
|
||||
<q-expansion-item
|
||||
group="extras"
|
||||
icon="swap_vertical_circle"
|
||||
label="API info"
|
||||
:content-inset-level="0.5"
|
||||
>
|
||||
<q-btn flat label="Swagger API" type="a" href="../docs#/MyExtension"></q-btn>
|
||||
</q-expansion-item>
|
||||
</q-expansion-item>
|
||||
|
|
|
|||
|
|
@ -1,13 +1,25 @@
|
|||
<q-expansion-item group="extras" icon="info" label="More info">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<p>
|
||||
Some more info about my excellent extension.
|
||||
</p>
|
||||
<small>Created by
|
||||
<a class="text-secondary" href="https://github.com/benarc" target="_blank">Ben Arc</a>.</small>
|
||||
<small>Repo
|
||||
<a class="text-secondary" href="https://github.com/lnbits/myextension" target="_blank">MyExtension</a>.</small>
|
||||
<p>Some more info about my excellent extension.</p>
|
||||
<small
|
||||
>Created by
|
||||
<a
|
||||
class="text-secondary"
|
||||
href="https://github.com/benarc"
|
||||
target="_blank"
|
||||
>Ben Arc</a
|
||||
>.</small
|
||||
>
|
||||
<small
|
||||
>Repo
|
||||
<a
|
||||
class="text-secondary"
|
||||
href="https://github.com/lnbits/myextension"
|
||||
target="_blank"
|
||||
>MyExtension</a
|
||||
>.</small
|
||||
>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
</q-expansion-item>
|
||||
</q-expansion-item>
|
||||
|
|
|
|||
|
|
@ -8,7 +8,9 @@
|
|||
<div class="col-12 col-md-8 col-lg-7 q-gutter-y-md">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<q-btn unelevated color="primary" @click="formDialog.show = true">New MyExtension</q-btn>
|
||||
<q-btn unelevated color="primary" @click="formDialog.show = true"
|
||||
>New MyExtension</q-btn
|
||||
>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
|
|
@ -22,8 +24,14 @@
|
|||
<q-btn flat color="grey" @click="exportCSV">Export to CSV</q-btn>
|
||||
</div>
|
||||
</div>
|
||||
<q-table dense flat :data="myex" row-key="id" :columns="myexTable.columns"
|
||||
:pagination.sync="myexTable.pagination">
|
||||
<q-table
|
||||
dense
|
||||
flat
|
||||
:data="myex"
|
||||
row-key="id"
|
||||
:columns="myexTable.columns"
|
||||
:pagination.sync="myexTable.pagination"
|
||||
>
|
||||
<myextension v-slot:header="props">
|
||||
<q-tr :props="props">
|
||||
<q-th v-for="col in props.cols" :key="col.name" :props="props">
|
||||
|
|
@ -39,28 +47,57 @@
|
|||
<div v-else>${ col.value }</div>
|
||||
</q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn unelevated dense size="sm" icon="qr_code" :color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||
class="q-mr-sm" @click="openUrlDialog(props.row.id)"></q-btn></q-td>
|
||||
<q-btn
|
||||
unelevated
|
||||
dense
|
||||
size="sm"
|
||||
icon="qr_code"
|
||||
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||
class="q-mr-sm"
|
||||
@click="openUrlDialog(props.row.id)"
|
||||
></q-btn
|
||||
></q-td>
|
||||
<q-td auto-width>
|
||||
<q-btn unelevated dense size="sm" icon="launch" :color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||
type="a" :href="props.row.myextension" target="_blank"><q-tooltip>Open public
|
||||
page</q-tooltip></q-btn></q-td>
|
||||
<q-btn
|
||||
unelevated
|
||||
dense
|
||||
size="sm"
|
||||
icon="launch"
|
||||
:color="($q.dark.isActive) ? 'grey-7' : 'grey-5'"
|
||||
type="a"
|
||||
:href="props.row.myextension"
|
||||
target="_blank"
|
||||
><q-tooltip>Open public page</q-tooltip></q-btn
|
||||
></q-td
|
||||
>
|
||||
|
||||
<q-td>
|
||||
<q-btn flat dense size="xs" @click="updateMyExtensionForm(props.row.id)" icon="edit" color="light-blue">
|
||||
<q-btn
|
||||
flat
|
||||
dense
|
||||
size="xs"
|
||||
@click="updateMyExtensionForm(props.row.id)"
|
||||
icon="edit"
|
||||
color="light-blue"
|
||||
>
|
||||
<q-tooltip> Edit copilot </q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
|
||||
<q-td>
|
||||
<q-btn flat dense size="xs" @click="deleteMyExtension(props.row.id)" icon="cancel" color="pink">
|
||||
<q-btn
|
||||
flat
|
||||
dense
|
||||
size="xs"
|
||||
@click="deleteMyExtension(props.row.id)"
|
||||
icon="cancel"
|
||||
color="pink"
|
||||
>
|
||||
<q-tooltip> Delete copilot </q-tooltip>
|
||||
</q-btn>
|
||||
</q-td>
|
||||
|
||||
</q-tr>
|
||||
</template>
|
||||
|
||||
</q-table>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
|
@ -69,9 +106,13 @@
|
|||
<div class="col-12 col-md-4 col-lg-5 q-gutter-y-md">
|
||||
<q-card>
|
||||
<q-card-section>
|
||||
<h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} MyExtension extension</h6>
|
||||
<p>Simple extension you can use as a base for your own extension. <br /> Includes very simple LNURL-pay and
|
||||
LNURL-withdraw example.</p>
|
||||
<h6 class="text-subtitle1 q-my-none">
|
||||
{{SITE_TITLE}} MyExtension extension
|
||||
</h6>
|
||||
<p>
|
||||
Simple extension you can use as a base for your own extension. <br />
|
||||
Includes very simple LNURL-pay and LNURL-withdraw example.
|
||||
</p>
|
||||
</q-card-section>
|
||||
<q-card-section class="q-pa-none">
|
||||
<q-separator></q-separator>
|
||||
|
|
@ -91,20 +132,54 @@
|
|||
<q-dialog v-model="formDialog.show" position="top" @hide="closeFormDialog">
|
||||
<q-card class="q-pa-lg q-pt-xl" style="width: 500px">
|
||||
<q-form @submit="sendMyExtensionData" class="q-gutter-md">
|
||||
<q-input filled dense v-model.trim="formDialog.data.name" label="Name"
|
||||
placeholder="Name for your record"></q-input>
|
||||
<q-select filled dense emit-value v-model="formDialog.data.wallet" :options="g.user.walletOptions"
|
||||
label="Wallet *"></q-select>
|
||||
<q-input filled dense type="number" v-model.trim="formDialog.data.lnurlwithdrawamount"
|
||||
label="LNURL-withdraw amount"></q-input>
|
||||
<q-input filled dense type="number" v-model.trim="formDialog.data.lnurlpayamount"
|
||||
label="LNURL-pay amount"></q-input>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="formDialog.data.name"
|
||||
label="Name"
|
||||
placeholder="Name for your record"
|
||||
></q-input>
|
||||
<q-select
|
||||
filled
|
||||
dense
|
||||
emit-value
|
||||
v-model="formDialog.data.wallet"
|
||||
:options="g.user.walletOptions"
|
||||
label="Wallet *"
|
||||
></q-select>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
type="number"
|
||||
v-model.trim="formDialog.data.lnurlwithdrawamount"
|
||||
label="LNURL-withdraw amount"
|
||||
></q-input>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
type="number"
|
||||
v-model.trim="formDialog.data.lnurlpayamount"
|
||||
label="LNURL-pay amount"
|
||||
></q-input>
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn v-if="formDialog.data.id" unelevated color="primary" type="submit">Update MyExtension</q-btn>
|
||||
<q-btn v-else unelevated color="primary"
|
||||
<q-btn
|
||||
v-if="formDialog.data.id"
|
||||
unelevated
|
||||
color="primary"
|
||||
type="submit"
|
||||
>Update MyExtension</q-btn
|
||||
>
|
||||
<q-btn
|
||||
v-else
|
||||
unelevated
|
||||
color="primary"
|
||||
:disable="formDialog.data.name == null || formDialog.data.wallet == null || formDialog.data.lnurlwithdrawamount == null || formDialog.data.lnurlpayamount == null"
|
||||
type="submit">Create MyExtension</q-btn>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto">Cancel</q-btn>
|
||||
type="submit"
|
||||
>Create MyExtension</q-btn
|
||||
>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||
>Cancel</q-btn
|
||||
>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
|
|
@ -119,29 +194,39 @@
|
|||
<q-responsive :ratio="1" class="q-mx-xl q-mb-md">
|
||||
<lnbits-qrcode :value="qrValue"></lnbits-qrcode>
|
||||
</q-responsive>
|
||||
<center><q-btn label="copy" @click="copyText(qrValue)"></q-btn>
|
||||
</center>
|
||||
<center><q-btn label="copy" @click="copyText(qrValue)"></q-btn></center>
|
||||
|
||||
<q-separator></q-separator>
|
||||
|
||||
<div class="row justify-start q-mt-lg">
|
||||
<div class="col col-md-auto">
|
||||
<q-btn outline style="color: primmary;" @click="qrValue = urlDialog.data.lnurlpay">lnurlpay</q-btn>
|
||||
|
||||
<q-btn
|
||||
outline
|
||||
style="color: primmary"
|
||||
@click="qrValue = urlDialog.data.lnurlpay"
|
||||
>lnurlpay</q-btn
|
||||
>
|
||||
</div>
|
||||
<div class="col col-md-auto">
|
||||
<q-btn outline style="color: primmary;" @click="qrValue = urlDialog.data.lnurlwithdraw">lnurlwithdraw</q-btn>
|
||||
|
||||
<q-btn
|
||||
outline
|
||||
style="color: primmary"
|
||||
@click="qrValue = urlDialog.data.lnurlwithdraw"
|
||||
>lnurlwithdraw</q-btn
|
||||
>
|
||||
</div>
|
||||
<div class="col q-pl-md">
|
||||
<q-input filled bottom-slots dense v-model="invoiceAmount">
|
||||
<template v-slot:append>
|
||||
<q-btn round @click="createInvoice(urlDialog.data.wallet, urlDialog.data.id)" color="primary" flat
|
||||
icon="add_circle" />
|
||||
</template>
|
||||
<template v-slot:hint>
|
||||
Create an invoice
|
||||
<q-btn
|
||||
round
|
||||
@click="createInvoice(urlDialog.data.wallet, urlDialog.data.id)"
|
||||
color="primary"
|
||||
flat
|
||||
icon="add_circle"
|
||||
/>
|
||||
</template>
|
||||
<template v-slot:hint> Create an invoice </template>
|
||||
</q-input>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -150,12 +235,10 @@
|
|||
</div>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
|
||||
</div>
|
||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
||||
<script src="https://cdn.jsdelivr.net/npm/canvas-confetti@1.4.0/dist/confetti.browser.min.js"></script>
|
||||
<script>
|
||||
|
||||
///////////////////////////////////////////////////
|
||||
//////////an object we can update with data////////
|
||||
///////////////////////////////////////////////////
|
||||
|
|
@ -178,15 +261,20 @@
|
|||
myex: [],
|
||||
myexTable: {
|
||||
columns: [
|
||||
{ name: 'id', align: 'left', label: 'ID', field: 'id' },
|
||||
{ name: 'name', align: 'left', label: 'Name', field: 'name' },
|
||||
{name: 'id', align: 'left', label: 'ID', field: 'id'},
|
||||
{name: 'name', align: 'left', label: 'Name', field: 'name'},
|
||||
{
|
||||
name: 'wallet',
|
||||
align: 'left',
|
||||
label: 'Wallet',
|
||||
field: 'wallet'
|
||||
},
|
||||
{ name: 'total', align: 'left', label: 'Total sent/received', field: 'total' },
|
||||
{
|
||||
name: 'total',
|
||||
align: 'left',
|
||||
label: 'Total sent/received',
|
||||
field: 'total'
|
||||
}
|
||||
],
|
||||
pagination: {
|
||||
rowsPerPage: 10
|
||||
|
|
@ -247,7 +335,7 @@
|
|||
}
|
||||
},
|
||||
updateMyExtensionForm(tempId) {
|
||||
const myextension = _.findWhere(this.myex, { id: tempId })
|
||||
const myextension = _.findWhere(this.myex, {id: tempId})
|
||||
this.formDialog.data = {
|
||||
...myextension
|
||||
}
|
||||
|
|
@ -291,7 +379,7 @@
|
|||
},
|
||||
deleteMyExtension: function (tempId) {
|
||||
var self = this
|
||||
var myextension = _.findWhere(this.myex, { id: tempId })
|
||||
var myextension = _.findWhere(this.myex, {id: tempId})
|
||||
|
||||
LNbits.utils
|
||||
.confirmDialog('Are you sure you want to delete this MyExtension?')
|
||||
|
|
@ -300,7 +388,8 @@
|
|||
.request(
|
||||
'DELETE',
|
||||
'/myextension/api/v1/myex/' + tempId,
|
||||
_.findWhere(self.g.user.wallets, { id: myextension.wallet }).adminkey
|
||||
_.findWhere(self.g.user.wallets, {id: myextension.wallet})
|
||||
.adminkey
|
||||
)
|
||||
.then(function (response) {
|
||||
self.myex = _.reject(self.myex, function (obj) {
|
||||
|
|
@ -316,12 +405,12 @@
|
|||
LNbits.utils.exportCSV(this.myexTable.columns, this.myex)
|
||||
},
|
||||
itemsArray(tempId) {
|
||||
const myextension = _.findWhere(this.myex, { id: tempId })
|
||||
const myextension = _.findWhere(this.myex, {id: tempId})
|
||||
return [...myextension.itemsMap.values()]
|
||||
},
|
||||
openformDialog(id) {
|
||||
const [tempId, itemId] = id.split(':')
|
||||
const myextension = _.findWhere(this.myex, { id: tempId })
|
||||
const myextension = _.findWhere(this.myex, {id: tempId})
|
||||
if (itemId) {
|
||||
const item = myextension.itemsMap.get(id)
|
||||
this.formDialog.data = {
|
||||
|
|
@ -339,7 +428,7 @@
|
|||
this.formDialog.data = {}
|
||||
},
|
||||
openUrlDialog(id) {
|
||||
this.urlDialog.data = _.findWhere(this.myex, { id })
|
||||
this.urlDialog.data = _.findWhere(this.myex, {id})
|
||||
this.qrValue = this.urlDialog.data.lnurlpay
|
||||
console.log(this.urlDialog.data.id)
|
||||
this.connectWebocket(this.urlDialog.data.id)
|
||||
|
|
@ -363,12 +452,7 @@
|
|||
}
|
||||
}
|
||||
LNbits.api
|
||||
.request(
|
||||
'POST',
|
||||
`/api/v1/payments`,
|
||||
wallet.inkey,
|
||||
dataToSend
|
||||
)
|
||||
.request('POST', `/api/v1/payments`, wallet.inkey, dataToSend)
|
||||
.then(response => {
|
||||
this.qrValue = response.data.payment_request
|
||||
})
|
||||
|
|
@ -377,15 +461,15 @@
|
|||
})
|
||||
},
|
||||
makeItRain() {
|
||||
document.getElementById("vue").disabled = true
|
||||
var end = Date.now() + (2 * 1000)
|
||||
document.getElementById('vue').disabled = true
|
||||
var end = Date.now() + 2 * 1000
|
||||
var colors = ['#FFD700', '#ffffff']
|
||||
function frame() {
|
||||
confetti({
|
||||
particleCount: 2,
|
||||
angle: 60,
|
||||
spread: 55,
|
||||
origin: { x: 0 },
|
||||
origin: {x: 0},
|
||||
colors: colors,
|
||||
zIndex: 999999
|
||||
})
|
||||
|
|
@ -393,15 +477,14 @@
|
|||
particleCount: 2,
|
||||
angle: 120,
|
||||
spread: 55,
|
||||
origin: { x: 1 },
|
||||
origin: {x: 1},
|
||||
colors: colors,
|
||||
zIndex: 999999
|
||||
})
|
||||
if (Date.now() < end) {
|
||||
requestAnimationFrame(frame)
|
||||
}
|
||||
else {
|
||||
document.getElementById("vue").disabled = false
|
||||
} else {
|
||||
document.getElementById('vue').disabled = false
|
||||
}
|
||||
}
|
||||
frame()
|
||||
|
|
@ -445,4 +528,4 @@
|
|||
}
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
|
|
@ -10,15 +10,20 @@
|
|||
<div class="text-center">
|
||||
<a class="text-secondary" href="lightning:{{ lnurl }}">
|
||||
<q-responsive :ratio="1" class="q-mx-md">
|
||||
<qrcode :value="qrValue" :options="{width: 800}" class="rounded-borders"></qrcode>
|
||||
<qrcode
|
||||
:value="qrValue"
|
||||
: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(qrValue)">Copy LNURL </q-btn>
|
||||
<q-btn outline color="grey" @click="copyText(qrValue)"
|
||||
>Copy LNURL
|
||||
</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">
|
||||
|
|
@ -26,13 +31,15 @@
|
|||
<q-card-section>
|
||||
<h6 class="text-subtitle1 q-mb-sm q-mt-none">Public page</h6>
|
||||
<p class="q-my-none">
|
||||
Most extensions have a public page that can be shared
|
||||
(this page will still be accessible even if you have restricted
|
||||
access to your LNbits install).
|
||||
Most extensions have a public page that can be shared (this page will
|
||||
still be accessible even if you have restricted access to your LNbits
|
||||
install).
|
||||
<br /><br />
|
||||
In this example when a user pays the LNURLpay it triggers an event via a websocket waiting for the payment,
|
||||
which you can subscribe to somewhere using wss://{your-lnbits}/api/v1/ws/{the-id-of-this-record}
|
||||
</q-card-section>
|
||||
In this example when a user pays the LNURLpay it triggers an event via
|
||||
a websocket waiting for the payment, which you can subscribe to
|
||||
somewhere using wss://{your-lnbits}/api/v1/ws/{the-id-of-this-record}
|
||||
</p></q-card-section
|
||||
>
|
||||
<q-card-section class="q-pa-none">
|
||||
<q-separator></q-separator>
|
||||
<q-list> </q-list>
|
||||
|
|
@ -57,8 +64,7 @@
|
|||
// Will trigger payment reaction when payment received, sent from tasks.py
|
||||
eventReactionWebocket(this.myExtensionID)
|
||||
},
|
||||
methods: {
|
||||
}
|
||||
methods: {}
|
||||
})
|
||||
</script>
|
||||
{% endblock %}
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue