Added ack and price

This commit is contained in:
Ben Arc
2021-04-16 11:07:14 +01:00
parent feefc465e8
commit 1c81f3b2a5
6 changed files with 88 additions and 15 deletions

View File

@@ -29,6 +29,7 @@ async def create_copilot(
lnurl_title: Optional[str] = None, lnurl_title: Optional[str] = None,
show_message: Optional[int] = None, show_message: Optional[int] = None,
show_ack: Optional[int] = None, show_ack: Optional[int] = None,
show_price: Optional[int] = None,
amount_made: Optional[int] = None, amount_made: Optional[int] = None,
) -> Copilots: ) -> Copilots:
copilot_id = urlsafe_short_hash() copilot_id = urlsafe_short_hash()
@@ -53,10 +54,11 @@ async def create_copilot(
lnurl_title, lnurl_title,
show_message, show_message,
show_ack, show_ack,
show_price,
lnurl_title, lnurl_title,
amount_made amount_made
) )
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
""", """,
( (
copilot_id, copilot_id,
@@ -76,6 +78,7 @@ async def create_copilot(
lnurl_title, lnurl_title,
show_message, show_message,
show_ack, show_ack,
show_price,
lnurl_title, lnurl_title,
0 0
), ),

View File

@@ -23,6 +23,7 @@ async def m001_initial(db):
lnurl_title TEXT, lnurl_title TEXT,
show_message INTEGER, show_message INTEGER,
show_ack INTEGER, show_ack INTEGER,
show_price INTEGER,
amount_made INTEGER, amount_made INTEGER,
fullscreen_cam INTEGER, fullscreen_cam INTEGER,
iframe_url TEXT, iframe_url TEXT,

View File

@@ -24,6 +24,7 @@ class Copilots(NamedTuple):
lnurl_title: str lnurl_title: str
show_message: int show_message: int
show_ack: int show_ack: int
show_price: int
amount_made: int amount_made: int
timestamp: int timestamp: int
fullscreen_cam: int fullscreen_cam: int

View File

@@ -15,20 +15,56 @@
></video> ></video>
<img src="" style="width: 100%" id="animations" class="fixed-bottom-left" /> <img src="" style="width: 100%" id="animations" class="fixed-bottom-left" />
<qrcode <div
v-if="'{{ lnurl_toggle }}' == 1" v-if="'{{ lnurl_toggle }}' == 1"
class="rounded-borders fixed-top-right column"
style="width: 20%; z-index: 9999" style="width: 20%; z-index: 9999"
>
<div class="col">
<qrcode
style="width: 100%"
:value="'{{ lnurl }}'" :value="'{{ lnurl }}'"
:options="{width:222}" :options="{width:222}"
class="rounded-borders fixed-top-right" class="rounded-borders"
></qrcode> ></qrcode>
</div>
<div
class="col"
style="
font-size: 25px;
background-color: white;
color: black;
width: 100%;
"
>
<center>{{ copilot.title }}</center>
</div>
</div>
<q-btn <h2
color="primary" v-if="'{{ copilot.show_price }}' != 'None'"
@click="reconnect" class="text-bold fixed-bottom-left"
label="Reconnect" style="
class="fixed-bottom-left" margin: 60px 60px;
/> font-size: 150px;
text-shadow: 4px 8px 4px black;
color: white;
"
>
{% raw %}{{ price }}{% endraw %}
</h2>
<p
v-if="'{{ copilot.show_ack }}' != 'None'"
class="fixed-top"
style="
font-size: 22px;
text-shadow: 2px 4px 1px black;
color: white;
padding-left: 40%;
"
>
Powered by LNbits/StreamerCopilot
</p>
</q-page> </q-page>
{% endblock %} {% block scripts %} {% endblock %} {% block scripts %}
<script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script> <script src="{{ url_for('static', filename='vendor/vue-qrcode@1.0.2/vue-qrcode.min.js') }}"></script>
@@ -52,7 +88,10 @@
el: '#vue', el: '#vue',
mixins: [windowMixin], mixins: [windowMixin],
data() { data() {
return {} return {
price: '',
counter: 1
}
}, },
methods: { methods: {
openURL: function (url) { openURL: function (url) {
@@ -78,6 +117,25 @@
setTimeout(function () { setTimeout(function () {
setInterval(function () { setInterval(function () {
self.connection.send('') self.connection.send('')
self.counter++
if (self.counter % 20 === 0) {
if ('{{ copilot.show_price }}' != 'None') {
LNbits.api
.request('GET', 'https://api.opennode.com/v1/rates', 'filla')
.then(function (response) {
self.price = String(
new Intl.NumberFormat('en-US', {
style: 'currency',
currency: 'USD'
}).format(response.data.data.BTCUSD.USD)
)
console.log(self.price)
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
}
}
}, 1000) }, 1000)
}, 2000) }, 2000)
} }

View File

@@ -318,6 +318,15 @@
</div> </div>
</div> </div>
<div class="q-gutter-sm">
<div class="row">
<q-checkbox
v-model="formDialogCopilot.data.show_price"
left-label
label="Show bitcoin price"
></q-checkbox>
</div>
</div>
<div class="q-gutter-sm"> <div class="q-gutter-sm">
<div class="row"> <div class="row">
<q-checkbox <q-checkbox
@@ -327,7 +336,6 @@
></q-checkbox> ></q-checkbox>
</div> </div>
</div> </div>
<div class="row q-mt-lg"> <div class="row q-mt-lg">
<q-btn <q-btn
unelevated unelevated
@@ -431,7 +439,8 @@
data: { data: {
lnurl_toggle: false, lnurl_toggle: false,
show_message: false, show_message: false,
show_ack: true, show_ack: false,
show_price: false,
title: '' title: ''
} }
}, },

View File

@@ -40,6 +40,7 @@ from .crud import (
"lnurl_title": {"type": "string", "empty": False, "required": False}, "lnurl_title": {"type": "string", "empty": False, "required": False},
"show_message": {"type": "integer", "empty": False, "required": False}, "show_message": {"type": "integer", "empty": False, "required": False},
"show_ack": {"type": "integer", "empty": False, "required": True}, "show_ack": {"type": "integer", "empty": False, "required": True},
"show_price": {"type": "integer", "empty": False, "required": True},
} }
) )
async def api_copilot_create_or_update(copilot_id=None): async def api_copilot_create_or_update(copilot_id=None):