From 4730500ed7ea6a0235c10a23dfd747b70cc0259b Mon Sep 17 00:00:00 2001 From: fiatjaf Date: Sun, 3 May 2020 13:55:17 -0300 Subject: [PATCH] apply prettier to everything. --- .gitignore | 2 + .prettierrc | 12 + Makefile | 2 + lnbits/core/static/js/extensions.js | 2 +- lnbits/core/static/js/index.js | 12 +- lnbits/core/static/js/wallet.js | 339 ++-- .../amilk/templates/amilk/_api_docs.html | 40 +- .../amilk/templates/amilk/index.html | 444 ++--- .../templates/diagonalley/_api_docs.html | 125 +- .../templates/diagonalley/index.html | 1422 ++++++++++------- .../templates/diagonalley/stall.html | 4 +- .../events/templates/events/display.html | 607 ++++--- .../events/templates/events/index.html | 815 +++++----- .../events/templates/events/registration.html | 790 +++++---- .../events/templates/events/ticket.html | 415 +++-- .../example/templates/example/index.html | 107 +- .../paywall/templates/paywall/_api_docs.html | 20 +- .../paywall/templates/paywall/display.html | 199 +-- .../paywall/templates/paywall/index.html | 444 ++--- .../tpos/templates/tpos/_api_docs.html | 65 +- .../extensions/tpos/templates/tpos/_tpos.html | 19 +- .../extensions/tpos/templates/tpos/index.html | 596 ++++--- .../extensions/tpos/templates/tpos/tpos.html | 454 +++--- .../templates/usermanager/_api_docs.html | 200 ++- .../templates/usermanager/index.html | 777 ++++----- .../templates/withdraw/_api_docs.html | 104 +- .../withdraw/templates/withdraw/_lnurl.html | 31 +- .../withdraw/templates/withdraw/display.html | 103 +- .../withdraw/templates/withdraw/index.html | 440 +++-- .../withdraw/templates/withdraw/print_qr.html | 115 +- lnbits/static/js/base.js | 244 +-- lnbits/static/js/components.js | 65 +- package.json | 5 + 33 files changed, 5068 insertions(+), 3951 deletions(-) create mode 100644 .prettierrc create mode 100644 Makefile create mode 100644 package.json diff --git a/.gitignore b/.gitignore index 4e36db9..ac8c265 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,5 @@ venv .pyre* __bundle__ + +node_modules diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..224c6ee --- /dev/null +++ b/.prettierrc @@ -0,0 +1,12 @@ +{ + "semi": false, + "arrowParens": "avoid", + "insertPragma": false, + "printWidth": 80, + "proseWrap": "preserve", + "singleQuote": true, + "trailingComma": "none", + "useTabs": false, + "jsxBracketSameLine": false, + "bracketSpacing": false +} diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..be5e342 --- /dev/null +++ b/Makefile @@ -0,0 +1,2 @@ +prettier: + ./node_modules/.bin/prettier --write lnbits/static/js/** lnbits/core/static/js/** lnbits/extensions/*/templates/** diff --git a/lnbits/core/static/js/extensions.js b/lnbits/core/static/js/extensions.js index 1ec818b..85ace77 100644 --- a/lnbits/core/static/js/extensions.js +++ b/lnbits/core/static/js/extensions.js @@ -1,4 +1,4 @@ new Vue({ el: '#vue', mixins: [windowMixin] -}); +}) diff --git a/lnbits/core/static/js/index.js b/lnbits/core/static/js/index.js index 1f1d96d..0a930e1 100644 --- a/lnbits/core/static/js/index.js +++ b/lnbits/core/static/js/index.js @@ -3,23 +3,23 @@ new Vue({ mixins: [windowMixin], data: function () { return { - disclaimerDialog: { + disclaimerDialog: { show: false, data: {} - }, + }, walletName: '' - }; + } }, methods: { createWallet: function () { - LNbits.href.createWallet(this.walletName); + LNbits.href.createWallet(this.walletName) }, processing: function () { this.$q.notify({ timeout: 0, message: 'Processing...', icon: null - }); + }) } } -}); +}) diff --git a/lnbits/core/static/js/wallet.js b/lnbits/core/static/js/wallet.js index 8a3c742..20e7778 100644 --- a/lnbits/core/static/js/wallet.js +++ b/lnbits/core/static/js/wallet.js @@ -1,39 +1,49 @@ -Vue.component(VueQrcode.name, VueQrcode); -Vue.use(VueQrcodeReader); - +Vue.component(VueQrcode.name, VueQrcode) +Vue.use(VueQrcodeReader) function generateChart(canvas, payments) { - var txs = []; - var n = 0; + var txs = [] + var n = 0 var data = { labels: [], income: [], outcome: [], cumulative: [] - }; + } - _.each(payments.slice(0).sort(function (a, b) { - return a.time - b.time; - }), function (tx) { - txs.push({ - hour: Quasar.utils.date.formatDate(tx.date, 'YYYY-MM-DDTHH:00'), - sat: tx.sat, - }); - }); + _.each( + payments.slice(0).sort(function (a, b) { + return a.time - b.time + }), + function (tx) { + txs.push({ + hour: Quasar.utils.date.formatDate(tx.date, 'YYYY-MM-DDTHH:00'), + sat: tx.sat + }) + } + ) _.each(_.groupBy(txs, 'hour'), function (value, day) { - var income = _.reduce(value, function(memo, tx) { - return (tx.sat >= 0) ? memo + tx.sat : memo; - }, 0); - var outcome = _.reduce(value, function(memo, tx) { - return (tx.sat < 0) ? memo + Math.abs(tx.sat) : memo; - }, 0); - n = n + income - outcome; - data.labels.push(day); - data.income.push(income); - data.outcome.push(outcome); - data.cumulative.push(n); - }); + var income = _.reduce( + value, + function (memo, tx) { + return tx.sat >= 0 ? memo + tx.sat : memo + }, + 0 + ) + var outcome = _.reduce( + value, + function (memo, tx) { + return tx.sat < 0 ? memo + Math.abs(tx.sat) : memo + }, + 0 + ) + n = n + income - outcome + data.labels.push(day) + data.income.push(income) + data.outcome.push(outcome) + data.cumulative.push(n) + }) new Chart(canvas.getContext('2d'), { type: 'bar', @@ -44,7 +54,7 @@ function generateChart(canvas, payments) { data: data.cumulative, type: 'line', label: 'balance', - backgroundColor: '#673ab7', // deep-purple + backgroundColor: '#673ab7', // deep-purple borderColor: '#673ab7', borderWidth: 4, pointRadius: 3, @@ -55,14 +65,14 @@ function generateChart(canvas, payments) { type: 'bar', label: 'in', barPercentage: 0.75, - backgroundColor: window.Color('rgb(76,175,80)').alpha(0.5).rgbString() // green + backgroundColor: window.Color('rgb(76,175,80)').alpha(0.5).rgbString() // green }, { data: data.outcome, type: 'bar', label: 'out', barPercentage: 0.75, - backgroundColor: window.Color('rgb(233,30,99)').alpha(0.5).rgbString() // pink + backgroundColor: window.Color('rgb(233,30,99)').alpha(0.5).rgbString() // pink } ] }, @@ -72,18 +82,20 @@ function generateChart(canvas, payments) { }, tooltips: { mode: 'index', - intersect:false + intersect: false }, scales: { - xAxes: [{ - type: 'time', - display: true, - offset: true, - time: { - minUnit: 'hour', - stepSize: 3 + xAxes: [ + { + type: 'time', + display: true, + offset: true, + time: { + minUnit: 'hour', + stepSize: 3 + } } - }], + ] }, // performance tweaks animation: { @@ -95,10 +107,9 @@ function generateChart(canvas, payments) { } } } - }); + }) } - new Vue({ el: '#vue', mixins: [windowMixin], @@ -128,8 +139,20 @@ new Vue({ paymentsTable: { columns: [ {name: 'memo', align: 'left', label: 'Memo', field: 'memo'}, - {name: 'date', align: 'left', label: 'Date', field: 'date', sortable: true}, - {name: 'sat', align: 'right', label: 'Amount (sat)', field: 'sat', sortable: true} + { + name: 'date', + align: 'left', + label: 'Date', + field: 'date', + sortable: true + }, + { + name: 'sat', + align: 'right', + label: 'Amount (sat)', + field: 'sat', + sortable: true + } ], pagination: { rowsPerPage: 10 @@ -143,46 +166,50 @@ new Vue({ show: false, location: window.location } - }; + } }, computed: { filteredPayments: function () { - var q = this.paymentsTable.filter; - if (!q || q == '') return this.payments; + var q = this.paymentsTable.filter + if (!q || q == '') return this.payments - return LNbits.utils.search(this.payments, q); + return LNbits.utils.search(this.payments, q) }, balance: function () { if (this.payments.length) { - return _.pluck(this.payments, 'amount').reduce(function (a, b) { return a + b; }, 0) / 1000; + return ( + _.pluck(this.payments, 'amount').reduce(function (a, b) { + return a + b + }, 0) / 1000 + ) } - return this.g.wallet.sat; + return this.g.wallet.sat }, fbalance: function () { return LNbits.utils.formatSat(this.balance) }, canPay: function () { - if (!this.send.invoice) return false; - return this.send.invoice.sat <= this.balance; + if (!this.send.invoice) return false + return this.send.invoice.sat <= this.balance }, pendingPaymentsExist: function () { - return (this.payments) + return this.payments ? _.where(this.payments, {pending: 1}).length > 0 - : false; + : false } }, methods: { closeCamera: function () { - this.sendCamera.show = false; + this.sendCamera.show = false }, showCamera: function () { - this.sendCamera.show = true; + this.sendCamera.show = true }, showChart: function () { - this.paymentsChart.show = true; + this.paymentsChart.show = true this.$nextTick(function () { - generateChart(this.$refs.canvas, this.payments); - }); + generateChart(this.$refs.canvas, this.payments) + }) }, showReceiveDialog: function () { this.receive = { @@ -194,7 +221,7 @@ new Vue({ memo: '' }, paymentChecker: null - }; + } }, showSendDialog: function () { this.send = { @@ -204,57 +231,64 @@ new Vue({ bolt11: '' }, paymentChecker: null - }; + } }, closeReceiveDialog: function () { - var checker = this.receive.paymentChecker; + var checker = this.receive.paymentChecker setTimeout(function () { - clearInterval(checker); - }, 10000); + clearInterval(checker) + }, 10000) }, closeSendDialog: function () { - this.sendCamera.show = false; - var checker = this.send.paymentChecker; + this.sendCamera.show = false + var checker = this.send.paymentChecker setTimeout(function () { - clearInterval(checker); - }, 1000); + clearInterval(checker) + }, 1000) }, createInvoice: function () { - var self = this; - this.receive.status = 'loading'; - LNbits.api.createInvoice(this.g.wallet, this.receive.data.amount, this.receive.data.memo) + var self = this + this.receive.status = 'loading' + LNbits.api + .createInvoice( + this.g.wallet, + this.receive.data.amount, + this.receive.data.memo + ) .then(function (response) { - self.receive.status = 'success'; - self.receive.paymentReq = response.data.payment_request; + self.receive.status = 'success' + self.receive.paymentReq = response.data.payment_request self.receive.paymentChecker = setInterval(function () { - LNbits.api.getPayment(self.g.wallet, response.data.checking_id).then(function (response) { - if (response.data.paid) { - self.fetchPayments(); - self.receive.show = false; - clearInterval(self.receive.paymentChecker); - } - }); - }, 2000); - - }).catch(function (error) { - LNbits.utils.notifyApiError(error); - self.receive.status = 'pending'; - }); + LNbits.api + .getPayment(self.g.wallet, response.data.checking_id) + .then(function (response) { + if (response.data.paid) { + self.fetchPayments() + self.receive.show = false + clearInterval(self.receive.paymentChecker) + } + }) + }, 2000) + }) + .catch(function (error) { + LNbits.utils.notifyApiError(error) + self.receive.status = 'pending' + }) }, decodeQR: function (res) { - this.send.data.bolt11 = res; - this.decodeInvoice(); - this.sendCamera.show = false; + this.send.data.bolt11 = res + this.decodeInvoice() + this.sendCamera.show = false }, decodeInvoice: function () { if (this.send.data.bolt11.startsWith('lightning:')) { - this.send.data.bolt11 = this.send.data.bolt11.slice(10); + this.send.data.bolt11 = this.send.data.bolt11.slice(10) } - let invoice; + let invoice try { - invoice = decode(this.send.data.bolt11); + invoice = decode(this.send.data.bolt11) } catch (error) { this.$q.notify({ timeout: 3000, @@ -262,101 +296,120 @@ new Vue({ message: error + '.', caption: '400 BAD REQUEST', icon: null - }); - return; + }) + return } let cleanInvoice = { msat: invoice.human_readable_part.amount, sat: invoice.human_readable_part.amount / 1000, fsat: LNbits.utils.formatSat(invoice.human_readable_part.amount / 1000) - }; + } _.each(invoice.data.tags, function (tag) { if (_.isObject(tag) && _.has(tag, 'description')) { - if (tag.description == 'payment_hash') { cleanInvoice.hash = tag.value; } - else if (tag.description == 'description') { cleanInvoice.description = tag.value; } - else if (tag.description == 'expiry') { - var expireDate = new Date((invoice.data.time_stamp + tag.value) * 1000); - cleanInvoice.expireDate = Quasar.utils.date.formatDate(expireDate, 'YYYY-MM-DDTHH:mm:ss.SSSZ'); - cleanInvoice.expired = false; // TODO + if (tag.description == 'payment_hash') { + cleanInvoice.hash = tag.value + } else if (tag.description == 'description') { + cleanInvoice.description = tag.value + } else if (tag.description == 'expiry') { + var expireDate = new Date( + (invoice.data.time_stamp + tag.value) * 1000 + ) + cleanInvoice.expireDate = Quasar.utils.date.formatDate( + expireDate, + 'YYYY-MM-DDTHH:mm:ss.SSSZ' + ) + cleanInvoice.expired = false // TODO } } - }); + }) - this.send.invoice = Object.freeze(cleanInvoice); + this.send.invoice = Object.freeze(cleanInvoice) }, payInvoice: function () { - var self = this; + var self = this dismissPaymentMsg = this.$q.notify({ timeout: 0, message: 'Processing payment...', icon: null - }); + }) - LNbits.api.payInvoice(this.g.wallet, this.send.data.bolt11).then(function (response) { - self.send.paymentChecker = setInterval(function () { - LNbits.api.getPayment(self.g.wallet, response.data.checking_id).then(function (res) { - if (res.data.paid) { - self.send.show = false; - clearInterval(self.send.paymentChecker); - dismissPaymentMsg(); - self.fetchPayments(); - } - }); - }, 2000); - }).catch(function (error) { - dismissPaymentMsg(); - LNbits.utils.notifyApiError(error); - }); + LNbits.api + .payInvoice(this.g.wallet, this.send.data.bolt11) + .then(function (response) { + self.send.paymentChecker = setInterval(function () { + LNbits.api + .getPayment(self.g.wallet, response.data.checking_id) + .then(function (res) { + if (res.data.paid) { + self.send.show = false + clearInterval(self.send.paymentChecker) + dismissPaymentMsg() + self.fetchPayments() + } + }) + }, 2000) + }) + .catch(function (error) { + dismissPaymentMsg() + LNbits.utils.notifyApiError(error) + }) }, deleteWallet: function (walletId, user) { - LNbits.utils.confirmDialog( - 'Are you sure you want to delete this wallet?' - ).onOk(function () { - LNbits.href.deleteWallet(walletId, user); - }); + LNbits.utils + .confirmDialog('Are you sure you want to delete this wallet?') + .onOk(function () { + LNbits.href.deleteWallet(walletId, user) + }) }, fetchPayments: function (checkPending) { - var self = this; + var self = this - return LNbits.api.getPayments(this.g.wallet, checkPending).then(function (response) { - self.payments = response.data.map(function (obj) { - return LNbits.map.payment(obj); - }).sort(function (a, b) { - return b.time - a.time; - }); - }); + return LNbits.api + .getPayments(this.g.wallet, checkPending) + .then(function (response) { + self.payments = response.data + .map(function (obj) { + return LNbits.map.payment(obj) + }) + .sort(function (a, b) { + return b.time - a.time + }) + }) }, checkPendingPayments: function () { var dismissMsg = this.$q.notify({ timeout: 0, message: 'Checking pending transactions...', icon: null - }); + }) this.fetchPayments(true).then(function () { - dismissMsg(); - }); + dismissMsg() + }) }, exportCSV: function () { - LNbits.utils.exportCSV(this.paymentsTable.columns, this.payments); + LNbits.utils.exportCSV(this.paymentsTable.columns, this.payments) } }, watch: { - 'payments': function () { - EventHub.$emit('update-wallet-balance', [this.g.wallet.id, this.balance]); + payments: function () { + EventHub.$emit('update-wallet-balance', [this.g.wallet.id, this.balance]) } }, created: function () { - this.fetchPayments(); - setTimeout(this.checkPendingPayments(), 1200); + this.fetchPayments() + setTimeout(this.checkPendingPayments(), 1200) }, mounted: function () { - if (this.$refs.disclaimer && !this.$q.localStorage.getItem('lnbits.disclaimerShown')) { - this.disclaimerDialog.show = true; - this.$q.localStorage.set('lnbits.disclaimerShown', true); + if ( + this.$refs.disclaimer && + !this.$q.localStorage.getItem('lnbits.disclaimerShown') + ) { + this.disclaimerDialog.show = true + this.$q.localStorage.set('lnbits.disclaimerShown', true) } } -}); +}) diff --git a/lnbits/extensions/amilk/templates/amilk/_api_docs.html b/lnbits/extensions/amilk/templates/amilk/_api_docs.html index bd2c42a..f1c27a1 100644 --- a/lnbits/extensions/amilk/templates/amilk/_api_docs.html +++ b/lnbits/extensions/amilk/templates/amilk/_api_docs.html @@ -1,16 +1,24 @@ - - - - -
Assistant Faucet Milker
-

Milking faucets with software, known as "assmilking", seems at first to be black-hat, although in fact there might be some unexplored use cases. An LNURL withdraw gives someone the right to pull funds, which can be done over time. An LNURL withdraw could be used outside of just faucets, to provide money streaming and repeat payments.
Paste or scan an LNURL withdraw, enter the amount for the AMilk to pull and the frequency for it to be pulled.
- Created by, Ben Arc

-
- - -
\ No newline at end of file + + + +
Assistant Faucet Milker
+

+ Milking faucets with software, known as "assmilking", seems at first to + be black-hat, although in fact there might be some unexplored use cases. + An LNURL withdraw gives someone the right to pull funds, which can be + done over time. An LNURL withdraw could be used outside of just faucets, + to provide money streaming and repeat payments.
Paste or scan an + LNURL withdraw, enter the amount for the AMilk to pull and the frequency + for it to be pulled.
+ + Created by, Ben Arc +

+
+
+
diff --git a/lnbits/extensions/amilk/templates/amilk/index.html b/lnbits/extensions/amilk/templates/amilk/index.html index 4166efd..63473bd 100644 --- a/lnbits/extensions/amilk/templates/amilk/index.html +++ b/lnbits/extensions/amilk/templates/amilk/index.html @@ -1,230 +1,252 @@ -{% extends "base.html" %} - -{% from "macros.jinja" import window_vars with context %} - - -{% block page %} -
-
- - - New AMilk - - - - - -
-
-
AMilks
-
-
- Export to CSV -
+{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} +
+
+ + + New AMilk + + + + + +
+
+
AMilks
- - {% raw %} - - - {% endraw %} - - - -
- -
- - -
LNbits Assistant Faucet Milker Extension
-
- - - - {% include "amilk/_api_docs.html" %} - - -
-
- - - - - - - - - - Create amilk - Cancel - - - +
+ Export to CSV +
+
+ + {% raw %} + + + {% endraw %} + + +
-{% endblock %} -{% block scripts %} - {{ window_vars(user) }} - + }, + created: function () { + if (this.g.user.wallets.length) { + this.getAMilks() + } + } + }) + {% endblock %} diff --git a/lnbits/extensions/diagonalley/templates/diagonalley/_api_docs.html b/lnbits/extensions/diagonalley/templates/diagonalley/_api_docs.html index 44ed8f1..585e8d7 100644 --- a/lnbits/extensions/diagonalley/templates/diagonalley/_api_docs.html +++ b/lnbits/extensions/diagonalley/templates/diagonalley/_api_docs.html @@ -1,20 +1,29 @@ - - - - -
Diagon Alley: Decentralised Market-Stalls
-

Make a list of products to sell, point your list of products at a public indexer. Buyers browse your products on the indexer, and pay you directly. Ratings are managed by the indexer. Your stall can be listed in multiple indexers, even over TOR, if you wish to be anonymous.
- More information on the Diagon Alley Protocol
- Created by, Ben Arc

-
- - - + + + +
+ Diagon Alley: Decentralised Market-Stalls +
+

+ Make a list of products to sell, point your list of products at a public + indexer. Buyers browse your products on the indexer, and pay you + directly. Ratings are managed by the indexer. Your stall can be listed + in multiple indexers, even over TOR, if you wish to be anonymous.
+ More information on the + Diagon Alley Protocol
+ + Created by, Ben Arc +

+
+
- - + - GET /api/v1/diagonalley/stall/products/<indexer_id> + GET + /api/v1/diagonalley/stall/products/<indexer_id>
Body (application/json)
-
Returns 201 CREATED (application/json)
+
+ Returns 201 CREATED (application/json) +
Product JSON list
Curl example
- curl -X GET {{ request.url_root }}diagonalley/api/v1/diagonalley/stall/products/<indexer_id> + curl -X GET {{ request.url_root + }}diagonalley/api/v1/diagonalley/stall/products/<indexer_id>
- + - POST /api/v1/diagonalley/stall/order/<indexer_id> + POST + /api/v1/diagonalley/stall/order/<indexer_id>
Body (application/json)
- {"id": <string>, "address": <string>, "shippingzone": <integer>, "email": <string>, "quantity": <integer>} -
Returns 201 CREATED (application/json)
- {"checking_id": <string>,"payment_request": <string>} + {"id": <string>, "address": <string>, "shippingzone": + <integer>, "email": <string>, "quantity": + <integer>} +
+ Returns 201 CREATED (application/json) +
+ {"checking_id": <string>,"payment_request": + <string>}
Curl example
- curl -X POST {{ request.url_root }}diagonalley/api/v1/diagonalley/stall/order/<indexer_id> -d '{"id": <product_id&>, "email": <customer_email>, "address": <customer_address>, "quantity": 2, "shippingzone": 1}' -H "Content-type: application/json" - + curl -X POST {{ request.url_root + }}diagonalley/api/v1/diagonalley/stall/order/<indexer_id> -d + '{"id": <product_id&>, "email": <customer_email>, + "address": <customer_address>, "quantity": 2, "shippingzone": + 1}' -H "Content-type: application/json" +
- + - GET /diagonalley/api/v1/diagonalley/stall/checkshipped/<checking_id> + GET + /diagonalley/api/v1/diagonalley/stall/checkshipped/<checking_id>
Headers
-
Returns 200 OK (application/json)
+
+ Returns 200 OK (application/json) +
{"shipped": <boolean>}
Curl example
- curl -X GET {{ request.url_root }}diagonalley/api/v1/diagonalley/stall/checkshipped/<checking_id> -H "Content-type: application/json" + curl -X GET {{ request.url_root + }}diagonalley/api/v1/diagonalley/stall/checkshipped/<checking_id> + -H "Content-type: application/json"
diff --git a/lnbits/extensions/diagonalley/templates/diagonalley/index.html b/lnbits/extensions/diagonalley/templates/diagonalley/index.html index bf11641..c4f9d79 100644 --- a/lnbits/extensions/diagonalley/templates/diagonalley/index.html +++ b/lnbits/extensions/diagonalley/templates/diagonalley/index.html @@ -1,429 +1,608 @@ -{% extends "base.html" %} - -{% from "macros.jinja" import window_vars with context %} - - -{% block page %} -
-
- - - New Product - New Indexer +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} +
+
+ + + New Product + New Indexer Frontend shop your stall will list its products in - - - - - - - - - -
-
-
Products
-
-
- Export to CSV -
+ + + + + + +
+
+
Products
- - {% raw %} - - - {% endraw %} - - - - - - - - - -
-
-
Indexers
-
-
- Export to CSV -
+
+ Export to CSV
- - {% raw %} - - - {% endraw %} - - - - - - - - - - -
-
-
Orders
-
-
- Export to CSV -
+
+ + {% raw %} + + + {% endraw %} + +
+
+ + + +
+
+
Indexers
- - {% raw %} - - - {% endraw %} - - - - - - -
- -
- - -
LNbits Diagon Alley Extension
-
- - - - {% include "diagonalley/_api_docs.html" %} - - -
-
- - - - - - - - - - - - - -
- Update Product +
+ + +
LNbits Diagon Alley Extension
+
+ + + + {% include "diagonalley/_api_docs.html" %} + + +
+
- + + + + + + + + + + + +
+ Update Product + + Create Product - - Cancel -
-
-
- - - - - - - - - - - - - - - - - -
- Update Indexer - - Create Product + + Cancel +
+
+
+
+ + + + + + + + + + + + + + + + +
+ Update Indexer + + Create Indexer - - Cancel -
-
-
-
- -
-{% endblock %} - -{% block scripts %} - {{ window_vars(user) }} - + } + }) + {% endblock %} diff --git a/lnbits/extensions/diagonalley/templates/diagonalley/stall.html b/lnbits/extensions/diagonalley/templates/diagonalley/stall.html index 34d3a12..a45d254 100644 --- a/lnbits/extensions/diagonalley/templates/diagonalley/stall.html +++ b/lnbits/extensions/diagonalley/templates/diagonalley/stall.html @@ -1 +1,3 @@ - \ No newline at end of file + diff --git a/lnbits/extensions/events/templates/events/display.html b/lnbits/extensions/events/templates/events/display.html index 74f5315..30ec250 100644 --- a/lnbits/extensions/events/templates/events/display.html +++ b/lnbits/extensions/events/templates/events/display.html @@ -1,4 +1,4 @@ - + @@ -202,204 +202,183 @@ type="text/javascript" > + + .skin-blue .sidebar-menu > li > .treeview-menu { + margin: 0 1px; + background: #1f2234; + } + + .skin-blue .sidebar-menu > li > a { + border-left: 3px solid transparent; + margin-right: 1px; + } + .skin-blue .sidebar-menu > li > a:hover, + .skin-blue .sidebar-menu > li.active > a { + color: #fff; + background: #3e355a; + border-left-color: #8964a9; + } + + .skin-blue .main-header .logo:hover { + background: #3e355a; + } + + .skin-blue .main-header .navbar .sidebar-toggle:hover { + background-color: #3e355a; + } + .main-footer { + background-color: #1f2234; + padding: 15px; + color: #fff; + border-top: 0px; + } + + .skin-blue .main-header .navbar { + background-color: #1f2234; + } + + .bg-red, + .callout.callout-danger, + .alert-danger, + .alert-error, + .label-danger, + .modal-danger .modal-body { + background-color: #1f2234 !important; + } + .alert-danger, + .alert-error { + border-color: #fff; + border: 1px solid #fff; + border-radius: 7px; + } + + .skin-blue .main-header .navbar .nav > li > a:hover, + .skin-blue .main-header .navbar .nav > li > a:active, + .skin-blue .main-header .navbar .nav > li > a:focus, + .skin-blue .main-header .navbar .nav .open > a, + .skin-blue .main-header .navbar .nav .open > a:hover, + .skin-blue .main-header .navbar .nav .open > a:focus { + color: #f6f6f6; + background-color: #3e355a; + } + .bg-aqua, + .callout.callout-info, + .alert-info, + .label-info, + .modal-info .modal-body { + background-color: #3e355a !important; + } + + .box { + position: relative; + border-radius: 3px; + background-color: #333646; + border-top: 3px solid #8964a9; + margin-bottom: 20px; + width: 100%; + } + .table-striped > tbody > tr:nth-of-type(2n + 1) { + background-color: #333646; + } + + .box-header { + color: #fff; + } + .box.box-danger { + border-top-color: #8964a9; + } + .box.box-primary { + border-top-color: #8964a9; + } + + a { + color: #8964a9; + } + .box-header.with-border { + border-bottom: none; + } + + a:hover, + a:active, + a:focus { + outline: none; + text-decoration: none; + color: #fff; + } + // .modal.in .modal-dialog{ + // color:#000; + // } + .form-control { + background-color: #333646; + color: #fff; + } + .box-footer { + border-top: none; + + background-color: #333646; + } + .modal-footer { + border-top: none; + } + .modal-content { + background-color: #333646; + } + .modal.in .modal-dialog { + background-color: #333646; + } + + .layout-boxed { + background: none; + background-color: rgba(0, 0, 0, 0); + background-color: #3e355a; + } + + .skin-blue .sidebar-menu > li > a:hover, + .skin-blue .sidebar-menu > li.active > a { + background: none; + } +
@@ -421,7 +400,6 @@ background-color: @@ -429,15 +407,13 @@ background-color: -
+
- diff --git a/lnbits/extensions/events/templates/events/index.html b/lnbits/extensions/events/templates/events/index.html index 4101780..18081ac 100644 --- a/lnbits/extensions/events/templates/events/index.html +++ b/lnbits/extensions/events/templates/events/index.html @@ -10,45 +10,43 @@
  • Instant wallet, bookmark to save
  • -{% endblock %} - -{% block menuitems %} -
  • - - Wallets - - - -
  • -
  • - - Extensions - - -
      - {% for extension in EXTENSIONS %} - {% if extension.code in user_ext %} -
    • - {{ extension.name }} -
    • - {% endif %} - {% endfor %} -
    • - Manager
    • -
    -
  • -{% endblock %} - - -{% block body %} +{% endblock %} {% block menuitems %} +
  • + + Wallets + + + +
  • +
  • + + Extensions + + +
      + {% for extension in EXTENSIONS %} {% if extension.code in user_ext %} +
    • + {{ extension.name }} +
    • + {% endif %} {% endfor %} +
    • + Manager +
    • +
    +
  • +{% endblock %} {% block body %}
    @@ -56,127 +54,150 @@

    Events bitcoin tickets -



    - +
    +
    + +
    +
    +

    Make a ticket wave

    +
    + -
    - -
    - - -
    -

    Make a ticket wave

    -
    - - - -
    -
    - -
    - - -
    - -
    - - -
    - - -
    - - -
    - - -
    - - -
    - -
    - - -
    - -
    - - -
    - - -
    - -
    - - - -
    - - - -
    - -
    -
    -

    Select a link

    -
    -
    -
    -
    - - -
    - -


    -
    -
    - -
    + +
    +
    +
    + +
    +
    + + +
    + + +
    + + +
    + +
    + + +
    +
    + +
    + + +
    + +
    +
    + + +
    +
    + + +
    +
    +
    +
    +
    + +
    +
    +

    Select a link

    +
    + +
    +
    +
    + +
    + +
    +
    +
    +
    +
    +
    +
    +
    +
    +
    @@ -187,16 +208,19 @@
    - +
    - - - - - - - + + + + + + +
    TitleAmtSoldClosingPriceWalletEditDelAmtSoldClosingPriceWalletEditDel
    @@ -207,274 +231,271 @@
    - - - +
    {% endblock %} diff --git a/lnbits/extensions/events/templates/events/registration.html b/lnbits/extensions/events/templates/events/registration.html index 3e637ed..46e98dd 100644 --- a/lnbits/extensions/events/templates/events/registration.html +++ b/lnbits/extensions/events/templates/events/registration.html @@ -1,4 +1,4 @@ - + @@ -202,204 +202,183 @@ type="text/javascript" > + + .skin-blue .sidebar-menu > li > .treeview-menu { + margin: 0 1px; + background: #1f2234; + } + + .skin-blue .sidebar-menu > li > a { + border-left: 3px solid transparent; + margin-right: 1px; + } + .skin-blue .sidebar-menu > li > a:hover, + .skin-blue .sidebar-menu > li.active > a { + color: #fff; + background: #3e355a; + border-left-color: #8964a9; + } + + .skin-blue .main-header .logo:hover { + background: #3e355a; + } + + .skin-blue .main-header .navbar .sidebar-toggle:hover { + background-color: #3e355a; + } + .main-footer { + background-color: #1f2234; + padding: 15px; + color: #fff; + border-top: 0px; + } + .skin-blue .main-header .navbar { + background-color: #1f2234; + } + + .bg-red, + .callout.callout-danger, + .alert-danger, + .alert-error, + .label-danger, + .modal-danger .modal-body { + background-color: #1f2234 !important; + } + .alert-danger, + .alert-error { + border-color: #fff; + border: 1px solid #fff; + border-radius: 7px; + } + + .skin-blue .main-header .navbar .nav > li > a:hover, + .skin-blue .main-header .navbar .nav > li > a:active, + .skin-blue .main-header .navbar .nav > li > a:focus, + .skin-blue .main-header .navbar .nav .open > a, + .skin-blue .main-header .navbar .nav .open > a:hover, + .skin-blue .main-header .navbar .nav .open > a:focus { + color: #f6f6f6; + background-color: #3e355a; + } + .bg-aqua, + .callout.callout-info, + .alert-info, + .label-info, + .modal-info .modal-body { + background-color: #3e355a !important; + } + + .box { + position: relative; + border-radius: 3px; + background-color: #333646; + border-top: 3px solid #8964a9; + margin-bottom: 20px; + width: 100%; + } + .table-striped > tbody > tr:nth-of-type(2n + 1) { + background-color: #333646; + } + + .box-header { + color: #fff; + } + + .box.box-danger { + border-top-color: #8964a9; + } + .box.box-primary { + border-top-color: #8964a9; + } + + a { + color: #8964a9; + } + .box-header.with-border { + border-bottom: none; + } + + a:hover, + a:active, + a:focus { + outline: none; + text-decoration: none; + color: #fff; + } + // .modal.in .modal-dialog{ + // color:#000; + // } + + .form-control { + background-color: #333646; + color: #fff; + } + .box-footer { + border-top: none; + background-color: #333646; + } + .modal-footer { + border-top: none; + } + .modal-content { + background-color: #333646; + } + .modal.in .modal-dialog { + background-color: #333646; + } + + .layout-boxed { + background: none; + background-color: rgba(0, 0, 0, 0); + background-color: #3e355a; + } + + .skin-blue .sidebar-menu > li > a:hover, + .skin-blue .sidebar-menu > li.active > a { + background: none; + } +
    @@ -421,7 +400,6 @@ background-color: @@ -429,17 +407,15 @@ background-color: -
    +
    - diff --git a/lnbits/extensions/events/templates/events/ticket.html b/lnbits/extensions/events/templates/events/ticket.html index a13c06b..83bf0db 100644 --- a/lnbits/extensions/events/templates/events/ticket.html +++ b/lnbits/extensions/events/templates/events/ticket.html @@ -1,4 +1,4 @@ - + @@ -202,204 +202,183 @@ type="text/javascript" > + + .skin-blue .sidebar-menu > li > a { + border-left: 3px solid transparent; + margin-right: 1px; + } + .skin-blue .sidebar-menu > li > a:hover, + .skin-blue .sidebar-menu > li.active > a { + color: #fff; + background: #3e355a; + border-left-color: #8964a9; + } + + .skin-blue .main-header .logo:hover { + background: #3e355a; + } + + .skin-blue .main-header .navbar .sidebar-toggle:hover { + background-color: #3e355a; + } + .main-footer { + background-color: #1f2234; + padding: 15px; + color: #fff; + border-top: 0px; + } + + .skin-blue .main-header .navbar { + background-color: #1f2234; + } + + .bg-red, + .callout.callout-danger, + .alert-danger, + .alert-error, + .label-danger, + .modal-danger .modal-body { + background-color: #1f2234 !important; + } + .alert-danger, + .alert-error { + border-color: #fff; + border: 1px solid #fff; + border-radius: 7px; + } + + .skin-blue .main-header .navbar .nav > li > a:hover, + .skin-blue .main-header .navbar .nav > li > a:active, + .skin-blue .main-header .navbar .nav > li > a:focus, + .skin-blue .main-header .navbar .nav .open > a, + .skin-blue .main-header .navbar .nav .open > a:hover, + .skin-blue .main-header .navbar .nav .open > a:focus { + color: #f6f6f6; + background-color: #3e355a; + } + .bg-aqua, + .callout.callout-info, + .alert-info, + .label-info, + .modal-info .modal-body { + background-color: #3e355a !important; + } + + .box { + position: relative; + border-radius: 3px; + background-color: #333646; + border-top: 3px solid #8964a9; + margin-bottom: 20px; + width: 100%; + } + .table-striped > tbody > tr:nth-of-type(2n + 1) { + background-color: #333646; + } + .box-header { + color: #fff; + } + + .box.box-danger { + border-top-color: #8964a9; + } + .box.box-primary { + border-top-color: #8964a9; + } + + a { + color: #8964a9; + } + .box-header.with-border { + border-bottom: none; + } + a:hover, + a:active, + a:focus { + outline: none; + text-decoration: none; + color: #fff; + } + // .modal.in .modal-dialog{ + // color:#000; + // } + + .form-control { + background-color: #333646; + color: #fff; + } + .box-footer { + border-top: none; + + background-color: #333646; + } + .modal-footer { + border-top: none; + } + .modal-content { + background-color: #333646; + } + .modal.in .modal-dialog { + background-color: #333646; + } + + .layout-boxed { + background: none; + background-color: rgba(0, 0, 0, 0); + background-color: #3e355a; + } + + .skin-blue .sidebar-menu > li > a:hover, + .skin-blue .sidebar-menu > li.active > a { + background: none; + } +
    @@ -421,7 +400,6 @@ background-color: @@ -429,15 +407,13 @@ background-color: -
    +
    - diff --git a/lnbits/extensions/example/templates/example/index.html b/lnbits/extensions/example/templates/example/index.html index f498a9b..e062dc1 100644 --- a/lnbits/extensions/example/templates/example/index.html +++ b/lnbits/extensions/example/templates/example/index.html @@ -1,54 +1,57 @@ -{% extends "base.html" %} - -{% from "macros.jinja" import window_vars with context %} - - -{% block page %} - - -
    Frameworks used by LNbits
    - - - {% raw %} - - {{ tool.name }} - {{ tool.language }} - - {% endraw %} - - - -

    A magical "g" is always available, with info about the user, wallets and extensions:

    - {% raw %}{{ g }}{% endraw %} -
    -
    -{% endblock %} - -{% block scripts %} - {{ window_vars(user) }} - + }, + created: function () { + var self = this + + // axios is available for making requests + axios({ + method: 'GET', + url: '/example/api/v1/tools', + headers: { + 'X-example-header': 'not-used' + } + }).then(function (response) { + self.tools = response.data + }) + } + }) + {% endblock %} diff --git a/lnbits/extensions/paywall/templates/paywall/_api_docs.html b/lnbits/extensions/paywall/templates/paywall/_api_docs.html index 6f853bd..74b4cb3 100644 --- a/lnbits/extensions/paywall/templates/paywall/_api_docs.html +++ b/lnbits/extensions/paywall/templates/paywall/_api_docs.html @@ -6,23 +6,23 @@ > - - - + - - - + - + - - - + diff --git a/lnbits/extensions/paywall/templates/paywall/display.html b/lnbits/extensions/paywall/templates/paywall/display.html index 33cb99c..fd37f8d 100644 --- a/lnbits/extensions/paywall/templates/paywall/display.html +++ b/lnbits/extensions/paywall/templates/paywall/display.html @@ -1,107 +1,122 @@ -{% extends "public.html" %} - - -{% block page %} -
    -
    - - -
    {{ paywall.memo }}
    - Price: sat - -
    - - - - - -
    - Copy invoice -
    +{% extends "public.html" %} {% block page %} +
    +
    + + +
    {{ paywall.memo }}
    + Price: + sat + +
    + + + + + +
    + Copy invoice
    -
    -

    You can access the URL behind this paywall:
    - {% raw %}{{ redirectUrl }}{% endraw %}

    -
    - Open URL -
    +
    +
    +

    + You can access the URL behind this paywall:
    + {% raw %}{{ redirectUrl }}{% endraw %} +

    +
    + Open URL
    - - -
    -
    - - -
    LNbits paywall
    -
    -
    -
    +
    +
    +
    -{% endblock %} - -{% block scripts %} - - + + } + }) + {% endblock %} diff --git a/lnbits/extensions/paywall/templates/paywall/index.html b/lnbits/extensions/paywall/templates/paywall/index.html index e4c774d..552a9e1 100644 --- a/lnbits/extensions/paywall/templates/paywall/index.html +++ b/lnbits/extensions/paywall/templates/paywall/index.html @@ -1,214 +1,274 @@ -{% extends "base.html" %} +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} +
    +
    + + + New paywall + + -{% from "macros.jinja" import window_vars with context %} - - -{% block page %} -
    -
    - - - New paywall - - - - - -
    -
    -
    Paywalls
    -
    -
    - Export to CSV -
    + + +
    +
    +
    Paywalls
    - - {% raw %} - - - {% endraw %} - - - -
    - -
    - - -
    LNbits paywall extension
    -
    - - - - {% include "paywall/_api_docs.html" %} - - -
    -
    - - - - - - - - - -
    - Create paywall - Cancel +
    + Export to CSV
    - - - +
    + + {% raw %} + + + {% endraw %} + +
    +
    -{% endblock %} -{% block scripts %} - {{ window_vars(user) }} - + }, + created: function () { + if (this.g.user.wallets.length) { + this.getPaywalls() + } + } + }) + {% endblock %} diff --git a/lnbits/extensions/tpos/templates/tpos/_api_docs.html b/lnbits/extensions/tpos/templates/tpos/_api_docs.html index c43c0fa..895f434 100644 --- a/lnbits/extensions/tpos/templates/tpos/_api_docs.html +++ b/lnbits/extensions/tpos/templates/tpos/_api_docs.html @@ -4,49 +4,84 @@ label="API info" :content-inset-level="0.5" > - + GET /tpos/api/v1/tposs
    Headers
    {"X-Api-Key": <invoice_key>}
    Body (application/json)
    -
    Returns 201 CREATED (application/json)
    - {"currency": <string>, "id": <string>, "name": <string>, "wallet": <string>} +
    + Returns 201 CREATED (application/json) +
    + {"currency": <string>, "id": <string>, "name": + <string>, "wallet": <string>}
    Curl example
    - curl -X GET {{ request.url_root }}tpos/api/v1/tposs -H "X-Api-Key: <invoice_key>" + curl -X GET {{ request.url_root }}tpos/api/v1/tposs -H "X-Api-Key: + <invoice_key>" +
    - POST /tpos/api/v1/tposs + POST /tpos/api/v1/tposs
    Headers
    {"X-Api-Key": <invoice_key>}
    Body (application/json)
    - {"name": <string>, "currency": <string*ie USD*>} -
    Returns 201 CREATED (application/json)
    - {"currency": <string>, "id": <string>, "name": <string>, "wallet": <string>} + {"name": <string>, "currency": <string*ie USD*>} +
    + Returns 201 CREATED (application/json) +
    + {"currency": <string>, "id": <string>, "name": + <string>, "wallet": <string>}
    Curl example
    - curl -X POST {{ request.url_root }}tpos/api/v1/tposs -d '{"name": <string>, "currency": <string>}' -H "Content-type: application/json" -H "X-Api-Key: <admin_key>" - + curl -X POST {{ request.url_root }}tpos/api/v1/tposs -d '{"name": + <string>, "currency": <string>}' -H "Content-type: + application/json" -H "X-Api-Key: <admin_key>" +
    - + - DELETE /tpos/api/v1/tposs/<tpos_id> + DELETE + /tpos/api/v1/tposs/<tpos_id>
    Headers
    {"X-Api-Key": <admin_key>}
    Returns 201 NO_CONTENT
    Curl example
    - curl -X DELETE {{ request.url_root }}tpos/api/v1/tposs/<tpos_id> -H "X-Api-Key: <admin_key>" - - + curl -X DELETE {{ request.url_root + }}tpos/api/v1/tposs/<tpos_id> -H "X-Api-Key: <admin_key>" +
    diff --git a/lnbits/extensions/tpos/templates/tpos/_tpos.html b/lnbits/extensions/tpos/templates/tpos/_tpos.html index 11641c0..54ddcd0 100644 --- a/lnbits/extensions/tpos/templates/tpos/_tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/_tpos.html @@ -1,11 +1,18 @@ - + -

    Thiago's Point of Sale is a secure, mobile-ready, instant and shareable point of sale terminal (PoS) for merchants. The PoS is linked to your LNbits wallet but completely air-gapped so users can ONLY create invoices. To share the TPoS hit the hash on the terminal.

    - Created by Tiago Vasconcelos. +

    + Thiago's Point of Sale is a secure, mobile-ready, instant and shareable + point of sale terminal (PoS) for merchants. The PoS is linked to your + LNbits wallet but completely air-gapped so users can ONLY create + invoices. To share the TPoS hit the hash on the terminal. +

    + Created by + Tiago Vasconcelos.
    diff --git a/lnbits/extensions/tpos/templates/tpos/index.html b/lnbits/extensions/tpos/templates/tpos/index.html index b5a55db..1b7e8ff 100644 --- a/lnbits/extensions/tpos/templates/tpos/index.html +++ b/lnbits/extensions/tpos/templates/tpos/index.html @@ -1,221 +1,423 @@ -{% extends "base.html" %} +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} +
    +
    + + + New TPoS + + -{% from "macros.jinja" import window_vars with context %} - - -{% block page %} -
    -
    - - - New TPoS - - - - - -
    -
    -
    TPoS
    -
    -
    - Export to CSV -
    + + +
    +
    +
    TPoS
    +
    +
    + Export to CSV
    - - {% raw %} - +
    + + {% raw %} + - - {% endraw %} - -
    -
    -
    + + {% endraw %} + +
    +
    +
    -
    - - -
    LNbits TPoS extension
    -
    - +
    + + +
    LNbits TPoS extension
    +
    + + + + {% include "tpos/_api_docs.html" %} - - {% include "tpos/_api_docs.html" %} - - {% include "tpos/_tpos.html" %} - - -
    -
    - - - - - - - - -
    - Create TPoS - Cancel -
    -
    -
    -
    + {% include "tpos/_tpos.html" %} + +
    +
    -{% endblock %} -{% block scripts %} - {{ window_vars(user) }} - + } + }) + {% endblock %} diff --git a/lnbits/extensions/tpos/templates/tpos/tpos.html b/lnbits/extensions/tpos/templates/tpos/tpos.html index c219966..6d96233 100644 --- a/lnbits/extensions/tpos/templates/tpos/tpos.html +++ b/lnbits/extensions/tpos/templates/tpos/tpos.html @@ -1,225 +1,265 @@ -{% extends "public.html" %} - - -{% block toolbar_title %}{{ tpos.name }}{% endblock %} - -{% block footer %}{% endblock %} - -{% block page_container %} - - - -
    -
    -

    {% raw %}{{ famount }}{% endraw %}

    -
    - {% raw %}{{ fsat }}{% endraw %} sat -
    -
    +{% extends "public.html" %} {% block toolbar_title %}{{ tpos.name }}{% endblock +%} {% block footer %}{% endblock %} {% block page_container %} + + + +
    +
    +

    {% raw %}{{ famount }}{% endraw %}

    +
    + {% raw %}{{ fsat }}{% endraw %} sat +
    - - -
    -
    -
    - 1 - 2 - 3 - C - 4 - 5 - 6 - 7 - 8 - 9 - OK - DEL - 0 - # -
    +
    + + +
    +
    +
    + 1 + 2 + 3 + C + 4 + 5 + 6 + 7 + 8 + 9 + OK + DEL + 0 + #
    - - - - - - -
    -

    {% raw %}{{ famount }}{% endraw %}

    -
    - {% raw %}{{ fsat }}{% endraw %} sat -
    -
    -
    - Close -
    -
    -
    - - - - - -
    -

    {{ tpos.name }}
    {{ request.url }}

    -
    -
    - Copy URL - Close -
    -
    -
    - - -{% endblock %} - -{% block styles %} - -{% endblock %} - -{% block scripts %} - - + + }, + created: function () { + var getRates = this.getRates + getRates() + setInterval(function () { + getRates() + }, 20000) + } + }) + {% endblock %} diff --git a/lnbits/extensions/usermanager/templates/usermanager/_api_docs.html b/lnbits/extensions/usermanager/templates/usermanager/_api_docs.html index de843f1..e692388 100644 --- a/lnbits/extensions/usermanager/templates/usermanager/_api_docs.html +++ b/lnbits/extensions/usermanager/templates/usermanager/_api_docs.html @@ -1,19 +1,26 @@ - - - - -
    User Manager: Make and manager users/wallets
    -

    To help developers use LNbits to manage their users, the User Manager extension allows the creation and management of users and wallets.
    For example, a games developer may be developing a game that needs each user to have their own wallet, LNbits can be included in the develpoers stack as the user and wallet manager.
    - Created by, Ben Arc

    -
    - - - + + + +
    + User Manager: Make and manager users/wallets +
    +

    + To help developers use LNbits to manage their users, the User Manager + extension allows the creation and management of users and wallets. +
    For example, a games developer may be developing a game that needs + each user to have their own wallet, LNbits can be included in the + develpoers stack as the user and wallet manager.
    + + Created by, Ben Arc +

    +
    +
    - - GET /usermanager/api/v1/users + GET + /usermanager/api/v1/users
    Body (application/json)
    -
    Returns 201 CREATED (application/json)
    +
    + Returns 201 CREATED (application/json) +
    JSON list of users
    Curl example
    - curl -X GET {{ request.url_root }}usermanager/api/v1/users -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" + curl -X GET {{ request.url_root }}usermanager/api/v1/users -H + "X-Api-Key: {{ g.user.wallets[0].inkey }}" +
    - + - GET /usermanager/api/v1/wallets/<user_id> + GET + /usermanager/api/v1/wallets/<user_id>
    Headers
    {"X-Api-Key": <string>}
    Body (application/json)
    -
    Returns 201 CREATED (application/json)
    +
    + Returns 201 CREATED (application/json) +
    JSON wallet data
    Curl example
    - curl -X GET {{ request.url_root }}usermanager/api/v1/wallets/<user_id> -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" + curl -X GET {{ request.url_root + }}usermanager/api/v1/wallets/<user_id> -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" +
    - + - GET /usermanager/api/v1/wallets<wallet_id> + GET + /usermanager/api/v1/wallets<wallet_id>
    Headers
    {"X-Api-Key": <string>}
    Body (application/json)
    -
    Returns 201 CREATED (application/json)
    +
    + Returns 201 CREATED (application/json) +
    JSON a wallets transactions
    Curl example
    - curl -X GET {{ request.url_root }}usermanager/api/v1/wallets<wallet_id> -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" + curl -X GET {{ request.url_root + }}usermanager/api/v1/wallets<wallet_id> -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" +
    - + - POST /usermanager/api/v1/users + POST + /usermanager/api/v1/users
    Headers
    - {"X-Api-Key": <string>, "Content-type": "application/json"} -
    Body (application/json) - "admin_id" is a YOUR user ID
    - {"admin_id": <string>, "user_name": <string>, "wallet_name": <string>} -
    Returns 201 CREATED (application/json)
    - {"checking_id": <string>,"payment_request": <string>} + {"X-Api-Key": <string>, "Content-type": + "application/json"} +
    + Body (application/json) - "admin_id" is a YOUR user ID +
    + {"admin_id": <string>, "user_name": <string>, + "wallet_name": <string>} +
    + Returns 201 CREATED (application/json) +
    + {"checking_id": <string>,"payment_request": + <string>}
    Curl example
    - curl -X POST {{ request.url_root }}usermanager/api/v1/users -d '{"admin_id": "{{ g.user.id }}", "wallet_name": <string>, "user_name": <string>}' -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -H "Content-type: application/json" - + curl -X POST {{ request.url_root }}usermanager/api/v1/users -d + '{"admin_id": "{{ g.user.id }}", "wallet_name": <string>, + "user_name": <string>}' -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" -H "Content-type: application/json" +
    - POST /usermanager/api/v1/wallets + POST + /usermanager/api/v1/wallets
    Headers
    - {"X-Api-Key": <string>, "Content-type": "application/json"} -
    Body (application/json) - "admin_id" is a YOUR user ID
    - {"user_id": <string>, "wallet_name": <string>, "admin_id": <string>} -
    Returns 201 CREATED (application/json)
    - {"checking_id": <string>,"payment_request": <string>} + {"X-Api-Key": <string>, "Content-type": + "application/json"} +
    + Body (application/json) - "admin_id" is a YOUR user ID +
    + {"user_id": <string>, "wallet_name": <string>, + "admin_id": <string>} +
    + Returns 201 CREATED (application/json) +
    + {"checking_id": <string>,"payment_request": + <string>}
    Curl example
    - curl -X POST {{ request.url_root }}usermanager/api/v1/wallets -d '{"user_id": <string>, "wallet_name": <string>, "admin_id": "{{ g.user.id }}"}' -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" -H "Content-type: application/json" - + curl -X POST {{ request.url_root }}usermanager/api/v1/wallets -d + '{"user_id": <string>, "wallet_name": <string>, + "admin_id": "{{ g.user.id }}"}' -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" -H "Content-type: application/json" +
    - + - DELETE /usermanager/api/v1/users/<user_id> + DELETE + /usermanager/api/v1/users/<user_id>
    Headers
    {"X-Api-Key": <string>}
    Curl example
    - curl -X DELETE {{ request.url_root }}usermanager/api/v1/users/<user_id> -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" + curl -X DELETE {{ request.url_root + }}usermanager/api/v1/users/<user_id> -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" +
    - + - DELETE /usermanager/api/v1/wallets/<wallet_id> + DELETE + /usermanager/api/v1/wallets/<wallet_id>
    Headers
    {"X-Api-Key": <string>}
    Curl example
    - curl -X DELETE {{ request.url_root }}usermanager/api/v1/wallets/<wallet_id> -H "X-Api-Key: {{ g.user.wallets[0].inkey }}" + curl -X DELETE {{ request.url_root + }}usermanager/api/v1/wallets/<wallet_id> -H "X-Api-Key: {{ + g.user.wallets[0].inkey }}" +
    - -
    diff --git a/lnbits/extensions/usermanager/templates/usermanager/index.html b/lnbits/extensions/usermanager/templates/usermanager/index.html index f1306ec..d5ff78b 100644 --- a/lnbits/extensions/usermanager/templates/usermanager/index.html +++ b/lnbits/extensions/usermanager/templates/usermanager/index.html @@ -1,416 +1,453 @@ -{% extends "base.html" %} - -{% from "macros.jinja" import window_vars with context %} - - -{% block page %} -
    -
    - - - New User - New Wallet - - - - - - -
    -
    -
    Users
    -
    -
    - Export to CSV -
    +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block page %} +
    +
    + + + New User + New Wallet + + + + + + +
    +
    +
    Users
    - - {% raw %} - - - {% endraw %} - - - - - - -
    -
    -
    Wallets
    -
    -
    - Export to CSV -
    +
    + Export to CSV
    - - {% raw %} - - - {% endraw %} - - - - - -
    - -
    - - -
    LNbits User Manager Extension
    -
    - - - - {% include "usermanager/_api_docs.html" %} - - -
    -
    - - - - - - - - - Create User - Cancel +
    + + {% raw %} + + + {% endraw %} + +
    +
    + + + +
    +
    +
    Wallets
    - - - - - - - - - - - - - Create Wallet - Cancel +
    + Export to CSV
    -
    -
    -
    - - +
    + + {% raw %} + + + {% endraw %} + +
    +
    -{% endblock %} - -{% block scripts %} - {{ window_vars(user) }} - + }, + created: function () { + if (this.g.user.wallets.length) { + this.getUsers() + this.getWallets() + } + } + }) + {% endblock %} diff --git a/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html b/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html index d60dea9..bbc2d59 100644 --- a/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html +++ b/lnbits/extensions/withdraw/templates/withdraw/_api_docs.html @@ -4,64 +4,126 @@ label="API info" :content-inset-level="0.5" > - + - GET /withdraw/api/v1/links + GET /withdraw/api/v1/links
    Headers
    {"X-Api-Key": <invoice_key>}
    Body (application/json)
    -
    Returns 201 CREATED (application/json)
    +
    + Returns 201 CREATED (application/json) +
    {"lnurl": <string>}
    Curl example
    - curl -X GET {{ request.url_root }}withdraw/api/v1/links -H "X-Api-Key: <invoice_key>" + curl -X GET {{ request.url_root }}withdraw/api/v1/links -H + "X-Api-Key: <invoice_key>" +
    - + - POST /withdraw/api/v1/links + POST + /withdraw/api/v1/links
    Headers
    {"X-Api-Key": <admin_key>}
    Body (application/json)
    - {"title": <string>, "min_withdrawable": <integer>, "max_withdrawable": <integer>, "uses": <integer>, "wait_time": <integer>, "is_unique": <boolean>} -
    Returns 201 CREATED (application/json)
    + {"title": <string>, "min_withdrawable": <integer>, + "max_withdrawable": <integer>, "uses": <integer>, + "wait_time": <integer>, "is_unique": <boolean>} +
    + Returns 201 CREATED (application/json) +
    {"lnurl": <string>}
    Curl example
    - curl -X POST {{ request.url_root }}withdraw/api/v1/links -d '{"title": <string>, "min_withdrawable": <integer>, "max_withdrawable": <integer>, "uses": <integer>, "wait_time": <integer>, "is_unique": <boolean>}' -H "Content-type: application/json" -H "X-Api-Key: <admin_key>" - + curl -X POST {{ request.url_root }}withdraw/api/v1/links -d + '{"title": <string>, "min_withdrawable": <integer>, + "max_withdrawable": <integer>, "uses": <integer>, + "wait_time": <integer>, "is_unique": <boolean>}' -H + "Content-type: application/json" -H "X-Api-Key: <admin_key>" +
    - + - PUT /withdraw/api/v1/links/<withdraw_id> + PUT + /withdraw/api/v1/links/<withdraw_id>
    Headers
    {"X-Api-Key": <admin_key>}
    Body (application/json)
    - {"title": <string>, "min_withdrawable": <integer>, "max_withdrawable": <integer>, "uses": <integer>, "wait_time": <integer>, "is_unique": <boolean>} -
    Returns 201 CREATED (application/json)
    + {"title": <string>, "min_withdrawable": <integer>, + "max_withdrawable": <integer>, "uses": <integer>, + "wait_time": <integer>, "is_unique": <boolean>} +
    + Returns 201 CREATED (application/json) +
    {"lnurl": <string>}
    Curl example
    - curl -X PUT {{ request.url_root }}withdraw/api/v1/links/<withdraw_id> -d '{"title": <string>, "min_withdrawable": <integer>, "max_withdrawable": <integer>, "uses": <integer>, "wait_time": <integer>, "is_unique": <boolean>}' -H "Content-type: application/json" -H "X-Api-Key: <admin_key>" - + curl -X PUT {{ request.url_root + }}withdraw/api/v1/links/<withdraw_id> -d '{"title": + <string>, "min_withdrawable": <integer>, + "max_withdrawable": <integer>, "uses": <integer>, + "wait_time": <integer>, "is_unique": <boolean>}' -H + "Content-type: application/json" -H "X-Api-Key: <admin_key>" +
    - + - DELETE /withdraw/api/v1/links/<withdraw_id> + DELETE + /withdraw/api/v1/links/<withdraw_id>
    Headers
    {"X-Api-Key": <admin_key>}
    Returns 201 NO_CONTENT
    {"lnurl": <string>}
    Curl example
    - curl -X DELETE {{ request.url_root }}withdraw/api/v1/links/<withdraw_id> -H "X-Api-Key: <admin_key>" - - + curl -X DELETE {{ request.url_root + }}withdraw/api/v1/links/<withdraw_id> -H "X-Api-Key: + <admin_key>" +
    diff --git a/lnbits/extensions/withdraw/templates/withdraw/_lnurl.html b/lnbits/extensions/withdraw/templates/withdraw/_lnurl.html index d132918..efb9a48 100644 --- a/lnbits/extensions/withdraw/templates/withdraw/_lnurl.html +++ b/lnbits/extensions/withdraw/templates/withdraw/_lnurl.html @@ -1,12 +1,29 @@ - + -

    WARNING: LNURL must be used over https or TOR
    LNURL is a range of lightning-network standards that allow us to use lightning-network differently. An LNURL withdraw is the permission for someone to pull a certain amount of funds from a lightning wallet. In this extension time is also added - an amount can be withdraw over a period of time. A typical use case for an LNURL withdraw is a faucet, although it is a very powerful technology, with much further reaching implications. For example, an LNURL withdraw could be minted to pay for a subscription service.

    -

    Exploring LNURL and finding use cases, is really helping inform lightning protocol development, rather than the protocol dictating how lightning-network should be engaged with.

    - Check Awesome LNURL for further information. +

    + WARNING: LNURL must be used over https or TOR
    + LNURL is a range of lightning-network standards that allow us to use + lightning-network differently. An LNURL withdraw is the permission for + someone to pull a certain amount of funds from a lightning wallet. In + this extension time is also added - an amount can be withdraw over a + period of time. A typical use case for an LNURL withdraw is a faucet, + although it is a very powerful technology, with much further reaching + implications. For example, an LNURL withdraw could be minted to pay for + a subscription service. +

    +

    + Exploring LNURL and finding use cases, is really helping inform + lightning protocol development, rather than the protocol dictating how + lightning-network should be engaged with. +

    + Check + Awesome LNURL + for further information.
    diff --git a/lnbits/extensions/withdraw/templates/withdraw/display.html b/lnbits/extensions/withdraw/templates/withdraw/display.html index 38b330f..27399f4 100644 --- a/lnbits/extensions/withdraw/templates/withdraw/display.html +++ b/lnbits/extensions/withdraw/templates/withdraw/display.html @@ -1,52 +1,57 @@ -{% extends "public.html" %} - - -{% block page %} -
    -
    - - -
    - {% if link.is_spent %} - Withdraw is spent. - {% endif %} - - - - - -
    -
    - Copy LNURL -
    -
    -
    -
    -
    - - -
    LNbits LNURL-withdraw link
    -

    Use a LNURL compatible bitcoin wallet to claim the sats.

    -
    - - - - {% include "withdraw/_lnurl.html" %} - - -
    -
    +{% extends "public.html" %} {% block page %} +
    +
    + + +
    + {% if link.is_spent %} + Withdraw is spent. + {% endif %} + + + + + +
    +
    + Copy LNURL +
    +
    +
    -{% endblock %} - -{% block scripts %} - - + + new Vue({ + el: '#vue', + mixins: [windowMixin] + }) + {% endblock %} diff --git a/lnbits/extensions/withdraw/templates/withdraw/index.html b/lnbits/extensions/withdraw/templates/withdraw/index.html index 691637e..2d94a2b 100644 --- a/lnbits/extensions/withdraw/templates/withdraw/index.html +++ b/lnbits/extensions/withdraw/templates/withdraw/index.html @@ -1,148 +1,213 @@ -{% extends "base.html" %} +{% extends "base.html" %} {% from "macros.jinja" import window_vars with context +%} {% block scripts %} {{ window_vars(user) }} + +{% assets filters='rjsmin', output='__bundle__/withdraw/index.js', +'withdraw/js/index.js' %} + +{% endassets %} {% endblock %} {% block page %} +
    +
    + + + New withdraw link + + -{% from "macros.jinja" import window_vars with context %} - - -{% block scripts %} - {{ window_vars(user) }} - - {% assets filters='rjsmin', output='__bundle__/withdraw/index.js', - 'withdraw/js/index.js' %} - - {% endassets %} -{% endblock %} - -{% block page %} -
    -
    - - - New withdraw link - - - - - -
    -
    -
    Withdraw links
    -
    -
    - Export to CSV -
    + + +
    +
    +
    Withdraw links
    +
    +
    + Export to CSV
    - - {% raw %} - - - {% endraw %} - - - -
    +
    + + {% raw %} + + + {% endraw %} + +
    +
    +
    -
    - - -
    LNbits LNURL-withdraw extension
    -
    - +
    + + +
    + LNbits LNURL-withdraw extension +
    +
    + + + + {% include "withdraw/_api_docs.html" %} - - {% include "withdraw/_api_docs.html" %} - - {% include "withdraw/_lnurl.html" %} - - -
    -
    + {% include "withdraw/_lnurl.html" %} + +
    +
    +
    - - - - - - - - - -
    -
    - - -
    -
    - - -
    + + + + + + + + + +
    +
    + + +
    +
    + +
    - - - - - - - Use unique withdraw QR codes to reduce `assmilking` - This is recommended if you are sharing the links on social media. NOT if you plan to print QR codes. - - - -
    - Update withdraw link - + + + + + Use unique withdraw QR codes to reduce + `assmilking` + This is recommended if you are sharing the links on social + media. NOT if you plan to print QR codes. + + + +
    + Update withdraw link + Create withdraw link - Cancel -
    - - - - - - - {% raw %} - - - -

    - ID: {{ qrCodeDialog.data.id }}
    - Unique: {{ qrCodeDialog.data.is_unique }} (QR code will change after each withdrawal)
    - Max. withdrawable: {{ qrCodeDialog.data.max_withdrawable }} sat
    - Wait time: {{ qrCodeDialog.data.wait_time }} seconds
    - Withdraws: {{ qrCodeDialog.data.used }} / {{ qrCodeDialog.data.uses }} -

    - {% endraw %} -
    - Copy LNURL - Shareable link - - Close + type="submit" + >Create withdraw link + Cancel
    -
    -
    -
    + + + + + + + {% raw %} + + + +

    + ID: {{ qrCodeDialog.data.id }}
    + Unique: {{ qrCodeDialog.data.is_unique }} + (QR code will change after each withdrawal)
    + Max. withdrawable: {{ + qrCodeDialog.data.max_withdrawable }} sat
    + Wait time: {{ qrCodeDialog.data.wait_time }} seconds
    + Withdraws: {{ qrCodeDialog.data.used }} / {{ + qrCodeDialog.data.uses }} + +

    + {% endraw %} +
    + Copy LNURL + Shareable link + + Close +
    +
    +
    +
    {% endblock %} diff --git a/lnbits/extensions/withdraw/templates/withdraw/print_qr.html b/lnbits/extensions/withdraw/templates/withdraw/print_qr.html index c0513de..4409001 100644 --- a/lnbits/extensions/withdraw/templates/withdraw/print_qr.html +++ b/lnbits/extensions/withdraw/templates/withdraw/print_qr.html @@ -1,66 +1,59 @@ -{% extends "print.html" %} - - -{% block page %} -
    -
    - {% for i in range(link.uses) %} -
    -
    - -

    - {{ SITE_TITLE }}
    - {{ link.max_withdrawable }} FREE SATS
    - Scan and follow link
    or use Lightning wallet
    -
    - -
    - {% endfor %} +{% extends "print.html" %} {% block page %} +
    +
    + {% for i in range(link.uses) %} +
    +
    + +

    + {{ SITE_TITLE }}
    + {{ link.max_withdrawable }} FREE SATS
    + Scan and follow link
    or use Lightning wallet
    +
    +
    + {% endfor %}
    -{% endblock %} +
    +{% endblock %} {% block styles %} + +{% endblock %} {% block scripts %} + + - + }) + {% endblock %} diff --git a/lnbits/static/js/base.js b/lnbits/static/js/base.js index 4bc2c09..5edaa2a 100644 --- a/lnbits/static/js/base.js +++ b/lnbits/static/js/base.js @@ -1,6 +1,6 @@ -var LOCALE = 'en'; +var LOCALE = 'en' -var EventHub = new Vue(); +var EventHub = new Vue() var LNbits = { api: { @@ -12,78 +12,97 @@ var LNbits = { 'X-Api-Key': apiKey }, data: data - }); + }) }, createInvoice: function (wallet, amount, memo) { return this.request('post', '/api/v1/payments', wallet.inkey, { out: false, amount: amount, memo: memo - }); + }) }, payInvoice: function (wallet, bolt11) { return this.request('post', '/api/v1/payments', wallet.adminkey, { out: true, bolt11: bolt11 - }); + }) }, getPayments: function (wallet, checkPending) { - var query_param = (checkPending) ? '?check_pending' : ''; - return this.request('get', ['/api/v1/payments', query_param].join(''), wallet.inkey); + var query_param = checkPending ? '?check_pending' : '' + return this.request( + 'get', + ['/api/v1/payments', query_param].join(''), + wallet.inkey + ) }, getPayment: function (wallet, payhash) { - return this.request('get', '/api/v1/payments/' + payhash, wallet.inkey); + return this.request('get', '/api/v1/payments/' + payhash, wallet.inkey) } }, href: { createWallet: function (walletName, userId) { - window.location.href = '/wallet?' + (userId ? 'usr=' + userId + '&' : '') + 'nme=' + walletName; + window.location.href = + '/wallet?' + (userId ? 'usr=' + userId + '&' : '') + 'nme=' + walletName }, deleteWallet: function (walletId, userId) { - window.location.href = '/deletewallet?usr=' + userId + '&wal=' + walletId; + window.location.href = '/deletewallet?usr=' + userId + '&wal=' + walletId } }, map: { extension: function (data) { - var obj = _.object(['code', 'isValid', 'name', 'shortDescription', 'icon'], data); - obj.url = ['/', obj.code, '/'].join(''); - return obj; + var obj = _.object( + ['code', 'isValid', 'name', 'shortDescription', 'icon'], + data + ) + obj.url = ['/', obj.code, '/'].join('') + return obj }, user: function (data) { - var obj = _.object(['id', 'email', 'extensions', 'wallets'], data); - var mapWallet = this.wallet; - obj.wallets = obj.wallets.map(function (obj) { - return mapWallet(obj); - }).sort(function (a, b) { - return a.name.localeCompare(b.name); - }); + var obj = _.object(['id', 'email', 'extensions', 'wallets'], data) + var mapWallet = this.wallet + obj.wallets = obj.wallets + .map(function (obj) { + return mapWallet(obj) + }) + .sort(function (a, b) { + return a.name.localeCompare(b.name) + }) obj.walletOptions = obj.wallets.map(function (obj) { return { label: [obj.name, ' - ', obj.id].join(''), value: obj.id - }; - }); - return obj; + } + }) + return obj }, wallet: function (data) { - var obj = _.object(['id', 'name', 'user', 'adminkey', 'inkey', 'balance'], data); - obj.msat = obj.balance; - obj.sat = Math.round(obj.balance / 1000); - obj.fsat = new Intl.NumberFormat(LOCALE).format(obj.sat); - obj.url = ['/wallet?usr=', obj.user, '&wal=', obj.id].join(''); - return obj; + var obj = _.object( + ['id', 'name', 'user', 'adminkey', 'inkey', 'balance'], + data + ) + obj.msat = obj.balance + obj.sat = Math.round(obj.balance / 1000) + obj.fsat = new Intl.NumberFormat(LOCALE).format(obj.sat) + obj.url = ['/wallet?usr=', obj.user, '&wal=', obj.id].join('') + return obj }, payment: function (data) { - var obj = _.object(['payhash', 'pending', 'amount', 'fee', 'memo', 'time'], data); - obj.date = Quasar.utils.date.formatDate(new Date(obj.time * 1000), 'YYYY-MM-DD HH:mm'); - obj.msat = obj.amount; - obj.sat = obj.msat / 1000; - obj.fsat = new Intl.NumberFormat(LOCALE).format(obj.sat); - obj.isIn = obj.amount > 0; - obj.isOut = obj.amount < 0; - obj.isPaid = obj.pending == 0; - obj._q = [obj.memo, obj.sat].join(' ').toLowerCase(); - return obj; + var obj = _.object( + ['payhash', 'pending', 'amount', 'fee', 'memo', 'time'], + data + ) + obj.date = Quasar.utils.date.formatDate( + new Date(obj.time * 1000), + 'YYYY-MM-DD HH:mm' + ) + obj.msat = obj.amount + obj.sat = obj.msat / 1000 + obj.fsat = new Intl.NumberFormat(LOCALE).format(obj.sat) + obj.isIn = obj.amount > 0 + obj.isOut = obj.amount < 0 + obj.isPaid = obj.pending == 0 + obj._q = [obj.memo, obj.sat].join(' ').toLowerCase() + return obj } }, utils: { @@ -98,84 +117,99 @@ var LNbits = { flat: true, color: 'grey' } - }); + }) }, formatCurrency: function (value, currency) { - return new Intl.NumberFormat(LOCALE, {style: 'currency', currency: currency}).format(value); + return new Intl.NumberFormat(LOCALE, { + style: 'currency', + currency: currency + }).format(value) }, formatSat: function (value) { - return new Intl.NumberFormat(LOCALE).format(value); + return new Intl.NumberFormat(LOCALE).format(value) }, notifyApiError: function (error) { var types = { 400: 'warning', 401: 'warning', 500: 'negative' - }; + } Quasar.plugins.Notify.create({ timeout: 5000, type: types[error.response.status] || 'warning', message: error.response.data.message || null, - caption: [error.response.status, ' ', error.response.statusText].join('').toUpperCase() || null, + caption: + [error.response.status, ' ', error.response.statusText] + .join('') + .toUpperCase() || null, icon: null - }); + }) }, search: function (data, q, field, separator) { - var field = field || '_q'; + var field = field || '_q' try { - var queries = q.toLowerCase().split(separator || ' '); + var queries = q.toLowerCase().split(separator || ' ') return data.filter(function (obj) { - var matches = 0; + var matches = 0 _.each(queries, function (q) { - if (obj[field].indexOf(q) !== -1) matches++; - }); - return matches == queries.length; - }); + if (obj[field].indexOf(q) !== -1) matches++ + }) + return matches == queries.length + }) } catch (err) { - return data; + return data } }, exportCSV: function (columns, data) { - var wrapCsvValue = function(val, formatFn) { - var formatted = formatFn !== void 0 - ? formatFn(val) - : val; + var wrapCsvValue = function (val, formatFn) { + var formatted = formatFn !== void 0 ? formatFn(val) : val - formatted = (formatted === void 0 || formatted === null) - ? '' - : String(formatted); + formatted = + formatted === void 0 || formatted === null ? '' : String(formatted) - formatted = formatted.split('"').join('""'); + formatted = formatted.split('"').join('""') - return `"${formatted}"`; + return `"${formatted}"` } - var content = [columns.map(function (col) { - return wrapCsvValue(col.label); - })].concat(data.map(function (row) { - return columns.map(function (col) { - return wrapCsvValue( - (typeof col.field === 'function') - ? col.field(row) - : row[(col.field === void 0) ? col.name : col.field], - col.format - ); - }).join(','); - })).join('\r\n'); + var content = [ + columns.map(function (col) { + return wrapCsvValue(col.label) + }) + ] + .concat( + data.map(function (row) { + return columns + .map(function (col) { + return wrapCsvValue( + typeof col.field === 'function' + ? col.field(row) + : row[col.field === void 0 ? col.name : col.field], + col.format + ) + }) + .join(',') + }) + ) + .join('\r\n') - var status = Quasar.utils.exportFile('table-export.csv', content, 'text/csv'); + var status = Quasar.utils.exportFile( + 'table-export.csv', + content, + 'text/csv' + ) if (status !== true) { Quasar.plugins.Notify.create({ message: 'Browser denied file download...', color: 'negative', icon: null - }); + }) } } } -}; +} var windowMixin = { data: function () { @@ -185,44 +219,52 @@ var windowMixin = { extensions: [], user: null, wallet: null, - payments: [], + payments: [] } - }; + } }, methods: { toggleDarkMode: function () { - this.$q.dark.toggle(); - this.$q.localStorage.set('lnbits.darkMode', this.$q.dark.isActive); + this.$q.dark.toggle() + this.$q.localStorage.set('lnbits.darkMode', this.$q.dark.isActive) }, copyText: function (text, message, position) { - var notify = this.$q.notify; + var notify = this.$q.notify Quasar.utils.copyToClipboard(text).then(function () { - notify({message: message || 'Copied to clipboard!', position: position || 'bottom'}); - }); + notify({ + message: message || 'Copied to clipboard!', + position: position || 'bottom' + }) + }) } }, created: function () { - this.$q.dark.set(this.$q.localStorage.getItem('lnbits.darkMode')); + this.$q.dark.set(this.$q.localStorage.getItem('lnbits.darkMode')) if (window.user) { - this.g.user = Object.freeze(LNbits.map.user(window.user)); + this.g.user = Object.freeze(LNbits.map.user(window.user)) } if (window.wallet) { - this.g.wallet = Object.freeze(LNbits.map.wallet(window.wallet)); + this.g.wallet = Object.freeze(LNbits.map.wallet(window.wallet)) } if (window.extensions) { - var user = this.g.user; - this.g.extensions = Object.freeze(window.extensions.map(function (data) { - return LNbits.map.extension(data); - }).map(function (obj) { - if (user) { - obj.isEnabled = user.extensions.indexOf(obj.code) != -1; - } else { - obj.isEnabled = false; - } - return obj; - }).sort(function (a, b) { - return a.name > b.name; - })); + var user = this.g.user + this.g.extensions = Object.freeze( + window.extensions + .map(function (data) { + return LNbits.map.extension(data) + }) + .map(function (obj) { + if (user) { + obj.isEnabled = user.extensions.indexOf(obj.code) != -1 + } else { + obj.isEnabled = false + } + return obj + }) + .sort(function (a, b) { + return a.name > b.name + }) + ) } } -}; +} diff --git a/lnbits/static/js/components.js b/lnbits/static/js/components.js index 76be279..1efb745 100644 --- a/lnbits/static/js/components.js +++ b/lnbits/static/js/components.js @@ -8,10 +8,10 @@ Vue.component('lnbits-fsat', { template: '{{ fsat }}', computed: { fsat: function () { - return LNbits.utils.formatSat(this.amount); + return LNbits.utils.formatSat(this.amount) } } -}); +}) Vue.component('lnbits-wallet-list', { data: function () { @@ -70,33 +70,34 @@ Vue.component('lnbits-wallet-list', { `, computed: { wallets: function () { - var bal = this.activeBalance; + var bal = this.activeBalance return this.user.wallets.map(function (obj) { - obj.live_fsat = (bal.length && bal[0] == obj.id) - ? LNbits.utils.formatSat(bal[1]) - : obj.fsat; - return obj; - }); + obj.live_fsat = + bal.length && bal[0] == obj.id + ? LNbits.utils.formatSat(bal[1]) + : obj.fsat + return obj + }) } }, methods: { createWallet: function () { - LNbits.href.createWallet(this.walletName, this.user.id); + LNbits.href.createWallet(this.walletName, this.user.id) }, updateWalletBalance: function (payload) { - this.activeBalance = payload; + this.activeBalance = payload } }, created: function () { if (window.user) { - this.user = LNbits.map.user(window.user); + this.user = LNbits.map.user(window.user) } if (window.wallet) { - this.activeWallet = LNbits.map.wallet(window.wallet); + this.activeWallet = LNbits.map.wallet(window.wallet) } - EventHub.$on('update-wallet-balance', this.updateWalletBalance); + EventHub.$on('update-wallet-balance', this.updateWalletBalance) } -}); +}) Vue.component('lnbits-extension-list', { data: function () { @@ -140,30 +141,34 @@ Vue.component('lnbits-extension-list', { `, computed: { userExtensions: function () { - if (!this.user) return []; + if (!this.user) return [] - var path = window.location.pathname; - var userExtensions = this.user.extensions; + var path = window.location.pathname + var userExtensions = this.user.extensions - return this.extensions.filter(function (obj) { - return userExtensions.indexOf(obj.code) !== -1; - }).map(function (obj) { - obj.isActive = path.startsWith(obj.url); - return obj; - }); + return this.extensions + .filter(function (obj) { + return userExtensions.indexOf(obj.code) !== -1 + }) + .map(function (obj) { + obj.isActive = path.startsWith(obj.url) + return obj + }) } }, created: function () { if (window.extensions) { - this.extensions = window.extensions.map(function (data) { - return LNbits.map.extension(data); - }).sort(function (a, b) { - return a.name.localeCompare(b.name); - }); + this.extensions = window.extensions + .map(function (data) { + return LNbits.map.extension(data) + }) + .sort(function (a, b) { + return a.name.localeCompare(b.name) + }) } if (window.user) { - this.user = LNbits.map.user(window.user); + this.user = LNbits.map.user(window.user) } } -}); +}) diff --git a/package.json b/package.json new file mode 100644 index 0000000..835ff77 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "devDependencies": { + "prettier": "^2.0.5" + } +}