Skip to content

Commit

Permalink
fix: atm page (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
dni authored Dec 16, 2024
1 parent 8cc8876 commit cf94a35
Show file tree
Hide file tree
Showing 7 changed files with 283 additions and 262 deletions.
2 changes: 2 additions & 0 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
from .crud import db
from .views import fossa_generic_router
from .views_api import fossa_api_router
from .views_api_atm import fossa_api_atm_router
from .views_lnurl import fossa_lnurl_router

fossa_ext: APIRouter = APIRouter(prefix="/fossa", tags=["fossa"])
fossa_ext.include_router(fossa_generic_router)
fossa_ext.include_router(fossa_api_router)
fossa_ext.include_router(fossa_lnurl_router)
fossa_ext.include_router(fossa_api_atm_router)

fossa_static_files = [
{
Expand Down
33 changes: 17 additions & 16 deletions static/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ window.app = Vue.createApp({
}
}
LNbits.api
.request('POST', '/fossa/api/v1', wallet, updatedData)
.request('POST', '/fossa/api/v1/fossa', wallet, updatedData)
.then(response => {
this.fossa.push(response.data)
this.formDialog.show = false
Expand All @@ -124,7 +124,7 @@ window.app = Vue.createApp({
},
getFossa() {
LNbits.api
.request('GET', '/fossa/api/v1', this.g.user.wallets[0].adminkey)
.request('GET', '/fossa/api/v1/fossa', this.g.user.wallets[0].adminkey)
.then(response => {
if (response.data) {
this.fossa = response.data
Expand All @@ -135,9 +135,9 @@ window.app = Vue.createApp({
getAtmPayments() {
LNbits.api
.request('GET', '/fossa/api/v1/atm', this.g.user.wallets[0].adminkey)
.then(function (response) {
.then(response => {
if (response.data) {
this.atmLinks = response.data.map(mapatmpayments)
this.atmLinks = response.data
}
})
.catch(LNbits.utils.notifyApiError)
Expand All @@ -160,17 +160,17 @@ window.app = Vue.createApp({
.catch(LNbits.utils.notifyApiError)
})
},
deleteATMLink(atmId) {
deleteAtmLink(atmId) {
LNbits.utils
.confirmDialog('Are you sure you want to delete this atm link?')
.onOk(function () {
.onOk(() => {
LNbits.api
.request(
'DELETE',
'/fossa/api/v1/atm/' + atmId,
this.g.user.wallets[0].adminkey
)
.then(function (response) {
.then(() => {
this.atmLinks = _.reject(this.atmLinks, function (obj) {
return obj.id === atmId
})
Expand Down Expand Up @@ -214,7 +214,12 @@ window.app = Vue.createApp({
}

LNbits.api
.request('PUT', '/fossa/api/v1/' + updatedData.id, wallet, updatedData)
.request(
'PUT',
'/fossa/api/v1/fossa/' + updatedData.id,
wallet,
updatedData
)
.then(response => {
this.fossa = _.reject(this.fossa, obj => {
return obj.id === updatedData.id
Expand All @@ -240,18 +245,14 @@ window.app = Vue.createApp({
exportAtmCSV() {
LNbits.utils.exportCSV(this.atmTable.columns, this.atmLinks)
},
openATMLink(deviceid, p) {
const url =
this.location + '/fossa/api/v1/lnurl/' + deviceid + '?atm=1&p=' + p
data = {
url: url
}
openAtmLink(deviceid, p) {
const url = `${this.protocol}//${this.location}/fossa/api/v1/lnurl/${deviceid}?atm=1&p=${p}`
LNbits.api
.request(
'POST',
'/fossa/api/v1/lnurlencode',
this.g.user.wallets[0].adminkey,
data
{url: url}
)
.then(response => {
window.open('/fossa/atm?lightning=' + response.data)
Expand All @@ -261,7 +262,7 @@ window.app = Vue.createApp({
},
created() {
this.getFossa()
// this.getatmpayments()
this.getAtmPayments()
LNbits.api
.request('GET', '/api/v1/currencies')
.then(response => {
Expand Down
23 changes: 10 additions & 13 deletions templates/fossa/atm.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

<q-tab
name="ln"
label="lightnig"
label="lightning"
@click="updateTabAndClear(val)"
></q-tab>

Expand Down Expand Up @@ -61,13 +61,10 @@
<div class="text-h8">LNURL withdraw</div>
<div class="text-center">
<a class="text-secondary" :href="'lightning:' + qr_value">
<q-responsive :ratio="1" class="q-mx-md">
<qrcode
:value="qr_value"
:options="{width: 800}"
class="rounded-borders"
></qrcode>
</q-responsive>
<lnbits-qrcode
:value="qr_value"
class="rounded-borders"
></lnbits-qrcode>
</a>
</div>

Expand Down Expand Up @@ -175,7 +172,7 @@ <h3 class="text-h5">
unelevated
type="a"
target="_blank"
:href="'/lnurldevice/print/' + recentpay"
:href="'/fossa/print/' + recentpay"
></q-btn>
</q-card-section>
</q-card>
Expand All @@ -188,7 +185,7 @@ <h3 class="text-h5">
el: '#vue',
mixins: [windowMixin],
delimiters: ['${', '}'],
data: function () {
data() {
return {
device_id: '{{device_id}}',
qr_value: '{{lnurl}}',
Expand All @@ -210,7 +207,7 @@ <h3 class="text-h5">
try {
const response = await LNbits.api.request(
'GET',
`/lnurldevice/api/v1/ln/${this.device_id}/${this.p}/${this.ln}`,
`/fossa/api/v1/ln/${this.device_id}/${this.p}/${this.ln}`,
''
)
console.log(response.data)
Expand Down Expand Up @@ -241,7 +238,7 @@ <h3 class="text-h5">
try {
const response = await LNbits.api.request(
'GET',
`/lnurldevice/api/v1/boltz/${this.device_id}/${this.p}/${this.onchain_liquid}/${this.address}`,
`/fossa/api/v1/boltz/${this.device_id}/${this.p}/${this.onchain_liquid}/${this.address}`,
''
)
if (response.data) {
Expand Down Expand Up @@ -294,7 +291,7 @@ <h3 class="text-h5">
}
},
watch: {
tab: function (newVal, oldVal) {
tab(newVal, oldVal) {
if (newVal === 'ln') {
this.launchFunction()
}
Expand Down
2 changes: 1 addition & 1 deletion templates/fossa/atm_receipt.html
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ <h3>ATM receipt for: "{{devicename}}"</h3>
el: '#vue',
mixins: [windowMixin],
delimiters: ['${', '}'],
data: function () {
data() {
return {
theurl: location.protocol + '//' + location.host,
printDialog: {
Expand Down
4 changes: 2 additions & 2 deletions templates/fossa/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ <h5 class="text-subtitle1 q-my-none">ATM Payments</h5>
flat
dense
size="xs"
@click="openATMLink(props.row.deviceid, props.row.payload)"
@click="openAtmLink(props.row.deviceid, props.row.payload)"
icon="link"
color="grey"
>
Expand All @@ -182,7 +182,7 @@ <h5 class="text-subtitle1 q-my-none">ATM Payments</h5>
flat
dense
size="xs"
@click="deleteATMLink(props.row.id)"
@click="deleteAtmLink(props.row.id)"
icon="cancel"
color="pink"
>
Expand Down
Loading

0 comments on commit cf94a35

Please sign in to comment.