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, 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/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 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] 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: `
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..4923b5d 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 })