2024-09-24 11:06:27 +02:00
|
|
|
window.app = Vue.createApp({
|
2023-10-10 12:02:40 +02:00
|
|
|
el: '#vue',
|
|
|
|
mixins: [windowMixin],
|
2024-12-10 13:42:01 +01:00
|
|
|
data() {
|
2023-10-10 12:02:40 +02:00
|
|
|
return {
|
|
|
|
settings: {},
|
|
|
|
logs: [],
|
|
|
|
serverlogEnabled: false,
|
|
|
|
lnbits_theme_options: [
|
|
|
|
'classic',
|
|
|
|
'bitcoin',
|
|
|
|
'flamingo',
|
|
|
|
'cyber',
|
|
|
|
'freedom',
|
|
|
|
'mint',
|
|
|
|
'autumn',
|
|
|
|
'monochrome',
|
|
|
|
'salvador'
|
|
|
|
],
|
|
|
|
auditData: {},
|
|
|
|
statusData: {},
|
|
|
|
statusDataTable: {
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
name: 'date',
|
|
|
|
align: 'left',
|
|
|
|
label: this.$t('date'),
|
|
|
|
field: 'date'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'message',
|
|
|
|
align: 'left',
|
|
|
|
label: this.$t('memo'),
|
|
|
|
field: 'message'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
|
|
|
formData: {},
|
|
|
|
formAddAdmin: '',
|
|
|
|
formAddUser: '',
|
|
|
|
formAddExtensionsManifest: '',
|
|
|
|
formAllowedIPs: '',
|
|
|
|
formBlockedIPs: '',
|
2024-09-30 14:53:38 +03:00
|
|
|
nostrAcceptedUrl: '',
|
2024-11-27 13:06:35 +02:00
|
|
|
formAddIncludePath: '',
|
|
|
|
formAddExcludePath: '',
|
|
|
|
formAddIncludeResponseCode: '',
|
2023-10-10 12:02:40 +02:00
|
|
|
isSuperUser: false,
|
|
|
|
wallet: {},
|
|
|
|
cancel: {},
|
2024-04-30 08:08:57 +01:00
|
|
|
colors: [
|
|
|
|
'primary',
|
|
|
|
'secondary',
|
|
|
|
'accent',
|
|
|
|
'positive',
|
|
|
|
'negative',
|
|
|
|
'info',
|
|
|
|
'warning',
|
|
|
|
'red',
|
|
|
|
'yellow',
|
|
|
|
'orange'
|
|
|
|
],
|
2023-10-10 12:02:40 +02:00
|
|
|
tab: 'funding',
|
|
|
|
needsRestart: false
|
|
|
|
}
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
this.getSettings()
|
|
|
|
this.getAudit()
|
|
|
|
this.balance = +'{{ balance|safe }}'
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
lnbitsVersion() {
|
|
|
|
return LNBITS_VERSION
|
|
|
|
},
|
|
|
|
checkChanges() {
|
|
|
|
return !_.isEqual(this.settings, this.formData)
|
|
|
|
},
|
|
|
|
updateAvailable() {
|
|
|
|
return LNBITS_VERSION !== this.statusData.version
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
2024-05-14 14:48:33 +03:00
|
|
|
addAdminUser() {
|
|
|
|
let addUser = this.formAddAdmin
|
|
|
|
let admin_users = this.formData.lnbits_admin_users
|
|
|
|
if (addUser && addUser.length && !admin_users.includes(addUser)) {
|
|
|
|
this.formData.lnbits_admin_users = [...admin_users, addUser]
|
|
|
|
this.formAddAdmin = ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeAdminUser(user) {
|
|
|
|
let admin_users = this.formData.lnbits_admin_users
|
|
|
|
this.formData.lnbits_admin_users = admin_users.filter(u => u !== user)
|
|
|
|
},
|
|
|
|
addAllowedUser() {
|
|
|
|
let addUser = this.formAddUser
|
|
|
|
let allowed_users = this.formData.lnbits_allowed_users
|
|
|
|
if (addUser && addUser.length && !allowed_users.includes(addUser)) {
|
|
|
|
this.formData.lnbits_allowed_users = [...allowed_users, addUser]
|
|
|
|
this.formAddUser = ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeAllowedUser(user) {
|
|
|
|
let allowed_users = this.formData.lnbits_allowed_users
|
|
|
|
this.formData.lnbits_allowed_users = allowed_users.filter(u => u !== user)
|
|
|
|
},
|
2024-11-27 13:06:35 +02:00
|
|
|
addIncludePath() {
|
|
|
|
if (!this.formAddIncludePath) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const paths = this.formData.lnbits_audit_include_paths
|
|
|
|
if (!paths.includes(this.formAddIncludePath)) {
|
|
|
|
this.formData.lnbits_audit_include_paths = [
|
|
|
|
...paths,
|
|
|
|
this.formAddIncludePath
|
|
|
|
]
|
|
|
|
}
|
|
|
|
this.formAddIncludePath = ''
|
|
|
|
},
|
|
|
|
removeIncludePath(path) {
|
|
|
|
this.formData.lnbits_audit_include_paths =
|
|
|
|
this.formData.lnbits_audit_include_paths.filter(p => p !== path)
|
|
|
|
},
|
|
|
|
addExcludePath() {
|
|
|
|
if (!this.formAddExcludePath) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const paths = this.formData.lnbits_audit_exclude_paths
|
|
|
|
if (!paths.includes(this.formAddExcludePath)) {
|
|
|
|
this.formData.lnbits_audit_exclude_paths = [
|
|
|
|
...paths,
|
|
|
|
this.formAddExcludePath
|
|
|
|
]
|
|
|
|
}
|
|
|
|
this.formAddExcludePath = ''
|
|
|
|
},
|
|
|
|
|
|
|
|
removeExcludePath(path) {
|
|
|
|
this.formData.lnbits_audit_exclude_paths =
|
|
|
|
this.formData.lnbits_audit_exclude_paths.filter(p => p !== path)
|
|
|
|
},
|
|
|
|
addIncludeResponseCode() {
|
|
|
|
if (!this.formAddIncludeResponseCode) {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
const codes = this.formData.lnbits_audit_http_response_codes
|
|
|
|
if (!codes.includes(this.formAddIncludeResponseCode)) {
|
|
|
|
this.formData.lnbits_audit_http_response_codes = [
|
|
|
|
...codes,
|
|
|
|
this.formAddIncludeResponseCode
|
|
|
|
]
|
|
|
|
}
|
|
|
|
this.formAddIncludeResponseCode = ''
|
|
|
|
},
|
|
|
|
removeIncludeResponseCode(code) {
|
|
|
|
this.formData.lnbits_audit_http_response_codes =
|
|
|
|
this.formData.lnbits_audit_http_response_codes.filter(c => c !== code)
|
|
|
|
},
|
2023-10-10 12:02:40 +02:00
|
|
|
addExtensionsManifest() {
|
|
|
|
const addManifest = this.formAddExtensionsManifest.trim()
|
|
|
|
const manifests = this.formData.lnbits_extensions_manifests
|
|
|
|
if (
|
|
|
|
addManifest &&
|
|
|
|
addManifest.length &&
|
|
|
|
!manifests.includes(addManifest)
|
|
|
|
) {
|
|
|
|
this.formData.lnbits_extensions_manifests = [...manifests, addManifest]
|
|
|
|
this.formAddExtensionsManifest = ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeExtensionsManifest(manifest) {
|
|
|
|
const manifests = this.formData.lnbits_extensions_manifests
|
|
|
|
this.formData.lnbits_extensions_manifests = manifests.filter(
|
|
|
|
m => m !== manifest
|
|
|
|
)
|
|
|
|
},
|
|
|
|
async toggleServerLog() {
|
|
|
|
this.serverlogEnabled = !this.serverlogEnabled
|
|
|
|
if (this.serverlogEnabled) {
|
|
|
|
const wsProto = location.protocol !== 'http:' ? 'wss://' : 'ws://'
|
|
|
|
const digestHex = await LNbits.utils.digestMessage(this.g.user.id)
|
|
|
|
const localUrl =
|
|
|
|
wsProto +
|
|
|
|
document.domain +
|
|
|
|
':' +
|
|
|
|
location.port +
|
|
|
|
'/api/v1/ws/' +
|
|
|
|
digestHex
|
|
|
|
this.ws = new WebSocket(localUrl)
|
|
|
|
this.ws.addEventListener('message', async ({data}) => {
|
|
|
|
this.logs.push(data.toString())
|
|
|
|
const scrollArea = this.$refs.logScroll
|
|
|
|
if (scrollArea) {
|
|
|
|
const scrollTarget = scrollArea.getScrollTarget()
|
|
|
|
const duration = 0
|
|
|
|
scrollArea.setScrollPosition(scrollTarget.scrollHeight, duration)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.ws.close()
|
|
|
|
}
|
|
|
|
},
|
|
|
|
addAllowedIPs() {
|
|
|
|
const allowedIPs = this.formAllowedIPs.trim()
|
|
|
|
const allowed_ips = this.formData.lnbits_allowed_ips
|
|
|
|
if (
|
|
|
|
allowedIPs &&
|
|
|
|
allowedIPs.length &&
|
|
|
|
!allowed_ips.includes(allowedIPs)
|
|
|
|
) {
|
|
|
|
this.formData.lnbits_allowed_ips = [...allowed_ips, allowedIPs]
|
|
|
|
this.formAllowedIPs = ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeAllowedIPs(allowed_ip) {
|
|
|
|
const allowed_ips = this.formData.lnbits_allowed_ips
|
|
|
|
this.formData.lnbits_allowed_ips = allowed_ips.filter(
|
|
|
|
a => a !== allowed_ip
|
|
|
|
)
|
|
|
|
},
|
|
|
|
addBlockedIPs() {
|
|
|
|
const blockedIPs = this.formBlockedIPs.trim()
|
|
|
|
const blocked_ips = this.formData.lnbits_blocked_ips
|
|
|
|
if (
|
|
|
|
blockedIPs &&
|
|
|
|
blockedIPs.length &&
|
|
|
|
!blocked_ips.includes(blockedIPs)
|
|
|
|
) {
|
|
|
|
this.formData.lnbits_blocked_ips = [...blocked_ips, blockedIPs]
|
|
|
|
this.formBlockedIPs = ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeBlockedIPs(blocked_ip) {
|
|
|
|
const blocked_ips = this.formData.lnbits_blocked_ips
|
|
|
|
this.formData.lnbits_blocked_ips = blocked_ips.filter(
|
|
|
|
b => b !== blocked_ip
|
|
|
|
)
|
|
|
|
},
|
2024-09-30 14:53:38 +03:00
|
|
|
addNostrUrl() {
|
|
|
|
const url = this.nostrAcceptedUrl.trim()
|
|
|
|
this.removeNostrUrl(url)
|
|
|
|
this.formData.nostr_absolute_request_urls.push(url)
|
|
|
|
this.nostrAcceptedUrl = ''
|
|
|
|
},
|
|
|
|
removeNostrUrl(url) {
|
|
|
|
this.formData.nostr_absolute_request_urls =
|
|
|
|
this.formData.nostr_absolute_request_urls.filter(b => b !== url)
|
|
|
|
},
|
2023-10-10 12:02:40 +02:00
|
|
|
restartServer() {
|
|
|
|
LNbits.api
|
2023-12-12 12:38:19 +02:00
|
|
|
.request('GET', '/admin/api/v1/restart/')
|
2023-10-10 12:02:40 +02:00
|
|
|
.then(response => {
|
2024-09-24 16:18:56 +02:00
|
|
|
Quasar.Notify.create({
|
2023-10-10 12:02:40 +02:00
|
|
|
type: 'positive',
|
|
|
|
message: 'Success! Restarted Server',
|
|
|
|
icon: null
|
|
|
|
})
|
|
|
|
this.needsRestart = false
|
|
|
|
})
|
2024-12-10 13:42:01 +01:00
|
|
|
.catch(LNbits.utils.notifyApiError)
|
2023-10-10 12:02:40 +02:00
|
|
|
},
|
|
|
|
formatDate(date) {
|
|
|
|
return moment(date * 1000).fromNow()
|
|
|
|
},
|
|
|
|
getNotifications() {
|
|
|
|
if (this.settings.lnbits_notifications) {
|
|
|
|
axios
|
|
|
|
.get(this.settings.lnbits_status_manifest)
|
|
|
|
.then(response => {
|
|
|
|
this.statusData = response.data
|
|
|
|
})
|
|
|
|
.catch(error => {
|
|
|
|
this.formData.lnbits_notifications = false
|
|
|
|
error.response.data = {}
|
|
|
|
error.response.data.message = 'Could not fetch status manifest.'
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
getAudit() {
|
|
|
|
LNbits.api
|
2024-04-04 07:54:21 +02:00
|
|
|
.request('GET', '/admin/api/v1/audit', this.g.user.wallets[0].adminkey)
|
2023-10-10 12:02:40 +02:00
|
|
|
.then(response => {
|
|
|
|
this.auditData = response.data
|
|
|
|
})
|
2024-12-10 13:42:01 +01:00
|
|
|
.catch(LNbits.utils.notifyApiError)
|
2023-10-10 12:02:40 +02:00
|
|
|
},
|
|
|
|
getSettings() {
|
|
|
|
LNbits.api
|
|
|
|
.request(
|
|
|
|
'GET',
|
2024-04-04 07:54:21 +02:00
|
|
|
'/admin/api/v1/settings',
|
2023-10-10 12:02:40 +02:00
|
|
|
this.g.user.wallets[0].adminkey
|
|
|
|
)
|
|
|
|
.then(response => {
|
|
|
|
this.isSuperUser = response.data.is_super_user || false
|
|
|
|
this.settings = response.data
|
|
|
|
this.formData = {...this.settings}
|
|
|
|
this.getNotifications()
|
|
|
|
})
|
2024-12-10 13:42:01 +01:00
|
|
|
.catch(LNbits.utils.notifyApiError)
|
2023-10-10 12:02:40 +02:00
|
|
|
},
|
|
|
|
updateSettings() {
|
2024-12-10 13:42:01 +01:00
|
|
|
const data = _.omit(this.formData, [
|
2023-10-10 12:02:40 +02:00
|
|
|
'is_super_user',
|
|
|
|
'lnbits_allowed_funding_sources'
|
|
|
|
])
|
|
|
|
LNbits.api
|
|
|
|
.request(
|
|
|
|
'PUT',
|
2024-04-04 07:54:21 +02:00
|
|
|
'/admin/api/v1/settings',
|
2023-10-10 12:02:40 +02:00
|
|
|
this.g.user.wallets[0].adminkey,
|
|
|
|
data
|
|
|
|
)
|
|
|
|
.then(response => {
|
|
|
|
this.needsRestart =
|
|
|
|
this.settings.lnbits_backend_wallet_class !==
|
|
|
|
this.formData.lnbits_backend_wallet_class ||
|
|
|
|
this.settings.lnbits_killswitch !== this.formData.lnbits_killswitch
|
|
|
|
this.settings = this.formData
|
|
|
|
this.formData = _.clone(this.settings)
|
2024-09-24 16:18:56 +02:00
|
|
|
Quasar.Notify.create({
|
2023-10-10 12:02:40 +02:00
|
|
|
type: 'positive',
|
|
|
|
message: `Success! Settings changed! ${
|
|
|
|
this.needsRestart ? 'Restart required!' : ''
|
|
|
|
}`,
|
|
|
|
icon: null
|
|
|
|
})
|
|
|
|
})
|
2024-12-10 13:42:01 +01:00
|
|
|
.catch(LNbits.utils.notifyApiError)
|
2023-10-10 12:02:40 +02:00
|
|
|
},
|
|
|
|
deleteSettings() {
|
|
|
|
LNbits.utils
|
|
|
|
.confirmDialog('Are you sure you want to restore settings to default?')
|
|
|
|
.onOk(() => {
|
|
|
|
LNbits.api
|
2024-04-04 07:54:21 +02:00
|
|
|
.request('DELETE', '/admin/api/v1/settings')
|
2023-10-10 12:02:40 +02:00
|
|
|
.then(response => {
|
2024-09-24 16:18:56 +02:00
|
|
|
Quasar.Notify.create({
|
2023-10-10 12:02:40 +02:00
|
|
|
type: 'positive',
|
|
|
|
message:
|
|
|
|
'Success! Restored settings to defaults, restart required!',
|
|
|
|
icon: null
|
|
|
|
})
|
|
|
|
this.needsRestart = true
|
|
|
|
})
|
2024-12-10 13:42:01 +01:00
|
|
|
.catch(LNbits.utils.notifyApiError)
|
2023-10-10 12:02:40 +02:00
|
|
|
})
|
|
|
|
},
|
|
|
|
downloadBackup() {
|
2024-04-04 07:54:21 +02:00
|
|
|
window.open('/admin/api/v1/backup', '_blank')
|
2023-10-10 12:02:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|