mirror of
https://github.com/lnbits/lnbits.git
synced 2025-07-04 20:41:04 +02:00
fix: paired devices list
This commit is contained in:
@ -49,7 +49,7 @@
|
|||||||
<q-item
|
<q-item
|
||||||
v-for="device in pairedDevices"
|
v-for="device in pairedDevices"
|
||||||
:key="device.id"
|
:key="device.id"
|
||||||
v-if="!selectedPort"
|
v-if="!selectedPort && showPairedDevices"
|
||||||
clickable
|
clickable
|
||||||
v-close-popup
|
v-close-popup
|
||||||
>
|
>
|
||||||
|
@ -51,7 +51,8 @@ async function serialSigner(path) {
|
|||||||
},
|
},
|
||||||
tx: null, // todo: move to hww
|
tx: null, // todo: move to hww
|
||||||
|
|
||||||
showConsole: false
|
showConsole: false,
|
||||||
|
showPairedDevices: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -59,14 +60,12 @@ async function serialSigner(path) {
|
|||||||
pairedDevices: {
|
pairedDevices: {
|
||||||
cache: false,
|
cache: false,
|
||||||
get: function () {
|
get: function () {
|
||||||
console.log('### get pairedDevices')
|
|
||||||
return (
|
return (
|
||||||
JSON.parse(window.localStorage.getItem('lnbits-paired-devices')) ||
|
JSON.parse(window.localStorage.getItem('lnbits-paired-devices')) ||
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
set: function (devices) {
|
set: function (devices) {
|
||||||
console.log('### set pairedDevices', devices)
|
|
||||||
window.localStorage.setItem(
|
window.localStorage.setItem(
|
||||||
'lnbits-paired-devices',
|
'lnbits-paired-devices',
|
||||||
JSON.stringify(devices)
|
JSON.stringify(devices)
|
||||||
@ -84,7 +83,6 @@ async function serialSigner(path) {
|
|||||||
await this.openSerialPort(this.config)
|
await this.openSerialPort(this.config)
|
||||||
},
|
},
|
||||||
openSerialPort: async function (config = {baudRate: 9600}) {
|
openSerialPort: async function (config = {baudRate: 9600}) {
|
||||||
console.log('### openSerialPort', config)
|
|
||||||
if (!this.checkSerialPortSupported()) return false
|
if (!this.checkSerialPortSupported()) return false
|
||||||
if (this.selectedPort) {
|
if (this.selectedPort) {
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
@ -314,11 +312,9 @@ async function serialSigner(path) {
|
|||||||
},
|
},
|
||||||
hwwPing: async function () {
|
hwwPing: async function () {
|
||||||
try {
|
try {
|
||||||
console.log('### hwwPing 1', window.location.host)
|
|
||||||
// Send an empty ping. The serial port buffer might have some jubk data. Flush it.
|
// Send an empty ping. The serial port buffer might have some jubk data. Flush it.
|
||||||
await this.sendCommandClearText(COMMAND_PING)
|
await this.sendCommandClearText(COMMAND_PING)
|
||||||
await this.sendCommandClearText(COMMAND_PING, [window.location.host])
|
await this.sendCommandClearText(COMMAND_PING, [window.location.host])
|
||||||
console.log('### hwwPing 2')
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'warning',
|
type: 'warning',
|
||||||
@ -735,7 +731,6 @@ async function serialSigner(path) {
|
|||||||
},
|
},
|
||||||
hwwHelp: async function () {
|
hwwHelp: async function () {
|
||||||
try {
|
try {
|
||||||
console.log('### cmd help')
|
|
||||||
await this.sendCommandSecure(COMMAND_HELP)
|
await this.sendCommandSecure(COMMAND_HELP)
|
||||||
this.$q.notify({
|
this.$q.notify({
|
||||||
type: 'positive',
|
type: 'positive',
|
||||||
@ -873,7 +868,6 @@ async function serialSigner(path) {
|
|||||||
|
|
||||||
sendCommandSecure: async function (command, attrs = []) {
|
sendCommandSecure: async function (command, attrs = []) {
|
||||||
const message = [command].concat(attrs).join(' ')
|
const message = [command].concat(attrs).join(' ')
|
||||||
console.log('### sendCommandSecure', message)
|
|
||||||
const iv = window.crypto.getRandomValues(new Uint8Array(16))
|
const iv = window.crypto.getRandomValues(new Uint8Array(16))
|
||||||
if (!this.sharedSecret || !this.sharedSecret.length) {
|
if (!this.sharedSecret || !this.sharedSecret.length) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@ -892,7 +886,6 @@ async function serialSigner(path) {
|
|||||||
},
|
},
|
||||||
sendCommandClearText: async function (command, attrs = []) {
|
sendCommandClearText: async function (command, attrs = []) {
|
||||||
const message = [command].concat(attrs).join(' ')
|
const message = [command].concat(attrs).join(' ')
|
||||||
console.log('### sendCommandClearText', message)
|
|
||||||
await this.writer.write(message + '\n')
|
await this.writer.write(message + '\n')
|
||||||
},
|
},
|
||||||
extractCommand: async function (value) {
|
extractCommand: async function (value) {
|
||||||
@ -968,6 +961,11 @@ async function serialSigner(path) {
|
|||||||
devices.splice(deviceIndex, 1)
|
devices.splice(deviceIndex, 1)
|
||||||
}
|
}
|
||||||
this.pairedDevices = devices
|
this.pairedDevices = devices
|
||||||
|
this.showPairedDevices = false
|
||||||
|
setTimeout(() => {
|
||||||
|
// force UI refresh
|
||||||
|
this.showPairedDevices = true
|
||||||
|
})
|
||||||
},
|
},
|
||||||
addPairedDevice: function (deviceId, sharedSecretHex, config) {
|
addPairedDevice: function (deviceId, sharedSecretHex, config) {
|
||||||
const devices = this.pairedDevices
|
const devices = this.pairedDevices
|
||||||
@ -979,6 +977,11 @@ async function serialSigner(path) {
|
|||||||
config
|
config
|
||||||
})
|
})
|
||||||
this.pairedDevices = devices
|
this.pairedDevices = devices
|
||||||
|
this.showPairedDevices = false
|
||||||
|
setTimeout(() => {
|
||||||
|
// force UI refresh
|
||||||
|
this.showPairedDevices = true
|
||||||
|
})
|
||||||
},
|
},
|
||||||
updatePairedDeviceConfig(deviceId, config) {
|
updatePairedDeviceConfig(deviceId, config) {
|
||||||
const device = this.getPairedDevice(deviceId)
|
const device = this.getPairedDevice(deviceId)
|
||||||
|
Reference in New Issue
Block a user