Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an optional name #27

Merged
merged 6 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ async def create_charge(
INSERT INTO satspay.charges (
id,
"user",
name,
description,
onchainwallet,
onchainaddress,
Expand All @@ -59,11 +60,12 @@ async def create_charge(
extra,
custom_css
)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""",
(
charge_id,
user,
data.name,
data.description,
data.onchainwallet,
onchainaddress,
Expand Down
1 change: 1 addition & 0 deletions helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
def public_charge(charge: Charges):
c = {
"id": charge.id,
"name": charge.name,
"description": charge.description,
"onchainaddress": charge.onchainaddress,
"payment_request": charge.payment_request,
Expand Down
10 changes: 10 additions & 0 deletions migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,13 @@ async def m007_add_pending_column(db):
)
except OperationalError:
pass


async def m008_add_name_column(db):
"""
Add 'name' column for storing the name of the charge
"""
try:
await db.execute(f"ALTER TABLE satspay.charges ADD COLUMN name TEXT;")
except OperationalError:
pass
2 changes: 2 additions & 0 deletions models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
class CreateCharge(BaseModel):
onchainwallet: str = Query(None)
lnbitswallet: str = Query(None)
name: str = Query(None)
description: str = Query(...)
webhook: str = Query(None)
completelink: str = Query(None)
Expand All @@ -34,6 +35,7 @@ class ChargeConfig(BaseModel):

class Charges(BaseModel):
id: str
name: Optional[str]
description: Optional[str]
onchainwallet: Optional[str]
onchainaddress: Optional[str]
Expand Down
1 change: 1 addition & 0 deletions static/js/components.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ Vue.component('satspay-paid', {

Vue.component('satspay-show-qr', {
props: ['charge-amount', 'type', 'value', 'href'],
mixins: [windowMixin],
template: `
<div>
<div class="row justify-center q-mb-sm">
Expand Down
2 changes: 1 addition & 1 deletion templates/satspay/display.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="col-lg-4 col-md-6 col-sm-8 col-xs-10">
<q-card>
<q-card-section class="text-center">
<div class="text-h4">SatsPay</div>
<div class="text-h4">${charge.name || 'LNbits SatsPay'}</div>
<div class="text-subtitle1">${charge.description}</div>
</q-card-section>
<satspay-time-elapsed :charge="charge"></satspay-time-elapsed>
Expand Down
15 changes: 13 additions & 2 deletions templates/satspay/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,13 @@ <h6 class="text-subtitle1 q-my-none">
<q-dialog v-model="formDialogCharge.show" position="top">
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
<q-form @submit="sendFormDataCharge" class="q-gutter-md">
<q-input
filled
dense
v-model.trim="formDialogCharge.data.name"
type="text"
label="Title (Default is 'LNbits SatsPay')"
></q-input>
<q-input
filled
dense
Expand Down Expand Up @@ -720,6 +727,7 @@ <h6 class="text-subtitle1 q-my-none">
this.formDialogThemes.show = false
},
cancelCharge: function (data) {
this.formDialogCharge.data.description = null
this.formDialogCharge.data.description = ''
this.formDialogCharge.data.onchain = false
this.formDialogCharge.data.onchainwallet = ''
Expand Down Expand Up @@ -877,8 +885,11 @@ <h6 class="text-subtitle1 q-my-none">
)

for (const charge of onchainActiveCharges) {
const fn = async () =>{
const api = charge.extra?.network === 'Testnet' ? addressesTestAPI : addressesAPI
const fn = async () => {
const api =
charge.extra?.network === 'Testnet'
? addressesTestAPI
: addressesAPI
return api.getAddressTxsUtxo({
address: charge.onchainaddress
})
Expand Down