Fixed json
This commit is contained in:
parent
d0a76cf665
commit
f747091257
3 changed files with 27 additions and 21 deletions
|
|
@ -54,7 +54,7 @@
|
||||||
mixins: [windowMixin],
|
mixins: [windowMixin],
|
||||||
data: function () {
|
data: function () {
|
||||||
return {
|
return {
|
||||||
gertyName: '{{gerty.name}}',
|
gerty: "",
|
||||||
walletColors: [
|
walletColors: [
|
||||||
{first: "#3f51b5",
|
{first: "#3f51b5",
|
||||||
second: "#1a237e"},
|
second: "#1a237e"},
|
||||||
|
|
@ -85,10 +85,18 @@
|
||||||
|
|
||||||
},
|
},
|
||||||
created: function () {
|
created: function () {
|
||||||
|
this.gerty = {{ gerty | tojson }}
|
||||||
console.log(this.gerty)
|
console.log(this.gerty)
|
||||||
// if(){
|
|
||||||
|
if(this.gerty.wallets){
|
||||||
// }
|
for (let i = 0; i < this.gerty.wallets.length; i++) {
|
||||||
|
this.gertywallets[i].name = this.gerty.wallets.name
|
||||||
|
this.gertywallets[i].amount = this.gerty.wallets.amount
|
||||||
|
this.gertywallets[i].color1 = this.walletColors[i].first
|
||||||
|
this.gertywallets[i].color2 = this.walletColors[i].second
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log(this.gertywallets)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ from .views_api import api_gerty_json
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
templates = Jinja2Templates(directory="templates")
|
templates = Jinja2Templates(directory="templates")
|
||||||
|
|
||||||
@gerty_ext.get("/", response_class=HTMLResponse)
|
@gerty_ext.get("/", response_class=HTMLResponse)
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ async def api_gerty_json(
|
||||||
gertyReturn = []
|
gertyReturn = []
|
||||||
|
|
||||||
# Get Wallet info
|
# Get Wallet info
|
||||||
wallets = ['wallets']
|
wallets = []
|
||||||
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)
|
||||||
|
|
@ -113,18 +113,16 @@ async def api_gerty_json(
|
||||||
"balance": wallet.balance_msat,
|
"balance": wallet.balance_msat,
|
||||||
"inkey": wallet.inkey,
|
"inkey": wallet.inkey,
|
||||||
})
|
})
|
||||||
gertyReturn.append(wallets)
|
|
||||||
|
|
||||||
#Get Satoshi quotes
|
#Get Satoshi quotes
|
||||||
satoshi = ['sats_quote']
|
satoshi = []
|
||||||
if gerty.sats_quote:
|
if gerty.sats_quote:
|
||||||
quote = await api_gerty_satoshi()
|
quote = await api_gerty_satoshi()
|
||||||
if quote:
|
if quote:
|
||||||
satoshi.append(await api_gerty_satoshi())
|
satoshi.append(await api_gerty_satoshi())
|
||||||
gertyReturn.append(satoshi)
|
|
||||||
|
|
||||||
#Get Exchange Value
|
#Get Exchange Value
|
||||||
exchange = ['exchange']
|
exchange = []
|
||||||
if gerty.exchange != "":
|
if gerty.exchange != "":
|
||||||
try:
|
try:
|
||||||
amount = await satoshis_amount_as_fiat(100000000, gerty.exchange)
|
amount = await satoshis_amount_as_fiat(100000000, gerty.exchange)
|
||||||
|
|
@ -135,35 +133,33 @@ async def api_gerty_json(
|
||||||
})
|
})
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
gertyReturn.append(exchange)
|
|
||||||
|
|
||||||
onchain = ['onchain']
|
onchain = []
|
||||||
if gerty.onchain_stats and isinstance(gerty.mempool_endpoint, str):
|
if gerty.onchain_stats and isinstance(gerty.mempool_endpoint, str):
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
difficulty = ['difficulty']
|
difficulty = []
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
||||||
if r:
|
if r:
|
||||||
difficulty.append(r.json())
|
difficulty.append(r.json())
|
||||||
onchain.append(difficulty)
|
onchain.append({"difficulty":difficulty})
|
||||||
mempool = ['mempool']
|
mempool = []
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/fees/mempool-blocks")
|
r = await client.get(gerty.mempool_endpoint + "/api/v1/fees/mempool-blocks")
|
||||||
if r:
|
if r:
|
||||||
mempool.append(r.json())
|
mempool.append(r.json())
|
||||||
onchain.append(mempool)
|
onchain.append({"mempool":mempool})
|
||||||
threed = ['threed']
|
threed = []
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/mining/hashrate/3d")
|
r = await client.get(gerty.mempool_endpoint + "/api/v1/mining/hashrate/3d")
|
||||||
if r:
|
if r:
|
||||||
threed.append(r.json())
|
threed.append(r.json())
|
||||||
onchain.append(threed)
|
onchain.append({"threed":threed})
|
||||||
gertyReturn.append(onchain)
|
|
||||||
|
|
||||||
ln = ['ln']
|
ln = []
|
||||||
if gerty.ln_stats and isinstance(gerty.mempool_endpoint, str):
|
if gerty.ln_stats and isinstance(gerty.mempool_endpoint, str):
|
||||||
async with httpx.AsyncClient() as client:
|
async with httpx.AsyncClient() as client:
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/lightning/statistics/latest")
|
r = await client.get(gerty.mempool_endpoint + "/api/v1/lightning/statistics/latest")
|
||||||
if r:
|
if r:
|
||||||
ln.append(r.json())
|
ln.append(r.json())
|
||||||
gertyReturn.append(ln)
|
|
||||||
return gertyReturn
|
return {"wallets":wallets, "sats_quote":satoshi, "exchange":exchange, "onchain":onchain, "ln":ln}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue