chore: cleanup base.html, minor issue and g.user initialisation (#3615)
Co-authored-by: Vlad Stan <stan.v.vlad@gmail.com>
This commit is contained in:
parent
1fe35070f4
commit
73634e5161
8 changed files with 24 additions and 25 deletions
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
|
|
@ -50,9 +50,6 @@ window.LNbits = {
|
||||||
}
|
}
|
||||||
newWallet.msat = data.balance_msat
|
newWallet.msat = data.balance_msat
|
||||||
newWallet.sat = Math.floor(data.balance_msat / 1000)
|
newWallet.sat = Math.floor(data.balance_msat / 1000)
|
||||||
newWallet.fsat = new Intl.NumberFormat(window.i18n.global.locale).format(
|
|
||||||
newWallet.sat
|
|
||||||
)
|
|
||||||
if (newWallet.walletType === 'lightning-shared') {
|
if (newWallet.walletType === 'lightning-shared') {
|
||||||
const perms = newWallet.sharePermissions
|
const perms = newWallet.sharePermissions
|
||||||
newWallet.canReceivePayments = perms.includes('receive-payments')
|
newWallet.canReceivePayments = perms.includes('receive-payments')
|
||||||
|
|
|
||||||
|
|
@ -360,7 +360,7 @@ window.app.component('lnbits-update-balance', {
|
||||||
props: ['wallet_id', 'small_btn'],
|
props: ['wallet_id', 'small_btn'],
|
||||||
computed: {
|
computed: {
|
||||||
admin() {
|
admin() {
|
||||||
return user.super_user
|
return this.g.user?.super_user === true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,7 @@ window.PageExtensions = {
|
||||||
selectedRelease: null,
|
selectedRelease: null,
|
||||||
uninstallAndDropDb: false,
|
uninstallAndDropDb: false,
|
||||||
maxStars: 5,
|
maxStars: 5,
|
||||||
paylinkWebsocket: null,
|
paylinkWebsocket: null
|
||||||
user: null
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
|
|
@ -636,7 +635,7 @@ window.PageExtensions = {
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
this.extensions = await this.fetchAllExtensions()
|
this.extensions = await this.fetchAllExtensions()
|
||||||
this.extbuilderEnabled = user.admin || this.LNBITS_EXT_BUILDER
|
this.extbuilderEnabled = this.g.user.admin || this.LNBITS_EXT_BUILDER
|
||||||
|
|
||||||
const extId = window.location.hash.replace('#', '')
|
const extId = window.location.hash.replace('#', '')
|
||||||
const ext = this.extensions.find(ext => ext.id === extId)
|
const ext = this.extensions.find(ext => ext.id === extId)
|
||||||
|
|
|
||||||
|
|
@ -20,14 +20,12 @@ window.windowMixin = {
|
||||||
console.error('ws message no payment', data)
|
console.error('ws message no payment', data)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// update sidebar wallet balances
|
// update sidebar wallet balances
|
||||||
this.g.user.wallets.forEach(w => {
|
this.g.user.wallets.forEach(w => {
|
||||||
if (w.id === data.payment.wallet_id) {
|
if (w.id === data.payment.wallet_id) {
|
||||||
w.sat = data.wallet_balance
|
w.sat = data.wallet_balance
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
// if current wallet, update balance and payments
|
// if current wallet, update balance and payments
|
||||||
if (this.g.wallet.id === data.payment.wallet_id) {
|
if (this.g.wallet.id === data.payment.wallet_id) {
|
||||||
this.g.wallet.sat = data.wallet_balance
|
this.g.wallet.sat = data.wallet_balance
|
||||||
|
|
@ -35,7 +33,6 @@ window.windowMixin = {
|
||||||
this.g.updatePayments = !this.g.updatePayments
|
this.g.updatePayments = !this.g.updatePayments
|
||||||
this.g.updatePaymentsHash = !this.g.updatePaymentsHash
|
this.g.updatePaymentsHash = !this.g.updatePaymentsHash
|
||||||
}
|
}
|
||||||
|
|
||||||
// NOTE: react only on incoming payments for now
|
// NOTE: react only on incoming payments for now
|
||||||
if (data.payment.amount > 0) {
|
if (data.payment.amount > 0) {
|
||||||
eventReaction(data.wallet_balance * 1000)
|
eventReaction(data.wallet_balance * 1000)
|
||||||
|
|
@ -72,9 +69,7 @@ window.windowMixin = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// map jinja variable once on pageload
|
if (this.g.user && this.g.walletEventListeners.length === 0) {
|
||||||
if (window.user && !this.g.user) {
|
|
||||||
this.g.user = window.LNbits.map.user(window.user)
|
|
||||||
this.paymentEvents()
|
this.paymentEvents()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
<lnbits-wallet-new></lnbits-wallet-new>
|
<lnbits-wallet-new></lnbits-wallet-new>
|
||||||
<lnbits-header-wallets></lnbits-header-wallets>
|
<lnbits-header-wallets></lnbits-header-wallets>
|
||||||
<router-view v-if="isVueRoute" :key="$route.path"></router-view>
|
<router-view v-if="isVueRoute" :key="$route.path"></router-view>
|
||||||
<!-- FastAPI Content -->
|
<!-- FastAPI Content from extensions -->
|
||||||
<div v-else>{% block page %}{% endblock %}</div>
|
<div v-else>{% block page %}{% endblock %}</div>
|
||||||
</q-page>
|
</q-page>
|
||||||
</q-page-container>
|
</q-page-container>
|
||||||
|
|
@ -60,11 +60,24 @@
|
||||||
window[key] = WINDOW_SETTINGS[key]
|
window[key] = WINDOW_SETTINGS[key]
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
{% include('components.vue') %} {% include('pages.vue') %} {% block
|
<!-- vue templates -->
|
||||||
vue_templates %}{% endblock %} {% for url in INCLUDED_JS %}
|
{% include('components.vue') %} {% include('pages.vue') %}
|
||||||
|
<!-- vue extension templates -->
|
||||||
|
{% block vue_templates %}{% endblock %}
|
||||||
|
<!-- scripts libraries -->
|
||||||
|
{% for url in INCLUDED_JS %}
|
||||||
<script src="{{ static_url_for('static', url) }}"></script>
|
<script src="{{ static_url_for('static', url) }}"></script>
|
||||||
{% endfor %} {% block scripts %}{% endblock %} {% for url in
|
{% endfor %}
|
||||||
INCLUDED_COMPONENTS %}
|
<!-- user init -->
|
||||||
|
{% if user %}
|
||||||
|
<script>
|
||||||
|
window.g.user = LNbits.map.user(JSON.parse({{ user | tojson | safe }}));
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
<!-- scripts from extensions -->
|
||||||
|
{% block scripts %}{% endblock %}
|
||||||
|
<!-- components js -->
|
||||||
|
{% for url in INCLUDED_COMPONENTS %}
|
||||||
<script src="{{ static_url_for('static', url) }}"></script>
|
<script src="{{ static_url_for('static', url) }}"></script>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,4 @@
|
||||||
{% macro window_vars(user) -%}
|
{% macro window_vars(user) -%}
|
||||||
<script id="window-vars-script">
|
|
||||||
{% if user %}
|
|
||||||
window.user = JSON.parse({{ user | tojson | safe }});
|
|
||||||
{% endif %}
|
|
||||||
</script>
|
|
||||||
<script>
|
<script>
|
||||||
//Needed for Vue to create the app on first load (although called on every page, its only loaded once)
|
//Needed for Vue to create the app on first load (although called on every page, its only loaded once)
|
||||||
window.app = Vue.createApp({
|
window.app = Vue.createApp({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue