update UI

This commit is contained in:
callebtc 2023-03-15 11:02:54 +01:00
parent 6ad9a83db1
commit d6b4233541

View file

@ -1,14 +1,13 @@
{% extends "base.html" %} {% from "macros.jinja" import window_vars with context {% extends "base.html" %} {% from "macros.jinja" import window_vars with context
%} {% block page %} %} {% block page %} {% raw %}
<div class="row q-col-gutter-md"> <div class="row q-col-gutter-md">
<div class="col-12 col-md-7 q-gutter-y-md"> <div class="col-12 col-md-7 q-gutter-y-md">
<q-card> <q-card>
<q-card-section> <q-card-section>
<div class="row items-center no-wrap q-mb-md"> <div class="row items-center no-wrap q-mb-md">
<div class="col"> <div class="col">
<h5 class="text-subtitle1 q-my-none">nostr relays</h5> <h5 class="text-subtitle1 q-my-none">Nostrclient</h5>
</div> </div>
<div class="col-auto"> <div class="col-auto">
<q-input <q-input
borderless borderless
@ -32,7 +31,6 @@
:pagination.sync="relayTable.pagination" :pagination.sync="relayTable.pagination"
:filter="filter" :filter="filter"
> >
{% raw %}
<template v-slot:header="props"> <template v-slot:header="props">
<q-tr :props="props"> <q-tr :props="props">
<q-th <q-th
@ -76,30 +74,23 @@
</q-td> </q-td>
</q-tr> </q-tr>
</template> </template>
{% endraw %}
</q-table> </q-table>
</q-card-section>
<q-card-section>
<div class="text-weight-bold"> Your endpoint:
<q-badge outline class="q-ml-sm text-subtitle2" color="primary" :label="`wss://${host}nostrclient/api/v1/relay`" />
</div>
</q-card-section> </q-card-section>
</q-card> </q-card>
<q-card> <q-card>
<!-- <q-tabs
v-model="listSelection"
dense
class="text-grey"
active-color="primary"
indicator-color="primary"
align="justify"
narrow-indicator
>
<q-tab name="denylist" label="Deny List"></q-tab>
<q-tab name="allowlist" label="Allow List"></q-tab>
</q-tabs> -->
<q-separator></q-separator> <q-separator></q-separator>
<q-form class="q-gutter-md q-y-md" @submit="addRelay"> <q-form class="q-gutter-md q-y-md" @submit="addRelay">
<div class="row"> <div class="row">
<div class="col q-mx-lg q-my-sm"> <div class="col q-mx-md q-my-sm">
<q-input v-model="relayToAdd" dense filled></q-input> <q-input outlined v-model="relayToAdd" dense filled label="Relay URL"></q-input>
</div> </div>
<div class="col q-mx-lg items-align flex items-center justify-right"> <div class="col q-mx-md items-align flex items-center justify-right">
<q-btn unelevated color="primary" type="submit">Add relay </q-btn> <q-btn unelevated color="primary" type="submit">Add relay </q-btn>
</div> </div>
</div> </div>
@ -110,15 +101,26 @@
<div class="col-12 col-md-5 q-gutter-y-md"> <div class="col-12 col-md-5 q-gutter-y-md">
<q-card> <q-card>
<q-card-section> <q-card-section>
<h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} Nostr Extension</h6> <h6 class="text-subtitle1 q-my-none">{{SITE_TITLE}} Nostrclient Extension</h6>
<p>An always-on nostr client other extensions can use to receive events. Only Admin users can manage this extension.</p> <p>
This extension is a always-on nostr client that other extensions can
use to send and receive events on nostr.
Add multiple nostr relays to connect to. The extension then opens a websocket for you to use
at
<p>
<!-- wss://{{host}}nostrclient/api/v1/relay -->
<q-badge outline class="q-ml-sm text-subtitle2" color="primary" :label="`wss://${host}nostrclient/api/v1/relay`" />
</p>
Only Admin users can manage
this extension.
</p>
<q-card-section></q-card-section> <q-card-section></q-card-section>
</q-card-section> </q-card-section>
</q-card> </q-card>
</div> </div>
</div> </div>
{% endblock %} {% block scripts %} {{ window_vars(user) }} {% endraw %} {% endblock %} {% block scripts %} {{ window_vars(user) }}
<script> <script>
Vue.component(VueQrcode.name, VueQrcode) Vue.component(VueQrcode.name, VueQrcode)
@ -146,6 +148,8 @@
mixins: [windowMixin], mixins: [windowMixin],
data: function () { data: function () {
return { return {
base_url: location.protocol + '//' + location.host,
host: location.host,
relayToAdd: '', relayToAdd: '',
nostrrelayLinks: [], nostrrelayLinks: [],
filter: '', filter: '',
@ -217,14 +221,14 @@
}) })
return return
} }
console.log("ADD RELAY " + this.relayToAdd) console.log('ADD RELAY ' + this.relayToAdd)
var self = this var self = this
LNbits.api LNbits.api
.request( .request(
'POST', 'POST',
'/nostrclient/api/v1/relay?usr=' + this.g.user.id, '/nostrclient/api/v1/relay?usr=' + this.g.user.id,
this.g.user.wallets[0].adminkey, this.g.user.wallets[0].adminkey,
{url:this.relayToAdd}, {url: this.relayToAdd}
) )
.then(function (response) { .then(function (response) {
if (response.data) { if (response.data) {
@ -237,16 +241,16 @@
.catch(function (error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
}) })
location.reload(); location.reload()
}, },
deleteRelay(url) { deleteRelay(url) {
console.log("DELETE RELAY " + url) console.log('DELETE RELAY ' + url)
LNbits.api LNbits.api
.request( .request(
'DELETE', 'DELETE',
'/nostrclient/api/v1/relay?usr=' + this.g.user.id, '/nostrclient/api/v1/relay?usr=' + this.g.user.id,
this.g.user.wallets[0].adminkey, this.g.user.wallets[0].adminkey,
{url:url}, {url: url}
) )
.then(function (response) { .then(function (response) {
if (response.data) { if (response.data) {
@ -256,7 +260,7 @@
.catch(function (error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
}) })
location.reload(); location.reload()
}, },
exportlnurldeviceCSV: function () { exportlnurldeviceCSV: function () {
var self = this var self = this
@ -266,7 +270,7 @@
created: function () { created: function () {
var self = this var self = this
this.getRelays() this.getRelays()
setInterval(this.getRelays, 5000); setInterval(this.getRelays, 5000)
} }
}) })
</script> </script>