mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-27 12:26:19 +02:00
chore: clean up javascript functions and var/let into const (#2791)
* chore: clean up javascript functions and var/let into const
This commit is contained in:
2
lnbits/static/bundle-components.min.js
vendored
2
lnbits/static/bundle-components.min.js
vendored
File diff suppressed because one or more lines are too long
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
@@ -1,7 +1,7 @@
|
|||||||
window.app = Vue.createApp({
|
window.app = Vue.createApp({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: null,
|
user: null,
|
||||||
hasUsername: false,
|
hasUsername: false,
|
||||||
@@ -25,21 +25,21 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
activeLanguage: function (lang) {
|
activeLanguage(lang) {
|
||||||
return window.i18n.global.locale === lang
|
return window.i18n.global.locale === lang
|
||||||
},
|
},
|
||||||
changeLanguage: function (newValue) {
|
changeLanguage(newValue) {
|
||||||
window.i18n.global.locale = newValue
|
window.i18n.global.locale = newValue
|
||||||
this.$q.localStorage.set('lnbits.lang', newValue)
|
this.$q.localStorage.set('lnbits.lang', newValue)
|
||||||
},
|
},
|
||||||
toggleDarkMode: function () {
|
toggleDarkMode() {
|
||||||
this.$q.dark.toggle()
|
this.$q.dark.toggle()
|
||||||
this.$q.localStorage.set('lnbits.darkMode', this.$q.dark.isActive)
|
this.$q.localStorage.set('lnbits.darkMode', this.$q.dark.isActive)
|
||||||
if (!this.$q.dark.isActive && this.gradientChoice) {
|
if (!this.$q.dark.isActive && this.gradientChoice) {
|
||||||
this.toggleGradient()
|
this.toggleGradient()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
applyGradient: function () {
|
applyGradient() {
|
||||||
darkBgColor = this.$q.localStorage.getItem('lnbits.darkBgColor')
|
darkBgColor = this.$q.localStorage.getItem('lnbits.darkBgColor')
|
||||||
primaryColor = this.$q.localStorage.getItem('lnbits.primaryColor')
|
primaryColor = this.$q.localStorage.getItem('lnbits.primaryColor')
|
||||||
if (this.gradientChoice) {
|
if (this.gradientChoice) {
|
||||||
@@ -64,8 +64,7 @@ window.app = Vue.createApp({
|
|||||||
this.$q.localStorage.set('lnbits.gradientBg', false)
|
this.$q.localStorage.set('lnbits.gradientBg', false)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
applyBorder: function () {
|
applyBorder() {
|
||||||
slef = this
|
|
||||||
if (this.borderChoice) {
|
if (this.borderChoice) {
|
||||||
this.$q.localStorage.setItem('lnbits.border', this.borderChoice)
|
this.$q.localStorage.setItem('lnbits.border', this.borderChoice)
|
||||||
}
|
}
|
||||||
@@ -85,7 +84,7 @@ window.app = Vue.createApp({
|
|||||||
style.innerHTML = `body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card.q-card--dark, .q-date--dark { ${borderStyleCSS} }`
|
style.innerHTML = `body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card.q-card--dark, .q-date--dark { ${borderStyleCSS} }`
|
||||||
document.head.appendChild(style)
|
document.head.appendChild(style)
|
||||||
},
|
},
|
||||||
toggleGradient: function () {
|
toggleGradient() {
|
||||||
this.gradientChoice = !this.gradientChoice
|
this.gradientChoice = !this.gradientChoice
|
||||||
this.applyGradient()
|
this.applyGradient()
|
||||||
if (!this.gradientChoice) {
|
if (!this.gradientChoice) {
|
||||||
@@ -93,10 +92,10 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
this.gradientChoice = this.$q.localStorage.getItem('lnbits.gradientBg')
|
this.gradientChoice = this.$q.localStorage.getItem('lnbits.gradientBg')
|
||||||
},
|
},
|
||||||
reactionChoiceFunc: function () {
|
reactionChoiceFunc() {
|
||||||
this.$q.localStorage.set('lnbits.reactions', this.reactionChoice)
|
this.$q.localStorage.set('lnbits.reactions', this.reactionChoice)
|
||||||
},
|
},
|
||||||
changeColor: function (newValue) {
|
changeColor(newValue) {
|
||||||
document.body.setAttribute('data-theme', newValue)
|
document.body.setAttribute('data-theme', newValue)
|
||||||
this.$q.localStorage.set('lnbits.theme', newValue)
|
this.$q.localStorage.set('lnbits.theme', newValue)
|
||||||
this.setColors()
|
this.setColors()
|
||||||
@@ -104,7 +103,7 @@ window.app = Vue.createApp({
|
|||||||
this.applyGradient()
|
this.applyGradient()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updateAccount: async function () {
|
async updateAccount() {
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'PUT',
|
'PUT',
|
||||||
@@ -127,7 +126,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(e)
|
LNbits.utils.notifyApiError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
disableUpdatePassword: function () {
|
disableUpdatePassword() {
|
||||||
return (
|
return (
|
||||||
!this.credentialsData.newPassword ||
|
!this.credentialsData.newPassword ||
|
||||||
!this.credentialsData.newPasswordRepeat ||
|
!this.credentialsData.newPasswordRepeat ||
|
||||||
@@ -135,7 +134,7 @@ window.app = Vue.createApp({
|
|||||||
this.credentialsData.newPasswordRepeat
|
this.credentialsData.newPasswordRepeat
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
updatePassword: async function () {
|
async updatePassword() {
|
||||||
if (!this.credentialsData.username) {
|
if (!this.credentialsData.username) {
|
||||||
Quasar.Notify.create({
|
Quasar.Notify.create({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
@@ -167,7 +166,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(e)
|
LNbits.utils.notifyApiError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
updatePubkey: async function () {
|
async updatePubkey() {
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'PUT',
|
'PUT',
|
||||||
@@ -189,7 +188,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(e)
|
LNbits.utils.notifyApiError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showUpdateCredentials: function () {
|
showUpdateCredentials() {
|
||||||
this.credentialsData = {
|
this.credentialsData = {
|
||||||
show: true,
|
show: true,
|
||||||
oldPassword: null,
|
oldPassword: null,
|
||||||
@@ -200,7 +199,7 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
async created() {
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.getAuthenticatedUser()
|
const {data} = await LNbits.api.getAuthenticatedUser()
|
||||||
this.user = data
|
this.user = data
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
window.app = Vue.createApp({
|
window.app = Vue.createApp({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [windowMixin],
|
mixins: [windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
settings: {},
|
settings: {},
|
||||||
logs: [],
|
logs: [],
|
||||||
@@ -258,9 +258,7 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
this.needsRestart = false
|
this.needsRestart = false
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
formatDate(date) {
|
formatDate(date) {
|
||||||
return moment(date * 1000).fromNow()
|
return moment(date * 1000).fromNow()
|
||||||
@@ -286,9 +284,7 @@ window.app = Vue.createApp({
|
|||||||
.then(response => {
|
.then(response => {
|
||||||
this.auditData = response.data
|
this.auditData = response.data
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
getSettings() {
|
getSettings() {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
@@ -303,12 +299,10 @@ window.app = Vue.createApp({
|
|||||||
this.formData = {...this.settings}
|
this.formData = {...this.settings}
|
||||||
this.getNotifications()
|
this.getNotifications()
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
updateSettings() {
|
updateSettings() {
|
||||||
let data = _.omit(this.formData, [
|
const data = _.omit(this.formData, [
|
||||||
'is_super_user',
|
'is_super_user',
|
||||||
'lnbits_allowed_funding_sources'
|
'lnbits_allowed_funding_sources'
|
||||||
])
|
])
|
||||||
@@ -334,9 +328,7 @@ window.app = Vue.createApp({
|
|||||||
icon: null
|
icon: null
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
deleteSettings() {
|
deleteSettings() {
|
||||||
LNbits.utils
|
LNbits.utils
|
||||||
@@ -353,9 +345,7 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
this.needsRestart = true
|
this.needsRestart = true
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
downloadBackup() {
|
downloadBackup() {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
window.app = Vue.createApp({
|
window.app = Vue.createApp({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
auditEntries: [],
|
auditEntries: [],
|
||||||
searchData: {
|
searchData: {
|
||||||
|
@@ -8,7 +8,7 @@ window.i18n = new VueI18n.createI18n({
|
|||||||
|
|
||||||
window.LNbits = {
|
window.LNbits = {
|
||||||
api: {
|
api: {
|
||||||
request: function (method, url, apiKey, data) {
|
request(method, url, apiKey, data) {
|
||||||
return axios({
|
return axios({
|
||||||
method: method,
|
method: method,
|
||||||
url: url,
|
url: url,
|
||||||
@@ -18,10 +18,10 @@ window.LNbits = {
|
|||||||
data: data
|
data: data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getServerHealth: function () {
|
getServerHealth() {
|
||||||
return this.request('get', '/api/v1/health')
|
return this.request('get', '/api/v1/health')
|
||||||
},
|
},
|
||||||
createInvoice: async function (
|
async createInvoice(
|
||||||
wallet,
|
wallet,
|
||||||
amount,
|
amount,
|
||||||
memo,
|
memo,
|
||||||
@@ -36,13 +36,13 @@ window.LNbits = {
|
|||||||
unit: unit
|
unit: unit
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
payInvoice: function (wallet, bolt11) {
|
payInvoice(wallet, bolt11) {
|
||||||
return this.request('post', '/api/v1/payments', wallet.adminkey, {
|
return this.request('post', '/api/v1/payments', wallet.adminkey, {
|
||||||
out: true,
|
out: true,
|
||||||
bolt11: bolt11
|
bolt11: bolt11
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
payLnurl: function (
|
payLnurl(
|
||||||
wallet,
|
wallet,
|
||||||
callback,
|
callback,
|
||||||
description_hash,
|
description_hash,
|
||||||
@@ -60,17 +60,17 @@ window.LNbits = {
|
|||||||
unit
|
unit
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
authLnurl: function (wallet, callback) {
|
authLnurl(wallet, callback) {
|
||||||
return this.request('post', '/api/v1/lnurlauth', wallet.adminkey, {
|
return this.request('post', '/api/v1/lnurlauth', wallet.adminkey, {
|
||||||
callback
|
callback
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
createAccount: function (name) {
|
createAccount(name) {
|
||||||
return this.request('post', '/api/v1/account', null, {
|
return this.request('post', '/api/v1/account', null, {
|
||||||
name: name
|
name: name
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
register: function (username, email, password, password_repeat) {
|
register(username, email, password, password_repeat) {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/v1/auth/register',
|
url: '/api/v1/auth/register',
|
||||||
@@ -82,7 +82,7 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
reset: function (reset_key, password, password_repeat) {
|
reset(reset_key, password, password_repeat) {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
url: '/api/v1/auth/reset',
|
url: '/api/v1/auth/reset',
|
||||||
@@ -93,14 +93,14 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
login: function (username, password) {
|
login(username, password) {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/v1/auth',
|
url: '/api/v1/auth',
|
||||||
data: {username, password}
|
data: {username, password}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loginByProvider: function (provider, headers, data) {
|
loginByProvider(provider, headers, data) {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: `/api/v1/auth/${provider}`,
|
url: `/api/v1/auth/${provider}`,
|
||||||
@@ -108,38 +108,38 @@ window.LNbits = {
|
|||||||
data
|
data
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
loginUsr: function (usr) {
|
loginUsr(usr) {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/v1/auth/usr',
|
url: '/api/v1/auth/usr',
|
||||||
data: {usr}
|
data: {usr}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
logout: function () {
|
logout() {
|
||||||
return axios({
|
return axios({
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
url: '/api/v1/auth/logout'
|
url: '/api/v1/auth/logout'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
getAuthenticatedUser: function () {
|
getAuthenticatedUser() {
|
||||||
return this.request('get', '/api/v1/auth')
|
return this.request('get', '/api/v1/auth')
|
||||||
},
|
},
|
||||||
getWallet: function (wallet) {
|
getWallet(wallet) {
|
||||||
return this.request('get', '/api/v1/wallet', wallet.inkey)
|
return this.request('get', '/api/v1/wallet', wallet.inkey)
|
||||||
},
|
},
|
||||||
createWallet: function (wallet, name) {
|
createWallet(wallet, name) {
|
||||||
return this.request('post', '/api/v1/wallet', wallet.adminkey, {
|
return this.request('post', '/api/v1/wallet', wallet.adminkey, {
|
||||||
name: name
|
name: name
|
||||||
}).then(res => {
|
}).then(res => {
|
||||||
window.location = '/wallet?wal=' + res.data.id
|
window.location = '/wallet?wal=' + res.data.id
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateWallet: function (name, wallet) {
|
updateWallet(name, wallet) {
|
||||||
return this.request('patch', '/api/v1/wallet', wallet.adminkey, {
|
return this.request('patch', '/api/v1/wallet', wallet.adminkey, {
|
||||||
name: name
|
name: name
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteWallet: function (wallet) {
|
deleteWallet(wallet) {
|
||||||
return this.request('delete', '/api/v1/wallet', wallet.adminkey).then(
|
return this.request('delete', '/api/v1/wallet', wallet.adminkey).then(
|
||||||
_ => {
|
_ => {
|
||||||
let url = new URL(window.location.href)
|
let url = new URL(window.location.href)
|
||||||
@@ -148,21 +148,21 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
getPayments: function (wallet, params) {
|
getPayments(wallet, params) {
|
||||||
return this.request(
|
return this.request(
|
||||||
'get',
|
'get',
|
||||||
'/api/v1/payments/paginated?' + params,
|
'/api/v1/payments/paginated?' + params,
|
||||||
wallet.inkey
|
wallet.inkey
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
getPayment: function (wallet, paymentHash) {
|
getPayment(wallet, paymentHash) {
|
||||||
return this.request(
|
return this.request(
|
||||||
'get',
|
'get',
|
||||||
'/api/v1/payments/' + paymentHash,
|
'/api/v1/payments/' + paymentHash,
|
||||||
wallet.inkey
|
wallet.inkey
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
updateBalance: function (credit, wallet_id) {
|
updateBalance(credit, wallet_id) {
|
||||||
return this.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
|
||||||
@@ -175,7 +175,7 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
events: {
|
events: {
|
||||||
onInvoicePaid: function (wallet, cb) {
|
onInvoicePaid(wallet, cb) {
|
||||||
let listener = ev => {
|
let listener = ev => {
|
||||||
cb(JSON.parse(ev.data))
|
cb(JSON.parse(ev.data))
|
||||||
}
|
}
|
||||||
@@ -209,12 +209,12 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
map: {
|
map: {
|
||||||
extension: function (data) {
|
extension(data) {
|
||||||
const obj = {...data}
|
const obj = {...data}
|
||||||
obj.url = ['/', obj.code, '/'].join('')
|
obj.url = ['/', obj.code, '/'].join('')
|
||||||
return obj
|
return obj
|
||||||
},
|
},
|
||||||
user: function (data) {
|
user(data) {
|
||||||
const obj = {
|
const obj = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
admin: data.admin,
|
admin: data.admin,
|
||||||
@@ -225,13 +225,13 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
const mapWallet = this.wallet
|
const mapWallet = this.wallet
|
||||||
obj.wallets = obj.wallets
|
obj.wallets = obj.wallets
|
||||||
.map(function (obj) {
|
.map(obj => {
|
||||||
return mapWallet(obj)
|
return mapWallet(obj)
|
||||||
})
|
})
|
||||||
.sort(function (a, b) {
|
.sort((a, b) => {
|
||||||
return a.name.localeCompare(b.name)
|
return a.name.localeCompare(b.name)
|
||||||
})
|
})
|
||||||
obj.walletOptions = obj.wallets.map(function (obj) {
|
obj.walletOptions = obj.wallets.map(obj => {
|
||||||
return {
|
return {
|
||||||
label: [obj.name, ' - ', obj.id].join(''),
|
label: [obj.name, ' - ', obj.id].join(''),
|
||||||
value: obj.id
|
value: obj.id
|
||||||
@@ -239,7 +239,7 @@ window.LNbits = {
|
|||||||
})
|
})
|
||||||
return obj
|
return obj
|
||||||
},
|
},
|
||||||
wallet: function (data) {
|
wallet(data) {
|
||||||
newWallet = {
|
newWallet = {
|
||||||
id: data.id,
|
id: data.id,
|
||||||
name: data.name,
|
name: data.name,
|
||||||
@@ -255,7 +255,7 @@ window.LNbits = {
|
|||||||
newWallet.url = `/wallet?&wal=${data.id}`
|
newWallet.url = `/wallet?&wal=${data.id}`
|
||||||
return newWallet
|
return newWallet
|
||||||
},
|
},
|
||||||
payment: function (data) {
|
payment(data) {
|
||||||
obj = {
|
obj = {
|
||||||
checking_id: data.checking_id,
|
checking_id: data.checking_id,
|
||||||
status: data.status,
|
status: data.status,
|
||||||
@@ -301,7 +301,7 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
utils: {
|
utils: {
|
||||||
confirmDialog: function (msg) {
|
confirmDialog(msg) {
|
||||||
return Quasar.Dialog.create({
|
return Quasar.Dialog.create({
|
||||||
message: msg,
|
message: msg,
|
||||||
ok: {
|
ok: {
|
||||||
@@ -314,7 +314,7 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
digestMessage: async function (message) {
|
async digestMessage(message) {
|
||||||
const msgUint8 = new TextEncoder().encode(message)
|
const msgUint8 = new TextEncoder().encode(message)
|
||||||
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
const hashBuffer = await crypto.subtle.digest('SHA-256', msgUint8)
|
||||||
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
const hashArray = Array.from(new Uint8Array(hashBuffer))
|
||||||
@@ -332,19 +332,19 @@ window.LNbits = {
|
|||||||
formatDateString(isoDateString) {
|
formatDateString(isoDateString) {
|
||||||
return Quasar.date.formatDate(new Date(isoDateString), window.dateFormat)
|
return Quasar.date.formatDate(new Date(isoDateString), window.dateFormat)
|
||||||
},
|
},
|
||||||
formatCurrency: function (value, currency) {
|
formatCurrency(value, currency) {
|
||||||
return new Intl.NumberFormat(window.LOCALE, {
|
return new Intl.NumberFormat(window.LOCALE, {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
currency: currency
|
currency: currency
|
||||||
}).format(value)
|
}).format(value)
|
||||||
},
|
},
|
||||||
formatSat: function (value) {
|
formatSat(value) {
|
||||||
return new Intl.NumberFormat(window.LOCALE).format(value)
|
return new Intl.NumberFormat(window.LOCALE).format(value)
|
||||||
},
|
},
|
||||||
formatMsat: function (value) {
|
formatMsat(value) {
|
||||||
return this.formatSat(value / 1000)
|
return this.formatSat(value / 1000)
|
||||||
},
|
},
|
||||||
notifyApiError: function (error) {
|
notifyApiError(error) {
|
||||||
if (!error.response) {
|
if (!error.response) {
|
||||||
return console.error(error)
|
return console.error(error)
|
||||||
}
|
}
|
||||||
@@ -365,12 +365,12 @@ window.LNbits = {
|
|||||||
icon: null
|
icon: null
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
search: function (data, q, field, separator) {
|
search(data, q, field, separator) {
|
||||||
try {
|
try {
|
||||||
const queries = q.toLowerCase().split(separator || ' ')
|
const queries = q.toLowerCase().split(separator || ' ')
|
||||||
return data.filter(function (obj) {
|
return data.filter(obj => {
|
||||||
let matches = 0
|
let matches = 0
|
||||||
_.each(queries, function (q) {
|
_.each(queries, q => {
|
||||||
if (obj[field].indexOf(q) !== -1) matches++
|
if (obj[field].indexOf(q) !== -1) matches++
|
||||||
})
|
})
|
||||||
return matches === queries.length
|
return matches === queries.length
|
||||||
@@ -384,7 +384,7 @@ window.LNbits = {
|
|||||||
tableConfig.pagination = props.pagination
|
tableConfig.pagination = props.pagination
|
||||||
tableConfig.filter = props.filter
|
tableConfig.filter = props.filter
|
||||||
}
|
}
|
||||||
let pagination = tableConfig.pagination
|
const pagination = tableConfig.pagination
|
||||||
tableConfig.loading = true
|
tableConfig.loading = true
|
||||||
const query = {
|
const query = {
|
||||||
limit: pagination.rowsPerPage,
|
limit: pagination.rowsPerPage,
|
||||||
@@ -398,8 +398,8 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
return new URLSearchParams(query)
|
return new URLSearchParams(query)
|
||||||
},
|
},
|
||||||
exportCSV: function (columns, data, fileName) {
|
exportCSV(columns, data, fileName) {
|
||||||
const wrapCsvValue = function (val, formatFn) {
|
const wrapCsvValue = (val, formatFn) => {
|
||||||
let formatted = formatFn !== void 0 ? formatFn(val) : val
|
let formatted = formatFn !== void 0 ? formatFn(val) : val
|
||||||
|
|
||||||
formatted =
|
formatted =
|
||||||
@@ -411,14 +411,14 @@ window.LNbits = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const content = [
|
const content = [
|
||||||
columns.map(function (col) {
|
columns.map(col => {
|
||||||
return wrapCsvValue(col.label)
|
return wrapCsvValue(col.label)
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
.concat(
|
.concat(
|
||||||
data.map(function (row) {
|
data.map(row => {
|
||||||
return columns
|
return columns
|
||||||
.map(function (col) {
|
.map(col => {
|
||||||
return wrapCsvValue(
|
return wrapCsvValue(
|
||||||
typeof col.field === 'function'
|
typeof col.field === 'function'
|
||||||
? col.field(row)
|
? col.field(row)
|
||||||
@@ -451,16 +451,16 @@ window.LNbits = {
|
|||||||
converter.setOption('simpleLineBreaks', true)
|
converter.setOption('simpleLineBreaks', true)
|
||||||
return converter.makeHtml(text)
|
return converter.makeHtml(text)
|
||||||
},
|
},
|
||||||
hexToRgb: function (hex) {
|
hexToRgb(hex) {
|
||||||
return Quasar.colors.hexToRgb(hex)
|
return Quasar.colors.hexToRgb(hex)
|
||||||
},
|
},
|
||||||
hexDarken: function (hex, percent) {
|
hexDarken(hex, percent) {
|
||||||
return Quasar.colors.lighten(hex, percent)
|
return Quasar.colors.lighten(hex, percent)
|
||||||
},
|
},
|
||||||
hexAlpha: function (hex, alpha) {
|
hexAlpha(hex, alpha) {
|
||||||
return Quasar.colors.changeAlpha(hex, alpha)
|
return Quasar.colors.changeAlpha(hex, alpha)
|
||||||
},
|
},
|
||||||
getPaletteColor: function (color) {
|
getPaletteColor(color) {
|
||||||
return Quasar.colors.getPaletteColor(color)
|
return Quasar.colors.getPaletteColor(color)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -468,7 +468,7 @@ window.LNbits = {
|
|||||||
|
|
||||||
window.windowMixin = {
|
window.windowMixin = {
|
||||||
i18n: window.i18n,
|
i18n: window.i18n,
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
toggleSubs: true,
|
toggleSubs: true,
|
||||||
reactionChoice: 'confettiBothSides',
|
reactionChoice: 'confettiBothSides',
|
||||||
@@ -490,11 +490,11 @@ window.windowMixin = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
methods: {
|
methods: {
|
||||||
changeColor: function (newValue) {
|
changeColor(newValue) {
|
||||||
document.body.setAttribute('data-theme', newValue)
|
document.body.setAttribute('data-theme', newValue)
|
||||||
this.$q.localStorage.set('lnbits.theme', newValue)
|
this.$q.localStorage.set('lnbits.theme', newValue)
|
||||||
},
|
},
|
||||||
applyGradient: function () {
|
applyGradient() {
|
||||||
if (this.$q.localStorage.getItem('lnbits.gradientBg')) {
|
if (this.$q.localStorage.getItem('lnbits.gradientBg')) {
|
||||||
this.setColors()
|
this.setColors()
|
||||||
darkBgColor = this.$q.localStorage.getItem('lnbits.darkBgColor')
|
darkBgColor = this.$q.localStorage.getItem('lnbits.darkBgColor')
|
||||||
@@ -514,7 +514,7 @@ window.windowMixin = {
|
|||||||
document.head.appendChild(style)
|
document.head.appendChild(style)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
applyBorder: function () {
|
applyBorder() {
|
||||||
if (this.borderChoice) {
|
if (this.borderChoice) {
|
||||||
this.$q.localStorage.setItem('lnbits.border', this.borderChoice)
|
this.$q.localStorage.setItem('lnbits.border', this.borderChoice)
|
||||||
}
|
}
|
||||||
@@ -538,7 +538,7 @@ window.windowMixin = {
|
|||||||
style.innerHTML = `body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card.q-card--dark, .q-date--dark { ${borderStyleCSS} }`
|
style.innerHTML = `body[data-theme="${this.$q.localStorage.getItem('lnbits.theme')}"] .q-card.q-card--dark, .q-date--dark { ${borderStyleCSS} }`
|
||||||
document.head.appendChild(style)
|
document.head.appendChild(style)
|
||||||
},
|
},
|
||||||
setColors: function () {
|
setColors() {
|
||||||
this.$q.localStorage.set(
|
this.$q.localStorage.set(
|
||||||
'lnbits.primaryColor',
|
'lnbits.primaryColor',
|
||||||
LNbits.utils.getPaletteColor('primary')
|
LNbits.utils.getPaletteColor('primary')
|
||||||
@@ -552,15 +552,15 @@ window.windowMixin = {
|
|||||||
LNbits.utils.getPaletteColor('dark')
|
LNbits.utils.getPaletteColor('dark')
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
copyText: function (text, message, position) {
|
copyText(text, message, position) {
|
||||||
Quasar.copyToClipboard(text).then(function () {
|
Quasar.copyToClipboard(text).then(() => {
|
||||||
Quasar.Notify.create({
|
Quasar.Notify.create({
|
||||||
message: message || 'Copied to clipboard!',
|
message: message || 'Copied to clipboard!',
|
||||||
position: position || 'bottom'
|
position: position || 'bottom'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
checkUsrInUrl: async function () {
|
async checkUsrInUrl() {
|
||||||
try {
|
try {
|
||||||
const params = new URLSearchParams(window.location.search)
|
const params = new URLSearchParams(window.location.search)
|
||||||
const usr = params.get('usr')
|
const usr = params.get('usr')
|
||||||
@@ -586,7 +586,7 @@ window.windowMixin = {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
logout: async function () {
|
async logout() {
|
||||||
LNbits.utils
|
LNbits.utils
|
||||||
.confirmDialog(
|
.confirmDialog(
|
||||||
'Do you really want to logout?' +
|
'Do you really want to logout?' +
|
||||||
@@ -652,7 +652,7 @@ window.windowMixin = {
|
|||||||
this.setColors()
|
this.setColors()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
async created() {
|
||||||
if (
|
if (
|
||||||
this.$q.localStorage.getItem('lnbits.darkMode') == true ||
|
this.$q.localStorage.getItem('lnbits.darkMode') == true ||
|
||||||
this.$q.localStorage.getItem('lnbits.darkMode') == false
|
this.$q.localStorage.getItem('lnbits.darkMode') == false
|
||||||
@@ -721,7 +721,7 @@ window.windowMixin = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.decryptLnurlPayAES = function (success_action, preimage) {
|
window.decryptLnurlPayAES = (success_action, preimage) => {
|
||||||
let keyb = new Uint8Array(
|
let keyb = new Uint8Array(
|
||||||
preimage.match(/[\da-f]{2}/gi).map(h => parseInt(h, 16))
|
preimage.match(/[\da-f]{2}/gi).map(h => parseInt(h, 16))
|
||||||
)
|
)
|
||||||
|
@@ -15,7 +15,7 @@ window.app.component('lnbits-fsat', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
fsat: function () {
|
fsat() {
|
||||||
return LNbits.utils.formatSat(this.amount)
|
return LNbits.utils.formatSat(this.amount)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ window.app.component('lnbits-fsat', {
|
|||||||
window.app.component('lnbits-wallet-list', {
|
window.app.component('lnbits-wallet-list', {
|
||||||
template: '#lnbits-wallet-list',
|
template: '#lnbits-wallet-list',
|
||||||
props: ['balance'],
|
props: ['balance'],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: null,
|
user: null,
|
||||||
activeWallet: null,
|
activeWallet: null,
|
||||||
@@ -35,9 +35,9 @@ window.app.component('lnbits-wallet-list', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
wallets: function () {
|
wallets() {
|
||||||
var bal = this.balance
|
const bal = this.balance
|
||||||
return this.user.wallets.map(function (obj) {
|
return this.user.wallets.map(obj => {
|
||||||
obj.live_fsat =
|
obj.live_fsat =
|
||||||
bal.length && bal[0] === obj.id
|
bal.length && bal[0] === obj.id
|
||||||
? LNbits.utils.formatSat(bal[1])
|
? LNbits.utils.formatSat(bal[1])
|
||||||
@@ -47,11 +47,11 @@ window.app.component('lnbits-wallet-list', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
createWallet: function () {
|
createWallet() {
|
||||||
LNbits.api.createWallet(this.user.wallets[0], this.walletName)
|
LNbits.api.createWallet(this.user.wallets[0], this.walletName)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created() {
|
||||||
if (window.user) {
|
if (window.user) {
|
||||||
this.user = LNbits.map.user(window.user)
|
this.user = LNbits.map.user(window.user)
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ window.app.component('lnbits-wallet-list', {
|
|||||||
|
|
||||||
window.app.component('lnbits-extension-list', {
|
window.app.component('lnbits-extension-list', {
|
||||||
template: '#lnbits-extension-list',
|
template: '#lnbits-extension-list',
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
extensions: [],
|
extensions: [],
|
||||||
user: null,
|
user: null,
|
||||||
@@ -78,17 +78,17 @@ window.app.component('lnbits-extension-list', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateUserExtensions: function (filterBy) {
|
updateUserExtensions(filterBy) {
|
||||||
if (!this.user) return []
|
if (!this.user) return []
|
||||||
|
|
||||||
const path = window.location.pathname
|
const path = window.location.pathname
|
||||||
const userExtensions = this.user.extensions
|
const userExtensions = this.user.extensions
|
||||||
|
|
||||||
return this.extensions
|
return this.extensions
|
||||||
.filter(function (o) {
|
.filter(o => {
|
||||||
return userExtensions.indexOf(o.code) !== -1
|
return userExtensions.indexOf(o.code) !== -1
|
||||||
})
|
})
|
||||||
.filter(function (o) {
|
.filter(o => {
|
||||||
if (!filterBy) return true
|
if (!filterBy) return true
|
||||||
return (
|
return (
|
||||||
`${o.code} ${o.name} ${o.short_description} ${o.url}`
|
`${o.code} ${o.name} ${o.short_description} ${o.url}`
|
||||||
@@ -96,13 +96,13 @@ window.app.component('lnbits-extension-list', {
|
|||||||
.indexOf(filterBy.toLocaleLowerCase()) !== -1
|
.indexOf(filterBy.toLocaleLowerCase()) !== -1
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
.map(function (obj) {
|
.map(obj => {
|
||||||
obj.isActive = path.startsWith(obj.url)
|
obj.isActive = path.startsWith(obj.url)
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
async created() {
|
||||||
if (window.user) {
|
if (window.user) {
|
||||||
this.user = LNbits.map.user(window.user)
|
this.user = LNbits.map.user(window.user)
|
||||||
}
|
}
|
||||||
@@ -110,10 +110,10 @@ window.app.component('lnbits-extension-list', {
|
|||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request('GET', '/api/v1/extension')
|
const {data} = await LNbits.api.request('GET', '/api/v1/extension')
|
||||||
this.extensions = data
|
this.extensions = data
|
||||||
.map(function (data) {
|
.map(data => {
|
||||||
return LNbits.map.extension(data)
|
return LNbits.map.extension(data)
|
||||||
})
|
})
|
||||||
.sort(function (a, b) {
|
.sort((a, b) => {
|
||||||
return a.name.localeCompare(b.name)
|
return a.name.localeCompare(b.name)
|
||||||
})
|
})
|
||||||
this.userExtensions = this.updateUserExtensions()
|
this.userExtensions = this.updateUserExtensions()
|
||||||
@@ -127,7 +127,7 @@ window.app.component('lnbits-manage', {
|
|||||||
template: '#lnbits-manage',
|
template: '#lnbits-manage',
|
||||||
props: ['showAdmin', 'showNode', 'showExtensions', 'showUsers', 'showAudit'],
|
props: ['showAdmin', 'showNode', 'showExtensions', 'showUsers', 'showAudit'],
|
||||||
methods: {
|
methods: {
|
||||||
isActive: function (path) {
|
isActive(path) {
|
||||||
return window.location.pathname === path
|
return window.location.pathname === path
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -148,7 +148,7 @@ window.app.component('lnbits-payment-details', {
|
|||||||
template: '#lnbits-payment-details',
|
template: '#lnbits-payment-details',
|
||||||
props: ['payment'],
|
props: ['payment'],
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
LNBITS_DENOMINATION: LNBITS_DENOMINATION
|
LNBITS_DENOMINATION: LNBITS_DENOMINATION
|
||||||
}
|
}
|
||||||
@@ -203,7 +203,7 @@ window.app.component('lnbits-lnurlpay-success-action', {
|
|||||||
decryptedValue: this.success_action.ciphertext
|
decryptedValue: this.success_action.ciphertext
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted() {
|
||||||
if (this.success_action.tag !== 'aes') return null
|
if (this.success_action.tag !== 'aes') return null
|
||||||
decryptLnurlPayAES(this.success_action, this.payment.preimage).then(
|
decryptLnurlPayAES(this.success_action, this.payment.preimage).then(
|
||||||
value => {
|
value => {
|
||||||
@@ -302,8 +302,6 @@ window.app.component('lnbits-notifications-btn', {
|
|||||||
return subscribedUsers.includes(user)
|
return subscribedUsers.includes(user)
|
||||||
},
|
},
|
||||||
subscribe() {
|
subscribe() {
|
||||||
var self = this
|
|
||||||
|
|
||||||
// catch clicks from disabled type='a' button (https://github.com/quasarframework/quasar/issues/9258)
|
// catch clicks from disabled type='a' button (https://github.com/quasarframework/quasar/issues/9258)
|
||||||
if (!this.isSupported || this.isPermissionDenied) {
|
if (!this.isSupported || this.isPermissionDenied) {
|
||||||
return
|
return
|
||||||
@@ -315,56 +313,48 @@ window.app.component('lnbits-notifications-btn', {
|
|||||||
this.isPermissionGranted = permission === 'granted'
|
this.isPermissionGranted = permission === 'granted'
|
||||||
this.isPermissionDenied = permission === 'denied'
|
this.isPermissionDenied = permission === 'denied'
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(console.log)
|
||||||
console.log(e)
|
|
||||||
})
|
|
||||||
|
|
||||||
// create push subscription
|
// create push subscription
|
||||||
navigator.serviceWorker.ready.then(registration => {
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
navigator.serviceWorker.getRegistration().then(registration => {
|
navigator.serviceWorker.getRegistration().then(registration => {
|
||||||
registration.pushManager
|
registration.pushManager
|
||||||
.getSubscription()
|
.getSubscription()
|
||||||
.then(function (subscription) {
|
.then(subscription => {
|
||||||
if (
|
if (
|
||||||
subscription === null ||
|
subscription === null ||
|
||||||
!self.isUserSubscribed(self.g.user.id)
|
!this.isUserSubscribed(this.g.user.id)
|
||||||
) {
|
) {
|
||||||
const applicationServerKey = self.urlB64ToUint8Array(
|
const applicationServerKey = this.urlB64ToUint8Array(
|
||||||
self.pubkey
|
this.pubkey
|
||||||
)
|
)
|
||||||
const options = {applicationServerKey, userVisibleOnly: true}
|
const options = {applicationServerKey, userVisibleOnly: true}
|
||||||
|
|
||||||
registration.pushManager
|
registration.pushManager
|
||||||
.subscribe(options)
|
.subscribe(options)
|
||||||
.then(function (subscription) {
|
.then(subscription => {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request(
|
||||||
'POST',
|
'POST',
|
||||||
'/api/v1/webpush',
|
'/api/v1/webpush',
|
||||||
self.g.user.wallets[0].adminkey,
|
this.g.user.wallets[0].adminkey,
|
||||||
{
|
{
|
||||||
subscription: JSON.stringify(subscription)
|
subscription: JSON.stringify(subscription)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(function (response) {
|
.then(response => {
|
||||||
self.saveUserSubscribed(response.data.user)
|
this.saveUserSubscribed(response.data.user)
|
||||||
self.isSubscribed = true
|
this.isSubscribed = true
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
})
|
||||||
|
.catch(LNbits.utils.notifyApiError)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(console.log)
|
||||||
console.log(e)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
unsubscribe() {
|
unsubscribe() {
|
||||||
var self = this
|
|
||||||
|
|
||||||
navigator.serviceWorker.ready
|
navigator.serviceWorker.ready
|
||||||
.then(registration => {
|
.then(registration => {
|
||||||
registration.pushManager.getSubscription().then(subscription => {
|
registration.pushManager.getSubscription().then(subscription => {
|
||||||
@@ -373,23 +363,19 @@ window.app.component('lnbits-notifications-btn', {
|
|||||||
.request(
|
.request(
|
||||||
'DELETE',
|
'DELETE',
|
||||||
'/api/v1/webpush?endpoint=' + btoa(subscription.endpoint),
|
'/api/v1/webpush?endpoint=' + btoa(subscription.endpoint),
|
||||||
self.g.user.wallets[0].adminkey
|
this.g.user.wallets[0].adminkey
|
||||||
)
|
)
|
||||||
.then(function () {
|
.then(() => {
|
||||||
self.removeUserSubscribed(self.g.user.id)
|
this.removeUserSubscribed(this.g.user.id)
|
||||||
self.isSubscribed = false
|
this.isSubscribed = false
|
||||||
})
|
|
||||||
.catch(function (error) {
|
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
})
|
||||||
|
.catch(LNbits.utils.notifyApiError)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(console.log)
|
||||||
console.log(e)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
checkSupported: function () {
|
checkSupported() {
|
||||||
let https = window.location.protocol === 'https:'
|
let https = window.location.protocol === 'https:'
|
||||||
let serviceWorkerApi = 'serviceWorker' in navigator
|
let serviceWorkerApi = 'serviceWorker' in navigator
|
||||||
let notificationApi = 'Notification' in window
|
let notificationApi = 'Notification' in window
|
||||||
@@ -411,22 +397,18 @@ window.app.component('lnbits-notifications-btn', {
|
|||||||
|
|
||||||
return this.isSupported
|
return this.isSupported
|
||||||
},
|
},
|
||||||
updateSubscriptionStatus: async function () {
|
async updateSubscriptionStatus() {
|
||||||
var self = this
|
|
||||||
|
|
||||||
await navigator.serviceWorker.ready
|
await navigator.serviceWorker.ready
|
||||||
.then(registration => {
|
.then(registration => {
|
||||||
registration.pushManager.getSubscription().then(subscription => {
|
registration.pushManager.getSubscription().then(subscription => {
|
||||||
self.isSubscribed =
|
this.isSubscribed =
|
||||||
!!subscription && self.isUserSubscribed(self.g.user.id)
|
!!subscription && this.isUserSubscribed(this.g.user.id)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (e) {
|
.catch(console.log)
|
||||||
console.log(e)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created() {
|
||||||
this.isPermissionDenied = Notification.permission === 'denied'
|
this.isPermissionDenied = Notification.permission === 'denied'
|
||||||
|
|
||||||
if (this.checkSupported()) {
|
if (this.checkSupported()) {
|
||||||
@@ -511,13 +493,13 @@ window.app.component('lnbits-update-balance', {
|
|||||||
return user.super_user
|
return user.super_user
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
credit: 0
|
credit: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
updateBalance: function (credit) {
|
updateBalance(credit) {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.updateBalance(credit, this.wallet_id)
|
.updateBalance(credit, this.wallet_id)
|
||||||
.then(res => {
|
.then(res => {
|
||||||
@@ -541,9 +523,7 @@ window.app.component('lnbits-update-balance', {
|
|||||||
})
|
})
|
||||||
return credit
|
return credit
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -22,7 +22,7 @@ window.app.component('lnbits-extension-settings-form', {
|
|||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
getSettings: async function () {
|
async getSettings() {
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'GET',
|
'GET',
|
||||||
@@ -34,7 +34,7 @@ window.app.component('lnbits-extension-settings-form', {
|
|||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
resetSettings: async function () {
|
async resetSettings() {
|
||||||
LNbits.utils
|
LNbits.utils
|
||||||
.confirmDialog('Are you sure you want to reset the settings?')
|
.confirmDialog('Are you sure you want to reset the settings?')
|
||||||
.onOk(async () => {
|
.onOk(async () => {
|
||||||
@@ -47,10 +47,10 @@ window.app.component('lnbits-extension-settings-form', {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
async created() {
|
||||||
await this.getSettings()
|
await this.getSettings()
|
||||||
},
|
},
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
settings: undefined
|
settings: undefined
|
||||||
}
|
}
|
||||||
@@ -61,7 +61,7 @@ window.app.component('lnbits-extension-settings-btn-dialog', {
|
|||||||
template: '#lnbits-extension-settings-btn-dialog',
|
template: '#lnbits-extension-settings-btn-dialog',
|
||||||
name: 'lnbits-extension-settings-btn-dialog',
|
name: 'lnbits-extension-settings-btn-dialog',
|
||||||
props: ['options', 'adminkey', 'endpoint'],
|
props: ['options', 'adminkey', 'endpoint'],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
show: false
|
show: false
|
||||||
}
|
}
|
||||||
|
@@ -85,7 +85,7 @@ window.app.component('payment-chart', {
|
|||||||
name: 'payment-chart',
|
name: 'payment-chart',
|
||||||
props: ['wallet'],
|
props: ['wallet'],
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
paymentsChart: {
|
paymentsChart: {
|
||||||
show: false,
|
show: false,
|
||||||
@@ -105,7 +105,7 @@ window.app.component('payment-chart', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showChart: function () {
|
showChart() {
|
||||||
this.paymentsChart.show = true
|
this.paymentsChart.show = true
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request(
|
.request(
|
||||||
|
@@ -3,7 +3,7 @@ window.app.component('payment-list', {
|
|||||||
template: '#payment-list',
|
template: '#payment-list',
|
||||||
props: ['update', 'wallet', 'mobileSimple', 'lazy'],
|
props: ['update', 'wallet', 'mobileSimple', 'lazy'],
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
denomination: LNBITS_DENOMINATION,
|
denomination: LNBITS_DENOMINATION,
|
||||||
failedPaymentsToggle: false,
|
failedPaymentsToggle: false,
|
||||||
@@ -116,8 +116,8 @@ window.app.component('payment-list', {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
filteredPayments: function () {
|
filteredPayments() {
|
||||||
var q = this.paymentsTable.search
|
const q = this.paymentsTable.search
|
||||||
if (!q || q === '') return this.payments
|
if (!q || q === '') return this.payments
|
||||||
|
|
||||||
return LNbits.utils.search(this.payments, q)
|
return LNbits.utils.search(this.payments, q)
|
||||||
@@ -128,12 +128,12 @@ window.app.component('payment-list', {
|
|||||||
}
|
}
|
||||||
return this.payments
|
return this.payments
|
||||||
},
|
},
|
||||||
pendingPaymentsExist: function () {
|
pendingPaymentsExist() {
|
||||||
return this.payments.findIndex(payment => payment.pending) !== -1
|
return this.payments.findIndex(payment => payment.pending) !== -1
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
fetchPayments: function (props) {
|
fetchPayments(props) {
|
||||||
const params = LNbits.utils.prepareFilterQuery(this.paymentsTable, props)
|
const params = LNbits.utils.prepareFilterQuery(this.paymentsTable, props)
|
||||||
return LNbits.api
|
return LNbits.api
|
||||||
.getPayments(this.wallet, params)
|
.getPayments(this.wallet, params)
|
||||||
@@ -149,7 +149,7 @@ window.app.component('payment-list', {
|
|||||||
LNbits.utils.notifyApiError(err)
|
LNbits.utils.notifyApiError(err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
paymentTableRowKey: function (row) {
|
paymentTableRowKey(row) {
|
||||||
return row.payment_hash + row.amount
|
return row.payment_hash + row.amount
|
||||||
},
|
},
|
||||||
exportCSV(detailed = false) {
|
exportCSV(detailed = false) {
|
||||||
@@ -194,7 +194,7 @@ window.app.component('payment-list', {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
addFilterTag: function () {
|
addFilterTag() {
|
||||||
if (!this.exportTagName) return
|
if (!this.exportTagName) return
|
||||||
const value = this.exportTagName.trim()
|
const value = this.exportTagName.trim()
|
||||||
this.exportPaymentTagList = this.exportPaymentTagList.filter(
|
this.exportPaymentTagList = this.exportPaymentTagList.filter(
|
||||||
@@ -203,12 +203,12 @@ window.app.component('payment-list', {
|
|||||||
this.exportPaymentTagList.push(value)
|
this.exportPaymentTagList.push(value)
|
||||||
this.exportTagName = ''
|
this.exportTagName = ''
|
||||||
},
|
},
|
||||||
removeExportTag: function (value) {
|
removeExportTag(value) {
|
||||||
this.exportPaymentTagList = this.exportPaymentTagList.filter(
|
this.exportPaymentTagList = this.exportPaymentTagList.filter(
|
||||||
v => v !== value
|
v => v !== value
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
formatCurrency: function (amount, currency) {
|
formatCurrency(amount, currency) {
|
||||||
try {
|
try {
|
||||||
return LNbits.utils.formatCurrency(amount, currency)
|
return LNbits.utils.formatCurrency(amount, currency)
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -228,14 +228,14 @@ window.app.component('payment-list', {
|
|||||||
}
|
}
|
||||||
this.fetchPayments()
|
this.fetchPayments()
|
||||||
},
|
},
|
||||||
lazy: function (newVal) {
|
lazy(newVal) {
|
||||||
if (newVal === true) this.fetchPayments()
|
if (newVal === true) this.fetchPayments()
|
||||||
},
|
},
|
||||||
update: function () {
|
update() {
|
||||||
this.fetchPayments()
|
this.fetchPayments()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created() {
|
||||||
if (this.lazy === undefined) this.fetchPayments()
|
if (this.lazy === undefined) this.fetchPayments()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
window.app = Vue.createApp({
|
window.app = Vue.createApp({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
disclaimerDialog: {
|
disclaimerDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
@@ -30,11 +30,11 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showLogin: function (authMethod) {
|
showLogin(authMethod) {
|
||||||
this.authAction = 'login'
|
this.authAction = 'login'
|
||||||
this.authMethod = authMethod
|
this.authMethod = authMethod
|
||||||
},
|
},
|
||||||
showRegister: function (authMethod) {
|
showRegister(authMethod) {
|
||||||
this.user = ''
|
this.user = ''
|
||||||
this.username = null
|
this.username = null
|
||||||
this.password = null
|
this.password = null
|
||||||
@@ -43,7 +43,7 @@ window.app = Vue.createApp({
|
|||||||
this.authAction = 'register'
|
this.authAction = 'register'
|
||||||
this.authMethod = authMethod
|
this.authMethod = authMethod
|
||||||
},
|
},
|
||||||
signInWithNostr: async function () {
|
async signInWithNostr() {
|
||||||
try {
|
try {
|
||||||
const nostrToken = await this.createNostrToken()
|
const nostrToken = await this.createNostrToken()
|
||||||
if (!nostrToken) {
|
if (!nostrToken) {
|
||||||
@@ -65,7 +65,7 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createNostrToken: async function () {
|
async createNostrToken() {
|
||||||
try {
|
try {
|
||||||
async function _signEvent(e) {
|
async function _signEvent(e) {
|
||||||
try {
|
try {
|
||||||
@@ -116,7 +116,7 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
register: async function () {
|
async register() {
|
||||||
try {
|
try {
|
||||||
await LNbits.api.register(
|
await LNbits.api.register(
|
||||||
this.username,
|
this.username,
|
||||||
@@ -129,7 +129,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(e)
|
LNbits.utils.notifyApiError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
reset: async function () {
|
async reset() {
|
||||||
try {
|
try {
|
||||||
await LNbits.api.reset(
|
await LNbits.api.reset(
|
||||||
this.reset_key,
|
this.reset_key,
|
||||||
@@ -141,7 +141,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(e)
|
LNbits.utils.notifyApiError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
login: async function () {
|
async login() {
|
||||||
try {
|
try {
|
||||||
await LNbits.api.login(this.username, this.password)
|
await LNbits.api.login(this.username, this.password)
|
||||||
window.location.href = '/wallet'
|
window.location.href = '/wallet'
|
||||||
@@ -149,7 +149,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(e)
|
LNbits.utils.notifyApiError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
loginUsr: async function () {
|
async loginUsr() {
|
||||||
try {
|
try {
|
||||||
await LNbits.api.loginUsr(this.usr)
|
await LNbits.api.loginUsr(this.usr)
|
||||||
this.usr = ''
|
this.usr = ''
|
||||||
@@ -159,19 +159,19 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(e)
|
LNbits.utils.notifyApiError(e)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createWallet: function () {
|
createWallet() {
|
||||||
LNbits.api.createAccount(this.walletName).then(res => {
|
LNbits.api.createAccount(this.walletName).then(res => {
|
||||||
window.location = '/wallet?usr=' + res.data.user + '&wal=' + res.data.id
|
window.location = '/wallet?usr=' + res.data.user + '&wal=' + res.data.id
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
processing: function () {
|
processing() {
|
||||||
Quasar.Notify.create({
|
Quasar.Notify.create({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
message: 'Processing...',
|
message: 'Processing...',
|
||||||
icon: null
|
icon: null
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
validateUsername: function (val) {
|
validateUsername(val) {
|
||||||
const usernameRegex = new RegExp(
|
const usernameRegex = new RegExp(
|
||||||
'^(?=[a-zA-Z0-9._]{2,20}$)(?!.*[_.]{2})[^_.].*[^_.]$'
|
'^(?=[a-zA-Z0-9._]{2,20}$)(?!.*[_.]{2})[^_.].*[^_.]$'
|
||||||
)
|
)
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
window.app.component('lnbits-node-ranks', {
|
window.app.component('lnbits-node-ranks', {
|
||||||
props: ['ranks'],
|
props: ['ranks'],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
user: {},
|
user: {},
|
||||||
stats: [
|
stats: [
|
||||||
@@ -31,7 +31,7 @@ window.app.component('lnbits-node-ranks', {
|
|||||||
|
|
||||||
window.app.component('lnbits-channel-stats', {
|
window.app.component('lnbits-channel-stats', {
|
||||||
props: ['stats'],
|
props: ['stats'],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
states: [
|
states: [
|
||||||
{label: 'Active', value: 'active', color: 'green'},
|
{label: 'Active', value: 'active', color: 'green'},
|
||||||
@@ -58,7 +58,7 @@ window.app.component('lnbits-channel-stats', {
|
|||||||
</div>
|
</div>
|
||||||
</q-card>
|
</q-card>
|
||||||
`,
|
`,
|
||||||
created: function () {
|
created() {
|
||||||
if (window.user) {
|
if (window.user) {
|
||||||
this.user = LNbits.map.user(window.user)
|
this.user = LNbits.map.user(window.user)
|
||||||
}
|
}
|
||||||
@@ -68,7 +68,7 @@ window.app.component('lnbits-channel-stats', {
|
|||||||
window.app.component('lnbits-stat', {
|
window.app.component('lnbits-stat', {
|
||||||
props: ['title', 'amount', 'msat', 'btc'],
|
props: ['title', 'amount', 'msat', 'btc'],
|
||||||
computed: {
|
computed: {
|
||||||
value: function () {
|
value() {
|
||||||
return (
|
return (
|
||||||
this.amount ??
|
this.amount ??
|
||||||
(this.btc
|
(this.btc
|
||||||
@@ -178,7 +178,7 @@ window.app.component('lnbits-node-info', {
|
|||||||
window.app.component('lnbits-stat', {
|
window.app.component('lnbits-stat', {
|
||||||
props: ['title', 'amount', 'msat', 'btc'],
|
props: ['title', 'amount', 'msat', 'btc'],
|
||||||
computed: {
|
computed: {
|
||||||
value: function () {
|
value() {
|
||||||
return (
|
return (
|
||||||
this.amount ??
|
this.amount ??
|
||||||
(this.btc
|
(this.btc
|
||||||
@@ -206,7 +206,7 @@ window.app.component('lnbits-stat', {
|
|||||||
window.app.component('lnbits-channel-balance', {
|
window.app.component('lnbits-channel-balance', {
|
||||||
props: ['balance', 'color'],
|
props: ['balance', 'color'],
|
||||||
methods: {
|
methods: {
|
||||||
formatMsat: function (msat) {
|
formatMsat(msat) {
|
||||||
return LNbits.utils.formatMsat(msat)
|
return LNbits.utils.formatMsat(msat)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -247,10 +247,10 @@ window.app.component('lnbits-channel-balance', {
|
|||||||
window.app.component('lnbits-date', {
|
window.app.component('lnbits-date', {
|
||||||
props: ['ts'],
|
props: ['ts'],
|
||||||
computed: {
|
computed: {
|
||||||
date: function () {
|
date() {
|
||||||
return LNbits.utils.formatDate(this.ts)
|
return LNbits.utils.formatDate(this.ts)
|
||||||
},
|
},
|
||||||
dateFrom: function () {
|
dateFrom() {
|
||||||
return moment(this.date).fromNow()
|
return moment(this.date).fromNow()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
window.app = Vue.createApp({
|
window.app = Vue.createApp({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
paymentsWallet: {},
|
paymentsWallet: {},
|
||||||
wallet: {},
|
wallet: {},
|
||||||
@@ -175,7 +175,7 @@ window.app = Vue.createApp({
|
|||||||
formatDate(date) {
|
formatDate(date) {
|
||||||
return LNbits.utils.formatDateString(date)
|
return LNbits.utils.formatDateString(date)
|
||||||
},
|
},
|
||||||
formatSat: function (value) {
|
formatSat(value) {
|
||||||
return LNbits.utils.formatSat(Math.floor(value / 1000))
|
return LNbits.utils.formatSat(Math.floor(value / 1000))
|
||||||
},
|
},
|
||||||
backToUsersPage() {
|
backToUsersPage() {
|
||||||
@@ -197,9 +197,7 @@ window.app = Vue.createApp({
|
|||||||
this.copyText(url)
|
this.copyText(url)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
createUser() {
|
createUser() {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
@@ -215,9 +213,7 @@ window.app = Vue.createApp({
|
|||||||
this.activeUser.data = resp.data
|
this.activeUser.data = resp.data
|
||||||
this.fetchUsers()
|
this.fetchUsers()
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
updateUser() {
|
updateUser() {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
@@ -237,9 +233,7 @@ window.app = Vue.createApp({
|
|||||||
this.activeUser.show = false
|
this.activeUser.show = false
|
||||||
this.fetchUsers()
|
this.fetchUsers()
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
createWallet() {
|
createWallet() {
|
||||||
const userId = this.activeWallet.userId
|
const userId = this.activeWallet.userId
|
||||||
@@ -265,9 +259,7 @@ window.app = Vue.createApp({
|
|||||||
message: 'Wallet created!'
|
message: 'Wallet created!'
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
deleteUser(user_id) {
|
deleteUser(user_id) {
|
||||||
LNbits.utils
|
LNbits.utils
|
||||||
@@ -285,9 +277,7 @@ window.app = Vue.createApp({
|
|||||||
this.activeUser.data = null
|
this.activeUser.data = null
|
||||||
this.activeUser.show = false
|
this.activeUser.show = false
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
undeleteUserWallet(user_id, wallet) {
|
undeleteUserWallet(user_id, wallet) {
|
||||||
@@ -304,9 +294,7 @@ window.app = Vue.createApp({
|
|||||||
icon: null
|
icon: null
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
deleteUserWallet(user_id, wallet, deleted) {
|
deleteUserWallet(user_id, wallet, deleted) {
|
||||||
const dialogText = deleted
|
const dialogText = deleted
|
||||||
@@ -323,9 +311,7 @@ window.app = Vue.createApp({
|
|||||||
icon: null
|
icon: null
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
copyWalletLink(walletId) {
|
copyWalletLink(walletId) {
|
||||||
@@ -342,9 +328,7 @@ window.app = Vue.createApp({
|
|||||||
this.usersTable.pagination.rowsNumber = res.data.total
|
this.usersTable.pagination.rowsNumber = res.data.total
|
||||||
this.users = res.data.data
|
this.users = res.data.data
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
fetchWallets(userId) {
|
fetchWallets(userId) {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
@@ -354,9 +338,7 @@ window.app = Vue.createApp({
|
|||||||
this.activeWallet.userId = userId
|
this.activeWallet.userId = userId
|
||||||
this.activeWallet.show = true
|
this.activeWallet.show = true
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleAdmin(userId) {
|
toggleAdmin(userId) {
|
||||||
@@ -370,9 +352,7 @@ window.app = Vue.createApp({
|
|||||||
icon: null
|
icon: null
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
exportUsers() {
|
exportUsers() {
|
||||||
console.log('export users')
|
console.log('export users')
|
||||||
@@ -438,9 +418,7 @@ window.app = Vue.createApp({
|
|||||||
this.wallet = {}
|
this.wallet = {}
|
||||||
this.fetchWallets(this.activeWallet.userId)
|
this.fetchWallets(this.activeWallet.userId)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(LNbits.utils.notifyApiError)
|
||||||
LNbits.utils.notifyApiError(error)
|
|
||||||
})
|
|
||||||
},
|
},
|
||||||
searchUserBy(fieldName) {
|
searchUserBy(fieldName) {
|
||||||
const fieldValue = this.searchData[fieldName]
|
const fieldValue = this.searchData[fieldName]
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
window.app = Vue.createApp({
|
window.app = Vue.createApp({
|
||||||
el: '#vue',
|
el: '#vue',
|
||||||
mixins: [window.windowMixin],
|
mixins: [window.windowMixin],
|
||||||
data: function () {
|
data() {
|
||||||
return {
|
return {
|
||||||
updatePayments: false,
|
updatePayments: false,
|
||||||
origin: window.location.origin,
|
origin: window.location.origin,
|
||||||
@@ -63,7 +63,7 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
formattedBalance: function () {
|
formattedBalance() {
|
||||||
if (LNBITS_DENOMINATION != 'sats') {
|
if (LNBITS_DENOMINATION != 'sats') {
|
||||||
return this.balance / 100
|
return this.balance / 100
|
||||||
} else {
|
} else {
|
||||||
@@ -78,11 +78,11 @@ window.app = Vue.createApp({
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
canPay: function () {
|
canPay() {
|
||||||
if (!this.parse.invoice) return false
|
if (!this.parse.invoice) return false
|
||||||
return this.parse.invoice.sat <= this.balance
|
return this.parse.invoice.sat <= this.balance
|
||||||
},
|
},
|
||||||
formattedAmount: function () {
|
formattedAmount() {
|
||||||
if (this.receive.unit != 'sat') {
|
if (this.receive.unit != 'sat') {
|
||||||
return LNbits.utils.formatCurrency(
|
return LNbits.utils.formatCurrency(
|
||||||
Number(this.receive.data.amount).toFixed(2),
|
Number(this.receive.data.amount).toFixed(2),
|
||||||
@@ -92,24 +92,24 @@ window.app = Vue.createApp({
|
|||||||
return LNbits.utils.formatMsat(this.receive.amountMsat) + ' sat'
|
return LNbits.utils.formatMsat(this.receive.amountMsat) + ' sat'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formattedSatAmount: function () {
|
formattedSatAmount() {
|
||||||
return LNbits.utils.formatMsat(this.receive.amountMsat) + ' sat'
|
return LNbits.utils.formatMsat(this.receive.amountMsat) + ' sat'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
msatoshiFormat: function (value) {
|
msatoshiFormat(value) {
|
||||||
return LNbits.utils.formatSat(value / 1000)
|
return LNbits.utils.formatSat(value / 1000)
|
||||||
},
|
},
|
||||||
closeCamera: function () {
|
closeCamera() {
|
||||||
this.parse.camera.show = false
|
this.parse.camera.show = false
|
||||||
},
|
},
|
||||||
showCamera: function () {
|
showCamera() {
|
||||||
this.parse.camera.show = true
|
this.parse.camera.show = true
|
||||||
},
|
},
|
||||||
focusInput(el) {
|
focusInput(el) {
|
||||||
this.$nextTick(() => this.$refs[el].focus())
|
this.$nextTick(() => this.$refs[el].focus())
|
||||||
},
|
},
|
||||||
showReceiveDialog: function () {
|
showReceiveDialog() {
|
||||||
this.receive.show = true
|
this.receive.show = true
|
||||||
this.receive.status = 'pending'
|
this.receive.status = 'pending'
|
||||||
this.receive.paymentReq = null
|
this.receive.paymentReq = null
|
||||||
@@ -121,12 +121,12 @@ window.app = Vue.createApp({
|
|||||||
this.receive.lnurl = null
|
this.receive.lnurl = null
|
||||||
this.focusInput('setAmount')
|
this.focusInput('setAmount')
|
||||||
},
|
},
|
||||||
onReceiveDialogHide: function () {
|
onReceiveDialogHide() {
|
||||||
if (this.hasNfc) {
|
if (this.hasNfc) {
|
||||||
this.nfcReaderAbortController.abort()
|
this.nfcReaderAbortController.abort()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showParseDialog: function () {
|
showParseDialog() {
|
||||||
this.parse.show = true
|
this.parse.show = true
|
||||||
this.parse.invoice = null
|
this.parse.invoice = null
|
||||||
this.parse.lnurlpay = null
|
this.parse.lnurlpay = null
|
||||||
@@ -139,19 +139,19 @@ window.app = Vue.createApp({
|
|||||||
this.parse.camera.show = false
|
this.parse.camera.show = false
|
||||||
this.focusInput('textArea')
|
this.focusInput('textArea')
|
||||||
},
|
},
|
||||||
closeParseDialog: function () {
|
closeParseDialog() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
clearInterval(this.parse.paymentChecker)
|
clearInterval(this.parse.paymentChecker)
|
||||||
}, 10000)
|
}, 10000)
|
||||||
},
|
},
|
||||||
onPaymentReceived: function (paymentHash) {
|
onPaymentReceived(paymentHash) {
|
||||||
this.updatePayments = !this.updatePayments
|
this.updatePayments = !this.updatePayments
|
||||||
if (this.receive.paymentHash === paymentHash) {
|
if (this.receive.paymentHash === paymentHash) {
|
||||||
this.receive.show = false
|
this.receive.show = false
|
||||||
this.receive.paymentHash = null
|
this.receive.paymentHash = null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
createInvoice: function () {
|
createInvoice() {
|
||||||
this.receive.status = 'loading'
|
this.receive.status = 'loading'
|
||||||
if (LNBITS_DENOMINATION != 'sats') {
|
if (LNBITS_DENOMINATION != 'sats') {
|
||||||
this.receive.data.amount = this.receive.data.amount * 100
|
this.receive.data.amount = this.receive.data.amount * 100
|
||||||
@@ -206,11 +206,11 @@ window.app = Vue.createApp({
|
|||||||
this.receive.status = 'pending'
|
this.receive.status = 'pending'
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
onInitQR: async function (promise) {
|
async onInitQR(promise) {
|
||||||
try {
|
try {
|
||||||
await promise
|
await promise
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
let mapping = {
|
const mapping = {
|
||||||
NotAllowedError: 'ERROR: you need to grant camera access permission',
|
NotAllowedError: 'ERROR: you need to grant camera access permission',
|
||||||
NotFoundError: 'ERROR: no camera on this device',
|
NotFoundError: 'ERROR: no camera on this device',
|
||||||
NotSupportedError:
|
NotSupportedError:
|
||||||
@@ -222,10 +222,10 @@ window.app = Vue.createApp({
|
|||||||
InsecureContextError:
|
InsecureContextError:
|
||||||
'ERROR: Camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP.'
|
'ERROR: Camera access is only permitted in secure context. Use HTTPS or localhost rather than HTTP.'
|
||||||
}
|
}
|
||||||
let valid_error = Object.keys(mapping).filter(key => {
|
const valid_error = Object.keys(mapping).filter(key => {
|
||||||
return error.name === key
|
return error.name === key
|
||||||
})
|
})
|
||||||
let camera_error = valid_error
|
const camera_error = valid_error
|
||||||
? mapping[valid_error]
|
? mapping[valid_error]
|
||||||
: `ERROR: Camera error (${error.name})`
|
: `ERROR: Camera error (${error.name})`
|
||||||
this.parse.camera.show = false
|
this.parse.camera.show = false
|
||||||
@@ -246,7 +246,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(err)
|
LNbits.utils.notifyApiError(err)
|
||||||
})
|
})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
let data = response.data
|
const data = response.data
|
||||||
|
|
||||||
if (data.status === 'ERROR') {
|
if (data.status === 'ERROR') {
|
||||||
Quasar.Notify.create({
|
Quasar.Notify.create({
|
||||||
@@ -283,15 +283,15 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
decodeQR: function (res) {
|
decodeQR(res) {
|
||||||
this.parse.data.request = res[0].rawValue
|
this.parse.data.request = res[0].rawValue
|
||||||
this.decodeRequest()
|
this.decodeRequest()
|
||||||
this.parse.camera.show = false
|
this.parse.camera.show = false
|
||||||
},
|
},
|
||||||
decodeRequest: function () {
|
decodeRequest() {
|
||||||
this.parse.show = true
|
this.parse.show = true
|
||||||
this.parse.data.request = this.parse.data.request.trim().toLowerCase()
|
this.parse.data.request = this.parse.data.request.trim().toLowerCase()
|
||||||
let req = this.parse.data.request
|
const req = this.parse.data.request
|
||||||
if (req.startsWith('lightning:')) {
|
if (req.startsWith('lightning:')) {
|
||||||
this.parse.data.request = req.slice(10)
|
this.parse.data.request = req.slice(10)
|
||||||
} else if (req.startsWith('lnurl:')) {
|
} else if (req.startsWith('lnurl:')) {
|
||||||
@@ -342,7 +342,7 @@ window.app = Vue.createApp({
|
|||||||
} else if (tag.description === 'description') {
|
} else if (tag.description === 'description') {
|
||||||
cleanInvoice.description = tag.value
|
cleanInvoice.description = tag.value
|
||||||
} else if (tag.description === 'expiry') {
|
} else if (tag.description === 'expiry') {
|
||||||
var expireDate = new Date(
|
const expireDate = new Date(
|
||||||
(invoice.data.time_stamp + tag.value) * 1000
|
(invoice.data.time_stamp + tag.value) * 1000
|
||||||
)
|
)
|
||||||
cleanInvoice.expireDate = Quasar.date.formatDate(
|
cleanInvoice.expireDate = Quasar.date.formatDate(
|
||||||
@@ -356,8 +356,8 @@ window.app = Vue.createApp({
|
|||||||
|
|
||||||
this.parse.invoice = Object.freeze(cleanInvoice)
|
this.parse.invoice = Object.freeze(cleanInvoice)
|
||||||
},
|
},
|
||||||
payInvoice: function () {
|
payInvoice() {
|
||||||
let dismissPaymentMsg = Quasar.Notify.create({
|
const dismissPaymentMsg = Quasar.Notify.create({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
message: this.$t('processing_payment')
|
message: this.$t('processing_payment')
|
||||||
})
|
})
|
||||||
@@ -389,8 +389,8 @@ window.app = Vue.createApp({
|
|||||||
this.parse.show = false
|
this.parse.show = false
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
payLnurl: function () {
|
payLnurl() {
|
||||||
let dismissPaymentMsg = Quasar.Notify.create({
|
const dismissPaymentMsg = Quasar.Notify.create({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
message: 'Processing payment...'
|
message: 'Processing payment...'
|
||||||
})
|
})
|
||||||
@@ -472,8 +472,8 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(err)
|
LNbits.utils.notifyApiError(err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
authLnurl: function () {
|
authLnurl() {
|
||||||
let dismissAuthMsg = Quasar.Notify.create({
|
const dismissAuthMsg = Quasar.Notify.create({
|
||||||
timeout: 10,
|
timeout: 10,
|
||||||
message: 'Performing authentication...'
|
message: 'Performing authentication...'
|
||||||
})
|
})
|
||||||
@@ -503,7 +503,7 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
updateWallet: function (data) {
|
updateWallet(data) {
|
||||||
LNbits.api
|
LNbits.api
|
||||||
.request('PATCH', '/api/v1/wallet', this.g.wallet.adminkey, data)
|
.request('PATCH', '/api/v1/wallet', this.g.wallet.adminkey, data)
|
||||||
.then(_ => {
|
.then(_ => {
|
||||||
@@ -518,7 +518,7 @@ window.app = Vue.createApp({
|
|||||||
LNbits.utils.notifyApiError(err)
|
LNbits.utils.notifyApiError(err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
deleteWallet: function () {
|
deleteWallet() {
|
||||||
LNbits.utils
|
LNbits.utils
|
||||||
.confirmDialog('Are you sure you want to delete this wallet?')
|
.confirmDialog('Are you sure you want to delete this wallet?')
|
||||||
.onOk(() => {
|
.onOk(() => {
|
||||||
@@ -536,7 +536,7 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
fetchBalance: function () {
|
fetchBalance() {
|
||||||
LNbits.api.getWallet(this.g.wallet).then(response => {
|
LNbits.api.getWallet(this.g.wallet).then(response => {
|
||||||
this.balance = Math.floor(response.data.balance / 1000)
|
this.balance = Math.floor(response.data.balance / 1000)
|
||||||
document.dispatchEvent(
|
document.dispatchEvent(
|
||||||
@@ -561,18 +561,18 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
.catch(e => console.error(e))
|
.catch(e => console.error(e))
|
||||||
},
|
},
|
||||||
updateBalanceCallback: function (res) {
|
updateBalanceCallback(res) {
|
||||||
if (res.success && wallet.id === res.wallet_id) {
|
if (res.success && wallet.id === res.wallet_id) {
|
||||||
this.balance += res.credit
|
this.balance += res.credit
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pasteToTextArea: function () {
|
pasteToTextArea() {
|
||||||
this.$refs.textArea.focus() // Set cursor to textarea
|
this.$refs.textArea.focus() // Set cursor to textarea
|
||||||
navigator.clipboard.readText().then(text => {
|
navigator.clipboard.readText().then(text => {
|
||||||
this.parse.data.request = text.trim()
|
this.parse.data.request = text.trim()
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
readNfcTag: function () {
|
readNfcTag() {
|
||||||
try {
|
try {
|
||||||
if (typeof NDEFReader == 'undefined') {
|
if (typeof NDEFReader == 'undefined') {
|
||||||
console.debug('NFC not supported on this device or browser.')
|
console.debug('NFC not supported on this device or browser.')
|
||||||
@@ -587,7 +587,7 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.hasNfc = true
|
this.hasNfc = true
|
||||||
let dismissNfcTapMsg = Quasar.Notify.create({
|
const dismissNfcTapMsg = Quasar.Notify.create({
|
||||||
message: 'Tap your NFC tag to pay this invoice with LNURLw.'
|
message: 'Tap your NFC tag to pay this invoice with LNURLw.'
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -635,8 +635,8 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
payInvoiceWithNfc: function (lnurl) {
|
payInvoiceWithNfc(lnurl) {
|
||||||
let dismissPaymentMsg = Quasar.Notify.create({
|
const dismissPaymentMsg = Quasar.Notify.create({
|
||||||
timeout: 0,
|
timeout: 0,
|
||||||
spinner: true,
|
spinner: true,
|
||||||
message: this.$t('processing_payment')
|
message: this.$t('processing_payment')
|
||||||
@@ -669,8 +669,8 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created: function () {
|
created() {
|
||||||
let urlParams = new URLSearchParams(window.location.search)
|
const urlParams = new URLSearchParams(window.location.search)
|
||||||
if (urlParams.has('lightning') || urlParams.has('lnurl')) {
|
if (urlParams.has('lightning') || urlParams.has('lnurl')) {
|
||||||
this.parse.data.request =
|
this.parse.data.request =
|
||||||
urlParams.get('lightning') || urlParams.get('lnurl')
|
urlParams.get('lightning') || urlParams.get('lnurl')
|
||||||
@@ -686,11 +686,11 @@ window.app = Vue.createApp({
|
|||||||
this.updateFiatBalance()
|
this.updateFiatBalance()
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
updatePayments: function () {
|
updatePayments() {
|
||||||
this.fetchBalance()
|
this.fetchBalance()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted: function () {
|
mounted() {
|
||||||
// show disclaimer
|
// show disclaimer
|
||||||
if (!this.$q.localStorage.getItem('lnbits.disclaimerShown')) {
|
if (!this.$q.localStorage.getItem('lnbits.disclaimerShown')) {
|
||||||
this.disclaimerDialog.show = true
|
this.disclaimerDialog.show = true
|
||||||
@@ -705,9 +705,7 @@ window.app = Vue.createApp({
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (navigator.serviceWorker != null) {
|
if (navigator.serviceWorker != null) {
|
||||||
navigator.serviceWorker
|
navigator.serviceWorker.register('/service-worker.js').then(registration => {
|
||||||
.register('/service-worker.js')
|
console.log('Registered events at scope: ', registration.scope)
|
||||||
.then(function (registration) {
|
})
|
||||||
console.log('Registered events at scope: ', registration.scope)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user