MVP working
This commit is contained in:
parent
ee79bdcfc8
commit
495719c366
3 changed files with 188 additions and 170 deletions
|
|
@ -13,6 +13,7 @@ from ...settings import LNBITS_PATH
|
||||||
from lnbits.utils.exchange_rates import satoshis_amount_as_fiat
|
from lnbits.utils.exchange_rates import satoshis_amount_as_fiat
|
||||||
from lnbits.core.crud import get_user, get_wallet_for_key
|
from lnbits.core.crud import get_user, get_wallet_for_key
|
||||||
|
|
||||||
|
|
||||||
def get_percent_difference(current, previous, precision=3):
|
def get_percent_difference(current, previous, precision=3):
|
||||||
difference = (current - previous) / current * 100
|
difference = (current - previous) / current * 100
|
||||||
return "{0}{1}%".format("+" if difference > 0 else "", round(difference, precision))
|
return "{0}{1}%".format("+" if difference > 0 else "", round(difference, precision))
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,19 @@
|
||||||
{% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{ gertyname }}{% endraw %}{%
|
{% extends "public.html" %} {% block toolbar_title %} Gerty: {% raw %}{{
|
||||||
endblock %}{% block page %} {% 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">
|
<div
|
||||||
|
class="q-pa-md row items-start q-gutter-md"
|
||||||
<q-card v-if="fun_exchange_market_rate" unelevated class="q-pa-sm" style="background: none !important">
|
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">
|
<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-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
|
|
@ -14,29 +22,41 @@ endblock %}{% block page %} {% raw %}
|
||||||
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">
|
<blockquote class="text-right" style="max-width: 900px">
|
||||||
<p>"{{fun_satoshi_quotes["quote"]}}"</p>
|
<p>"{{fun_satoshi_quotes["quote"]}}"</p>
|
||||||
<small>~ Satoshi {{fun_satoshi_quotes["date"]}}</small>
|
<small>~ Satoshi {{fun_satoshi_quotes["date"]}}</small>
|
||||||
</blockquote>
|
</blockquote>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="q-pa-md row items-start q-gutter-md" v-if="lnbits_wallets_balance">
|
<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">
|
<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-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
</div>
|
</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 class="q-pa-sm" v-if="dashboard_onchain" 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>
|
||||||
<q-card-section class="q-pa-none">
|
<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-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
|
|
@ -45,7 +65,9 @@ endblock %}{% block page %} {% raw %}
|
||||||
<div class="text-h6">Mining</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">
|
||||||
<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-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
|
|
@ -54,10 +76,11 @@ endblock %}{% block page %} {% raw %}
|
||||||
<div class="text-h6">Lightning (Last 7 days)</div>
|
<div class="text-h6">Lightning (Last 7 days)</div>
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-section class="q-pa-none">
|
<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-section>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% endraw %} {% endblock %} {% block scripts %}
|
{% endraw %} {% endblock %} {% block scripts %}
|
||||||
|
|
@ -75,85 +98,83 @@ endblock %}{% block page %} {% raw %}
|
||||||
fun_exchange_market_rate: {},
|
fun_exchange_market_rate: {},
|
||||||
gerty: [],
|
gerty: [],
|
||||||
gerty_id: `{{gerty}}`,
|
gerty_id: `{{gerty}}`,
|
||||||
gertyname: "",
|
gertyname: '',
|
||||||
walletColors: [
|
walletColors: [
|
||||||
{first: "#3f51b5",
|
{first: '#3f51b5', second: '#1a237e'},
|
||||||
second: "#1a237e"},
|
{first: '#9c27b0', second: '#4a148c'},
|
||||||
{first: "#9c27b0",
|
{first: '#e91e63', second: '#880e4f'},
|
||||||
second: "#4a148c"},
|
{first: '#009688', second: '#004d40'},
|
||||||
{first: "#e91e63",
|
{first: '#ff9800', second: '#e65100'},
|
||||||
second: "#880e4f"},
|
{first: '#2196f3', second: '#0d47a1'},
|
||||||
{first: "#009688",
|
{first: '#4caf50', second: '#1b5e20'}
|
||||||
second: "#004d40"},
|
|
||||||
{first: "#ff9800",
|
|
||||||
second: "#e65100"},
|
|
||||||
{first: "#2196f3",
|
|
||||||
second: "#0d47a1"},
|
|
||||||
{first: "#4caf50",
|
|
||||||
second: "#1b5e20"}
|
|
||||||
],
|
],
|
||||||
gertywallets: []
|
gertywallets: []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
getGertyInfo: async function () {
|
getGertyInfo: async function () {
|
||||||
for (let i = 0; i < 8; i++){
|
for (let i = 0; i < 8; i++) {
|
||||||
try {
|
try {
|
||||||
const {data} = await LNbits.api.request(
|
const {data} = await LNbits.api.request(
|
||||||
'GET',
|
'GET',
|
||||||
`/gerty/api/v1/gerty/pages/${this.gerty_id}/${i}`
|
`/gerty/api/v1/gerty/pages/${this.gerty_id}/${i}`
|
||||||
)
|
)
|
||||||
this.gerty[i] = data
|
this.gerty[i] = data
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(this.gerty)
|
console.log(this.gerty)
|
||||||
for (let i = 0; i < this.gerty.length; i++) {
|
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++) {
|
for (let q = 0; q < this.gerty[i].screen.areas.length; q++) {
|
||||||
this.lnbits_wallets_balance[q] = {
|
this.lnbits_wallets_balance[q] = {
|
||||||
"name": this.gerty[i].screen.areas[q][0].value,
|
name: this.gerty[i].screen.areas[q][0].value,
|
||||||
"amount": this.gerty[i].screen.areas[q][1].value,
|
amount: this.gerty[i].screen.areas[q][1].value,
|
||||||
"color1": this.walletColors[q].first,
|
color1: this.walletColors[q].first,
|
||||||
"color2": this.walletColors[q].second,
|
color2: this.walletColors[q].second
|
||||||
}
|
}
|
||||||
this.gertyname = this.gerty[i].settings.name
|
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
|
||||||
}
|
}
|
||||||
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.dashboard_mining = this.gerty[i].screen.areas
|
||||||
this.gertyname = this.gerty[i].settings.name
|
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.lightning_dashboard = this.gerty[i].screen.areas
|
||||||
this.gertyname = this.gerty[i].settings.name
|
this.gertyname = this.gerty[i].settings.name
|
||||||
}
|
}
|
||||||
if(this.gerty[i].screen.group == "fun_satoshi_quotes"){
|
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['quote'] = this.gerty[
|
||||||
this.fun_satoshi_quotes["date"] = this.gerty[i].screen.areas[0][1].value
|
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
|
this.gertyname = this.gerty[i].settings.name
|
||||||
}
|
}
|
||||||
if(this.gerty[i].screen.group == "fun_exchange_market_rate"){
|
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['unit'] = this.gerty[
|
||||||
this.fun_exchange_market_rate["amount"] = this.gerty[i].screen.areas[0][1].value
|
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
|
this.gertyname = this.gerty[i].settings.name
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setTimeout(this.getGertyInfo, 20000);
|
setTimeout(this.getGertyInfo, 20000)
|
||||||
this.$forceUpdate();
|
this.$forceUpdate()
|
||||||
return this.gerty
|
return this.gerty
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
created: async function () {
|
created: async function () {
|
||||||
|
|
||||||
await this.getGertyInfo()
|
await this.getGertyInfo()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -142,15 +142,16 @@
|
||||||
></q-input>
|
></q-input>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
class="q-pl-md"
|
class="q-pl-md"
|
||||||
|
|
||||||
size="xs"
|
size="xs"
|
||||||
v-model="formDialog.data.display_preferences.fun_satoshi_quotes"
|
v-model="formDialog.data.display_preferences.fun_satoshi_quotes"
|
||||||
val="xs"
|
val="xs"
|
||||||
label="Satoshi Quotes"
|
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
|
<q-checkbox
|
||||||
class="q-pl-md"
|
class="q-pl-md"
|
||||||
|
|
||||||
size="xs"
|
size="xs"
|
||||||
v-model="formDialog.data.display_preferences.fun_exchange_market_rate"
|
v-model="formDialog.data.display_preferences.fun_exchange_market_rate"
|
||||||
val="xs"
|
val="xs"
|
||||||
|
|
@ -158,7 +159,6 @@
|
||||||
></q-checkbox>
|
></q-checkbox>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
class="q-pl-md"
|
class="q-pl-md"
|
||||||
|
|
||||||
size="xs"
|
size="xs"
|
||||||
v-model="formDialog.data.display_preferences.lnbits_wallets_balance"
|
v-model="formDialog.data.display_preferences.lnbits_wallets_balance"
|
||||||
val="xs"
|
val="xs"
|
||||||
|
|
@ -166,7 +166,6 @@
|
||||||
></q-checkbox>
|
></q-checkbox>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
class="q-pl-md"
|
class="q-pl-md"
|
||||||
|
|
||||||
size="xs"
|
size="xs"
|
||||||
v-model="formDialog.data.display_preferences.dashboard_onchain"
|
v-model="formDialog.data.display_preferences.dashboard_onchain"
|
||||||
val="xs"
|
val="xs"
|
||||||
|
|
@ -174,7 +173,6 @@
|
||||||
></q-checkbox>
|
></q-checkbox>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
class="q-pl-md"
|
class="q-pl-md"
|
||||||
|
|
||||||
size="xs"
|
size="xs"
|
||||||
v-model="formDialog.data.display_preferences.dashboard_mining"
|
v-model="formDialog.data.display_preferences.dashboard_mining"
|
||||||
val="xs"
|
val="xs"
|
||||||
|
|
@ -182,14 +180,12 @@
|
||||||
></q-checkbox>
|
></q-checkbox>
|
||||||
<q-checkbox
|
<q-checkbox
|
||||||
class="q-pl-md"
|
class="q-pl-md"
|
||||||
|
|
||||||
size="xs"
|
size="xs"
|
||||||
v-model="formDialog.data.display_preferences.lightning_dashboard"
|
v-model="formDialog.data.display_preferences.lightning_dashboard"
|
||||||
val="xs"
|
val="xs"
|
||||||
label="Lightning"
|
label="Lightning"
|
||||||
></q-checkbox>
|
></q-checkbox>
|
||||||
|
|
||||||
|
|
||||||
<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
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue