fix issue @ben ;)

This commit is contained in:
dni ⚡ 2023-01-04 17:09:50 +01:00
parent 32b785d790
commit 40bcee6d22
3 changed files with 256 additions and 250 deletions

View file

@ -70,7 +70,7 @@ def get_text_item_dict(
else: else:
data_text["x"] = x_pos if x_pos > 0 else 0 data_text["x"] = x_pos if x_pos > 0 else 0
data_text["y"] = y_pos if x_pos > 0 else 0 data_text["y"] = y_pos if x_pos > 0 else 0
return text return data_text
def get_date_suffix(dayNumber): def get_date_suffix(dayNumber):
@ -532,7 +532,6 @@ async def get_screen_data(screen_num: int, screens_list: list, gerty):
"title": title, "title": title,
"areas": areas, "areas": areas,
} }
return data return data

View file

@ -1,251 +1,258 @@
{% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{ {% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{
gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %} gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
<div <div
class="q-pa-md row items-start q-gutter-md" class="q-pa-md row items-start q-gutter-md"
v-if="fun_exchange_market_rate || fun_satoshi_quotes" v-if="fun_exchange_market_rate || fun_satoshi_quotes"
>
<q-card
v-if="fun_exchange_market_rate"
unelevated
class="q-pa-sm"
style="background: none !important"
> >
<q-card <q-card-section class="text-h1 q-pa-none">
v-if="fun_exchange_market_rate" <small> <b>{{fun_exchange_market_rate["amount"]}}</b></small>
unelevated <small class="text-h4"
class="q-pa-sm" >{{fun_exchange_market_rate["unit"].split(" ")[1]}}</small
style="background: none !important" >
> </q-card-section>
<q-card-section class="text-h1 q-pa-none"> </q-card>
<small> <b>{{fun_exchange_market_rate["amount"]}}</b></small>
<small class="text-h4" <q-card
>{{fun_exchange_market_rate["unit"].split(" ")[1]}}</small v-if="fun_satoshi_quotes['quote']"
> unelevated
</q-card-section> class="q-pa-none text-body1 blockquote"
</q-card> style="background: none !important"
<q-card
v-if="fun_satoshi_quotes['quote']"
unelevated
class="q-pa-none text-body1 blockquote"
style="background: none !important"
>
<blockquote class="text-right" style="max-width: 900px">
<p>"{{fun_satoshi_quotes["quote"]}}"</p>
<small>~ Satoshi {{fun_satoshi_quotes["date"]}}</small>
</blockquote>
</q-card>
</div>
<div class="q-pa-md row items-start q-gutter-md" v-if="lnbits_wallets_balance[0]">
<q-card
class="q-pa-sm"
v-for="(wallet, t) in lnbits_wallets_balance"
:style="`background-color: ${wallet.color1} !important`"
unelevated
class="q-pa-none q-pa-sm"
>
<q-card-section class="text-h1 q-pa-none">
<small> <b>{{wallet["amount"]}}</b></small>
<small class="text-h4">({{wallet["name"]}})</small>
</q-card-section>
</q-card>
</div>
<div
class="q-pa-md row items-start q-gutter-md"
v-if="dashboard_onchain[0] || dashboard_mining[0] || lightning_dashboard[0]"
> >
<q-card <blockquote class="text-right" style="max-width: 900px">
class="q-pa-sm" <p>"{{fun_satoshi_quotes["quote"]}}"</p>
v-if="dashboard_onchain[0]" <small>~ Satoshi {{fun_satoshi_quotes["date"]}}</small>
unelevated </blockquote>
class="q-pa-sm" </q-card>
> </div>
<q-card-section>
<div class="text-h6">Onchain</div> <div
</q-card-section> class="q-pa-md row items-start q-gutter-md"
<q-card-section class="q-pa-none"> v-if="lnbits_wallets_balance[0]"
<p v-for="(item, t) in dashboard_onchain"> >
<b>{{item[0].value}}: </b>{{item[1].value}} <q-card
</p> class="q-pa-sm"
</q-card-section> v-for="(wallet, t) in lnbits_wallets_balance"
</q-card> :style="`background-color: ${wallet.color1} !important`"
unelevated
<q-card class="q-pa-sm" v-if="dashboard_mining[0]" unelevated class="q-pa-sm"> class="q-pa-none q-pa-sm"
<q-card-section> >
<div class="text-h6">Mining</div> <q-card-section class="text-h1 q-pa-none">
</q-card-section> <small> <b>{{wallet["amount"]}}</b></small>
<q-card-section class="q-pa-none"> <small class="text-h4">({{wallet["name"]}})</small>
<p v-for="(item, t) in dashboard_mining"> </q-card-section>
<b>{{item[0].value}}:</b> {{item[1].value}} </q-card>
</p> </div>
</q-card-section>
</q-card> <div
class="q-pa-md row items-start q-gutter-md"
<q-card class="q-pa-sm" v-if="lightning_dashboard[0]" unelevated class="q-pa-sm"> v-if="dashboard_onchain[0] || dashboard_mining[0] || lightning_dashboard[0]"
<q-card-section> >
<div class="text-h6">Lightning (Last 7 days)</div> <q-card
</q-card-section> class="q-pa-sm"
<q-card-section class="q-pa-none"> v-if="dashboard_onchain[0]"
<p v-for="(item, t) in lightning_dashboard"> unelevated
<b>{{item[0].value}}:</b> {{item[1].value}} class="q-pa-sm"
</p> >
</q-card-section> <q-card-section>
</q-card> <div class="text-h6">Onchain</div>
</q-card-section>
<q-card class="q-pa-sm" v-if="url_checker[0]" unelevated class="q-pa-sm"> <q-card-section class="q-pa-none">
<q-card-section> <p v-for="(item, t) in dashboard_onchain">
<div class="text-h6">Servers to check</div> <b>{{item[0].value}}: </b>{{item[1].value}}
</q-card-section> </p>
<q-card-section class="q-pa-none"> </q-card-section>
<div class="row q-pb-md" v-for="(item, t) in url_checker"> </q-card>
<div class="col-8">
<small> <q-card class="q-pa-sm" v-if="dashboard_mining[0]" unelevated class="q-pa-sm">
<b style="word-wrap: break-word; max-width: 230px; display: block"> <q-card-section>
<a class="text-secondary" class="text-primary"> <div class="text-h6">Mining</div>
{{item[0].value}} </q-card-section>
</a> <q-card-section class="q-pa-none">
</b> <p v-for="(item, t) in dashboard_mining">
</small> <b>{{item[0].value}}:</b> {{item[1].value}}
</div> </p>
<div class="col-4"> </q-card-section>
<q-chip </q-card>
v-if="item[1].value < 300"
square <q-card
size="sm" class="q-pa-sm"
color="green" v-if="lightning_dashboard[0]"
text-color="white" unelevated
icon="sentiment_satisfied" class="q-pa-sm"
> >
{{item[1].value}} <q-card-section>
</q-chip> <div class="text-h6">Lightning (Last 7 days)</div>
<q-chip </q-card-section>
v-else-if="item[1].value >= 300" <q-card-section class="q-pa-none">
square <p v-for="(item, t) in lightning_dashboard">
size="sm" <b>{{item[0].value}}:</b> {{item[1].value}}
color="yellow" </p>
text-color="white" </q-card-section>
icon="sentiment_dissatisfied" </q-card>
>
{{item[1].value}} <q-card class="q-pa-sm" v-if="url_checker[0]" unelevated class="q-pa-sm">
</q-chip> <q-card-section>
<q-chip <div class="text-h6">Servers to check</div>
v-else </q-card-section>
square <q-card-section class="q-pa-none">
size="sm" <div class="row q-pb-md" v-for="(item, t) in url_checker">
color="red" <div class="col-8">
text-color="white" <small>
icon="sentiment_dissatisfied" <b style="word-wrap: break-word; max-width: 230px; display: block">
> <a class="text-secondary" class="text-primary">
{{item[1].value}} {{item[0].value}}
</q-chip> </a>
</div> </b>
</small>
</div> </div>
</q-card-section> <div class="col-4">
</q-card> <q-chip
</div> v-if="item[1].value < 300"
square
{% endraw %} {% endblock %} {% block scripts %} size="sm"
<script> color="green"
Vue.component(VueQrcode.name, VueQrcode) text-color="white"
icon="sentiment_satisfied"
new Vue({ >
el: '#vue', {{item[1].value}}
mixins: [windowMixin], </q-chip>
data: function () { <q-chip
return { v-else-if="item[1].value >= 300"
lnbits_wallets_balance: {}, square
dashboard_onchain: {}, size="sm"
fun_satoshi_quotes: {}, color="yellow"
fun_exchange_market_rate: { text-color="white"
unit: "" icon="sentiment_dissatisfied"
}, >
dashboard_mining: {}, {{item[1].value}}
lightning_dashboard: {}, </q-chip>
url_checker: {}, <q-chip
dashboard_mining: {}, v-else
gerty: [], square
gerty_id: `{{gerty}}`, size="sm"
gertyname: '', color="red"
walletColors: [ text-color="white"
{first: '#3f51b5', second: '#1a237e'}, icon="sentiment_dissatisfied"
{first: '#9c27b0', second: '#4a148c'}, >
{first: '#e91e63', second: '#880e4f'}, {{item[1].value}}
{first: '#009688', second: '#004d40'}, </q-chip>
{first: '#ff9800', second: '#e65100'}, </div>
{first: '#2196f3', second: '#0d47a1'}, </div>
{first: '#4caf50', second: '#1b5e20'} </q-card-section>
], </q-card>
gertywallets: [] </div>
}
}, {% endraw %} {% endblock %} {% block scripts %}
methods: { <script>
getGertyInfo: async function () { Vue.component(VueQrcode.name, VueQrcode)
for (let i = 0; i < 8; i++) {
try { new Vue({
const {data} = await LNbits.api.request( el: '#vue',
'GET', mixins: [windowMixin],
`/gerty/api/v1/gerty/pages/${this.gerty_id}/${i}` data: function () {
) return {
this.gerty[i] = data lnbits_wallets_balance: {},
} catch (error) { dashboard_onchain: {},
LNbits.utils.notifyApiError(error) fun_satoshi_quotes: {},
} fun_exchange_market_rate: {
} unit: ''
console.log(this.gerty) },
for (let i = 0; i < this.gerty.length; i++) { dashboard_mining: {},
if (this.gerty[i].screen.group == 'lnbits_wallets_balance') { lightning_dashboard: {},
for (let q = 0; q < this.gerty[i].screen.areas.length; q++) { url_checker: {},
this.lnbits_wallets_balance[q] = { dashboard_mining: {},
name: this.gerty[i].screen.areas[q][0].value, gerty: [],
amount: this.gerty[i].screen.areas[q][1].value, gerty_id: `{{gerty}}`,
color1: this.walletColors[q].first, gertyname: '',
color2: this.walletColors[q].second walletColors: [
} {first: '#3f51b5', second: '#1a237e'},
this.gertyname = this.gerty[i].settings.name {first: '#9c27b0', second: '#4a148c'},
} {first: '#e91e63', second: '#880e4f'},
} {first: '#009688', second: '#004d40'},
if (this.gerty[i].screen.group == 'url_checker') { {first: '#ff9800', second: '#e65100'},
this.url_checker = this.gerty[i].screen.areas {first: '#2196f3', second: '#0d47a1'},
this.gertyname = this.gerty[i].settings.name {first: '#4caf50', second: '#1b5e20'}
} ],
if (this.gerty[i].screen.group == 'dashboard_onchain') { gertywallets: []
this.dashboard_onchain = this.gerty[i].screen.areas
this.gertyname = this.gerty[i].settings.name
}
if (this.gerty[i].screen.group == 'dashboard_mining') {
this.dashboard_mining = this.gerty[i].screen.areas
this.gertyname = this.gerty[i].settings.name
}
if (this.gerty[i].screen.group == 'lightning_dashboard') {
this.lightning_dashboard = this.gerty[i].screen.areas
this.gertyname = this.gerty[i].settings.name
}
if (this.gerty[i].screen.group == 'fun_satoshi_quotes') {
this.fun_satoshi_quotes['quote'] = this.gerty[
i
].screen.areas[0][0].value
this.fun_satoshi_quotes['date'] = this.gerty[
i
].screen.areas[0][1].value
this.gertyname = this.gerty[i].settings.name
}
if (this.gerty[i].screen.group == 'fun_exchange_market_rate') {
this.fun_exchange_market_rate['unit'] = this.gerty[
i
].screen.areas[0][0].value
this.fun_exchange_market_rate['amount'] = this.gerty[
i
].screen.areas[0][1].value
this.gertyname = this.gerty[i].settings.name
}
}
setTimeout(this.getGertyInfo, 20000)
this.$forceUpdate()
return this.gerty
}
},
created: async function () {
await this.getGertyInfo()
} }
}) },
</script> methods: {
{% endblock %} getGertyInfo: async function () {
for (let i = 0; i < 8; i++) {
try {
const {data} = await LNbits.api.request(
'GET',
`/gerty/api/v1/gerty/pages/${this.gerty_id}/${i}`
)
this.gerty[i] = data
} catch (error) {
LNbits.utils.notifyApiError(error)
}
}
console.log(this.gerty)
for (let i = 0; i < this.gerty.length; i++) {
if (this.gerty[i].screen.group == 'lnbits_wallets_balance') {
for (let q = 0; q < this.gerty[i].screen.areas.length; q++) {
this.lnbits_wallets_balance[q] = {
name: this.gerty[i].screen.areas[q][0].value,
amount: this.gerty[i].screen.areas[q][1].value,
color1: this.walletColors[q].first,
color2: this.walletColors[q].second
}
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
}
if (this.gerty[i].screen.group == 'dashboard_mining') {
this.dashboard_mining = this.gerty[i].screen.areas
this.gertyname = this.gerty[i].settings.name
}
if (this.gerty[i].screen.group == 'lightning_dashboard') {
this.lightning_dashboard = this.gerty[i].screen.areas
this.gertyname = this.gerty[i].settings.name
}
if (this.gerty[i].screen.group == 'fun_satoshi_quotes') {
this.fun_satoshi_quotes['quote'] = this.gerty[
i
].screen.areas[0][0].value
this.fun_satoshi_quotes['date'] = this.gerty[
i
].screen.areas[0][1].value
this.gertyname = this.gerty[i].settings.name
}
if (this.gerty[i].screen.group == 'fun_exchange_market_rate') {
this.fun_exchange_market_rate['unit'] = this.gerty[
i
].screen.areas[0][0].value
this.fun_exchange_market_rate['amount'] = this.gerty[
i
].screen.areas[0][1].value
this.gertyname = this.gerty[i].settings.name
}
}
setTimeout(this.getGertyInfo, 20000)
this.$forceUpdate()
return this.gerty
}
},
created: async function () {
await this.getGertyInfo()
}
})
</script>
{% endblock %}

View file

@ -18,10 +18,10 @@ from .crud import (
update_gerty, update_gerty,
) )
from .helpers import ( from .helpers import (
get_screen_data,
get_satoshi,
gerty_should_sleep, gerty_should_sleep,
get_next_update_time, get_next_update_time,
get_satoshi,
get_screen_data,
get_screen_slug_by_index, get_screen_slug_by_index,
) )
from .models import Gerty from .models import Gerty