From 3727478e494d3875733fea58a5d2fad6091901ef Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 19 Oct 2023 11:34:06 +0100 Subject: [PATCH 1/6] add name column --- migrations.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/migrations.py b/migrations.py index d7b3ca0..fddb2d2 100644 --- a/migrations.py +++ b/migrations.py @@ -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 From cbd5dbb8d89db1fdd4938dc27c6c55da93fee28e Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 19 Oct 2023 11:34:32 +0100 Subject: [PATCH 2/6] add optional name to models --- helpers.py | 1 + models.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/helpers.py b/helpers.py index e2dad6f..9091487 100644 --- a/helpers.py +++ b/helpers.py @@ -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, diff --git a/models.py b/models.py index d91d7ea..86c35eb 100644 --- a/models.py +++ b/models.py @@ -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) @@ -34,6 +35,7 @@ class ChargeConfig(BaseModel): class Charges(BaseModel): id: str + name: Optional[str] description: Optional[str] onchainwallet: Optional[str] onchainaddress: Optional[str] From 1b030a180d5d4b346cbb3ce7e8926281c611351f Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 19 Oct 2023 11:35:24 +0100 Subject: [PATCH 3/6] send name on create charge --- crud.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crud.py b/crud.py index c8285e6..e476d24 100644 --- a/crud.py +++ b/crud.py @@ -43,6 +43,7 @@ async def create_charge( INSERT INTO satspay.charges ( id, "user", + name, description, onchainwallet, onchainaddress, @@ -59,11 +60,12 @@ async def create_charge( extra, custom_css ) - VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) + VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) """, ( charge_id, user, + data.name, data.description, data.onchainwallet, onchainaddress, From 1ee958a2808a90775eebb8d9b8a7e5a239130a56 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 19 Oct 2023 11:35:56 +0100 Subject: [PATCH 4/6] fix UI accordinlgly --- templates/satspay/display.html | 2 +- templates/satspay/index.html | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/templates/satspay/display.html b/templates/satspay/display.html index 5a527d7..93707ab 100644 --- a/templates/satspay/display.html +++ b/templates/satspay/display.html @@ -3,7 +3,7 @@
-
SatsPay
+
${charge.name || 'LNbits SatsPay'}
${charge.description}
diff --git a/templates/satspay/index.html b/templates/satspay/index.html index 07d6238..4e4f518 100644 --- a/templates/satspay/index.html +++ b/templates/satspay/index.html @@ -366,6 +366,13 @@
+ 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 = '' @@ -877,8 +885,11 @@
) 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 }) From ffaf1d1ed16d54fd0a3cd83a32d8ab320c709404 Mon Sep 17 00:00:00 2001 From: Tiago Vasconcelos Date: Thu, 19 Oct 2023 12:03:03 +0100 Subject: [PATCH 5/6] Update templates/satspay/index.html Co-authored-by: Vlad Stan --- templates/satspay/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/satspay/index.html b/templates/satspay/index.html index 4e4f518..4923b5d 100644 --- a/templates/satspay/index.html +++ b/templates/satspay/index.html @@ -371,7 +371,7 @@
dense v-model.trim="formDialogCharge.data.name" type="text" - label="Title (Default is 'SatsPay')" + label="Title (Default is 'LNbits SatsPay')" > Date: Thu, 19 Oct 2023 12:04:05 +0100 Subject: [PATCH 6/6] hotfix copyText --- static/js/components.js | 1 + 1 file changed, 1 insertion(+) diff --git a/static/js/components.js b/static/js/components.js index 72af8a3..8e70cfe 100644 --- a/static/js/components.js +++ b/static/js/components.js @@ -32,6 +32,7 @@ Vue.component('satspay-paid', { Vue.component('satspay-show-qr', { props: ['charge-amount', 'type', 'value', 'href'], + mixins: [windowMixin], template: `