From dde28e66a24e09517b668e291ed58a6eb7df37e2 Mon Sep 17 00:00:00 2001 From: Tiago vasconcelos Date: Thu, 13 Oct 2022 15:52:02 +0100 Subject: [PATCH] added tooltips, moved reset, and warnings --- .../admin/templates/admin/index.html | 97 ++++++++++++------- 1 file changed, 61 insertions(+), 36 deletions(-) diff --git a/lnbits/extensions/admin/templates/admin/index.html b/lnbits/extensions/admin/templates/admin/index.html index 575b377f..7d268301 100644 --- a/lnbits/extensions/admin/templates/admin/index.html +++ b/lnbits/extensions/admin/templates/admin/index.html @@ -1,8 +1,14 @@ {% extends "base.html" %} {% from "macros.jinja" import window_vars with context %} {% block page %}
-
- +
+ + Save your changes - - - + + + Restart the server for changes to take effect + + + + + Add funds to a wallet. + + > --> + + Delete all settings and reset to defaults. +
@@ -121,6 +136,7 @@ show: false }, tab: 'funding', + needsRestart: false, funding_sources: new Map([ ['VoidWallet', null], [ @@ -302,13 +318,12 @@ this.balance = +'{{ balance|safe }}' this.formData = _.clone(this.settings) //model this.updateFundingData() - console.log(this.settings) }, computed: { checkChanges() { return !_.isEqual(this.settings, this.formData) - }, + } }, methods: { addAdminUser() { @@ -361,6 +376,7 @@ message: 'Success! Restarted Server', icon: null }) + this.needsRestart = false }) .catch(function (error) { LNbits.utils.notifyApiError(error) @@ -390,16 +406,15 @@ LNbits.utils.notifyApiError(error) }) }, - updateFundingData(){ + updateFundingData() { this.settings.lnbits_allowed_funding_sources.map(f => { let opts = this.funding_sources.get(f) if (!opts) return - + Object.keys(opts).forEach(e => { opts[e].value = this.settings[e] }) }) - console.log("funding", this.funding_sources) }, updateSettings() { let data = { @@ -415,31 +430,41 @@ .then(response => { this.settings = response.data.settings this.formData = _.clone(this.settings) + this.needsRestart = true this.updateFundingData() this.$q.notify({ type: 'positive', message: 'Success! Settings changed!', icon: null }) - console.log(this.settings) }) .catch(function (error) { LNbits.utils.notifyApiError(error) }) }, deleteSettings() { - LNbits.api - .request('DELETE', '/admin/api/v1/settings/?usr=' + this.g.user.id) - .then(response => { - this.$q.notify({ - type: 'positive', - message: - 'Success! Restored settings to defaults, restart required!', - icon: null - }) - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) + LNbits.utils + .confirmDialog( + 'Are you sure you want to restore settings to default?' + ) + .onOk(() => { + LNbits.api + .request( + 'DELETE', + '/admin/api/v1/settings/?usr=' + this.g.user.id + ) + .then(response => { + this.$q.notify({ + type: 'positive', + message: + 'Success! Restored settings to defaults, restart required!', + icon: null + }) + this.needsRestart = true + }) + .catch(function (error) { + LNbits.utils.notifyApiError(error) + }) }) }, downloadBackup() {