Used prettier

This commit is contained in:
Ben Arc 2021-06-23 22:31:44 +01:00
parent 1ef1b2f4fa
commit 9267aba6d9
4 changed files with 159 additions and 120 deletions

View File

@ -138,15 +138,20 @@
pushAnim(content) { pushAnim(content) {
document.getElementById('animations').style.width = content[0] document.getElementById('animations').style.width = content[0]
document.getElementById('animations').src = content[1] document.getElementById('animations').src = content[1]
setTimeout(function(){ document.getElementById('animations').src = '' }, 5000) setTimeout(function () {
document.getElementById('animations').src = ''
}, 5000)
}, },
launch() { launch() {
self = this self = this
console.log("poo") console.log('poo')
LNbits.api LNbits.api
.request( .request(
'GET', 'GET',
'/copilot/api/v1/copilot/ws/' + self.copilot.id + '/launching/rocket') '/copilot/api/v1/copilot/ws/' +
self.copilot.id +
'/launching/rocket'
)
.then(function (response1) { .then(function (response1) {
self.$q.notify({ self.$q.notify({
color: 'green', color: 'green',
@ -156,7 +161,7 @@
.catch(err => { .catch(err => {
LNbits.utils.notifyApiError(err) LNbits.utils.notifyApiError(err)
}) })
}, }
}, },
mounted() { mounted() {
this.initCamera() this.initCamera()
@ -168,8 +173,7 @@
LNbits.api LNbits.api
.request( .request(
'GET', 'GET',
'/copilot/api/v1/copilot/' + '/copilot/api/v1/copilot/' + self.copilot.id,
self.copilot.id,
localStorage.getItem('inkey') localStorage.getItem('inkey')
) )
.then(function (response) { .then(function (response) {
@ -182,31 +186,29 @@
this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net') this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net')
const obj = JSON.stringify({ const obj = JSON.stringify({
event: "bts:subscribe", event: 'bts:subscribe',
data: { channel: "live_trades_" + self.copilot.show_price}, data: {channel: 'live_trades_' + self.copilot.show_price}
}) })
this.connectionBitStamp.onmessage = function (e) { this.connectionBitStamp.onmessage = function (e) {
console.log(JSON.parse(e.data).data.price) console.log(JSON.parse(e.data).data.price)
console.log(self.copilot) console.log(self.copilot)
if (self.copilot.show_price) { if (self.copilot.show_price) {
if(self.copilot.show_price == "btcusd"){ if (self.copilot.show_price == 'btcusd') {
self.price = String( self.price = String(
new Intl.NumberFormat('en-US', { new Intl.NumberFormat('en-US', {
style: 'currency', style: 'currency',
currency: 'USD' currency: 'USD'
}).format(JSON.parse(e.data).data.price) }).format(JSON.parse(e.data).data.price)
) )
} } else if (self.copilot.show_price == 'btceur') {
else if(self.copilot.show_price == "btceur"){
self.price = String( self.price = String(
new Intl.NumberFormat('en-US', { new Intl.NumberFormat('en-US', {
style: 'currency', style: 'currency',
currency: 'EUR' currency: 'EUR'
}).format(JSON.parse(e.data).data.price) }).format(JSON.parse(e.data).data.price)
) )
} } else if (self.copilot.show_price == 'btcgbp') {
else if(self.copilot.show_price == "btcgbp"){
self.price = String( self.price = String(
new Intl.NumberFormat('en-US', { new Intl.NumberFormat('en-US', {
style: 'currency', style: 'currency',
@ -218,32 +220,39 @@
} }
this.connectionBitStamp.onopen = () => this.connectionBitStamp.send(obj) this.connectionBitStamp.onopen = () => this.connectionBitStamp.send(obj)
const fetch = (data) => new Promise(resolve => setTimeout(resolve, 5000, this.pushAnim(data))) const fetch = data =>
new Promise(resolve => setTimeout(resolve, 5000, this.pushAnim(data)))
const addTask = (() => { const addTask = (() => {
let pending = Promise.resolve(); let pending = Promise.resolve()
const run = async (data) => { const run = async data => {
try { try {
await pending; await pending
} finally { } finally {
return fetch(data); return fetch(data)
} }
} }
return (data) => (pending = run(data)) return data => (pending = run(data))
})(); })()
if (location.protocol !== 'http:') { if (location.protocol !== 'http:') {
localUrl = 'wss://' + localUrl =
'wss://' +
document.domain + document.domain +
':' + ':' +
location.port + location.port +
'/copilot/ws/' + self.copilot.id + '/' '/copilot/ws/' +
self.copilot.id +
'/'
} else { } else {
localUrl = 'ws://' + localUrl =
'ws://' +
document.domain + document.domain +
':' + ':' +
location.port + location.port +
'/copilot/ws/' + self.copilot.id + '/' '/copilot/ws/' +
self.copilot.id +
'/'
} }
this.connection = new WebSocket(localUrl) this.connection = new WebSocket(localUrl)
this.connection.onmessage = function (e) { this.connection.onmessage = function (e) {

View File

@ -105,7 +105,14 @@
</q-btn> </q-btn>
</q-td> </q-td>
<q-td auto-width> <q-td auto-width>
<q-btn flat dense size="xs" @click="openUpdateCopilotLink(props.row.id)" icon="edit" color="light-blue"></q-btn> <q-btn
flat
dense
size="xs"
@click="openUpdateCopilotLink(props.row.id)"
icon="edit"
color="light-blue"
></q-btn>
</q-td> </q-td>
<q-td <q-td
v-for="col in props.cols" v-for="col in props.cols"
@ -334,7 +341,6 @@
:options="currencyOptions" :options="currencyOptions"
label="Show price" label="Show price"
/> />
</div> </div>
<div class="q-gutter-sm"> <div class="q-gutter-sm">
<div class="row"> <div class="row">
@ -490,14 +496,12 @@
self.g.user.wallets[0].adminkey, self.g.user.wallets[0].adminkey,
self.formDialogCopilot.data self.formDialogCopilot.data
) )
} } else {
else{
this.createCopilot( this.createCopilot(
self.g.user.wallets[0].adminkey, self.g.user.wallets[0].adminkey,
self.formDialogCopilot.data self.formDialogCopilot.data
) )
} }
}, },
createCopilot: function (wallet, data) { createCopilot: function (wallet, data) {
@ -595,7 +599,12 @@
console.log(updatedData) console.log(updatedData)
LNbits.api LNbits.api
.request('PUT', '/copilot/api/v1/copilot/' + updatedData.id, wallet, updatedData) .request(
'PUT',
'/copilot/api/v1/copilot/' + updatedData.id,
wallet,
updatedData
)
.then(function (response) { .then(function (response) {
self.CopilotLinks.push(mapCopilot(response.data)) self.CopilotLinks.push(mapCopilot(response.data))
self.formDialogCopilot.show = false self.formDialogCopilot.show = false

View File

@ -129,7 +129,8 @@
LNbits.api LNbits.api
.request( .request(
'GET', 'GET',
'/copilot/api/v1/copilot/ws/' + self.copilot.id + '/none/' + name) '/copilot/api/v1/copilot/ws/' + self.copilot.id + '/none/' + name
)
.then(function (response1) { .then(function (response1) {
self.$q.notify({ self.$q.notify({
color: 'green', color: 'green',
@ -139,7 +140,7 @@
.catch(err => { .catch(err => {
LNbits.utils.notifyApiError(err) LNbits.utils.notifyApiError(err)
}) })
}, }
}, },
created: function () { created: function () {
self = this self = this

28
package-lock.json generated
View File

@ -1,11 +1,31 @@
{ {
"name": "lnbits",
"lockfileVersion": 2,
"requires": true, "requires": true,
"lockfileVersion": 1, "packages": {
"": {
"devDependencies": {
"prettier": "2.1.1"
}
},
"node_modules/prettier": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz",
"integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
}
}
},
"dependencies": { "dependencies": {
"prettier": { "prettier": {
"version": "2.0.5", "version": "2.1.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz",
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==",
"dev": true "dev": true
} }
} }