mirror of
https://github.com/lnbits/lnbits.git
synced 2025-03-28 18:52:00 +01:00
working
This commit is contained in:
parent
8d1542d982
commit
c7c1af9465
@ -83,7 +83,9 @@
|
|||||||
<small> {{LNBITS_DENOMINATION}}</small>
|
<small> {{LNBITS_DENOMINATION}}</small>
|
||||||
</h6>
|
</h6>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
</q-scroll-area>
|
</q-scroll-area>
|
||||||
@ -95,7 +97,11 @@
|
|||||||
, width: $q.screen.lt.md && mobileSimple ? '90% !important': ''
|
, width: $q.screen.lt.md && mobileSimple ? '90% !important': ''
|
||||||
} : ''"
|
} : ''"
|
||||||
>
|
>
|
||||||
|
<div v-show="$q.screen.gt.sm" style="width: 100%; height: 100%;" class="absolute float-left">
|
||||||
|
<canvas ref="transactionChart"></canvas>
|
||||||
|
</div>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
|
|
||||||
<h3 class="q-my-none text-no-wrap">
|
<h3 class="q-my-none text-no-wrap">
|
||||||
<strong v-text="formattedBalance"></strong>
|
<strong v-text="formattedBalance"></strong>
|
||||||
<small> {{LNBITS_DENOMINATION}}</small>
|
<small> {{LNBITS_DENOMINATION}}</small>
|
||||||
@ -105,6 +111,7 @@
|
|||||||
class="q-ml-md"
|
class="q-ml-md"
|
||||||
></lnbits-update-balance>
|
></lnbits-update-balance>
|
||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div v-if="g.wallet.currency">
|
<div v-if="g.wallet.currency">
|
||||||
|
@ -237,5 +237,6 @@ window.app.component('payment-list', {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.lazy === undefined) this.fetchPayments()
|
if (this.lazy === undefined) this.fetchPayments()
|
||||||
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -59,7 +59,10 @@ window.app = Vue.createApp({
|
|||||||
adminkeyHidden: true,
|
adminkeyHidden: true,
|
||||||
hasNfc: false,
|
hasNfc: false,
|
||||||
nfcReaderAbortController: null,
|
nfcReaderAbortController: null,
|
||||||
primaryColor: this.$q.localStorage.getItem('lnbits.primaryColor')
|
primaryColor: this.$q.localStorage.getItem('lnbits.primaryColor'),
|
||||||
|
transactions: [],
|
||||||
|
transactionChart: null,
|
||||||
|
paymentsRef: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -97,6 +100,64 @@ window.app = Vue.createApp({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
computeCumulativeBalance(transactions) {
|
||||||
|
let balance = 0;
|
||||||
|
return transactions.map(amount => (balance += amount));
|
||||||
|
},
|
||||||
|
initCharts() {
|
||||||
|
this.transactionChart = new Chart(
|
||||||
|
this.$refs.transactionChart.getContext('2d'),
|
||||||
|
{
|
||||||
|
type: 'line',
|
||||||
|
options: {
|
||||||
|
responsive: true,
|
||||||
|
maintainAspectRatio: false,
|
||||||
|
layout: {
|
||||||
|
padding: 0,
|
||||||
|
margin: 0, // Remove padding around the chart
|
||||||
|
},
|
||||||
|
plugins: {
|
||||||
|
legend: {
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
title: {
|
||||||
|
display: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
elements: {
|
||||||
|
point: {
|
||||||
|
radius: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
scales: {
|
||||||
|
x: {
|
||||||
|
display: false
|
||||||
|
},
|
||||||
|
y: {
|
||||||
|
display: false
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data: {
|
||||||
|
labels: this.transactions.map((tx) =>
|
||||||
|
new Date(tx.date).toLocaleDateString()
|
||||||
|
),
|
||||||
|
datasets: [
|
||||||
|
{
|
||||||
|
label: 'Cumulative Balance',
|
||||||
|
data: this.computeCumulativeBalance(this.transactions),
|
||||||
|
backgroundColor: LNbits.utils.hexAlpha(this.primaryColor, 0.05),
|
||||||
|
borderColor: this.primaryColor,
|
||||||
|
borderWidth: 1,
|
||||||
|
fill: true,
|
||||||
|
tension: 0.2,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
msatoshiFormat(value) {
|
msatoshiFormat(value) {
|
||||||
return LNbits.utils.formatSat(value / 1000)
|
return LNbits.utils.formatSat(value / 1000)
|
||||||
},
|
},
|
||||||
@ -652,7 +713,25 @@ window.app = Vue.createApp({
|
|||||||
dismissPaymentMsg()
|
dismissPaymentMsg()
|
||||||
LNbits.utils.notifyApiError(err)
|
LNbits.utils.notifyApiError(err)
|
||||||
})
|
})
|
||||||
}
|
},
|
||||||
|
handleWallet(wallet) {
|
||||||
|
console.log('Wallet from child:', wallet);
|
||||||
|
},
|
||||||
|
fetchPayments() {
|
||||||
|
return LNbits.api
|
||||||
|
.getPayments(this.g.wallet, "sortby=time&direction=asc&status[ne]=failed")
|
||||||
|
.then(response => {
|
||||||
|
console.log(response.data.data)
|
||||||
|
for (let payment of response.data.data) {
|
||||||
|
this.transactions.push(payment.amount)
|
||||||
|
}
|
||||||
|
console.log(this.transactions)
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
this.paymentsTable.loading = false
|
||||||
|
LNbits.utils.notifyApiError(err)
|
||||||
|
})
|
||||||
|
},
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
const urlParams = new URLSearchParams(window.location.search)
|
const urlParams = new URLSearchParams(window.location.search)
|
||||||
@ -669,6 +748,9 @@ window.app = Vue.createApp({
|
|||||||
this.update.currency = this.g.wallet.currency
|
this.update.currency = this.g.wallet.currency
|
||||||
this.receive.units = ['sat', ...window.currencies]
|
this.receive.units = ['sat', ...window.currencies]
|
||||||
this.updateFiatBalance()
|
this.updateFiatBalance()
|
||||||
|
this.fetchPayments().then(() => {
|
||||||
|
this.initCharts()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
updatePayments() {
|
updatePayments() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user