chore: code clean-up
This commit is contained in:
parent
d2e1dcc2ee
commit
b748dc3cb0
2 changed files with 68 additions and 14 deletions
|
|
@ -110,17 +110,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<q-btn unelevated color="primary" class="float-right"
|
<q-btn @click="toggleTestPanel" :label="testData.show ? 'Close' : 'Test Endpoint' " unelevated color="primary" class="float-right"
|
||||||
>Test Endpoint</q-btn
|
></q-btn
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-separator></q-separator>
|
<q-separator v-if="testData.show"></q-separator>
|
||||||
<q-card-section>
|
<q-card-section v-if="testData.show">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<span>Private Key (optional):</span>
|
<span>Sender Private Key:</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-9">
|
<div class="col-9">
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -147,6 +147,20 @@
|
||||||
</q-badge>
|
</q-badge>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div v-if="testData.senderPublicKey" class="row">
|
||||||
|
<div class="col-3">
|
||||||
|
<span>Sender Public Key:</span>
|
||||||
|
</div>
|
||||||
|
<div class="col-9">
|
||||||
|
<q-input
|
||||||
|
outlined
|
||||||
|
v-model="testData.senderPublicKey"
|
||||||
|
dense
|
||||||
|
readonly
|
||||||
|
filled
|
||||||
|
></q-input>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="row q-mt-md">
|
<div class="row q-mt-md">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<span>Test Message:</span>
|
<span>Test Message:</span>
|
||||||
|
|
@ -165,7 +179,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="row q-mt-md">
|
<div class="row q-mt-md">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<span>Public Key (hex or npub):</span>
|
<span>Receiver Public Key:</span>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-9">
|
<div class="col-9">
|
||||||
<q-input
|
<q-input
|
||||||
|
|
@ -173,7 +187,7 @@
|
||||||
v-model="testData.recieverPublicKey"
|
v-model="testData.recieverPublicKey"
|
||||||
dense
|
dense
|
||||||
filled
|
filled
|
||||||
label="Public Key *"
|
label="Public Key (hex or npub) *"
|
||||||
></q-input>
|
></q-input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -198,8 +212,8 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-separator></q-separator>
|
<q-separator v-if="testData.show"></q-separator>
|
||||||
<q-card-section>
|
<q-card-section v-if="testData.show">
|
||||||
<div class="row q-mt-md">
|
<div class="row q-mt-md">
|
||||||
<div class="col-3">
|
<div class="col-3">
|
||||||
<span>Sent Data:</span>
|
<span>Sent Data:</span>
|
||||||
|
|
@ -292,8 +306,10 @@
|
||||||
nostrrelayLinks: [],
|
nostrrelayLinks: [],
|
||||||
filter: '',
|
filter: '',
|
||||||
testData: {
|
testData: {
|
||||||
|
show: false,
|
||||||
wsConnection: null,
|
wsConnection: null,
|
||||||
senderPrivateKey: null,
|
senderPrivateKey: null,
|
||||||
|
senderPublicKey: null,
|
||||||
recieverPublicKey: null,
|
recieverPublicKey: null,
|
||||||
message: null,
|
message: null,
|
||||||
sentData: '',
|
sentData: '',
|
||||||
|
|
@ -405,6 +421,38 @@
|
||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
toggleTestPanel: async function() {
|
||||||
|
if (this.testData.show) {
|
||||||
|
await this.hideTestPannel()
|
||||||
|
} else {
|
||||||
|
await this.showTestPanel()
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showTestPanel: async function() {
|
||||||
|
this.testData = {
|
||||||
|
show: true,
|
||||||
|
wsConnection: null,
|
||||||
|
senderPrivateKey: this.$q.localStorage.getItem('lnbits.nostrclient.senderPrivateKey') || '',
|
||||||
|
recieverPublicKey: null,
|
||||||
|
message: null,
|
||||||
|
sentData: '',
|
||||||
|
receivedData: ''
|
||||||
|
}
|
||||||
|
await this.closeWebsocket()
|
||||||
|
this.connectToWebsocket()
|
||||||
|
},
|
||||||
|
hideTestPannel: async function() {
|
||||||
|
await this.closeWebsocket()
|
||||||
|
this.testData = {
|
||||||
|
show: false,
|
||||||
|
wsConnection: null,
|
||||||
|
senderPrivateKey: null,
|
||||||
|
recieverPublicKey: null,
|
||||||
|
message: null,
|
||||||
|
sentData: '',
|
||||||
|
receivedData: ''
|
||||||
|
}
|
||||||
|
},
|
||||||
sendTestMessage: async function () {
|
sendTestMessage: async function () {
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
|
|
@ -423,6 +471,7 @@
|
||||||
data.private_key || ''
|
data.private_key || ''
|
||||||
)
|
)
|
||||||
const event = JSON.parse(data.event_json)[1]
|
const event = JSON.parse(data.event_json)[1]
|
||||||
|
this.testData.senderPublicKey = event.pubkey
|
||||||
await this.sendDataToWebSocket(data.event_json)
|
await this.sendDataToWebSocket(data.event_json)
|
||||||
const subscription = JSON.stringify([
|
const subscription = JSON.stringify([
|
||||||
'REQ',
|
'REQ',
|
||||||
|
|
@ -469,6 +518,16 @@
|
||||||
this.testData.wsConnection.onerror = updateReciveData
|
this.testData.wsConnection.onerror = updateReciveData
|
||||||
this.testData.wsConnection.onclose = updateReciveData
|
this.testData.wsConnection.onclose = updateReciveData
|
||||||
},
|
},
|
||||||
|
closeWebsocket: async function () {
|
||||||
|
try {
|
||||||
|
if (this.testData.wsConnection) {
|
||||||
|
this.testData.wsConnection.close()
|
||||||
|
await this.sleep(100)
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(error)
|
||||||
|
}
|
||||||
|
},
|
||||||
exportlnurldeviceCSV: function () {
|
exportlnurldeviceCSV: function () {
|
||||||
var self = this
|
var self = this
|
||||||
LNbits.utils.exportCSV(self.relayTable.columns, this.nostrLinks)
|
LNbits.utils.exportCSV(self.relayTable.columns, this.nostrLinks)
|
||||||
|
|
@ -479,9 +538,6 @@
|
||||||
var self = this
|
var self = this
|
||||||
this.getRelays()
|
this.getRelays()
|
||||||
setInterval(this.getRelays, 5000)
|
setInterval(this.getRelays, 5000)
|
||||||
this.testData.senderPrivateKey =
|
|
||||||
this.$q.localStorage.getItem('lnbits.nostrclient.senderPrivateKey') ||
|
|
||||||
''
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -93,8 +93,6 @@ async def api_test_endpoint(data: TestMessage) -> TestMessageResponse:
|
||||||
)
|
)
|
||||||
private_key.sign_event(dm)
|
private_key.sign_event(dm)
|
||||||
|
|
||||||
print("### api_test_endpoint", data)
|
|
||||||
|
|
||||||
return TestMessageResponse(private_key=private_key.hex(), public_key=to_public_key, event_json=dm.to_message())
|
return TestMessageResponse(private_key=private_key.hex(), public_key=to_public_key, event_json=dm.to_message())
|
||||||
except (ValueError, AssertionError) as ex:
|
except (ValueError, AssertionError) as ex:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue