function shortenNodeId(nodeId) {
return nodeId
? nodeId.substring(0, 5) + '...' + nodeId.substring(nodeId.length - 5)
: '...'
}
Vue.component('lnbits-node-ranks', {
props: ['ranks'],
data: function () {
return {
user: {},
stats: [
{label: 'Capacity', key: 'capacity'},
{label: 'Channels', key: 'channelcount'},
{label: 'Age', key: 'age'},
{label: 'Growth', key: 'growth'},
{label: 'Availability', key: 'availability'}
]
}
},
template: `
1ml Node Rank
{{ stat.label }}
{{ (ranks && ranks[stat.key]) ?? '-' }}
`
})
Vue.component('lnbits-channel-stats', {
props: ['stats'],
data: function () {
return {
states: [
{label: 'Active', value: 'active', color: 'green'},
{label: 'Pending', value: 'pending', color: 'orange'},
{label: 'Inactive', value: 'inactive', color: 'grey'},
{label: 'Closed', value: 'closed', color: 'red'}
]
}
},
template: `
Channels
{{ state.label }}
{{ (stats?.counts && stats.counts[state.value]) ?? "-" }}
`,
created: function () {
if (window.user) {
this.user = LNbits.map.user(window.user)
}
}
})
Vue.component('lnbits-stat', {
props: ['title', 'amount', 'msat', 'btc'],
computed: {
value: function () {
return (
this.amount ??
(this.btc
? LNbits.utils.formatSat(this.btc)
: LNbits.utils.formatMsat(this.msat))
)
}
},
template: `
{{ title }}
{{ value }}
sats
BTC
`
})
Vue.component('lnbits-node-qrcode', {
props: ['info'],
mixins: [windowMixin],
template: `
Public Key Click to copy
`
})
Vue.component('lnbits-node-info', {
props: ['info'],
data() {
return {
showDialog: false
}
},
mixins: [windowMixin],
methods: {
shortenNodeId
},
template: `
{{ this.info.alias }}
{{ this.info.backend_name }}
#{{ this.info.color }}
{{ shortenNodeId(this.info.id) }}
`
})
Vue.component('lnbits-stat', {
props: ['title', 'amount', 'msat', 'btc'],
computed: {
value: function () {
return (
this.amount ??
(this.btc
? LNbits.utils.formatSat(this.btc)
: LNbits.utils.formatMsat(this.msat))
)
}
},
template: `
{{ title }}
{{ value }}
sats
BTC
`
})
Vue.component('lnbits-channel-balance', {
props: ['balance', 'color'],
methods: {
formatMsat: function (msat) {
return LNbits.utils.formatMsat(msat)
}
},
template: `
Local: {{ formatMsat(balance.local_msat) }}
sats
Remote: {{ formatMsat(balance.remote_msat) }}
sats
{{ balance.alias }}
`
})
Vue.component('lnbits-date', {
props: ['ts'],
computed: {
date: function () {
return Quasar.utils.date.formatDate(
new Date(this.ts * 1000),
'YYYY-MM-DD HH:mm'
)
},
dateFrom: function () {
return moment(this.date).fromNow()
}
},
template: `
{{ this.date }}
{{ this.dateFrom }}
`
})