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"
>{{fun_exchange_market_rate["unit"].split(" ")[1]}}</small
>
</q-card-section>
</q-card>
<q-card <q-card
v-if="fun_satoshi_quotes['quote']" 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"
>
<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>
</q-card-section>
<q-card-section class="q-pa-none">
<p v-for="(item, t) in dashboard_onchain">
<b>{{item[0].value}}: </b>{{item[1].value}}
</p>
</q-card-section>
</q-card>
<q-card class="q-pa-sm" v-if="dashboard_mining[0]" unelevated class="q-pa-sm"> <div
<q-card-section> class="q-pa-md row items-start q-gutter-md"
<div class="text-h6">Mining</div> v-if="lnbits_wallets_balance[0]"
</q-card-section> >
<q-card-section class="q-pa-none"> <q-card
<p v-for="(item, t) in dashboard_mining"> class="q-pa-sm"
<b>{{item[0].value}}:</b> {{item[1].value}} v-for="(wallet, t) in lnbits_wallets_balance"
</p> :style="`background-color: ${wallet.color1} !important`"
</q-card-section> unelevated
</q-card> 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>
<q-card class="q-pa-sm" v-if="lightning_dashboard[0]" unelevated class="q-pa-sm"> <div
<q-card-section> class="q-pa-md row items-start q-gutter-md"
<div class="text-h6">Lightning (Last 7 days)</div> v-if="dashboard_onchain[0] || dashboard_mining[0] || lightning_dashboard[0]"
</q-card-section> >
<q-card-section class="q-pa-none"> <q-card
<p v-for="(item, t) in lightning_dashboard"> class="q-pa-sm"
<b>{{item[0].value}}:</b> {{item[1].value}} v-if="dashboard_onchain[0]"
</p> unelevated
</q-card-section> class="q-pa-sm"
</q-card> >
<q-card-section>
<div class="text-h6">Onchain</div>
</q-card-section>
<q-card-section class="q-pa-none">
<p v-for="(item, t) in dashboard_onchain">
<b>{{item[0].value}}: </b>{{item[1].value}}
</p>
</q-card-section>
</q-card>
<q-card class="q-pa-sm" v-if="url_checker[0]" unelevated class="q-pa-sm"> <q-card class="q-pa-sm" v-if="dashboard_mining[0]" unelevated class="q-pa-sm">
<q-card-section> <q-card-section>
<div class="text-h6">Servers to check</div> <div class="text-h6">Mining</div>
</q-card-section> </q-card-section>
<q-card-section class="q-pa-none"> <q-card-section class="q-pa-none">
<div class="row q-pb-md" v-for="(item, t) in url_checker"> <p v-for="(item, t) in dashboard_mining">
<div class="col-8"> <b>{{item[0].value}}:</b> {{item[1].value}}
<small> </p>
<b style="word-wrap: break-word; max-width: 230px; display: block"> </q-card-section>
<a class="text-secondary" class="text-primary"> </q-card>
{{item[0].value}}
</a> <q-card
</b> class="q-pa-sm"
</small> v-if="lightning_dashboard[0]"
</div> unelevated
<div class="col-4"> class="q-pa-sm"
<q-chip >
v-if="item[1].value < 300" <q-card-section>
square <div class="text-h6">Lightning (Last 7 days)</div>
size="sm" </q-card-section>
color="green" <q-card-section class="q-pa-none">
text-color="white" <p v-for="(item, t) in lightning_dashboard">
icon="sentiment_satisfied" <b>{{item[0].value}}:</b> {{item[1].value}}
> </p>
{{item[1].value}} </q-card-section>
</q-chip> </q-card>
<q-chip
v-else-if="item[1].value >= 300" <q-card class="q-pa-sm" v-if="url_checker[0]" unelevated class="q-pa-sm">
square <q-card-section>
size="sm" <div class="text-h6">Servers to check</div>
color="yellow" </q-card-section>
text-color="white" <q-card-section class="q-pa-none">
icon="sentiment_dissatisfied" <div class="row q-pb-md" v-for="(item, t) in url_checker">
> <div class="col-8">
{{item[1].value}} <small>
</q-chip> <b style="word-wrap: break-word; max-width: 230px; display: block">
<q-chip <a class="text-secondary" class="text-primary">
v-else {{item[0].value}}
square </a>
size="sm" </b>
color="red" </small>
text-color="white"
icon="sentiment_dissatisfied"
>
{{item[1].value}}
</q-chip>
</div>
</div> </div>
</q-card-section> <div class="col-4">
</q-card> <q-chip
</div> v-if="item[1].value < 300"
square
size="sm"
color="green"
text-color="white"
icon="sentiment_satisfied"
>
{{item[1].value}}
</q-chip>
<q-chip
v-else-if="item[1].value >= 300"
square
size="sm"
color="yellow"
text-color="white"
icon="sentiment_dissatisfied"
>
{{item[1].value}}
</q-chip>
<q-chip
v-else
square
size="sm"
color="red"
text-color="white"
icon="sentiment_dissatisfied"
>
{{item[1].value}}
</q-chip>
</div>
</div>
</q-card-section>
</q-card>
</div>
{% endraw %} {% endblock %} {% block scripts %} {% endraw %} {% endblock %} {% block scripts %}
<script> <script>
Vue.component(VueQrcode.name, VueQrcode) Vue.component(VueQrcode.name, VueQrcode)
new Vue({ new Vue({
el: '#vue', el: '#vue',
mixins: [windowMixin], mixins: [windowMixin],
data: function () { data: function () {
return { return {
lnbits_wallets_balance: {}, lnbits_wallets_balance: {},
dashboard_onchain: {}, dashboard_onchain: {},
fun_satoshi_quotes: {}, fun_satoshi_quotes: {},
fun_exchange_market_rate: { fun_exchange_market_rate: {
unit: "" unit: ''
}, },
dashboard_mining: {}, dashboard_mining: {},
lightning_dashboard: {}, lightning_dashboard: {},
url_checker: {}, url_checker: {},
dashboard_mining: {}, dashboard_mining: {},
gerty: [], gerty: [],
gerty_id: `{{gerty}}`, gerty_id: `{{gerty}}`,
gertyname: '', gertyname: '',
walletColors: [ walletColors: [
{first: '#3f51b5', second: '#1a237e'}, {first: '#3f51b5', second: '#1a237e'},
{first: '#9c27b0', second: '#4a148c'}, {first: '#9c27b0', second: '#4a148c'},
{first: '#e91e63', second: '#880e4f'}, {first: '#e91e63', second: '#880e4f'},
{first: '#009688', second: '#004d40'}, {first: '#009688', second: '#004d40'},
{first: '#ff9800', second: '#e65100'}, {first: '#ff9800', second: '#e65100'},
{first: '#2196f3', second: '#0d47a1'}, {first: '#2196f3', second: '#0d47a1'},
{first: '#4caf50', second: '#1b5e20'} {first: '#4caf50', second: '#1b5e20'}
], ],
gertywallets: [] gertywallets: []
}
},
methods: {
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> 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