diff --git a/static/components/relay-details/relay-details.js b/static/components/relay-details/relay-details.js index d3c2d72..a5e53a2 100644 --- a/static/components/relay-details/relay-details.js +++ b/static/components/relay-details/relay-details.js @@ -36,6 +36,11 @@ async function relayDetails(path) { this.adminkey ) this.$emit('relay-deleted', this.relayId) + this.$q.notify({ + type: 'positive', + message: 'Relay Deleted', + timeout: 5000 + }) } catch (error) { console.warn(error) LNbits.utils.notifyApiError(error) @@ -53,6 +58,25 @@ async function relayDetails(path) { } catch (error) { LNbits.utils.notifyApiError(error) } + }, + updateRelay: async function () { + try { + const {data} = await LNbits.api.request( + 'PUT', + '/nostrrelay/api/v1/relay/' + this.relayId, + this.adminkey, + this.relay + ) + this.relay = data + this.$emit('relay-updated', this.relay) + this.$q.notify({ + type: 'positive', + message: 'Relay Updated', + timeout: 5000 + }) + } catch (error) { + LNbits.utils.notifyApiError(error) + } } }, diff --git a/static/js/index.js b/static/js/index.js index 66a9f49..950edd1 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -157,7 +157,6 @@ const relays = async () => { }, sendFormDataRelay: async function () { - console.log('### sendFormDataRelay') this.createRelay(this.formDialogRelay.data) }, @@ -166,6 +165,13 @@ const relays = async () => { return obj.id === relayId }) }, + handleRelayUpdated: function (relay) { + const index = this.relayLinks.findIndex(r => r.id === relay.id) + if (index !== -1) { + relay.expanded = true + this.relayLinks.splice(index, 1, relay) + } + }, exportrelayCSV: function () { LNbits.utils.exportCSV( diff --git a/templates/nostrrelay/index.html b/templates/nostrrelay/index.html index cdf4fb0..dcc51ea 100644 --- a/templates/nostrrelay/index.html +++ b/templates/nostrrelay/index.html @@ -97,6 +97,7 @@ :adminkey="g.user.wallets[0].adminkey" :inkey="g.user.wallets[0].inkey" @relay-deleted="handleRelayDeleted" + @relay-updated="handleRelayUpdated" >