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

View File

@ -105,7 +105,14 @@
</q-btn>
</q-td>
<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
v-for="col in props.cols"
@ -326,15 +333,14 @@
</div>
<div class="q-gutter-sm">
<q-select
filled
dense
style="width:50%"
v-model.trim="formDialogCopilot.data.show_price"
:options="currencyOptions"
label="Show price"
/>
<q-select
filled
dense
style="width: 50%"
v-model.trim="formDialogCopilot.data.show_price"
:options="currencyOptions"
label="Show price"
/>
</div>
<div class="q-gutter-sm">
<div class="row">
@ -485,19 +491,17 @@
sendFormDataCopilot: function () {
var self = this
console.log(self.formDialogCopilot.data.animation1threshold)
if(self.formDialogCopilot.data.id){
if (self.formDialogCopilot.data.id) {
this.updateCopilot(
self.g.user.wallets[0].adminkey,
self.formDialogCopilot.data
)
}
else{
self.g.user.wallets[0].adminkey,
self.formDialogCopilot.data
)
} else {
this.createCopilot(
self.g.user.wallets[0].adminkey,
self.formDialogCopilot.data
)
self.g.user.wallets[0].adminkey,
self.formDialogCopilot.data
)
}
},
createCopilot: function (wallet, data) {
@ -588,14 +592,19 @@
var updatedData = {}
console.log(data)
for (const property in data) {
if(data[property]){
if (data[property]) {
updatedData[property] = data[property]
}
}
console.log(updatedData)
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) {
self.CopilotLinks.push(mapCopilot(response.data))
self.formDialogCopilot.show = false

View File

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

28
package-lock.json generated
View File

@ -1,11 +1,31 @@
{
"name": "lnbits",
"lockfileVersion": 2,
"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": {
"prettier": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz",
"integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==",
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz",
"integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==",
"dev": true
}
}