Added servers to check
This commit is contained in:
parent
2403d0adfb
commit
68bcfadd42
6 changed files with 203 additions and 112 deletions
|
|
@ -79,101 +79,98 @@ def format_number(number, precision=None):
|
||||||
async def get_mining_dashboard(gerty):
|
async def get_mining_dashboard(gerty):
|
||||||
areas = []
|
areas = []
|
||||||
if isinstance(gerty.mempool_endpoint, str):
|
if isinstance(gerty.mempool_endpoint, str):
|
||||||
async with httpx.AsyncClient() as client:
|
# current hashrate
|
||||||
# current hashrate
|
r = await get_mempool_info("hashrate_1w", gerty)
|
||||||
r = await get_mempool_info("hashrate_1w", gerty)
|
data = r
|
||||||
data = r
|
hashrateNow = data["currentHashrate"]
|
||||||
hashrateNow = data["currentHashrate"]
|
hashrateOneWeekAgo = data["hashrates"][6]["avgHashrate"]
|
||||||
hashrateOneWeekAgo = data["hashrates"][6]["avgHashrate"]
|
|
||||||
|
|
||||||
text = []
|
text = []
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
text="Current mining hashrate", font_size=12, gerty_type=gerty.type
|
text="Current mining hashrate", font_size=12, gerty_type=gerty.type
|
||||||
)
|
|
||||||
)
|
)
|
||||||
text.append(
|
)
|
||||||
get_text_item_dict(
|
text.append(
|
||||||
text="{0}hash".format(si_format(hashrateNow, 6, True, " ")),
|
get_text_item_dict(
|
||||||
font_size=20,
|
text="{0}hash".format(si_format(hashrateNow, 6, True, " ")),
|
||||||
gerty_type=gerty.type,
|
font_size=20,
|
||||||
)
|
gerty_type=gerty.type,
|
||||||
)
|
)
|
||||||
text.append(
|
)
|
||||||
get_text_item_dict(
|
text.append(
|
||||||
text="{0} vs 7 days ago".format(
|
get_text_item_dict(
|
||||||
get_percent_difference(hashrateNow, hashrateOneWeekAgo, 3)
|
text="{0} vs 7 days ago".format(
|
||||||
),
|
get_percent_difference(hashrateNow, hashrateOneWeekAgo, 3)
|
||||||
font_size=12,
|
),
|
||||||
gerty_type=gerty.type,
|
font_size=12,
|
||||||
)
|
gerty_type=gerty.type,
|
||||||
)
|
)
|
||||||
areas.append(text)
|
)
|
||||||
|
areas.append(text)
|
||||||
|
|
||||||
r = await get_mempool_info("difficulty_adjustment", gerty)
|
r = await get_mempool_info("difficulty_adjustment", gerty)
|
||||||
|
|
||||||
# timeAvg
|
# timeAvg
|
||||||
text = []
|
text = []
|
||||||
progress = "{0}%".format(round(r["progressPercent"], 2))
|
progress = "{0}%".format(round(r["progressPercent"], 2))
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
text="Progress through current epoch",
|
text="Progress through current epoch",
|
||||||
font_size=12,
|
font_size=12,
|
||||||
gerty_type=gerty.type,
|
gerty_type=gerty.type,
|
||||||
)
|
|
||||||
)
|
)
|
||||||
text.append(
|
)
|
||||||
get_text_item_dict(text=progress, font_size=60, gerty_type=gerty.type)
|
text.append(
|
||||||
)
|
get_text_item_dict(text=progress, font_size=60, gerty_type=gerty.type)
|
||||||
areas.append(text)
|
)
|
||||||
|
areas.append(text)
|
||||||
|
|
||||||
# difficulty adjustment
|
# difficulty adjustment
|
||||||
text = []
|
text = []
|
||||||
stat = r["remainingTime"]
|
stat = r["remainingTime"]
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
text="Time to next difficulty adjustment",
|
text="Time to next difficulty adjustment",
|
||||||
font_size=12,
|
font_size=12,
|
||||||
gerty_type=gerty.type,
|
gerty_type=gerty.type,
|
||||||
)
|
|
||||||
)
|
)
|
||||||
text.append(
|
)
|
||||||
get_text_item_dict(
|
text.append(
|
||||||
text=get_time_remaining(stat / 1000, 3),
|
get_text_item_dict(
|
||||||
font_size=12,
|
text=get_time_remaining(stat / 1000, 3),
|
||||||
gerty_type=gerty.type,
|
font_size=12,
|
||||||
)
|
gerty_type=gerty.type,
|
||||||
)
|
)
|
||||||
areas.append(text)
|
)
|
||||||
|
areas.append(text)
|
||||||
|
|
||||||
# difficultyChange
|
# difficultyChange
|
||||||
text = []
|
text = []
|
||||||
difficultyChange = round(r["difficultyChange"], 2)
|
difficultyChange = round(r["difficultyChange"], 2)
|
||||||
text.append(
|
text.append(
|
||||||
get_text_item_dict(
|
get_text_item_dict(
|
||||||
text="Estimated difficulty change",
|
text="Estimated difficulty change",
|
||||||
font_size=12,
|
font_size=12,
|
||||||
gerty_type=gerty.type,
|
gerty_type=gerty.type,
|
||||||
)
|
|
||||||
)
|
)
|
||||||
text.append(
|
)
|
||||||
get_text_item_dict(
|
text.append(
|
||||||
text="{0}{1}%".format(
|
get_text_item_dict(
|
||||||
"+" if difficultyChange > 0 else "", round(difficultyChange, 2)
|
text="{0}{1}%".format(
|
||||||
),
|
"+" if difficultyChange > 0 else "", round(difficultyChange, 2)
|
||||||
font_size=60,
|
),
|
||||||
gerty_type=gerty.type,
|
font_size=60,
|
||||||
)
|
gerty_type=gerty.type,
|
||||||
)
|
)
|
||||||
areas.append(text)
|
)
|
||||||
|
areas.append(text)
|
||||||
|
|
||||||
r = await get_mempool_info("hashrate_1m", gerty)
|
r = await get_mempool_info("hashrate_1m", gerty)
|
||||||
data = r
|
data = r
|
||||||
stat = {}
|
stat = {}
|
||||||
stat["current"] = data["currentDifficulty"]
|
stat["current"] = data["currentDifficulty"]
|
||||||
stat["previous"] = data["difficulty"][len(data["difficulty"]) - 2][
|
stat["previous"] = data["difficulty"][len(data["difficulty"]) - 2]["difficulty"]
|
||||||
"difficulty"
|
|
||||||
]
|
|
||||||
return areas
|
return areas
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -456,6 +453,43 @@ async def get_screen_data(screen_num: int, screens_list: dict, gerty):
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
areas.append(text)
|
areas.append(text)
|
||||||
|
elif screen_slug == "url_checker":
|
||||||
|
for url in json.loads(gerty.urls):
|
||||||
|
async with httpx.AsyncClient() as client:
|
||||||
|
text = []
|
||||||
|
try:
|
||||||
|
response = await client.get(url)
|
||||||
|
text.append(
|
||||||
|
get_text_item_dict(
|
||||||
|
text=url,
|
||||||
|
font_size=20,
|
||||||
|
gerty_type=gerty.type,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
text.append(
|
||||||
|
get_text_item_dict(
|
||||||
|
text=str(response.status_code),
|
||||||
|
font_size=40,
|
||||||
|
gerty_type=gerty.type,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
except:
|
||||||
|
text = []
|
||||||
|
text.append(
|
||||||
|
get_text_item_dict(
|
||||||
|
text=url,
|
||||||
|
font_size=20,
|
||||||
|
gerty_type=gerty.type,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
text.append(
|
||||||
|
get_text_item_dict(
|
||||||
|
text=str("DOWN"),
|
||||||
|
font_size=40,
|
||||||
|
gerty_type=gerty.type,
|
||||||
|
)
|
||||||
|
)
|
||||||
|
areas.append(text)
|
||||||
elif screen_slug == "fun_satoshi_quotes":
|
elif screen_slug == "fun_satoshi_quotes":
|
||||||
areas.append(await get_satoshi_quotes(gerty))
|
areas.append(await get_satoshi_quotes(gerty))
|
||||||
elif screen_slug == "fun_exchange_market_rate":
|
elif screen_slug == "fun_exchange_market_rate":
|
||||||
|
|
@ -940,8 +974,3 @@ def get_time_remaining(seconds, granularity=2):
|
||||||
name = name.rstrip("s")
|
name = name.rstrip("s")
|
||||||
result.append("{} {}".format(round(value), name))
|
result.append("{} {}".format(round(value), name))
|
||||||
return ", ".join(result[:granularity])
|
return ", ".join(result[:granularity])
|
||||||
|
|
||||||
|
|
||||||
async def get_urls_to_watch(gerty):
|
|
||||||
gerty = await get_gerty(gerty)
|
|
||||||
return json.loads(gerty.urls)
|
|
||||||
|
|
@ -51,8 +51,9 @@ async def m004_initial(db):
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
async def m005_add_gerty_model_col(db):
|
async def m005_add_gerty_model_col(db):
|
||||||
"""
|
"""
|
||||||
support for Gerty model col
|
support for Gerty model col
|
||||||
"""
|
"""
|
||||||
await db.execute("ALTER TABLE gerty.gertys ADD COLUMN urls TEXT DEFAULT '';")
|
await db.execute("ALTER TABLE gerty.gertys ADD COLUMN urls TEXT;")
|
||||||
|
|
|
||||||
|
|
@ -45,4 +45,4 @@ class Mempool(BaseModel):
|
||||||
mempool_endpoint: str = Query(None)
|
mempool_endpoint: str = Query(None)
|
||||||
endpoint: str = Query(None)
|
endpoint: str = Query(None)
|
||||||
data: str = Query(None)
|
data: str = Query(None)
|
||||||
time: int = Query(None)
|
time: int = Query(None)
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,6 @@
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
<a href="https://shop.lnbits.com/product/gerty-a-bitcoin-assistant"
|
<a href="https://shop.lnbits.com/product/gerty-a-bitcoin-assistant"
|
||||||
><img src="/gerty/static/gerty.jpg"
|
><img src="/gerty/static/gerty.jpg" style="max-width: 100%"
|
||||||
/></a>
|
/></a>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,14 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
||||||
>
|
>
|
||||||
<q-card-section class="text-h1 q-pa-none">
|
<q-card-section class="text-h1 q-pa-none">
|
||||||
<small> <b>{{fun_exchange_market_rate["amount"]}}</b></small>
|
<small> <b>{{fun_exchange_market_rate["amount"]}}</b></small>
|
||||||
<small class="text-h4">{{fun_exchange_market_rate["unit"]}}</small>
|
<small class="text-h4"
|
||||||
|
>{{fun_exchange_market_rate["unit"].split(" ")[1]}}</small
|
||||||
|
>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
<q-card
|
<q-card
|
||||||
v-if="fun_satoshi_quotes"
|
v-if="fun_satoshi_quotes['quote']"
|
||||||
unelevated
|
unelevated
|
||||||
class="q-pa-none text-body1 blockquote"
|
class="q-pa-none text-body1 blockquote"
|
||||||
style="background: none !important"
|
style="background: none !important"
|
||||||
|
|
@ -49,7 +51,12 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
||||||
class="q-pa-md row items-start q-gutter-md"
|
class="q-pa-md row items-start q-gutter-md"
|
||||||
v-if="dashboard_onchain || dashboard_mining || lightning_dashboard"
|
v-if="dashboard_onchain || dashboard_mining || lightning_dashboard"
|
||||||
>
|
>
|
||||||
<q-card class="q-pa-sm" v-if="dashboard_onchain" unelevated class="q-pa-sm">
|
<q-card
|
||||||
|
class="q-pa-sm"
|
||||||
|
v-if="dashboard_onchain[0]"
|
||||||
|
unelevated
|
||||||
|
class="q-pa-sm"
|
||||||
|
>
|
||||||
<q-card-section>
|
<q-card-section>
|
||||||
<div class="text-h6">Onchain</div>
|
<div class="text-h6">Onchain</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
|
|
@ -81,6 +88,44 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
||||||
</p>
|
</p>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
|
<q-card class="q-pa-sm" v-if="url_checker" unelevated class="q-pa-sm">
|
||||||
|
<q-card-section>
|
||||||
|
<div class="text-h6">Servers to check</div>
|
||||||
|
</q-card-section>
|
||||||
|
<q-card-section class="q-pa-none">
|
||||||
|
<p v-for="(item, t) in url_checker">
|
||||||
|
<b>{{item[0].value.slice(0, 20)}}...:</b>
|
||||||
|
<q-chip
|
||||||
|
v-if="item[1].value < 300"
|
||||||
|
square
|
||||||
|
color="green"
|
||||||
|
text-color="white"
|
||||||
|
icon="sentiment_satisfied"
|
||||||
|
>
|
||||||
|
{{item[1].value}}
|
||||||
|
</q-chip>
|
||||||
|
<q-chip
|
||||||
|
v-else-if="item[1].value >= 300"
|
||||||
|
square
|
||||||
|
color="yellow"
|
||||||
|
text-color="white"
|
||||||
|
icon="sentiment_dissatisfied"
|
||||||
|
>
|
||||||
|
{{item[1].value}}
|
||||||
|
</q-chip>
|
||||||
|
<q-chip
|
||||||
|
v-else
|
||||||
|
square
|
||||||
|
color="red"
|
||||||
|
text-color="white"
|
||||||
|
icon="sentiment_dissatisfied"
|
||||||
|
>
|
||||||
|
{{item[1].value}}
|
||||||
|
</q-chip>
|
||||||
|
</p>
|
||||||
|
</q-card-section>
|
||||||
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endraw %} {% endblock %} {% block scripts %}
|
{% endraw %} {% endblock %} {% block scripts %}
|
||||||
|
|
@ -137,6 +182,10 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
||||||
this.gertyname = this.gerty[i].settings.name
|
this.gertyname = this.gerty[i].settings.name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (this.gerty[i].screen.group == 'url_checker') {
|
||||||
|
this.url_checker = this.gerty[i].screen.areas
|
||||||
|
this.gertyname = this.gerty[i].settings.name
|
||||||
|
}
|
||||||
if (this.gerty[i].screen.group == 'dashboard_onchain') {
|
if (this.gerty[i].screen.group == 'dashboard_onchain') {
|
||||||
this.dashboard_onchain = this.gerty[i].screen.areas
|
this.dashboard_onchain = this.gerty[i].screen.areas
|
||||||
this.gertyname = this.gerty[i].settings.name
|
this.gertyname = this.gerty[i].settings.name
|
||||||
|
|
|
||||||
|
|
@ -192,6 +192,7 @@
|
||||||
val="xs"
|
val="xs"
|
||||||
label="URL Checker"
|
label="URL Checker"
|
||||||
></q-checkbox>
|
></q-checkbox>
|
||||||
|
<br />
|
||||||
<q-select
|
<q-select
|
||||||
v-if="formDialog.data.display_preferences.fun_exchange_market_rate"
|
v-if="formDialog.data.display_preferences.fun_exchange_market_rate"
|
||||||
filled
|
filled
|
||||||
|
|
@ -220,22 +221,22 @@
|
||||||
</q-select>
|
</q-select>
|
||||||
|
|
||||||
<q-select
|
<q-select
|
||||||
v-if="formDialog.data.display_preferences.url_checker"
|
v-if="formDialog.data.display_preferences.url_checker"
|
||||||
filled
|
filled
|
||||||
multiple
|
multiple
|
||||||
dense
|
dense
|
||||||
emit-value
|
emit-value
|
||||||
v-model="formDialog.data.urls"
|
v-model="formDialog.data.urls"
|
||||||
use-input
|
use-input
|
||||||
use-chips
|
use-chips
|
||||||
multiple
|
multiple
|
||||||
hide-dropdown-icon
|
hide-dropdown-icon
|
||||||
new-value-mode="add-unique"
|
new-value-mode="add-unique"
|
||||||
label="Urls to watch."
|
label="Urls to watch."
|
||||||
>
|
>
|
||||||
<q-tooltip>Hit enter to add values</q-tooltip>
|
<q-tooltip>Hit enter to add values</q-tooltip>
|
||||||
</q-select>
|
</q-select>
|
||||||
|
|
||||||
<q-toggle
|
<q-toggle
|
||||||
label="*Advanced"
|
label="*Advanced"
|
||||||
v-model="toggleStates.advanced"
|
v-model="toggleStates.advanced"
|
||||||
|
|
@ -527,7 +528,6 @@
|
||||||
mempool_recommended_fees: false,
|
mempool_recommended_fees: false,
|
||||||
dashboard_mining: false,
|
dashboard_mining: false,
|
||||||
lightning_dashboard: false,
|
lightning_dashboard: false,
|
||||||
url_checker: false,
|
|
||||||
onchain: false,
|
onchain: false,
|
||||||
onchain_difficulty_epoch_progress: false,
|
onchain_difficulty_epoch_progress: false,
|
||||||
onchain_difficulty_retarget_date: false,
|
onchain_difficulty_retarget_date: false,
|
||||||
|
|
@ -537,9 +537,11 @@
|
||||||
mempool_tx_count: false,
|
mempool_tx_count: false,
|
||||||
mining_current_hash_rate: false,
|
mining_current_hash_rate: false,
|
||||||
mining_current_difficulty: false,
|
mining_current_difficulty: false,
|
||||||
lnbits_wallets_balance: false
|
lnbits_wallets_balance: false,
|
||||||
|
url_checker: false
|
||||||
},
|
},
|
||||||
lnbits_wallets: [],
|
lnbits_wallets: [],
|
||||||
|
urls: [],
|
||||||
mempool_endpoint: 'https://mempool.space',
|
mempool_endpoint: 'https://mempool.space',
|
||||||
refresh_time: 300
|
refresh_time: 300
|
||||||
}
|
}
|
||||||
|
|
@ -558,6 +560,12 @@
|
||||||
self.formDialog.data.lnbits_wallets = []
|
self.formDialog.data.lnbits_wallets = []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
setUrls: function () {
|
||||||
|
self = this
|
||||||
|
if (!self.formDialog.data.display_preferences.url_checker) {
|
||||||
|
self.formDialog.data.urls = []
|
||||||
|
}
|
||||||
|
},
|
||||||
setOnchain: function () {
|
setOnchain: function () {
|
||||||
self = this
|
self = this
|
||||||
self.formDialog.data.display_preferences.onchain_difficulty_epoch_progress =
|
self.formDialog.data.display_preferences.onchain_difficulty_epoch_progress =
|
||||||
|
|
@ -582,6 +590,7 @@
|
||||||
this.formDialog.data = {
|
this.formDialog.data = {
|
||||||
utc_offset: 0,
|
utc_offset: 0,
|
||||||
lnbits_wallets: [],
|
lnbits_wallets: [],
|
||||||
|
urls: [],
|
||||||
mempool_endpoint: 'https://mempool.space',
|
mempool_endpoint: 'https://mempool.space',
|
||||||
refresh_time: 300,
|
refresh_time: 300,
|
||||||
display_preferences: {}
|
display_preferences: {}
|
||||||
|
|
@ -608,7 +617,7 @@
|
||||||
this.formDialog.data.type = gerty.type
|
this.formDialog.data.type = gerty.type
|
||||||
this.formDialog.data.utc_offset = gerty.utc_offset
|
this.formDialog.data.utc_offset = gerty.utc_offset
|
||||||
this.formDialog.data.lnbits_wallets = JSON.parse(gerty.lnbits_wallets)
|
this.formDialog.data.lnbits_wallets = JSON.parse(gerty.lnbits_wallets)
|
||||||
this.formDialog.data.urls = JSON.stringify(gerty.urls)
|
this.formDialog.data.urls = JSON.parse(gerty.urls)
|
||||||
;(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.refresh_time = gerty.refresh_time),
|
(this.formDialog.data.refresh_time = gerty.refresh_time),
|
||||||
|
|
@ -675,7 +684,8 @@
|
||||||
this.formDialog.data.display_preferences.dashboard ||
|
this.formDialog.data.display_preferences.dashboard ||
|
||||||
this.formDialog.data.display_preferences.dashboard_onchain ||
|
this.formDialog.data.display_preferences.dashboard_onchain ||
|
||||||
this.formDialog.data.display_preferences.dashboard_onchain ||
|
this.formDialog.data.display_preferences.dashboard_onchain ||
|
||||||
this.formDialog.data.display_preferences.lightning_dashboard
|
this.formDialog.data.display_preferences.lightning_dashboard ||
|
||||||
|
this.formDialog.data.display_preferences.url_checker
|
||||||
) {
|
) {
|
||||||
this.formDialog.data.type = 'Gerty'
|
this.formDialog.data.type = 'Gerty'
|
||||||
}
|
}
|
||||||
|
|
@ -684,6 +694,7 @@
|
||||||
data.lnbits_wallets = JSON.stringify(
|
data.lnbits_wallets = JSON.stringify(
|
||||||
this.formDialog.data.lnbits_wallets
|
this.formDialog.data.lnbits_wallets
|
||||||
)
|
)
|
||||||
|
data.urls = JSON.stringify(this.formDialog.data.urls)
|
||||||
data.display_preferences = JSON.stringify(
|
data.display_preferences = JSON.stringify(
|
||||||
this.formDialog.data.display_preferences
|
this.formDialog.data.display_preferences
|
||||||
)
|
)
|
||||||
|
|
@ -748,6 +759,7 @@
|
||||||
this.formDialog.data.display_preferences.fun_satoshi_quotes = false
|
this.formDialog.data.display_preferences.fun_satoshi_quotes = false
|
||||||
this.formDialog.data.display_preferences.mempool_recommended_fees = false
|
this.formDialog.data.display_preferences.mempool_recommended_fees = false
|
||||||
this.formDialog.data.display_preferences.onchain = false
|
this.formDialog.data.display_preferences.onchain = false
|
||||||
|
this.formDialog.data.display_preferences.url_checker = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue