Added servers to check
This commit is contained in:
parent
2403d0adfb
commit
68bcfadd42
6 changed files with 203 additions and 112 deletions
|
|
@ -79,7 +79,6 @@ def format_number(number, precision=None):
|
|||
async def get_mining_dashboard(gerty):
|
||||
areas = []
|
||||
if isinstance(gerty.mempool_endpoint, str):
|
||||
async with httpx.AsyncClient() as client:
|
||||
# current hashrate
|
||||
r = await get_mempool_info("hashrate_1w", gerty)
|
||||
data = r
|
||||
|
|
@ -171,9 +170,7 @@ async def get_mining_dashboard(gerty):
|
|||
data = r
|
||||
stat = {}
|
||||
stat["current"] = data["currentDifficulty"]
|
||||
stat["previous"] = data["difficulty"][len(data["difficulty"]) - 2][
|
||||
"difficulty"
|
||||
]
|
||||
stat["previous"] = data["difficulty"][len(data["difficulty"]) - 2]["difficulty"]
|
||||
return areas
|
||||
|
||||
|
||||
|
|
@ -456,6 +453,43 @@ async def get_screen_data(screen_num: int, screens_list: dict, gerty):
|
|||
)
|
||||
)
|
||||
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":
|
||||
areas.append(await get_satoshi_quotes(gerty))
|
||||
elif screen_slug == "fun_exchange_market_rate":
|
||||
|
|
@ -940,8 +974,3 @@ def get_time_remaining(seconds, granularity=2):
|
|||
name = name.rstrip("s")
|
||||
result.append("{} {}".format(round(value), name))
|
||||
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):
|
||||
"""
|
||||
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;")
|
||||
|
|
|
|||
|
|
@ -12,6 +12,6 @@
|
|||
>
|
||||
</p>
|
||||
<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>
|
||||
</q-card-section>
|
||||
|
|
|
|||
|
|
@ -13,12 +13,14 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
|||
>
|
||||
<q-card-section class="text-h1 q-pa-none">
|
||||
<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>
|
||||
|
||||
<q-card
|
||||
v-if="fun_satoshi_quotes"
|
||||
v-if="fun_satoshi_quotes['quote']"
|
||||
unelevated
|
||||
class="q-pa-none text-body1 blockquote"
|
||||
style="background: none !important"
|
||||
|
|
@ -49,7 +51,12 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
|||
class="q-pa-md row items-start q-gutter-md"
|
||||
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>
|
||||
<div class="text-h6">Onchain</div>
|
||||
</q-card-section>
|
||||
|
|
@ -81,6 +88,44 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
|||
</p>
|
||||
</q-card-section>
|
||||
</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>
|
||||
|
||||
{% endraw %} {% endblock %} {% block scripts %}
|
||||
|
|
@ -137,6 +182,10 @@ gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
|
|||
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') {
|
||||
this.dashboard_onchain = this.gerty[i].screen.areas
|
||||
this.gertyname = this.gerty[i].settings.name
|
||||
|
|
|
|||
|
|
@ -192,6 +192,7 @@
|
|||
val="xs"
|
||||
label="URL Checker"
|
||||
></q-checkbox>
|
||||
<br />
|
||||
<q-select
|
||||
v-if="formDialog.data.display_preferences.fun_exchange_market_rate"
|
||||
filled
|
||||
|
|
@ -527,7 +528,6 @@
|
|||
mempool_recommended_fees: false,
|
||||
dashboard_mining: false,
|
||||
lightning_dashboard: false,
|
||||
url_checker: false,
|
||||
onchain: false,
|
||||
onchain_difficulty_epoch_progress: false,
|
||||
onchain_difficulty_retarget_date: false,
|
||||
|
|
@ -537,9 +537,11 @@
|
|||
mempool_tx_count: false,
|
||||
mining_current_hash_rate: false,
|
||||
mining_current_difficulty: false,
|
||||
lnbits_wallets_balance: false
|
||||
lnbits_wallets_balance: false,
|
||||
url_checker: false
|
||||
},
|
||||
lnbits_wallets: [],
|
||||
urls: [],
|
||||
mempool_endpoint: 'https://mempool.space',
|
||||
refresh_time: 300
|
||||
}
|
||||
|
|
@ -558,6 +560,12 @@
|
|||
self.formDialog.data.lnbits_wallets = []
|
||||
}
|
||||
},
|
||||
setUrls: function () {
|
||||
self = this
|
||||
if (!self.formDialog.data.display_preferences.url_checker) {
|
||||
self.formDialog.data.urls = []
|
||||
}
|
||||
},
|
||||
setOnchain: function () {
|
||||
self = this
|
||||
self.formDialog.data.display_preferences.onchain_difficulty_epoch_progress =
|
||||
|
|
@ -582,6 +590,7 @@
|
|||
this.formDialog.data = {
|
||||
utc_offset: 0,
|
||||
lnbits_wallets: [],
|
||||
urls: [],
|
||||
mempool_endpoint: 'https://mempool.space',
|
||||
refresh_time: 300,
|
||||
display_preferences: {}
|
||||
|
|
@ -608,7 +617,7 @@
|
|||
this.formDialog.data.type = gerty.type
|
||||
this.formDialog.data.utc_offset = gerty.utc_offset
|
||||
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.mempool_endpoint = gerty.mempool_endpoint),
|
||||
(this.formDialog.data.refresh_time = gerty.refresh_time),
|
||||
|
|
@ -675,7 +684,8 @@
|
|||
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.lightning_dashboard
|
||||
this.formDialog.data.display_preferences.lightning_dashboard ||
|
||||
this.formDialog.data.display_preferences.url_checker
|
||||
) {
|
||||
this.formDialog.data.type = 'Gerty'
|
||||
}
|
||||
|
|
@ -684,6 +694,7 @@
|
|||
data.lnbits_wallets = JSON.stringify(
|
||||
this.formDialog.data.lnbits_wallets
|
||||
)
|
||||
data.urls = JSON.stringify(this.formDialog.data.urls)
|
||||
data.display_preferences = JSON.stringify(
|
||||
this.formDialog.data.display_preferences
|
||||
)
|
||||
|
|
@ -748,6 +759,7 @@
|
|||
this.formDialog.data.display_preferences.fun_satoshi_quotes = false
|
||||
this.formDialog.data.display_preferences.mempool_recommended_fees = 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