diff --git a/lnbits/extensions/gerty/helpers.py b/lnbits/extensions/gerty/helpers.py index 82eac150..5f3c70d2 100644 --- a/lnbits/extensions/gerty/helpers.py +++ b/lnbits/extensions/gerty/helpers.py @@ -13,6 +13,7 @@ from ...settings import LNBITS_PATH from lnbits.utils.exchange_rates import satoshis_amount_as_fiat from lnbits.core.crud import get_user, get_wallet_for_key + def get_percent_difference(current, previous, precision=3): difference = (current - previous) / current * 100 return "{0}{1}%".format("+" if difference > 0 else "", round(difference, precision)) @@ -437,7 +438,7 @@ async def get_screen_data(screen_num: int, screens_list: dict, gerty): areas = await get_dashboard(gerty) if screen_slug == "lnbits_wallets_balance": wallets = await get_lnbits_wallet_balances(gerty) - + for wallet in wallets: text = [] text.append( diff --git a/lnbits/extensions/gerty/templates/gerty/gerty.html b/lnbits/extensions/gerty/templates/gerty/gerty.html index a8ab2e6d..2aad6104 100644 --- a/lnbits/extensions/gerty/templates/gerty/gerty.html +++ b/lnbits/extensions/gerty/templates/gerty/gerty.html @@ -1,42 +1,62 @@ -{% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{ gertyname }}{% endraw %}{% -endblock %}{% block page %} {% raw %} +{% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{ +gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %} -
- - +
+ - {{fun_exchange_market_rate["amount"]}} {{fun_exchange_market_rate["unit"]}} + {{fun_exchange_market_rate["amount"]}} + {{fun_exchange_market_rate["unit"]}} -
-

"{{fun_satoshi_quotes["quote"]}}"

- ~ Satoshi {{fun_satoshi_quotes["date"]}} -
-
+ v-if="fun_satoshi_quotes" + unelevated + class="q-pa-none text-body1 blockquote" + style="background: none !important" + > +
+

"{{fun_satoshi_quotes["quote"]}}"

+ ~ Satoshi {{fun_satoshi_quotes["date"]}} +
+
- + - {{wallet["amount"]}} ({{wallet["name"]}}) + {{wallet["amount"]}} + ({{wallet["name"]}})
-
+
Onchain
-

{{item[0].value}}: {{item[1].value}}

+

+ {{item[0].value}}: {{item[1].value}} +

@@ -45,7 +65,9 @@ endblock %}{% block page %} {% raw %}
Mining
-

{{item[0].value}}: {{item[1].value}}

+

+ {{item[0].value}}: {{item[1].value}} +

@@ -54,10 +76,11 @@ endblock %}{% block page %} {% raw %}
Lightning (Last 7 days)
-

{{item[0].value}}: {{item[1].value}}

+

+ {{item[0].value}}: {{item[1].value}} +

-
{% endraw %} {% endblock %} {% block scripts %} @@ -75,86 +98,84 @@ endblock %}{% block page %} {% raw %} fun_exchange_market_rate: {}, gerty: [], gerty_id: `{{gerty}}`, - gertyname: "", + gertyname: '', walletColors: [ - {first: "#3f51b5", - second: "#1a237e"}, - {first: "#9c27b0", - second: "#4a148c"}, - {first: "#e91e63", - second: "#880e4f"}, - {first: "#009688", - second: "#004d40"}, - {first: "#ff9800", - second: "#e65100"}, - {first: "#2196f3", - second: "#0d47a1"}, - {first: "#4caf50", - second: "#1b5e20"} + {first: '#3f51b5', second: '#1a237e'}, + {first: '#9c27b0', second: '#4a148c'}, + {first: '#e91e63', second: '#880e4f'}, + {first: '#009688', second: '#004d40'}, + {first: '#ff9800', second: '#e65100'}, + {first: '#2196f3', second: '#0d47a1'}, + {first: '#4caf50', second: '#1b5e20'} ], gertywallets: [] } }, methods: { getGertyInfo: async function () { - for (let i = 0; i < 8; i++){ + for (let i = 0; i < 8; i++) { try { const {data} = await LNbits.api.request( 'GET', `/gerty/api/v1/gerty/pages/${this.gerty_id}/${i}` ) this.gerty[i] = data - } catch (error) { LNbits.utils.notifyApiError(error) } } console.log(this.gerty) - for (let i = 0; i < this.gerty.length; i++) { - if(this.gerty[i].screen.group == "lnbits_wallets_balance"){ - for (let q = 0; q < this.gerty[i].screen.areas.length; q++) { - this.lnbits_wallets_balance[q] = { - "name": this.gerty[i].screen.areas[q][0].value, - "amount": this.gerty[i].screen.areas[q][1].value, - "color1": this.walletColors[q].first, - "color2": this.walletColors[q].second, + for (let i = 0; i < this.gerty.length; i++) { + if (this.gerty[i].screen.group == 'lnbits_wallets_balance') { + for (let q = 0; q < this.gerty[i].screen.areas.length; q++) { + this.lnbits_wallets_balance[q] = { + name: this.gerty[i].screen.areas[q][0].value, + amount: this.gerty[i].screen.areas[q][1].value, + color1: this.walletColors[q].first, + color2: this.walletColors[q].second + } + this.gertyname = this.gerty[i].settings.name } + } + if (this.gerty[i].screen.group == 'dashboard_onchain') { + this.dashboard_onchain = this.gerty[i].screen.areas + this.gertyname = this.gerty[i].settings.name + } + if (this.gerty[i].screen.group == 'dashboard_mining') { + this.dashboard_mining = this.gerty[i].screen.areas + this.gertyname = this.gerty[i].settings.name + } + if (this.gerty[i].screen.group == 'lightning_dashboard') { + this.lightning_dashboard = this.gerty[i].screen.areas + this.gertyname = this.gerty[i].settings.name + } + if (this.gerty[i].screen.group == 'fun_satoshi_quotes') { + this.fun_satoshi_quotes['quote'] = this.gerty[ + i + ].screen.areas[0][0].value + this.fun_satoshi_quotes['date'] = this.gerty[ + i + ].screen.areas[0][1].value + this.gertyname = this.gerty[i].settings.name + } + if (this.gerty[i].screen.group == 'fun_exchange_market_rate') { + this.fun_exchange_market_rate['unit'] = this.gerty[ + i + ].screen.areas[0][0].value + this.fun_exchange_market_rate['amount'] = this.gerty[ + i + ].screen.areas[0][1].value this.gertyname = this.gerty[i].settings.name } } - if(this.gerty[i].screen.group == "dashboard_onchain"){ - this.dashboard_onchain = this.gerty[i].screen.areas - this.gertyname = this.gerty[i].settings.name - } - if(this.gerty[i].screen.group == "dashboard_mining"){ - this.dashboard_mining = this.gerty[i].screen.areas - this.gertyname = this.gerty[i].settings.name - } - if(this.gerty[i].screen.group == "lightning_dashboard"){ - this.lightning_dashboard = this.gerty[i].screen.areas - this.gertyname = this.gerty[i].settings.name - } - if(this.gerty[i].screen.group == "fun_satoshi_quotes"){ - this.fun_satoshi_quotes["quote"] = this.gerty[i].screen.areas[0][0].value - this.fun_satoshi_quotes["date"] = this.gerty[i].screen.areas[0][1].value - this.gertyname = this.gerty[i].settings.name - } - if(this.gerty[i].screen.group == "fun_exchange_market_rate"){ - this.fun_exchange_market_rate["unit"] = this.gerty[i].screen.areas[0][0].value - this.fun_exchange_market_rate["amount"] = this.gerty[i].screen.areas[0][1].value - this.gertyname = this.gerty[i].settings.name - } - - } - setTimeout(this.getGertyInfo, 20000); - this.$forceUpdate(); - return this.gerty - }, + setTimeout(this.getGertyInfo, 20000) + this.$forceUpdate() + return this.gerty + } }, created: async function () { - - await this.getGertyInfo() + await this.getGertyInfo() } }) diff --git a/lnbits/extensions/gerty/templates/gerty/index.html b/lnbits/extensions/gerty/templates/gerty/index.html index e990dd75..688349dd 100644 --- a/lnbits/extensions/gerty/templates/gerty/index.html +++ b/lnbits/extensions/gerty/templates/gerty/index.html @@ -141,56 +141,52 @@ placeholder="Son of Gerty" > Displays random quotes from Satoshi + + + + + - size="xs" - v-model="formDialog.data.display_preferences.fun_satoshi_quotes" - val="xs" - label="Satoshi Quotes" - >Displays random quotes from Satoshi - - - - - - - - - Hit enter to add values - + v-if="formDialog.data.display_preferences.lnbits_wallets_balance" + filled + multiple + dense + emit-value + v-model="formDialog.data.lnbits_wallets" + use-input + use-chips + multiple + hide-dropdown-icon + new-value-mode="add-unique" + label="Invoice keys of wallets to watch" + > + Hit enter to add values + - -
- - - - The amount of time in seconds between screen updates - - + +
+ + + + The amount of time in seconds between screen updates + +