2022-03-07 05:03:32 +00:00
|
|
|
{% extends "base.html" %} {% from "macros.jinja" import window_vars with context
|
|
|
|
%} {% block page %}
|
2022-10-03 22:14:07 +02:00
|
|
|
<div class="row q-col-gutter-md justify-center">
|
2022-10-13 15:52:02 +01:00
|
|
|
<div class="col q-my-md">
|
|
|
|
<q-btn
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('save')"
|
2022-10-13 15:52:02 +01:00
|
|
|
color="primary"
|
|
|
|
@click="updateSettings"
|
|
|
|
:disabled="!checkChanges"
|
|
|
|
>
|
2023-04-05 12:51:05 +02:00
|
|
|
<q-tooltip v-if="checkChanges"
|
|
|
|
>{%raw%}{{ $t('save_tooltip') }}{%endraw%}</q-tooltip
|
|
|
|
>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-12 19:04:46 +01:00
|
|
|
<q-badge
|
|
|
|
v-if="checkChanges"
|
|
|
|
color="red"
|
|
|
|
rounded
|
|
|
|
floating
|
|
|
|
style="padding: 6px; border-radius: 6px"
|
|
|
|
/>
|
2022-10-07 18:39:53 +01:00
|
|
|
</q-btn>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-12-14 16:09:27 +00:00
|
|
|
<q-btn
|
|
|
|
v-if="isSuperUser"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('restart')"
|
2022-12-14 16:09:27 +00:00
|
|
|
color="primary"
|
|
|
|
@click="restartServer"
|
|
|
|
>
|
2023-04-05 12:51:05 +02:00
|
|
|
<q-tooltip v-if="needsRestart"
|
|
|
|
>{%raw%}{{ $t('restart_tooltip') }}{%endraw%}</q-tooltip
|
|
|
|
>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-13 15:52:02 +01:00
|
|
|
<q-badge
|
|
|
|
v-if="needsRestart"
|
|
|
|
color="red"
|
|
|
|
rounded
|
|
|
|
floating
|
|
|
|
style="padding: 6px; border-radius: 6px"
|
|
|
|
/>
|
|
|
|
</q-btn>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-12-14 16:09:27 +00:00
|
|
|
<q-btn
|
|
|
|
v-if="isSuperUser"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('topup')"
|
2022-12-14 16:09:27 +00:00
|
|
|
color="primary"
|
|
|
|
@click="topUpDialog.show = true"
|
|
|
|
>
|
2023-04-05 12:51:05 +02:00
|
|
|
<q-tooltip>{%raw%}{{ $t('add_funds_tooltip') }}{%endraw%}</q-tooltip>
|
2022-10-13 15:52:02 +01:00
|
|
|
</q-btn>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2023-04-05 12:51:05 +02:00
|
|
|
<q-btn :label="$t('download_backup')" flat @click="downloadBackup"></q-btn>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-13 15:52:02 +01:00
|
|
|
<q-btn
|
|
|
|
flat
|
2022-12-06 16:08:21 +00:00
|
|
|
v-if="isSuperUser"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('reset_defaults')"
|
2022-10-13 15:52:02 +01:00
|
|
|
color="primary"
|
|
|
|
@click="deleteSettings"
|
|
|
|
class="float-right"
|
|
|
|
>
|
2023-04-05 12:51:05 +02:00
|
|
|
<q-tooltip>{%raw%}{{ $t('reset_defaults_tooltip') }}{%endraw%}</q-tooltip>
|
2022-10-13 15:52:02 +01:00
|
|
|
</q-btn>
|
2022-10-03 22:14:07 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-03-18 16:55:31 +00:00
|
|
|
<div class="row q-col-gutter-md justify-center">
|
|
|
|
<div class="col q-gutter-y-md">
|
|
|
|
<q-card>
|
|
|
|
<div class="q-pa-md">
|
|
|
|
<div class="q-gutter-y-md">
|
|
|
|
<q-tabs v-model="tab" active-color="primary" align="justify">
|
|
|
|
<q-tab
|
|
|
|
name="funding"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('funding')"
|
2022-03-18 16:55:31 +00:00
|
|
|
@update="val => tab = val.name"
|
|
|
|
></q-tab>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-03-18 16:55:31 +00:00
|
|
|
<q-tab
|
|
|
|
name="users"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('users')"
|
2022-03-18 16:55:31 +00:00
|
|
|
@update="val => tab = val.name"
|
|
|
|
></q-tab>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-03-18 16:55:31 +00:00
|
|
|
<q-tab
|
|
|
|
name="server"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('server')"
|
2022-03-18 16:55:31 +00:00
|
|
|
@update="val => tab = val.name"
|
|
|
|
></q-tab>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2023-06-20 10:26:33 +01:00
|
|
|
<q-tab
|
|
|
|
name="security"
|
|
|
|
:label="$t('security')"
|
|
|
|
@update="val => tab = val.name"
|
|
|
|
></q-tab>
|
|
|
|
|
2022-03-18 16:55:31 +00:00
|
|
|
<q-tab
|
|
|
|
name="theme"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('theme')"
|
2022-03-18 16:55:31 +00:00
|
|
|
@update="val => tab = val.name"
|
|
|
|
></q-tab>
|
|
|
|
</q-tabs>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-05 09:19:07 +02:00
|
|
|
<q-form name="settings_form" id="settings_form">
|
2022-04-14 16:37:13 +01:00
|
|
|
<q-tab-panels v-model="tab" animated>
|
2022-10-03 16:36:14 +02:00
|
|
|
{% include "admin/_tab_funding.html" %} {% include
|
|
|
|
"admin/_tab_users.html" %} {% include "admin/_tab_server.html" %} {%
|
2023-06-20 10:26:33 +01:00
|
|
|
include "admin/_tab_security.html" %} {% include
|
|
|
|
"admin/_tab_theme.html" %}
|
2022-04-14 16:37:13 +01:00
|
|
|
</q-tab-panels>
|
|
|
|
</q-form>
|
2022-03-18 16:55:31 +00:00
|
|
|
</q-card>
|
|
|
|
</div>
|
2022-04-14 16:37:13 +01:00
|
|
|
</div>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-12-14 16:09:27 +00:00
|
|
|
<q-dialog v-if="isSuperUser" v-model="topUpDialog.show" position="top">
|
2022-10-07 18:39:53 +01:00
|
|
|
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
|
|
|
<q-form class="q-gutter-md">
|
2023-04-05 12:51:05 +02:00
|
|
|
<p v-text="$t('topup_wallet')"></p>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-07 18:39:53 +01:00
|
|
|
<div class="row">
|
|
|
|
<div class="col-12">
|
|
|
|
<q-input
|
|
|
|
dense
|
|
|
|
type="text"
|
|
|
|
filled
|
|
|
|
v-model="wallet.id"
|
|
|
|
label="Wallet ID"
|
2023-04-05 12:51:05 +02:00
|
|
|
:hint="$t('topup_hint')"
|
2022-10-07 18:39:53 +01:00
|
|
|
></q-input>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-07 18:39:53 +01:00
|
|
|
<br />
|
|
|
|
</div>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-07 18:39:53 +01:00
|
|
|
<div class="col-12">
|
|
|
|
<q-input
|
|
|
|
dense
|
|
|
|
type="number"
|
|
|
|
filled
|
|
|
|
v-model="wallet.amount"
|
2023-04-05 12:51:05 +02:00
|
|
|
:label="$t('amount')"
|
2022-10-07 18:39:53 +01:00
|
|
|
></q-input>
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-01-26 11:08:40 +01:00
|
|
|
|
2022-10-07 18:39:53 +01:00
|
|
|
<div class="row q-mt-lg">
|
2023-04-05 12:51:05 +02:00
|
|
|
<q-btn
|
|
|
|
:label="$t('topup')"
|
|
|
|
color="primary"
|
|
|
|
@click="topupWallet"
|
|
|
|
></q-btn>
|
|
|
|
|
|
|
|
<q-btn
|
|
|
|
v-close-popup
|
|
|
|
flat
|
|
|
|
color="grey"
|
|
|
|
class="q-ml-auto"
|
|
|
|
:label="$t('cancel')"
|
|
|
|
></q-btn>
|
2022-10-07 18:39:53 +01:00
|
|
|
</div>
|
|
|
|
</q-form>
|
|
|
|
</q-card>
|
|
|
|
</q-dialog>
|
2022-03-07 05:03:32 +00:00
|
|
|
{% endblock %} {% block scripts %} {{ window_vars(user) }}
|
|
|
|
<script>
|
|
|
|
new Vue({
|
|
|
|
el: '#vue',
|
|
|
|
mixins: [windowMixin],
|
|
|
|
data: function () {
|
|
|
|
return {
|
2022-10-03 22:14:07 +02:00
|
|
|
settings: {},
|
2023-06-20 10:26:33 +01:00
|
|
|
logs: [],
|
|
|
|
serverlogEnabled: false,
|
2022-12-16 22:44:18 +00:00
|
|
|
lnbits_theme_options: [
|
2023-01-10 17:35:43 +01:00
|
|
|
'classic',
|
|
|
|
'bitcoin',
|
|
|
|
'flamingo',
|
2023-02-20 22:41:11 +00:00
|
|
|
'cyber',
|
2023-01-10 17:35:43 +01:00
|
|
|
'freedom',
|
|
|
|
'mint',
|
|
|
|
'autumn',
|
|
|
|
'monochrome',
|
|
|
|
'salvador'
|
|
|
|
],
|
2023-06-20 10:26:33 +01:00
|
|
|
auditData: {},
|
|
|
|
statusData: {},
|
|
|
|
statusDataTable: {
|
|
|
|
columns: [
|
|
|
|
{
|
|
|
|
name: 'date',
|
|
|
|
align: 'left',
|
|
|
|
label: this.$t('date'),
|
|
|
|
field: 'date'
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'message',
|
|
|
|
align: 'left',
|
|
|
|
label: this.$t('memo'),
|
|
|
|
field: 'message'
|
|
|
|
}
|
|
|
|
]
|
|
|
|
},
|
2022-10-07 18:39:53 +01:00
|
|
|
formData: {},
|
2022-12-06 16:08:21 +00:00
|
|
|
formAddAdmin: '',
|
|
|
|
formAddUser: '',
|
2023-01-11 16:36:12 +02:00
|
|
|
formAddExtensionsManifest: '',
|
2023-06-20 10:26:33 +01:00
|
|
|
formAllowedIPs: '',
|
|
|
|
formBlockedIPs: '',
|
2022-12-06 16:08:21 +00:00
|
|
|
isSuperUser: false,
|
2022-10-03 22:14:07 +02:00
|
|
|
wallet: {},
|
2022-03-07 05:03:32 +00:00
|
|
|
cancel: {},
|
2022-10-07 18:39:53 +01:00
|
|
|
topUpDialog: {
|
|
|
|
show: false
|
|
|
|
},
|
2022-10-12 19:04:46 +01:00
|
|
|
tab: 'funding',
|
2022-10-13 15:52:02 +01:00
|
|
|
needsRestart: false,
|
2022-10-12 19:04:46 +01:00
|
|
|
funding_sources: new Map([
|
|
|
|
['VoidWallet', null],
|
|
|
|
[
|
|
|
|
'FakeWallet',
|
|
|
|
{
|
|
|
|
fake_wallet_secret: {
|
|
|
|
value: null,
|
|
|
|
label: 'Secret'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
2023-01-26 11:08:40 +01:00
|
|
|
'CoreLightningWallet',
|
2022-10-12 19:04:46 +01:00
|
|
|
{
|
|
|
|
corelightning_rpc: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2023-08-23 08:59:39 +02:00
|
|
|
[
|
|
|
|
'CoreLightningRestWallet',
|
|
|
|
{
|
|
|
|
corelightning_rest_url: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
|
|
|
corelightning_rest_cert: {
|
|
|
|
value: null,
|
|
|
|
label: 'Certificate'
|
|
|
|
},
|
|
|
|
corelightning_rest_macaroon: {
|
|
|
|
value: null,
|
|
|
|
label: 'Macaroon'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
2022-10-12 19:04:46 +01:00
|
|
|
[
|
|
|
|
'LndRestWallet',
|
|
|
|
{
|
|
|
|
lnd_rest_endpoint: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
|
|
|
lnd_rest_cert: {
|
|
|
|
value: null,
|
|
|
|
label: 'Certificate'
|
|
|
|
},
|
|
|
|
lnd_rest_macaroon: {
|
|
|
|
value: null,
|
|
|
|
label: 'Macaroon'
|
|
|
|
},
|
|
|
|
lnd_rest_macaroon_encrypted: {
|
|
|
|
value: null,
|
|
|
|
label: 'Encrypted Macaroon'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'LndWallet',
|
|
|
|
{
|
|
|
|
lnd_grpc_endpoint: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
|
|
|
lnd_grpc_cert: {
|
|
|
|
value: null,
|
|
|
|
label: 'Certificate'
|
|
|
|
},
|
|
|
|
lnd_grpc_port: {
|
|
|
|
value: null,
|
|
|
|
label: 'Port'
|
|
|
|
},
|
|
|
|
lnd_grpc_admin_macaroon: {
|
|
|
|
value: null,
|
|
|
|
label: 'Admin Macaroon'
|
|
|
|
},
|
|
|
|
lnd_grpc_macaroon_encrypted: {
|
|
|
|
value: null,
|
|
|
|
label: 'Encrypted Macaroon'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
2023-01-26 11:08:40 +01:00
|
|
|
'LnTipsWallet',
|
2022-10-12 19:04:46 +01:00
|
|
|
{
|
2023-01-26 11:08:40 +01:00
|
|
|
lntips_api_endpoint: {
|
2022-10-12 19:04:46 +01:00
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
2023-01-26 11:08:40 +01:00
|
|
|
lntips_api_key: {
|
2022-10-12 19:04:46 +01:00
|
|
|
value: null,
|
2023-01-26 11:08:40 +01:00
|
|
|
label: 'API Key'
|
2022-10-12 19:04:46 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'LNPayWallet',
|
|
|
|
{
|
|
|
|
lnpay_api_endpoint: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
|
|
|
lnpay_api_key: {
|
|
|
|
value: null,
|
|
|
|
label: 'API Key'
|
|
|
|
},
|
|
|
|
lnpay_wallet_key: {
|
|
|
|
value: null,
|
|
|
|
label: 'Wallet Key'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'EclairWallet',
|
|
|
|
{
|
|
|
|
eclair_url: {
|
|
|
|
value: null,
|
2023-01-26 11:08:40 +01:00
|
|
|
label: 'URL'
|
2022-10-12 19:04:46 +01:00
|
|
|
},
|
|
|
|
eclair_pass: {
|
|
|
|
value: null,
|
|
|
|
label: 'Password'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
2022-11-30 23:47:52 +01:00
|
|
|
'LNbitsWallet',
|
2022-10-12 19:04:46 +01:00
|
|
|
{
|
|
|
|
lnbits_endpoint: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
|
|
|
lnbits_key: {
|
|
|
|
value: null,
|
|
|
|
label: 'Admin Key'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'OpenNodeWallet',
|
|
|
|
{
|
|
|
|
opennode_api_endpoint: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
|
|
|
opennode_key: {
|
|
|
|
value: null,
|
|
|
|
label: 'Key'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'ClicheWallet',
|
|
|
|
{
|
|
|
|
cliche_endpoint: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
],
|
|
|
|
[
|
|
|
|
'SparkWallet',
|
|
|
|
{
|
|
|
|
spark_url: {
|
|
|
|
value: null,
|
|
|
|
label: 'Endpoint'
|
|
|
|
},
|
|
|
|
spark_token: {
|
|
|
|
value: null,
|
|
|
|
label: 'Token'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
])
|
2022-03-07 05:03:32 +00:00
|
|
|
}
|
|
|
|
},
|
2023-07-21 08:50:18 +01:00
|
|
|
created() {
|
2022-10-21 11:13:40 +02:00
|
|
|
this.getSettings()
|
2023-06-20 10:26:33 +01:00
|
|
|
this.getAudit()
|
2022-10-07 18:39:53 +01:00
|
|
|
this.balance = +'{{ balance|safe }}'
|
2022-03-07 05:03:32 +00:00
|
|
|
},
|
2022-10-10 12:17:35 +01:00
|
|
|
computed: {
|
2023-06-20 10:26:33 +01:00
|
|
|
lnbitsVersion() {
|
|
|
|
return LNBITS_VERSION
|
|
|
|
},
|
2022-10-12 19:04:46 +01:00
|
|
|
checkChanges() {
|
2022-10-10 12:17:35 +01:00
|
|
|
return !_.isEqual(this.settings, this.formData)
|
2023-06-20 10:26:33 +01:00
|
|
|
},
|
|
|
|
updateAvailable() {
|
|
|
|
return LNBITS_VERSION !== this.statusData.version
|
2022-10-13 15:52:02 +01:00
|
|
|
}
|
2022-10-07 19:44:03 +01:00
|
|
|
},
|
2022-03-07 05:03:32 +00:00
|
|
|
methods: {
|
2022-04-14 16:37:13 +01:00
|
|
|
addAdminUser() {
|
2022-12-06 16:08:21 +00:00
|
|
|
let addUser = this.formAddAdmin
|
|
|
|
let admin_users = this.formData.lnbits_admin_users
|
2022-09-22 15:55:37 +02:00
|
|
|
if (addUser && addUser.length && !admin_users.includes(addUser)) {
|
2022-12-06 16:08:21 +00:00
|
|
|
//admin_users = [...admin_users, addUser]
|
|
|
|
this.formData.lnbits_admin_users = [...admin_users, addUser]
|
|
|
|
this.formAddAdmin = ''
|
2022-03-18 16:55:31 +00:00
|
|
|
}
|
|
|
|
},
|
2022-04-14 16:37:13 +01:00
|
|
|
removeAdminUser(user) {
|
2022-12-06 16:08:21 +00:00
|
|
|
let admin_users = this.formData.lnbits_admin_users
|
|
|
|
this.formData.lnbits_admin_users = admin_users.filter(u => u !== user)
|
2022-03-18 16:55:31 +00:00
|
|
|
},
|
2022-04-14 16:37:13 +01:00
|
|
|
addAllowedUser() {
|
2022-12-06 16:08:21 +00:00
|
|
|
let addUser = this.formAddUser
|
|
|
|
let allowed_users = this.formData.lnbits_allowed_users
|
2022-09-22 15:55:37 +02:00
|
|
|
if (addUser && addUser.length && !allowed_users.includes(addUser)) {
|
2022-12-06 16:08:21 +00:00
|
|
|
this.formData.lnbits_allowed_users = [...allowed_users, addUser]
|
|
|
|
this.formAddUser = ''
|
2022-03-18 16:55:31 +00:00
|
|
|
}
|
|
|
|
},
|
2022-04-14 16:37:13 +01:00
|
|
|
removeAllowedUser(user) {
|
2022-12-06 16:08:21 +00:00
|
|
|
let allowed_users = this.formData.lnbits_allowed_users
|
|
|
|
this.formData.lnbits_allowed_users = allowed_users.filter(
|
2022-10-12 19:04:46 +01:00
|
|
|
u => u !== user
|
|
|
|
)
|
2022-03-18 16:55:31 +00:00
|
|
|
},
|
2023-01-11 16:36:12 +02:00
|
|
|
addExtensionsManifest() {
|
2023-01-25 21:20:20 +00:00
|
|
|
const addManifest = this.formAddExtensionsManifest.trim()
|
2023-01-11 16:36:12 +02:00
|
|
|
const manifests = this.formData.lnbits_extensions_manifests
|
2023-02-20 11:40:10 +01:00
|
|
|
if (
|
|
|
|
addManifest &&
|
|
|
|
addManifest.length &&
|
|
|
|
!manifests.includes(addManifest)
|
|
|
|
) {
|
|
|
|
this.formData.lnbits_extensions_manifests = [
|
|
|
|
...manifests,
|
|
|
|
addManifest
|
|
|
|
]
|
2023-01-11 16:36:12 +02:00
|
|
|
this.formAddExtensionsManifest = ''
|
|
|
|
}
|
|
|
|
},
|
|
|
|
removeExtensionsManifest(manifest) {
|
|
|
|
const manifests = this.formData.lnbits_extensions_manifests
|
2023-02-20 11:40:10 +01:00
|
|
|
this.formData.lnbits_extensions_manifests = manifests.filter(
|
|
|
|
m => m !== manifest
|
|
|
|
)
|
2023-01-11 16:36:12 +02:00
|
|
|
},
|
2023-06-20 10:26:33 +01:00
|
|
|
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
|
|
|
|
)
|
|
|
|
},
|
2022-09-27 16:37:08 +02:00
|
|
|
restartServer() {
|
|
|
|
LNbits.api
|
2022-10-07 18:39:53 +01:00
|
|
|
.request('GET', '/admin/api/v1/restart/?usr=' + this.g.user.id)
|
2022-09-27 16:37:08 +02:00
|
|
|
.then(response => {
|
|
|
|
this.$q.notify({
|
|
|
|
type: 'positive',
|
|
|
|
message: 'Success! Restarted Server',
|
|
|
|
icon: null
|
|
|
|
})
|
2022-10-13 15:52:02 +01:00
|
|
|
this.needsRestart = false
|
2022-09-27 16:37:08 +02:00
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
})
|
|
|
|
},
|
2022-03-22 10:29:18 +00:00
|
|
|
topupWallet() {
|
2022-03-07 05:03:32 +00:00
|
|
|
LNbits.api
|
|
|
|
.request(
|
2022-10-12 13:08:59 +02:00
|
|
|
'PUT',
|
2022-10-05 09:19:07 +02:00
|
|
|
'/admin/api/v1/topup/?usr=' + this.g.user.id,
|
2022-10-12 13:08:59 +02:00
|
|
|
this.g.user.wallets[0].adminkey,
|
|
|
|
this.wallet
|
2022-03-07 05:03:32 +00:00
|
|
|
)
|
2022-04-14 16:37:13 +01:00
|
|
|
.then(response => {
|
2022-03-22 10:29:18 +00:00
|
|
|
this.$q.notify({
|
2022-03-07 05:03:32 +00:00
|
|
|
type: 'positive',
|
|
|
|
message:
|
2022-04-14 16:37:13 +01:00
|
|
|
'Success! Added ' +
|
2022-10-03 22:14:07 +02:00
|
|
|
this.wallet.amount +
|
2022-04-14 16:37:13 +01:00
|
|
|
' to ' +
|
2022-10-03 22:14:07 +02:00
|
|
|
this.wallet.id,
|
2022-03-07 05:03:32 +00:00
|
|
|
icon: null
|
|
|
|
})
|
2022-10-03 22:14:07 +02:00
|
|
|
this.wallet = {}
|
2022-03-07 05:03:32 +00:00
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
})
|
|
|
|
},
|
2022-10-13 15:52:02 +01:00
|
|
|
updateFundingData() {
|
2022-10-12 19:04:46 +01:00
|
|
|
this.settings.lnbits_allowed_funding_sources.map(f => {
|
|
|
|
let opts = this.funding_sources.get(f)
|
|
|
|
if (!opts) return
|
|
|
|
Object.keys(opts).forEach(e => {
|
|
|
|
opts[e].value = this.settings[e]
|
|
|
|
})
|
|
|
|
})
|
2022-10-21 11:13:40 +02:00
|
|
|
},
|
2023-06-20 10:26:33 +01: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
|
|
|
|
.request(
|
|
|
|
'GET',
|
|
|
|
'/admin/api/v1/audit/?usr=' + this.g.user.id,
|
|
|
|
this.g.user.wallets[0].adminkey
|
|
|
|
)
|
|
|
|
.then(response => {
|
|
|
|
this.auditData = response.data
|
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
})
|
|
|
|
},
|
2022-10-21 11:13:40 +02:00
|
|
|
getSettings() {
|
|
|
|
LNbits.api
|
|
|
|
.request(
|
|
|
|
'GET',
|
|
|
|
'/admin/api/v1/settings/?usr=' + this.g.user.id,
|
|
|
|
this.g.user.wallets[0].adminkey
|
|
|
|
)
|
|
|
|
.then(response => {
|
2023-05-09 11:20:51 +03:00
|
|
|
this.isSuperUser = response.data.is_super_user || false
|
2022-10-21 11:13:40 +02:00
|
|
|
this.settings = response.data
|
2023-07-21 08:50:18 +01:00
|
|
|
this.formData = {...this.settings}
|
2022-10-21 11:13:40 +02:00
|
|
|
this.updateFundingData()
|
2023-06-20 10:26:33 +01:00
|
|
|
this.getNotifications()
|
2022-10-21 11:13:40 +02:00
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
})
|
2022-10-12 19:04:46 +01:00
|
|
|
},
|
2022-10-03 22:14:07 +02:00
|
|
|
updateSettings() {
|
2022-12-06 16:08:21 +00:00
|
|
|
let data = _.omit(this.formData, [
|
2023-05-09 11:20:51 +03:00
|
|
|
'is_super_user',
|
2022-12-06 16:08:21 +00:00
|
|
|
'lnbits_allowed_funding_sources'
|
|
|
|
])
|
2022-03-07 05:03:32 +00:00
|
|
|
LNbits.api
|
|
|
|
.request(
|
2022-10-03 22:14:07 +02:00
|
|
|
'PUT',
|
2022-10-05 09:19:07 +02:00
|
|
|
'/admin/api/v1/settings/?usr=' + this.g.user.id,
|
2022-03-22 10:29:18 +00:00
|
|
|
this.g.user.wallets[0].adminkey,
|
2022-03-12 14:18:09 +00:00
|
|
|
data
|
2022-03-07 05:03:32 +00:00
|
|
|
)
|
2022-03-22 10:29:18 +00:00
|
|
|
.then(response => {
|
2022-12-01 10:57:42 +00:00
|
|
|
this.needsRestart =
|
|
|
|
this.settings.lnbits_backend_wallet_class !==
|
2023-07-03 16:52:33 +02:00
|
|
|
this.formData.lnbits_backend_wallet_class ||
|
|
|
|
this.settings.lnbits_killswitch !==
|
|
|
|
this.formData.lnbits_killswitch
|
2022-12-06 16:08:21 +00:00
|
|
|
this.settings = this.formData
|
2022-10-10 12:17:35 +01:00
|
|
|
this.formData = _.clone(this.settings)
|
2022-10-12 19:04:46 +01:00
|
|
|
this.updateFundingData()
|
2022-03-22 10:29:18 +00:00
|
|
|
this.$q.notify({
|
2022-03-07 05:03:32 +00:00
|
|
|
type: 'positive',
|
2023-07-21 08:50:18 +01:00
|
|
|
message: `Success! Settings changed! ${
|
|
|
|
this.needsRestart ? 'Restart required!' : ''
|
|
|
|
}`,
|
2022-03-07 05:03:32 +00:00
|
|
|
icon: null
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
2022-10-07 18:39:53 +01:00
|
|
|
})
|
2022-10-05 09:19:07 +02:00
|
|
|
},
|
|
|
|
deleteSettings() {
|
2022-10-13 15:52:02 +01:00
|
|
|
LNbits.utils
|
|
|
|
.confirmDialog(
|
|
|
|
'Are you sure you want to restore settings to default?'
|
|
|
|
)
|
|
|
|
.onOk(() => {
|
|
|
|
LNbits.api
|
|
|
|
.request(
|
|
|
|
'DELETE',
|
|
|
|
'/admin/api/v1/settings/?usr=' + this.g.user.id
|
|
|
|
)
|
|
|
|
.then(response => {
|
|
|
|
this.$q.notify({
|
|
|
|
type: 'positive',
|
|
|
|
message:
|
|
|
|
'Success! Restored settings to defaults, restart required!',
|
|
|
|
icon: null
|
|
|
|
})
|
|
|
|
this.needsRestart = true
|
|
|
|
})
|
|
|
|
.catch(function (error) {
|
|
|
|
LNbits.utils.notifyApiError(error)
|
|
|
|
})
|
2022-10-07 18:39:53 +01:00
|
|
|
})
|
2022-10-05 09:19:07 +02:00
|
|
|
},
|
|
|
|
downloadBackup() {
|
2023-03-02 15:22:39 +01:00
|
|
|
window.open('/admin/api/v1/backup/?usr=' + this.g.user.id, '_blank')
|
2022-03-07 05:03:32 +00:00
|
|
|
}
|
2022-10-12 19:04:46 +01:00
|
|
|
}
|
2022-03-07 05:03:32 +00:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
{% endblock %}
|