MVP working

This commit is contained in:
ben 2022-12-15 23:12:13 +00:00
parent ee79bdcfc8
commit 495719c366
3 changed files with 188 additions and 170 deletions

View file

@ -13,6 +13,7 @@ from ...settings import LNBITS_PATH
from lnbits.utils.exchange_rates import satoshis_amount_as_fiat
from lnbits.core.crud import get_user, get_wallet_for_key
def get_percent_difference(current, previous, precision=3):
difference = (current - previous) / current * 100
return "{0}{1}%".format("+" if difference > 0 else "", round(difference, precision))

View file

@ -1,11 +1,19 @@
{% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{ gertyname }}{% endraw %}{%
endblock %}{% block page %} {% raw %}
{% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{
gertyname }}{% endraw %}{% endblock %}{% block page %} {% raw %}
<div class="q-pa-md row items-start q-gutter-md" 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">
<div
class="q-pa-md row items-start q-gutter-md"
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-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> <b>{{fun_exchange_market_rate["amount"]}}</b></small>
<small class="text-h4">{{fun_exchange_market_rate["unit"]}}</small>
</q-card-section>
</q-card>
@ -14,29 +22,41 @@ endblock %}{% block page %} {% raw %}
unelevated
class="q-pa-none text-body1 blockquote"
style="background: none !important"
>
<blockquote class="text-right" style="max-width: 900px">
>
<blockquote class="text-right" style="max-width: 900px">
<p>"{{fun_satoshi_quotes["quote"]}}"</p>
<small>~ Satoshi {{fun_satoshi_quotes["date"]}}</small>
</blockquote>
</q-card>
</blockquote>
</q-card>
</div>
<div class="q-pa-md row items-start q-gutter-md" v-if="lnbits_wallets_balance">
<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
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>
<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 || dashboard_mining || lightning_dashboard">
<div
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-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>
<p v-for="(item, t) in dashboard_onchain">
<b>{{item[0].value}}: </b>{{item[1].value}}
</p>
</q-card-section>
</q-card>
@ -45,7 +65,9 @@ endblock %}{% block page %} {% raw %}
<div class="text-h6">Mining</div>
</q-card-section>
<q-card-section class="q-pa-none">
<p v-for="(item, t) in dashboard_mining"><b>{{item[0].value}}:</b> {{item[1].value}}</p>
<p v-for="(item, t) in dashboard_mining">
<b>{{item[0].value}}:</b> {{item[1].value}}
</p>
</q-card-section>
</q-card>
@ -54,10 +76,11 @@ endblock %}{% block page %} {% raw %}
<div class="text-h6">Lightning (Last 7 days)</div>
</q-card-section>
<q-card-section class="q-pa-none">
<p v-for="(item, t) in lightning_dashboard"><b>{{item[0].value}}:</b> {{item[1].value}}</p>
<p v-for="(item, t) in lightning_dashboard">
<b>{{item[0].value}}:</b> {{item[1].value}}
</p>
</q-card-section>
</q-card>
</div>
{% endraw %} {% endblock %} {% block scripts %}
@ -75,85 +98,83 @@ endblock %}{% block page %} {% raw %}
fun_exchange_market_rate: {},
gerty: [],
gerty_id: `{{gerty}}`,
gertyname: "",
gertyname: '',
walletColors: [
{first: "#3f51b5",
second: "#1a237e"},
{first: "#9c27b0",
second: "#4a148c"},
{first: "#e91e63",
second: "#880e4f"},
{first: "#009688",
second: "#004d40"},
{first: "#ff9800",
second: "#e65100"},
{first: "#2196f3",
second: "#0d47a1"},
{first: "#4caf50",
second: "#1b5e20"}
{first: '#3f51b5', second: '#1a237e'},
{first: '#9c27b0', second: '#4a148c'},
{first: '#e91e63', second: '#880e4f'},
{first: '#009688', second: '#004d40'},
{first: '#ff9800', second: '#e65100'},
{first: '#2196f3', second: '#0d47a1'},
{first: '#4caf50', second: '#1b5e20'}
],
gertywallets: []
}
},
methods: {
getGertyInfo: async function () {
for (let i = 0; i < 8; i++){
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"){
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,
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 == "dashboard_onchain"){
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"){
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"){
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
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
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();
setTimeout(this.getGertyInfo, 20000)
this.$forceUpdate()
return this.gerty
},
}
},
created: async function () {
await this.getGertyInfo()
}
})

View file

@ -142,15 +142,16 @@
></q-input>
<q-checkbox
class="q-pl-md"
size="xs"
v-model="formDialog.data.display_preferences.fun_satoshi_quotes"
val="xs"
label="Satoshi Quotes"
><q-tooltip>Displays random quotes from Satoshi</q-tooltip></q-checkbox>
><q-tooltip
>Displays random quotes from Satoshi</q-tooltip
></q-checkbox
>
<q-checkbox
class="q-pl-md"
size="xs"
v-model="formDialog.data.display_preferences.fun_exchange_market_rate"
val="xs"
@ -158,7 +159,6 @@
></q-checkbox>
<q-checkbox
class="q-pl-md"
size="xs"
v-model="formDialog.data.display_preferences.lnbits_wallets_balance"
val="xs"
@ -166,7 +166,6 @@
></q-checkbox>
<q-checkbox
class="q-pl-md"
size="xs"
v-model="formDialog.data.display_preferences.dashboard_onchain"
val="xs"
@ -174,7 +173,6 @@
></q-checkbox>
<q-checkbox
class="q-pl-md"
size="xs"
v-model="formDialog.data.display_preferences.dashboard_mining"
val="xs"
@ -182,14 +180,12 @@
></q-checkbox>
<q-checkbox
class="q-pl-md"
size="xs"
v-model="formDialog.data.display_preferences.lightning_dashboard"
val="xs"
label="Lightning"
></q-checkbox>
<q-select
v-if="formDialog.data.display_preferences.fun_exchange_market_rate"
filled