loads more work on API formatting

This commit is contained in:
Black Coffee 2022-10-06 17:06:22 +01:00
parent 662e637758
commit d3e6bb3444
2 changed files with 20 additions and 18 deletions

View file

@ -667,8 +667,8 @@
data data
) )
.then(function (response) { .then(function (response) {
self.gertys.push(mapGerty(response.data))
self.formDialog.show = false self.formDialog.show = false
self.gertys.push(mapGerty(response.data))
}) })
.catch(function (error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)
@ -689,8 +689,8 @@
self.gertys = _.reject(self.gertys, function (obj) { self.gertys = _.reject(self.gertys, function (obj) {
return obj.id == data.id return obj.id == data.id
}) })
self.gertys.push(mapGerty(response.data))
self.formDialog.show = false self.formDialog.show = false
self.gertys.push(mapGerty(response.data))
}) })
.catch(function (error) { .catch(function (error) {
LNbits.utils.notifyApiError(error) LNbits.utils.notifyApiError(error)

View file

@ -172,7 +172,12 @@ async def get_screen_data(screen_num: int, screens_list: dict, gerty):
if screen_slug == "dashboard": if screen_slug == "dashboard":
areas = await get_dashboard(gerty) areas = await get_dashboard(gerty)
if screen_slug == "lnbits_wallets_balance": if screen_slug == "lnbits_wallets_balance":
areas.append(await get_lnbits_wallet_balances(gerty)) wallets = await get_lnbits_wallet_balances(gerty)
text = []
for wallet in wallets:
text.append(get_text_item_dict("{0}'s Wallet".format(wallet['name']), 20))
text.append(get_text_item_dict("{0} sats".format(format_number(wallet['balance'])), 40))
areas.append(text)
elif screen_slug == "fun_satoshi_quotes": elif screen_slug == "fun_satoshi_quotes":
areas.append(await get_satoshi_quotes()) areas.append(await get_satoshi_quotes())
elif screen_slug == "fun_pieter_wuille_facts": elif screen_slug == "fun_pieter_wuille_facts":
@ -216,10 +221,11 @@ async def get_dashboard(gerty):
areas.append(text) areas.append(text)
# balance # balance
text = [] text = []
text.append(get_text_item_dict("Alice's wallet balance", 15)) wallets = await get_lnbits_wallet_balances(gerty)
text.append(get_text_item_dict("102,101", 40)) text = []
text.append(get_text_item_dict("Bob's wallet balance", 15)) for wallet in wallets:
text.append(get_text_item_dict("102", 40)) text.append(get_text_item_dict("{0}'s Wallet".format(wallet['name']), 15))
text.append(get_text_item_dict("{0} sats".format(format_number(wallet['balance'])), 40))
areas.append(text) areas.append(text)
# Mempool fees # Mempool fees
@ -240,21 +246,17 @@ async def get_dashboard(gerty):
async def get_lnbits_wallet_balances(gerty): async def get_lnbits_wallet_balances(gerty):
# Get Wallet info # Get Wallet info
wallets = [] wallets = []
text = []
if gerty.lnbits_wallets != "": if gerty.lnbits_wallets != "":
for lnbits_wallet in json.loads(gerty.lnbits_wallets): for lnbits_wallet in json.loads(gerty.lnbits_wallets):
wallet = await get_wallet_for_key(key=lnbits_wallet) wallet = await get_wallet_for_key(key=lnbits_wallet)
logger.debug(wallet) logger.debug(wallet.name)
if wallet: if wallet:
# wallets.append({ wallets.append({
# "name": wallet.name, "name": wallet.name,
# "balance": wallet.balance_msat, "balance": wallet.balance_msat,
# "inkey": wallet.inkey, "inkey": wallet.inkey,
# }) })
text.append(get_text_item_dict(wallet.name, 20)) return wallets
text.append(get_text_item_dict(format_number(wallet.balance_msat), 40))
return text
async def get_placeholder_text(): async def get_placeholder_text():