feat: add currency options to LNbits.api (#2713)
* feat: add currency options to LNbits.api
This commit is contained in:
parent
0b8da2b524
commit
3a64cf5245
2 changed files with 21 additions and 14 deletions
2
lnbits/static/bundle.min.js
vendored
2
lnbits/static/bundle.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -151,10 +151,15 @@ window.LNbits = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
updateBalance: function (credit, wallet_id) {
|
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,
|
amount: credit,
|
||||||
id: wallet_id
|
id: wallet_id
|
||||||
})
|
})
|
||||||
|
},
|
||||||
|
getCurrencies() {
|
||||||
|
return this.request('GET', '/api/v1/currencies').then(response => {
|
||||||
|
return ['sats', ...response.data]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
|
|
@ -193,7 +198,7 @@ window.LNbits = {
|
||||||
},
|
},
|
||||||
map: {
|
map: {
|
||||||
extension: function (data) {
|
extension: function (data) {
|
||||||
var obj = _.object(
|
const obj = _.object(
|
||||||
[
|
[
|
||||||
'code',
|
'code',
|
||||||
'isValid',
|
'isValid',
|
||||||
|
|
@ -210,7 +215,7 @@ window.LNbits = {
|
||||||
return obj
|
return obj
|
||||||
},
|
},
|
||||||
user: function (data) {
|
user: function (data) {
|
||||||
var obj = {
|
const obj = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
admin: data.admin,
|
admin: data.admin,
|
||||||
email: data.email,
|
email: data.email,
|
||||||
|
|
@ -218,7 +223,7 @@ window.LNbits = {
|
||||||
wallets: data.wallets,
|
wallets: data.wallets,
|
||||||
admin: data.admin
|
admin: data.admin
|
||||||
}
|
}
|
||||||
var mapWallet = this.wallet
|
const mapWallet = this.wallet
|
||||||
obj.wallets = obj.wallets
|
obj.wallets = obj.wallets
|
||||||
.map(function (obj) {
|
.map(function (obj) {
|
||||||
return mapWallet(obj)
|
return mapWallet(obj)
|
||||||
|
|
@ -334,8 +339,10 @@ window.LNbits = {
|
||||||
return this.formatSat(value / 1000)
|
return this.formatSat(value / 1000)
|
||||||
},
|
},
|
||||||
notifyApiError: function (error) {
|
notifyApiError: function (error) {
|
||||||
console.error(error)
|
if (!error.response) {
|
||||||
var types = {
|
return console.error(error)
|
||||||
|
}
|
||||||
|
const types = {
|
||||||
400: 'warning',
|
400: 'warning',
|
||||||
401: 'warning',
|
401: 'warning',
|
||||||
500: 'negative'
|
500: 'negative'
|
||||||
|
|
@ -354,9 +361,9 @@ window.LNbits = {
|
||||||
},
|
},
|
||||||
search: function (data, q, field, separator) {
|
search: function (data, q, field, separator) {
|
||||||
try {
|
try {
|
||||||
var queries = q.toLowerCase().split(separator || ' ')
|
const queries = q.toLowerCase().split(separator || ' ')
|
||||||
return data.filter(function (obj) {
|
return data.filter(function (obj) {
|
||||||
var matches = 0
|
let matches = 0
|
||||||
_.each(queries, function (q) {
|
_.each(queries, function (q) {
|
||||||
if (obj[field].indexOf(q) !== -1) matches++
|
if (obj[field].indexOf(q) !== -1) matches++
|
||||||
})
|
})
|
||||||
|
|
@ -385,8 +392,8 @@ window.LNbits = {
|
||||||
return new URLSearchParams(query)
|
return new URLSearchParams(query)
|
||||||
},
|
},
|
||||||
exportCSV: function (columns, data, fileName) {
|
exportCSV: function (columns, data, fileName) {
|
||||||
var wrapCsvValue = function (val, formatFn) {
|
const wrapCsvValue = function (val, formatFn) {
|
||||||
var formatted = formatFn !== void 0 ? formatFn(val) : val
|
let formatted = formatFn !== void 0 ? formatFn(val) : val
|
||||||
|
|
||||||
formatted =
|
formatted =
|
||||||
formatted === void 0 || formatted === null ? '' : String(formatted)
|
formatted === void 0 || formatted === null ? '' : String(formatted)
|
||||||
|
|
@ -396,7 +403,7 @@ window.LNbits = {
|
||||||
return `"${formatted}"`
|
return `"${formatted}"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = [
|
const content = [
|
||||||
columns.map(function (col) {
|
columns.map(function (col) {
|
||||||
return wrapCsvValue(col.label)
|
return wrapCsvValue(col.label)
|
||||||
})
|
})
|
||||||
|
|
@ -417,7 +424,7 @@ window.LNbits = {
|
||||||
)
|
)
|
||||||
.join('\r\n')
|
.join('\r\n')
|
||||||
|
|
||||||
var status = Quasar.exportFile(
|
const status = Quasar.exportFile(
|
||||||
`${fileName || 'table-export'}.csv`,
|
`${fileName || 'table-export'}.csv`,
|
||||||
content,
|
content,
|
||||||
'text/csv'
|
'text/csv'
|
||||||
|
|
@ -668,7 +675,7 @@ window.windowMixin = {
|
||||||
this.g.wallet = Object.freeze(window.LNbits.map.wallet(window.wallet))
|
this.g.wallet = Object.freeze(window.LNbits.map.wallet(window.wallet))
|
||||||
}
|
}
|
||||||
if (window.extensions) {
|
if (window.extensions) {
|
||||||
var user = this.g.user
|
const user = this.g.user
|
||||||
const extensions = Object.freeze(
|
const extensions = Object.freeze(
|
||||||
window.extensions
|
window.extensions
|
||||||
.map(function (data) {
|
.map(function (data) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue