mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-30 10:34:28 +02:00
run prettier
This commit is contained in:
@ -1,9 +1,9 @@
|
|||||||
// the cache version gets updated every time there is a new deployment
|
// the cache version gets updated every time there is a new deployment
|
||||||
const CACHE_VERSION = 1;
|
const CACHE_VERSION = 1
|
||||||
const CURRENT_CACHE = `lnbits-${CACHE_VERSION}-`;
|
const CURRENT_CACHE = `lnbits-${CACHE_VERSION}-`
|
||||||
|
|
||||||
const getApiKey = (request) => {
|
const getApiKey = request => {
|
||||||
return request.headers.get('X-Api-Key') || "none"
|
return request.headers.get('X-Api-Key') || 'none'
|
||||||
}
|
}
|
||||||
|
|
||||||
// on activation we clean up the previously registered service workers
|
// on activation we clean up the previously registered service workers
|
||||||
@ -14,32 +14,38 @@ self.addEventListener('activate', evt =>
|
|||||||
cacheNames.map(cacheName => {
|
cacheNames.map(cacheName => {
|
||||||
const currentCacheVersion = cacheName.split('-').slice(-2, 2)
|
const currentCacheVersion = cacheName.split('-').slice(-2, 2)
|
||||||
if (currentCacheVersion !== CACHE_VERSION) {
|
if (currentCacheVersion !== CACHE_VERSION) {
|
||||||
return caches.delete(cacheName);
|
return caches.delete(cacheName)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
)
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
);
|
)
|
||||||
|
|
||||||
// The fetch handler serves responses for same-origin resources from a cache.
|
// The fetch handler serves responses for same-origin resources from a cache.
|
||||||
// If no response is found, it populates the runtime cache with the response
|
// If no response is found, it populates the runtime cache with the response
|
||||||
// from the network before returning it to the page.
|
// from the network before returning it to the page.
|
||||||
self.addEventListener('fetch', event => {
|
self.addEventListener('fetch', event => {
|
||||||
// Skip cross-origin requests, like those for Google Analytics.
|
// Skip cross-origin requests, like those for Google Analytics.
|
||||||
if (event.request.url.startsWith(self.location.origin) && event.request.method == "GET") {
|
if (
|
||||||
|
event.request.url.startsWith(self.location.origin) &&
|
||||||
|
event.request.method == 'GET'
|
||||||
|
) {
|
||||||
// Open the cache
|
// Open the cache
|
||||||
event.respondWith(caches.open(CURRENT_CACHE + getApiKey(event.request)).then((cache) => {
|
event.respondWith(
|
||||||
// Go to the network first
|
caches.open(CURRENT_CACHE + getApiKey(event.request)).then(cache => {
|
||||||
return fetch(event.request).then((fetchedResponse) => {
|
// Go to the network first
|
||||||
cache.put(event.request, fetchedResponse.clone());
|
return fetch(event.request)
|
||||||
|
.then(fetchedResponse => {
|
||||||
|
cache.put(event.request, fetchedResponse.clone())
|
||||||
|
|
||||||
return fetchedResponse;
|
return fetchedResponse
|
||||||
}).catch(() => {
|
})
|
||||||
// If the network is unavailable, get
|
.catch(() => {
|
||||||
return cache.match(event.request.url);
|
// If the network is unavailable, get
|
||||||
});
|
return cache.match(event.request.url)
|
||||||
}));
|
})
|
||||||
|
})
|
||||||
|
)
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
|
@ -704,8 +704,9 @@ new Vue({
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (navigator.serviceWorker != null) {
|
if (navigator.serviceWorker != null) {
|
||||||
navigator.serviceWorker.register('/service-worker.js')
|
navigator.serviceWorker
|
||||||
.then(function(registration) {
|
.register('/service-worker.js')
|
||||||
console.log('Registered events at scope: ', registration.scope);
|
.then(function (registration) {
|
||||||
});
|
console.log('Registered events at scope: ', registration.scope)
|
||||||
|
})
|
||||||
}
|
}
|
@ -1,6 +1,4 @@
|
|||||||
{% extends "public.html" %}
|
{% extends "public.html" %} {% block toolbar_title %} {{ tpos.name }}
|
||||||
{% block toolbar_title %}
|
|
||||||
{{ tpos.name }}
|
|
||||||
<q-btn
|
<q-btn
|
||||||
flat
|
flat
|
||||||
dense
|
dense
|
||||||
@ -9,8 +7,7 @@
|
|||||||
icon="share"
|
icon="share"
|
||||||
color="white"
|
color="white"
|
||||||
></q-btn>
|
></q-btn>
|
||||||
{% endblock %}
|
{% endblock %} {% block footer %}{% endblock %} {% block page_container %}
|
||||||
{% block footer %}{% endblock %} {% block page_container %}
|
|
||||||
<q-page-container>
|
<q-page-container>
|
||||||
<q-page>
|
<q-page>
|
||||||
<q-page-sticky v-if="exchangeRate" expand position="top">
|
<q-page-sticky v-if="exchangeRate" expand position="top">
|
||||||
@ -179,27 +176,24 @@
|
|||||||
</q-card>
|
</q-card>
|
||||||
</q-dialog>
|
</q-dialog>
|
||||||
|
|
||||||
<q-dialog
|
<q-dialog v-model="tipDialog.show" position="top">
|
||||||
v-model="tipDialog.show"
|
|
||||||
position="top"
|
|
||||||
>
|
|
||||||
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
<q-card class="q-pa-lg q-pt-xl lnbits__dialog-card">
|
||||||
<div class="text-center q-mb-xl">
|
<div class="text-center q-mb-xl">
|
||||||
<b style="font-size: 24px;">Would you like to leave a tip?</b>
|
<b style="font-size: 24px">Would you like to leave a tip?</b>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center q-mb-xl">
|
<div class="text-center q-mb-xl">
|
||||||
<q-btn
|
<q-btn
|
||||||
style="padding: 10px; margin: 3px;"
|
style="padding: 10px; margin: 3px"
|
||||||
unelevated
|
unelevated
|
||||||
@click="processTipSelection(tip)"
|
@click="processTipSelection(tip)"
|
||||||
size="xl"
|
size="xl"
|
||||||
:outline="!($q.dark.isActive)"
|
:outline="!($q.dark.isActive)"
|
||||||
rounded
|
rounded
|
||||||
color="primary"
|
color="primary"
|
||||||
v-for="tip in this.tip_options"
|
v-for="tip in this.tip_options"
|
||||||
:key="tip"
|
:key="tip"
|
||||||
>{% raw %}{{ tip }}{% endraw %}%</q-btn
|
>{% raw %}{{ tip }}{% endraw %}%</q-btn
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
<div class="text-center q-mb-xl">
|
<div class="text-center q-mb-xl">
|
||||||
<p><a @click="processTipSelection(0)"> No, thanks</a></p>
|
<p><a @click="processTipSelection(0)"> No, thanks</a></p>
|
||||||
@ -264,7 +258,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.keypad .btn-confirm {
|
.keypad .btn-confirm {
|
||||||
grid-area: 1 / 4 / 5 / 4;
|
grid-area: 1 / 4 / 5 / 4;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endblock %} {% block scripts %}
|
{% endblock %} {% block scripts %}
|
||||||
@ -281,7 +275,7 @@
|
|||||||
tip_options: JSON.parse('{{ tpos.tip_options }}'),
|
tip_options: JSON.parse('{{ tpos.tip_options }}'),
|
||||||
exchangeRate: null,
|
exchangeRate: null,
|
||||||
stack: [],
|
stack: [],
|
||||||
tipAmount: 0.00,
|
tipAmount: 0.0,
|
||||||
invoiceDialog: {
|
invoiceDialog: {
|
||||||
show: false,
|
show: false,
|
||||||
data: null,
|
data: null,
|
||||||
@ -289,7 +283,7 @@
|
|||||||
paymentChecker: null
|
paymentChecker: null
|
||||||
},
|
},
|
||||||
tipDialog: {
|
tipDialog: {
|
||||||
show: false,
|
show: false
|
||||||
},
|
},
|
||||||
urlDialog: {
|
urlDialog: {
|
||||||
show: false
|
show: false
|
||||||
@ -323,7 +317,7 @@
|
|||||||
methods: {
|
methods: {
|
||||||
closeInvoiceDialog: function () {
|
closeInvoiceDialog: function () {
|
||||||
this.stack = []
|
this.stack = []
|
||||||
this.tipAmount = 0.00
|
this.tipAmount = 0.0
|
||||||
var dialog = this.invoiceDialog
|
var dialog = this.invoiceDialog
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
clearInterval(dialog.paymentChecker)
|
clearInterval(dialog.paymentChecker)
|
||||||
@ -333,8 +327,10 @@
|
|||||||
processTipSelection: function (selectedTipOption) {
|
processTipSelection: function (selectedTipOption) {
|
||||||
this.tipDialog.show = false
|
this.tipDialog.show = false
|
||||||
|
|
||||||
if(selectedTipOption) {
|
if (selectedTipOption) {
|
||||||
const tipAmount = parseFloat(parseFloat((selectedTipOption / 100) * this.amount))
|
const tipAmount = parseFloat(
|
||||||
|
parseFloat((selectedTipOption / 100) * this.amount)
|
||||||
|
)
|
||||||
const subtotal = parseFloat(this.amount)
|
const subtotal = parseFloat(this.amount)
|
||||||
const grandTotal = parseFloat((tipAmount + subtotal).toFixed(2))
|
const grandTotal = parseFloat((tipAmount + subtotal).toFixed(2))
|
||||||
const totalString = grandTotal.toFixed(2).toString()
|
const totalString = grandTotal.toFixed(2).toString()
|
||||||
@ -343,7 +339,7 @@
|
|||||||
for (var i = 0; i < totalString.length; i++) {
|
for (var i = 0; i < totalString.length; i++) {
|
||||||
const char = totalString[i]
|
const char = totalString[i]
|
||||||
|
|
||||||
if(char !== ".") {
|
if (char !== '.') {
|
||||||
this.stack.push(char)
|
this.stack.push(char)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -353,14 +349,14 @@
|
|||||||
|
|
||||||
this.showInvoice()
|
this.showInvoice()
|
||||||
},
|
},
|
||||||
submitForm: function() {
|
submitForm: function () {
|
||||||
if(this.tip_options.length) {
|
if (this.tip_options.length) {
|
||||||
this.showTipModal()
|
this.showTipModal()
|
||||||
} else {
|
} else {
|
||||||
this.showInvoice()
|
this.showInvoice()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
showTipModal: function() {
|
showTipModal: function () {
|
||||||
this.tipDialog.show = true
|
this.tipDialog.show = true
|
||||||
},
|
},
|
||||||
showInvoice: function () {
|
showInvoice: function () {
|
||||||
@ -371,7 +367,7 @@
|
|||||||
.post('/tpos/api/v1/tposs/' + this.tposId + '/invoices', null, {
|
.post('/tpos/api/v1/tposs/' + this.tposId + '/invoices', null, {
|
||||||
params: {
|
params: {
|
||||||
amount: this.sat,
|
amount: this.sat,
|
||||||
tipAmount: this.tipAmountSat,
|
tipAmount: this.tipAmountSat
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
|
@ -17,10 +17,8 @@
|
|||||||
<meta name="mobile-web-app-capable" content="yes" />
|
<meta name="mobile-web-app-capable" content="yes" />
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||||
{% if web_manifest %}
|
{% if web_manifest %}
|
||||||
<link async="async" rel="manifest" href="{{ web_manifest }}" />
|
<link async="async" rel="manifest" href="{{ web_manifest }}" />
|
||||||
{% endif %}
|
{% endif %} {% block head_scripts %}{% endblock %}
|
||||||
|
|
||||||
{% block head_scripts %}{% endblock %}
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body data-theme="bitcoin">
|
<body data-theme="bitcoin">
|
||||||
@ -55,10 +53,13 @@
|
|||||||
>
|
>
|
||||||
</q-badge>
|
</q-badge>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
<q-badge v-if="g.offline" color="red" text-color="white" class="q-mr-md">
|
<q-badge
|
||||||
<span>
|
v-if="g.offline"
|
||||||
OFFLINE
|
color="red"
|
||||||
</span>
|
text-color="white"
|
||||||
|
class="q-mr-md"
|
||||||
|
>
|
||||||
|
<span> OFFLINE </span>
|
||||||
</q-badge>
|
</q-badge>
|
||||||
<q-btn-dropdown
|
<q-btn-dropdown
|
||||||
v-if="g.allowedThemes && g.allowedThemes.length > 1"
|
v-if="g.allowedThemes && g.allowedThemes.length > 1"
|
||||||
|
Reference in New Issue
Block a user