mirror of
https://github.com/lnbits/lnbits-legend.git
synced 2025-02-24 14:51:05 +01:00
allow admins to manually create addresses without paying
This commit is contained in:
parent
0f417110cb
commit
6787e4916e
2 changed files with 99 additions and 2 deletions
|
@ -7,6 +7,9 @@
|
|||
<q-btn unelevated color="primary" @click="formDialog.show = true"
|
||||
>New Domain</q-btn
|
||||
>
|
||||
<q-btn unelevated color="primary" @click="addressFormDialog.show = true"
|
||||
>New Address</q-btn
|
||||
>
|
||||
</q-card-section>
|
||||
</q-card>
|
||||
|
||||
|
@ -189,7 +192,6 @@
|
|||
color="primary"
|
||||
:disable="formDialog.data.wallet == null || formDialog.data.currency == null"
|
||||
type="submit"
|
||||
v-if="typeof formDialog.data.id == 'undefined'"
|
||||
>Create Domain</q-btn
|
||||
>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||
|
@ -199,6 +201,47 @@
|
|||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
<q-dialog v-model="addressFormDialog.show" position="top" @hide="closeAddressFormDialog">
|
||||
<q-card class="q-pa-lg q-pt-xl" style="width: 500px">
|
||||
<q-form @submit="saveAddress" class="q-gutter-md">
|
||||
<q-select
|
||||
filled
|
||||
dense
|
||||
emit-value
|
||||
v-model="addressFormDialog.data.domain_id"
|
||||
:options="domainOptions"
|
||||
label="Domain *"
|
||||
></q-select>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="addressFormDialog.data.pubkey"
|
||||
label="Public Key"
|
||||
placeholder="npub..."
|
||||
></q-input>
|
||||
<q-input
|
||||
filled
|
||||
dense
|
||||
v-model.trim="addressFormDialog.data.local_part"
|
||||
label="Local Part"
|
||||
placeholder="benarc"
|
||||
></q-input>
|
||||
|
||||
<div class="row q-mt-lg">
|
||||
<q-btn
|
||||
unelevated
|
||||
color="primary"
|
||||
:disable="addressFormDialog.data.domain_id == null || addressFormDialog.data.pubkey == null || addressFormDialog.data.local_part == null"
|
||||
type="submit"
|
||||
>Create Address</q-btn
|
||||
>
|
||||
<q-btn v-close-popup flat color="grey" class="q-ml-auto"
|
||||
>Cancel</q-btn
|
||||
>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
</q-dialog>
|
||||
</div>
|
||||
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
||||
<script>
|
||||
|
@ -437,10 +480,17 @@
|
|||
formDialog: {
|
||||
show: false,
|
||||
data: {}
|
||||
},
|
||||
addressFormDialog: {
|
||||
show: false,
|
||||
data: {}
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
closeAddressFormDialog: function () {
|
||||
this.formDialog.data = {}
|
||||
},
|
||||
closeFormDialog: function () {
|
||||
this.formDialog.data = {}
|
||||
},
|
||||
|
@ -519,6 +569,33 @@
|
|||
})
|
||||
})
|
||||
},
|
||||
saveAddress: function () {
|
||||
var self = this
|
||||
var formDialog = this.addressFormDialog
|
||||
var domain = _.findWhere(this.domains, {id: formDialog.data.domain_id})
|
||||
|
||||
axios
|
||||
.post(
|
||||
'/nostrnip5/api/v1/domain/' + formDialog.data.domain_id + '/address',
|
||||
formDialog.data
|
||||
)
|
||||
.then(function (response) {
|
||||
return LNbits.api
|
||||
.request(
|
||||
'POST',
|
||||
'/nostrnip5/api/v1/domain/' + formDialog.data.domain_id + '/address/' + response.data.address_id + '/activate',
|
||||
_.findWhere(self.g.user.wallets, {id: domain.wallet}).adminkey
|
||||
)
|
||||
})
|
||||
.then(function (response) {
|
||||
self.addressFormDialog.data = {}
|
||||
self.addressFormDialog.show = false
|
||||
self.getAddresses()
|
||||
})
|
||||
.catch(function (error) {
|
||||
LNbits.utils.notifyApiError(error)
|
||||
})
|
||||
},
|
||||
deleteAddress: function (address_id) {
|
||||
var self = this
|
||||
var address = _.findWhere(this.addresses, {id: address_id})
|
||||
|
@ -555,6 +632,16 @@
|
|||
this.getDomains()
|
||||
this.getAddresses()
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
domainOptions: function () {
|
||||
return this.domains.map(el => {
|
||||
return {
|
||||
label: el.domain,
|
||||
value: el.id
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
|
|
@ -25,6 +25,7 @@ from .crud import (
|
|||
get_domain,
|
||||
get_domain_by_name,
|
||||
get_domains,
|
||||
activate_address,
|
||||
)
|
||||
from .models import CreateAddressData, CreateDomainData
|
||||
|
||||
|
@ -97,6 +98,15 @@ async def api_address_delete(
|
|||
|
||||
return True
|
||||
|
||||
@nostrnip5_ext.post("/api/v1/domain/{domain_id}/address/{address_id}/activate", status_code=HTTPStatus.OK)
|
||||
async def api_address_activate(
|
||||
domain_id: str,
|
||||
address_id: str,
|
||||
wallet: WalletTypeInfo = Depends(require_admin_key),
|
||||
):
|
||||
await activate_address(domain_id, address_id)
|
||||
|
||||
return True
|
||||
|
||||
@nostrnip5_ext.post(
|
||||
"/api/v1/domain/{domain_id}/address", status_code=HTTPStatus.CREATED
|
||||
|
@ -151,7 +161,7 @@ async def api_address_create(
|
|||
except Exception as e:
|
||||
raise HTTPException(status_code=HTTPStatus.INTERNAL_SERVER_ERROR, detail=str(e))
|
||||
|
||||
return {"payment_hash": payment_hash, "payment_request": payment_request}
|
||||
return {"payment_hash": payment_hash, "payment_request": payment_request, "address_id": address.id}
|
||||
|
||||
|
||||
@nostrnip5_ext.get(
|
||||
|
|
Loading…
Add table
Reference in a new issue