Browse Source

format: prettier lnurlp files.

aiosqlite
fiatjaf 5 years ago
parent
commit
01b19add79
  1. 53
      lnbits/extensions/lnurlp/templates/lnurlp/index.html
  2. 4
      lnbits/extensions/lnurlp/templates/lnurlp/print_qr.html

53
lnbits/extensions/lnurlp/templates/lnurlp/index.html

@ -206,8 +206,7 @@
</q-card> </q-card>
</q-dialog> </q-dialog>
</div> </div>
{% endblock %} {% endblock %} {% block scripts %} {{ window_vars(user) }}
{% block scripts %} {{ window_vars(user) }}
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script> <script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
<script> <script>
Vue.component(VueQrcode.name, VueQrcode) Vue.component(VueQrcode.name, VueQrcode)
@ -219,7 +218,7 @@
window.location.pathname window.location.pathname
].join('') ].join('')
var mapPayLink = function(obj) { var mapPayLink = function (obj) {
obj._data = _.clone(obj) obj._data = _.clone(obj)
obj.date = Quasar.utils.date.formatDate( obj.date = Quasar.utils.date.formatDate(
new Date(obj.time * 1000), new Date(obj.time * 1000),
@ -234,7 +233,7 @@
new Vue({ new Vue({
el: '#vue', el: '#vue',
mixins: [windowMixin], mixins: [windowMixin],
data: function() { data: function () {
return { return {
checker: null, checker: null,
payLinks: [], payLinks: [],
@ -273,7 +272,7 @@
} }
}, },
methods: { methods: {
getPayLinks: function() { getPayLinks: function () {
var self = this var self = this
LNbits.api LNbits.api
@ -282,32 +281,32 @@
'/lnurlp/api/v1/links?all_wallets', '/lnurlp/api/v1/links?all_wallets',
this.g.user.wallets[0].inkey this.g.user.wallets[0].inkey
) )
.then(function(response) { .then(function (response) {
self.payLinks = response.data.map(function(obj) { self.payLinks = response.data.map(function (obj) {
return mapPayLink(obj) return mapPayLink(obj)
}) })
}) })
.catch(function(error) { .catch(function (error) {
clearInterval(self.checker) clearInterval(self.checker)
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
}) })
}, },
closeFormDialog: function() { closeFormDialog: function () {
this.formDialog.data = { this.formDialog.data = {
is_unique: false is_unique: false
} }
}, },
openQrCodeDialog: function(linkId) { openQrCodeDialog: function (linkId) {
var link = _.findWhere(this.payLinks, {id: linkId}) var link = _.findWhere(this.payLinks, {id: linkId})
this.qrCodeDialog.data = _.clone(link) this.qrCodeDialog.data = _.clone(link)
this.qrCodeDialog.show = true this.qrCodeDialog.show = true
}, },
openUpdateDialog: function(linkId) { openUpdateDialog: function (linkId) {
var link = _.findWhere(this.payLinks, {id: linkId}) var link = _.findWhere(this.payLinks, {id: linkId})
this.formDialog.data = _.clone(link._data) this.formDialog.data = _.clone(link._data)
this.formDialog.show = true this.formDialog.show = true
}, },
sendFormData: function() { sendFormData: function () {
var wallet = _.findWhere(this.g.user.wallets, { var wallet = _.findWhere(this.g.user.wallets, {
id: this.formDialog.data.wallet id: this.formDialog.data.wallet
}) })
@ -327,7 +326,7 @@
this.createPayLink(wallet, data) this.createPayLink(wallet, data)
} }
}, },
updatePayLink: function(wallet, data) { updatePayLink: function (wallet, data) {
var self = this var self = this
LNbits.api LNbits.api
@ -337,62 +336,62 @@
wallet.adminkey, wallet.adminkey,
_.pick(data, 'description', 'amount') _.pick(data, 'description', 'amount')
) )
.then(function(response) { .then(function (response) {
self.payLinks = _.reject(self.payLinks, function(obj) { self.payLinks = _.reject(self.payLinks, function (obj) {
return obj.id === data.id return obj.id === data.id
}) })
self.payLinks.push(mapPayLink(response.data)) self.payLinks.push(mapPayLink(response.data))
self.formDialog.show = false self.formDialog.show = false
}) })
.catch(function(error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
}) })
}, },
createPayLink: function(wallet, data) { createPayLink: function (wallet, data) {
var self = this var self = this
LNbits.api LNbits.api
.request('POST', '/lnurlp/api/v1/links', wallet.adminkey, data) .request('POST', '/lnurlp/api/v1/links', wallet.adminkey, data)
.then(function(response) { .then(function (response) {
self.payLinks.push(mapPayLink(response.data)) self.payLinks.push(mapPayLink(response.data))
self.formDialog.show = false self.formDialog.show = false
}) })
.catch(function(error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
}) })
}, },
deletePayLink: function(linkId) { deletePayLink: function (linkId) {
var self = this var self = this
var link = _.findWhere(this.payLinks, {id: linkId}) var link = _.findWhere(this.payLinks, {id: linkId})
LNbits.utils LNbits.utils
.confirmDialog('Are you sure you want to delete this pay link?') .confirmDialog('Are you sure you want to delete this pay link?')
.onOk(function() { .onOk(function () {
LNbits.api LNbits.api
.request( .request(
'DELETE', 'DELETE',
'/lnurlp/api/v1/links/' + linkId, '/lnurlp/api/v1/links/' + linkId,
_.findWhere(self.g.user.wallets, {id: link.wallet}).adminkey _.findWhere(self.g.user.wallets, {id: link.wallet}).adminkey
) )
.then(function(response) { .then(function (response) {
self.payLinks = _.reject(self.payLinks, function(obj) { self.payLinks = _.reject(self.payLinks, function (obj) {
return obj.id === linkId return obj.id === linkId
}) })
}) })
.catch(function(error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
}) })
}) })
}, },
exportCSV: function() { exportCSV: function () {
LNbits.utils.exportCSV(this.paywallsTable.columns, this.paywalls) LNbits.utils.exportCSV(this.paywallsTable.columns, this.paywalls)
} }
}, },
created: function() { created: function () {
if (this.g.user.wallets.length) { if (this.g.user.wallets.length) {
var getPayLinks = this.getPayLinks var getPayLinks = this.getPayLinks
getPayLinks() getPayLinks()
this.checker = setInterval(function() { this.checker = setInterval(function () {
getPayLinks() getPayLinks()
}, 20000) }, 20000)
} }

4
lnbits/extensions/lnurlp/templates/lnurlp/print_qr.html

@ -17,10 +17,10 @@
new Vue({ new Vue({
el: '#vue', el: '#vue',
created: function() { created: function () {
window.print() window.print()
}, },
data: function() { data: function () {
return {width: window.innerWidth * 0.5} return {width: window.innerWidth * 0.5}
} }
}) })

Loading…
Cancel
Save