Added refresh time to gerty settings
This commit is contained in:
parent
c0edd15edb
commit
55de179730
4 changed files with 58 additions and 45 deletions
|
|
@ -6,6 +6,7 @@ async def m001_initial(db):
|
||||||
"""
|
"""
|
||||||
CREATE TABLE gerty.gertys (
|
CREATE TABLE gerty.gertys (
|
||||||
id TEXT PRIMARY KEY,
|
id TEXT PRIMARY KEY,
|
||||||
|
refresh_time INT,
|
||||||
name TEXT NOT NULL,
|
name TEXT NOT NULL,
|
||||||
wallet TEXT NOT NULL,
|
wallet TEXT NOT NULL,
|
||||||
lnbits_wallets TEXT,
|
lnbits_wallets TEXT,
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ class Gerty(BaseModel):
|
||||||
id: str = Query(None)
|
id: str = Query(None)
|
||||||
name: str
|
name: str
|
||||||
wallet: str
|
wallet: str
|
||||||
|
refresh_time: int = Query(None)
|
||||||
lnbits_wallets: str = Query(None) # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"}
|
lnbits_wallets: str = Query(None) # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"}
|
||||||
mempool_endpoint: str = Query(None) # Mempool endpoint to use
|
mempool_endpoint: str = Query(None) # Mempool endpoint to use
|
||||||
exchange: str = Query(None) # BTC <-> Fiat exchange rate to pull ie "USD", in 0.0001 and sats
|
exchange: str = Query(None) # BTC <-> Fiat exchange rate to pull ie "USD", in 0.0001 and sats
|
||||||
|
|
|
||||||
|
|
@ -164,6 +164,15 @@
|
||||||
<q-tooltip>Used for getting onchain/ln stats</q-tooltip>
|
<q-tooltip>Used for getting onchain/ln stats</q-tooltip>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
||||||
|
<q-input
|
||||||
|
filled
|
||||||
|
dense
|
||||||
|
v-model.trim="formDialog.data.refresh_time"
|
||||||
|
label="Refresh time in seconds"
|
||||||
|
>
|
||||||
|
<q-tooltip>The amount of time in seconds between screen updates</q-tooltip>
|
||||||
|
</q-input>
|
||||||
|
|
||||||
<p>Use the toggles below to control what your Gerty will display</p>
|
<p>Use the toggles below to control what your Gerty will display</p>
|
||||||
|
|
||||||
<q-expansion-item
|
<q-expansion-item
|
||||||
|
|
@ -608,6 +617,7 @@
|
||||||
},
|
},
|
||||||
lnbits_wallets: [],
|
lnbits_wallets: [],
|
||||||
mempool_endpoint: "https://mempool.space",
|
mempool_endpoint: "https://mempool.space",
|
||||||
|
refresh_time: 300,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -621,6 +631,7 @@
|
||||||
this.formDialog.data = {
|
this.formDialog.data = {
|
||||||
lnbits_wallets: [],
|
lnbits_wallets: [],
|
||||||
mempool_endpoint: "https://mempool.space",
|
mempool_endpoint: "https://mempool.space",
|
||||||
|
refresh_time: 300,
|
||||||
display_preferences: {},
|
display_preferences: {},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -646,11 +657,10 @@
|
||||||
this.formDialog.data.wallet = gerty.wallet
|
this.formDialog.data.wallet = gerty.wallet
|
||||||
this.formDialog.data.lnbits_wallets = JSON.parse(gerty.lnbits_wallets)
|
this.formDialog.data.lnbits_wallets = JSON.parse(gerty.lnbits_wallets)
|
||||||
this.formDialog.data.exchange = gerty.exchange,
|
this.formDialog.data.exchange = gerty.exchange,
|
||||||
this.formDialog.data.mempool_endpoint = gerty.mempool_endpoint,
|
this.formDialog.data.mempool_endpoint = gerty.mempool_endpoint,
|
||||||
this.formDialog.data.display_preferences = JSON.parse(gerty.display_preferences),
|
this.formDialog.data.refresh_time = gerty.refresh_time,
|
||||||
this.formDialog.show = true
|
this.formDialog.data.display_preferences = JSON.parse(gerty.display_preferences),
|
||||||
|
this.formDialog.show = true
|
||||||
console.log('updateformDialog', this.formDialog.data)
|
|
||||||
},
|
},
|
||||||
sendFormDataGerty: function () {
|
sendFormDataGerty: function () {
|
||||||
if (this.formDialog.data.id) {
|
if (this.formDialog.data.id) {
|
||||||
|
|
@ -673,6 +683,7 @@
|
||||||
lnbits_wallets: JSON.stringify(this.formDialog.data.lnbits_wallets),
|
lnbits_wallets: JSON.stringify(this.formDialog.data.lnbits_wallets),
|
||||||
exchange: this.formDialog.data.exchange,
|
exchange: this.formDialog.data.exchange,
|
||||||
mempool_endpoint: this.formDialog.data.mempool_endpoint,
|
mempool_endpoint: this.formDialog.data.mempool_endpoint,
|
||||||
|
refresh_time: this.formDialog.data.refresh_time,
|
||||||
display_preferences: JSON.stringify(this.formDialog.data.display_preferences)
|
display_preferences: JSON.stringify(this.formDialog.data.display_preferences)
|
||||||
}
|
}
|
||||||
console.log('createGerty', data)
|
console.log('createGerty', data)
|
||||||
|
|
|
||||||
|
|
@ -116,50 +116,50 @@ async def api_gerty_json(
|
||||||
|
|
||||||
#Get Satoshi quotes
|
#Get Satoshi quotes
|
||||||
satoshi = []
|
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())
|
||||||
|
|
||||||
#Get Exchange Value
|
#Get Exchange Value
|
||||||
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)
|
||||||
if amount:
|
# if amount:
|
||||||
exchange.append({
|
# exchange.append({
|
||||||
"fiat": gerty.exchange,
|
# "fiat": gerty.exchange,
|
||||||
"amount": amount,
|
# "amount": amount,
|
||||||
})
|
# })
|
||||||
except:
|
# except:
|
||||||
pass
|
# pass
|
||||||
|
#
|
||||||
|
# onchain = []
|
||||||
|
# if gerty.onchain_stats and isinstance(gerty.mempool_endpoint, str):
|
||||||
|
# async with httpx.AsyncClient() as client:
|
||||||
|
# difficulty = []
|
||||||
|
# r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
||||||
|
# if r:
|
||||||
|
# difficulty.append(r.json())
|
||||||
|
# onchain.append({"difficulty":difficulty})
|
||||||
|
# mempool = []
|
||||||
|
# r = await client.get(gerty.mempool_endpoint + "/api/v1/fees/mempool-blocks")
|
||||||
|
# if r:
|
||||||
|
# mempool.append(r.json())
|
||||||
|
# onchain.append({"mempool":mempool})
|
||||||
|
# threed = []
|
||||||
|
# r = await client.get(gerty.mempool_endpoint + "/api/v1/mining/hashrate/3d")
|
||||||
|
# if r:
|
||||||
|
# threed.append(r.json())
|
||||||
|
# onchain.append({"threed":threed})
|
||||||
|
|
||||||
onchain = []
|
# ln = []
|
||||||
if gerty.onchain_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:
|
||||||
difficulty = []
|
# r = await client.get(gerty.mempool_endpoint + "/api/v1/lightning/statistics/latest")
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/difficulty-adjustment")
|
# if r:
|
||||||
if r:
|
# ln.append(r.json())
|
||||||
difficulty.append(r.json())
|
|
||||||
onchain.append({"difficulty":difficulty})
|
|
||||||
mempool = []
|
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/fees/mempool-blocks")
|
|
||||||
if r:
|
|
||||||
mempool.append(r.json())
|
|
||||||
onchain.append({"mempool":mempool})
|
|
||||||
threed = []
|
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/mining/hashrate/3d")
|
|
||||||
if r:
|
|
||||||
threed.append(r.json())
|
|
||||||
onchain.append({"threed":threed})
|
|
||||||
|
|
||||||
ln = []
|
return {"name":gerty.name}
|
||||||
if gerty.ln_stats and isinstance(gerty.mempool_endpoint, str):
|
|
||||||
async with httpx.AsyncClient() as client:
|
|
||||||
r = await client.get(gerty.mempool_endpoint + "/api/v1/lightning/statistics/latest")
|
|
||||||
if r:
|
|
||||||
ln.append(r.json())
|
|
||||||
|
|
||||||
return {"name":gerty.name, "wallets":wallets, "sats_quote":satoshi, "exchange":exchange, "onchain":onchain, "ln":ln}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue