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

@ -135,18 +135,23 @@
console.log('Something went wrong!') console.log('Something went wrong!')
}) })
}, },
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,9 +173,8 @@
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) {
self.copilot = response.data self.copilot = response.data
@ -178,108 +182,113 @@
.catch(err => { .catch(err => {
LNbits.utils.notifyApiError(err) LNbits.utils.notifyApiError(err)
}) })
this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net')
const obj = JSON.stringify({ this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net')
event: "bts:subscribe",
data: { channel: "live_trades_" + self.copilot.show_price},
})
this.connectionBitStamp.onmessage = function (e) { const obj = JSON.stringify({
console.log(JSON.parse(e.data).data.price) event: 'bts:subscribe',
console.log(self.copilot) data: {channel: 'live_trades_' + self.copilot.show_price}
if(self.copilot.show_price){ })
if(self.copilot.show_price == "btcusd"){
self.price = String( this.connectionBitStamp.onmessage = function (e) {
new Intl.NumberFormat('en-US', { console.log(JSON.parse(e.data).data.price)
console.log(self.copilot)
if (self.copilot.show_price) {
if (self.copilot.show_price == 'btcusd') {
self.price = String(
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',
currency: 'GBP' currency: 'GBP'
}).format(JSON.parse(e.data).data.price) }).format(JSON.parse(e.data).data.price)
) )
}
} }
} }
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 addTask = (() => { const fetch = data =>
let pending = Promise.resolve(); new Promise(resolve => setTimeout(resolve, 5000, this.pushAnim(data)))
const run = async (data) => {
try { const addTask = (() => {
await pending; let pending = Promise.resolve()
} finally { const run = async data => {
return fetch(data); try {
} await pending
} finally {
return fetch(data)
} }
return (data) => (pending = run(data)) }
})(); return data => (pending = run(data))
})()
if (location.protocol !== 'http:') { if (location.protocol !== 'http:') {
localUrl = 'wss://' + localUrl =
document.domain + 'wss://' +
':' + document.domain +
location.port + ':' +
'/copilot/ws/' + self.copilot.id + '/' location.port +
'/copilot/ws/' +
self.copilot.id +
'/'
} else { } else {
localUrl = 'ws://' + localUrl =
document.domain + 'ws://' +
':' + document.domain +
location.port + ':' +
'/copilot/ws/' + self.copilot.id + '/' location.port +
'/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) {
console.log(e.data) console.log(e.data)
res = e.data.split('-') res = e.data.split('-')
if (res[0] == 'rocket') { if (res[0] == 'rocket') {
addTask(['40%', '/copilot/static/rocket.gif']) addTask(['40%', '/copilot/static/rocket.gif'])
}
if (res[0] == 'face') {
addTask(['35%', '/copilot/static/face.gif'])
}
if (res[0] == 'bitcoin') {
addTask(['30%', '/copilot/static/bitcoin.gif'])
}
if (res[0] == 'confetti') {
addTask(['100%', '/copilot/static/confetti.gif'])
}
if (res[0] == 'martijn') {
addTask(['40%', '/copilot/static/martijn.gif'])
}
if (res[0] == 'rick') {
addTask(['40%', '/copilot/static/rick.gif'])
}
if (res[0] == 'true') {
document.getElementById('videoCamera').style.width = '20%'
self.initScreenShare()
}
if (res[0] == 'false') {
document.getElementById('videoCamera').style.width = '100%'
document.getElementById('videoScreen').src = null
}
console.log(res[1])
if (res[1] != 'none') {
showNotif(res[1])
}
} }
if (res[0] == 'face') {
addTask(['35%', '/copilot/static/face.gif'])
}
if (res[0] == 'bitcoin') {
addTask(['30%', '/copilot/static/bitcoin.gif'])
}
if (res[0] == 'confetti') {
addTask(['100%', '/copilot/static/confetti.gif'])
}
if (res[0] == 'martijn') {
addTask(['40%', '/copilot/static/martijn.gif'])
}
if (res[0] == 'rick') {
addTask(['40%', '/copilot/static/rick.gif'])
}
if (res[0] == 'true') {
document.getElementById('videoCamera').style.width = '20%'
self.initScreenShare()
}
if (res[0] == 'false') {
document.getElementById('videoCamera').style.width = '100%'
document.getElementById('videoScreen').src = null
}
console.log(res[1])
if (res[1] != 'none') {
showNotif(res[1])
}
}
this.connection.onopen = () => this.launch this.connection.onopen = () => this.launch
} }
}) })

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"
@ -326,15 +333,14 @@
</div> </div>
<div class="q-gutter-sm"> <div class="q-gutter-sm">
<q-select <q-select
filled filled
dense dense
style="width:50%" style="width: 50%"
v-model.trim="formDialogCopilot.data.show_price" v-model.trim="formDialogCopilot.data.show_price"
: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">
@ -485,19 +491,17 @@
sendFormDataCopilot: function () { sendFormDataCopilot: function () {
var self = this var self = this
console.log(self.formDialogCopilot.data.animation1threshold) console.log(self.formDialogCopilot.data.animation1threshold)
if(self.formDialogCopilot.data.id){ if (self.formDialogCopilot.data.id) {
this.updateCopilot( this.updateCopilot(
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) {
@ -588,14 +592,19 @@
var updatedData = {} var updatedData = {}
console.log(data) console.log(data)
for (const property in data) { for (const property in data) {
if(data[property]){ if (data[property]) {
updatedData[property] = data[property] updatedData[property] = data[property]
} }
} }
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
} }
} }