Merge pull request #16 from lnbits/UI_hotfixes

UI hotfixes
This commit is contained in:
Vlad Stan 2023-03-15 23:11:55 +02:00 committed by GitHub
commit b2f5f519c3
6 changed files with 64 additions and 45 deletions

View file

@ -82,7 +82,7 @@
</q-card-section> </q-card-section>
</div> </div>
<q-inner-loading :showing="loading"> <q-inner-loading :showing="loading">
<q-spinner-cube size="50px" color="primary" /> <q-spinner-comment size="50px" color="primary" />
</q-inner-loading> </q-inner-loading>
</q-card> </q-card>
</q-dialog> </q-dialog>

View file

@ -1,6 +1,6 @@
<div> <div>
<div v-if="searchNostr" class="row q-col-gutter-md"> <div v-if="searchNostr" class="row q-col-gutter-md">
<div class="col-12 col-md-7 q-gutter-y-md"> <div class="col-12 q-gutter-y-md">
<q-card> <q-card>
<!-- <q-card-section class="row items-center q-pb-none"> <!-- <q-card-section class="row items-center q-pb-none">
<div class="text-h6">Search Globally</div> <div class="text-h6">Search Globally</div>

View file

@ -60,7 +60,7 @@
filled filled
dense dense
v-model.trim="checkoutDialog.data.username" v-model.trim="checkoutDialog.data.username"
label="Name *optional" label="Name (optional)"
></q-input> ></q-input>
<q-expansion-item <q-expansion-item
v-if="!account" v-if="!account"
@ -126,7 +126,7 @@
:type="isPwd ? 'password' : 'text'" :type="isPwd ? 'password' : 'text'"
v-if="!customerUseExtension" v-if="!customerUseExtension"
v-model.trim="checkoutDialog.data.privkey" v-model.trim="checkoutDialog.data.privkey"
label="Private key *optional" label="Private key (optional)"
hint="Enter your private key" hint="Enter your private key"
> >
<template v-slot:append> <template v-slot:append>
@ -141,14 +141,15 @@
filled filled
dense dense
v-model.trim="checkoutDialog.data.address" v-model.trim="checkoutDialog.data.address"
label="Address" label="Address (optional)"
hint="If ordering a physical product make sure to fill this"
></q-input> ></q-input>
<q-input <q-input
v-model="checkoutDialog.data.email" v-model="checkoutDialog.data.email"
filled filled
dense dense
type="email" type="email"
label="Email *optional" label="Email (optional)"
hint="Merchant may not use email" hint="Merchant may not use email"
></q-input> ></q-input>
<q-input <q-input
@ -156,7 +157,7 @@
filled filled
dense dense
type="text" type="text"
label="Message *optional" label="Message (optional)"
></q-input> ></q-input>
<p>Select the shipping zone:</p> <p>Select the shipping zone:</p>
<div class="row q-mt-lg"> <div class="row q-mt-lg">
@ -177,8 +178,7 @@
:loading="loading" :loading="loading"
unelevated unelevated
color="primary" color="primary"
:disable="checkoutDialog.data.address == null :disable="checkoutDialog.data.shippingzone == null
|| checkoutDialog.data.shippingzone == null
|| checkoutDialog.data.pubkey == null" || checkoutDialog.data.pubkey == null"
@click="downloadOrder" @click="downloadOrder"
>Download Order</q-btn >Download Order</q-btn
@ -188,8 +188,7 @@
:loading="loading" :loading="loading"
unelevated unelevated
color="primary" color="primary"
:disable="checkoutDialog.data.address == null :disable="checkoutDialog.data.shippingzone == null
|| checkoutDialog.data.shippingzone == null
|| checkoutDialog.data.pubkey == null" || checkoutDialog.data.pubkey == null"
type="submit" type="submit"
>Checkout</q-btn >Checkout</q-btn
@ -226,7 +225,7 @@
</q-responsive> </q-responsive>
</a> </a>
<q-inner-loading :showing="loading"> <q-inner-loading :showing="loading">
<q-spinner-cube size="50px" color="primary" /> <q-spinner-puff size="50px" color="primary" />
</q-inner-loading> </q-inner-loading>
</div> </div>
<div class="row q-mt-lg"> <div class="row q-mt-lg">

View file

@ -189,7 +189,6 @@ async function customerStall(path) {
} }
}, },
closeQrCodeDialog() { closeQrCodeDialog() {
this.qrCodeDialog.dismissMsg()
this.qrCodeDialog.show = false this.qrCodeDialog.show = false
}, },
async placeOrder() { async placeOrder() {
@ -254,19 +253,22 @@ async function customerStall(path) {
} else if (this.customerUseExtension && this.hasNip07) { } else if (this.customerUseExtension && this.hasNip07) {
event = await window.nostr.signEvent(event) event = await window.nostr.signEvent(event)
} }
this.resetCheckout()
await this.sendOrder(event) await this.sendOrder(event)
}) })
}, },
async sendOrder(order) { async sendOrder(order) {
this.$q.notify({
message: 'Waiting for invoice from merchant...'
})
for (const url of Array.from(this.relays)) { for (const url of Array.from(this.relays)) {
try { try {
let relay = NostrTools.relayInit(url) let relay = NostrTools.relayInit(url)
relay.on('connect', () => { relay.on('connect', () => {
console.log(`connected to ${relay.url}`) console.debug(`connected to ${relay.url}`)
}) })
relay.on('error', () => { relay.on('error', () => {
console.log(`failed to connect to ${relay.url}`) console.debug(`failed to connect to ${relay.url}`)
relay.close() relay.close()
return return
}) })
@ -274,11 +276,11 @@ async function customerStall(path) {
await relay.connect() await relay.connect()
let pub = relay.publish(order) let pub = relay.publish(order)
pub.on('ok', () => { pub.on('ok', () => {
console.log(`${relay.url} has accepted our event`) console.debug(`${relay.url} has accepted our event`)
relay.close() relay.close()
}) })
pub.on('failed', reason => { pub.on('failed', reason => {
console.log(`failed to publish to ${relay.url}: ${reason}`) console.debug(`failed to publish to ${relay.url}: ${reason}`)
relay.close() relay.close()
}) })
} catch (err) { } catch (err) {
@ -286,12 +288,8 @@ async function customerStall(path) {
} }
} }
this.loading = false this.loading = false
this.resetCheckout()
this.resetCart() this.resetCart()
this.qrCodeDialog.show = true this.qrCodeDialog.show = true
this.$q.notify({
message: 'Waiting for invoice from merchant...'
})
this.listenMessages() this.listenMessages()
}, },
async listenMessages() { async listenMessages() {
@ -329,7 +327,6 @@ async function customerStall(path) {
event.content event.content
) )
} }
//console.log(`${mine ? 'Me' : 'Merchant'}: ${plaintext}`)
this.messageFilter(plaintext, cb => Promise.resolve(pool.close)) this.messageFilter(plaintext, cb => Promise.resolve(pool.close))
} catch { } catch {
@ -345,9 +342,8 @@ async function customerStall(path) {
let json = JSON.parse(text) let json = JSON.parse(text)
if (json.id != this.activeOrder) return if (json.id != this.activeOrder) return
if (json.payment_options) { if (json.payment_options) {
let payment_request = json.payment_options.find( let payment_request = json.payment_options.find(o => o.type == 'ln')
o => o.type == 'ln' .link
).link
if (!payment_request) return if (!payment_request) return
this.loading = false this.loading = false
this.qrCodeDialog.data.payment_request = payment_request this.qrCodeDialog.data.payment_request = payment_request

View file

@ -114,7 +114,7 @@ const market = async () => {
this.pubkeys.add(this.account.pubkey) this.pubkeys.add(this.account.pubkey)
} }
if (relays && relays.length) { if (relays && relays.length) {
this.relays = new Set([...defaultRelays, ...relays]) this.relays = new Set(relays)
} else { } else {
this.relays = new Set(defaultRelays) this.relays = new Set(defaultRelays)
} }
@ -196,6 +196,12 @@ const market = async () => {
return return
}, },
async updateData(events) { async updateData(events) {
if (events.length < 1) {
this.$q.notify({
message: 'No matches were found!'
})
return
}
let products = new Map() let products = new Map()
let stalls = new Map() let stalls = new Map()
@ -215,15 +221,21 @@ const market = async () => {
this.stalls = await Array.from(stalls.values()) this.stalls = await Array.from(stalls.values())
this.products = Array.from(products.values()).map(obj => { this.products = Array.from(products.values())
let stall = this.stalls.find(s => s.id == obj.stall_id) .map(obj => {
obj.stallName = stall.name let stall = this.stalls.find(s => s.id == obj.stall_id)
obj.images = [obj.image] if (!stall) return
if (obj.currency != 'sat') { obj.stallName = stall.name
obj.formatedPrice = this.getAmountFormated(obj.price, obj.currency) obj.images = [obj.image]
} if (obj.currency != 'sat') {
return obj obj.formatedPrice = this.getAmountFormated(
}) obj.price,
obj.currency
)
}
return obj
})
.filter(f => f)
}, },
async initNostr() { async initNostr() {
this.$q.loading.show() this.$q.loading.show()
@ -261,15 +273,21 @@ const market = async () => {
await Promise.resolve(sub) await Promise.resolve(sub)
this.stalls = await Array.from(stalls.values()) this.stalls = await Array.from(stalls.values())
this.products = Array.from(products.values()).map(obj => { this.products = Array.from(products.values())
let stall = this.stalls.find(s => s.id == obj.stall_id) .map(obj => {
obj.stallName = stall.name let stall = this.stalls.find(s => s.id == obj.stall_id)
obj.images = [obj.image] if (!stall) return
if (obj.currency != 'sat') { obj.stallName = stall.name
obj.formatedPrice = this.getAmountFormated(obj.price, obj.currency) obj.images = [obj.image]
} if (obj.currency != 'sat') {
return obj obj.formatedPrice = this.getAmountFormated(
}) obj.price,
obj.currency
)
}
return obj
})
.filter(f => f)
this.$q.loading.hide() this.$q.loading.hide()
pool.close(relays) pool.close(relays)
return return

View file

@ -35,4 +35,10 @@
>Swagger REST API Documentation</a >Swagger REST API Documentation</a
> >
</q-card-section> </q-card-section>
<q-card-section>
<a target="_blank" href="/nostrmarket/market" class="text-white"
><q-tooltip>Visit the market client</q-tooltip
><q-icon name="storefront" class="q-mr-sm"></q-icon>Market client</a
>
</q-card-section>
</q-card> </q-card>