feat: add currency options to LNbits.api (#2713)

* feat: add currency options to LNbits.api
This commit is contained in:
dni ⚡ 2024-09-30 14:01:30 +02:00 committed by GitHub
parent 0b8da2b524
commit 3a64cf5245
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 14 deletions

File diff suppressed because one or more lines are too long

View File

@ -151,10 +151,15 @@ window.LNbits = {
)
},
updateBalance: function (credit, wallet_id) {
return LNbits.api.request('PUT', '/users/api/v1/topup', null, {
return this.request('PUT', '/users/api/v1/topup', null, {
amount: credit,
id: wallet_id
})
},
getCurrencies() {
return this.request('GET', '/api/v1/currencies').then(response => {
return ['sats', ...response.data]
})
}
},
events: {
@ -193,7 +198,7 @@ window.LNbits = {
},
map: {
extension: function (data) {
var obj = _.object(
const obj = _.object(
[
'code',
'isValid',
@ -210,7 +215,7 @@ window.LNbits = {
return obj
},
user: function (data) {
var obj = {
const obj = {
id: data.id,
admin: data.admin,
email: data.email,
@ -218,7 +223,7 @@ window.LNbits = {
wallets: data.wallets,
admin: data.admin
}
var mapWallet = this.wallet
const mapWallet = this.wallet
obj.wallets = obj.wallets
.map(function (obj) {
return mapWallet(obj)
@ -334,8 +339,10 @@ window.LNbits = {
return this.formatSat(value / 1000)
},
notifyApiError: function (error) {
console.error(error)
var types = {
if (!error.response) {
return console.error(error)
}
const types = {
400: 'warning',
401: 'warning',
500: 'negative'
@ -354,9 +361,9 @@ window.LNbits = {
},
search: function (data, q, field, separator) {
try {
var queries = q.toLowerCase().split(separator || ' ')
const queries = q.toLowerCase().split(separator || ' ')
return data.filter(function (obj) {
var matches = 0
let matches = 0
_.each(queries, function (q) {
if (obj[field].indexOf(q) !== -1) matches++
})
@ -385,8 +392,8 @@ window.LNbits = {
return new URLSearchParams(query)
},
exportCSV: function (columns, data, fileName) {
var wrapCsvValue = function (val, formatFn) {
var formatted = formatFn !== void 0 ? formatFn(val) : val
const wrapCsvValue = function (val, formatFn) {
let formatted = formatFn !== void 0 ? formatFn(val) : val
formatted =
formatted === void 0 || formatted === null ? '' : String(formatted)
@ -396,7 +403,7 @@ window.LNbits = {
return `"${formatted}"`
}
var content = [
const content = [
columns.map(function (col) {
return wrapCsvValue(col.label)
})
@ -417,7 +424,7 @@ window.LNbits = {
)
.join('\r\n')
var status = Quasar.exportFile(
const status = Quasar.exportFile(
`${fileName || 'table-export'}.csv`,
content,
'text/csv'
@ -668,7 +675,7 @@ window.windowMixin = {
this.g.wallet = Object.freeze(window.LNbits.map.wallet(window.wallet))
}
if (window.extensions) {
var user = this.g.user
const user = this.g.user
const extensions = Object.freeze(
window.extensions
.map(function (data) {