Skip to content

Commit 913f8d9

Browse files
committed
Adds all the currencies!
1 parent f5b4f42 commit 913f8d9

3 files changed

Lines changed: 52 additions & 112 deletions

File tree

static/js/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ window.app = Vue.createApp({
7676
data: null
7777
},
7878
options: ['bitcoin', 'confetti', 'rocket', 'face', 'martijn', 'rick'],
79-
currencyOptions: ['None', 'btcusd', 'btceur', 'btcgbp']
79+
// currencyOptions: ['None', 'btcusd', 'btceur', 'btcgbp'],
80+
currencyOptions: ['sat', ...window.currencies]
8081
}
8182
},
8283
methods: {

templates/copilot/compose.html

Lines changed: 48 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,65 @@
11
{% extends "public.html" %} {% block page %}<q-page>
2-
<video
3-
autoplay="true"
4-
id="videoScreen"
5-
style="width: 100%"
6-
class="fixed-bottom-right"
7-
></video>
8-
<video
9-
autoplay="true"
10-
id="videoCamera"
11-
style="width: 100%"
12-
class="fixed-bottom-right"
13-
></video>
2+
<video autoplay="true" id="videoScreen" style="width: 100%" class="fixed-bottom-right"></video>
3+
<video autoplay="true" id="videoCamera" style="width: 100%" class="fixed-bottom-right"></video>
144
<img src="" style="width: 100%" id="animations" class="fixed-bottom-left" />
155

16-
<q-card
17-
id="draggabletroll"
18-
v-show="troll_box"
19-
class="rounded-borders bg-dark"
20-
style="width: 350px; height: 500px; margin-top: 10%; float: right"
21-
>
6+
<q-card id="draggabletroll" v-show="troll_box" class="rounded-borders bg-dark"
7+
style="width: 350px; height: 500px; margin-top: 10%; float: right">
228
<q-card-section>
239
<div class="row">
2410
<div class="col" style="max-width: 100px">
25-
<lnbits-qrcode
26-
:value="chatUrl"
27-
class="rounded-borders"
28-
></lnbits-qrcode>
11+
<lnbits-qrcode :value="chatUrl" class="rounded-borders"></lnbits-qrcode>
2912
</div>
3013
<div class="col">
3114
<div class="text-h6 q-ml-md">Trollbox</div>
32-
<a
33-
:href="chatLink"
34-
class="text-white"
35-
style="color: #43a047"
36-
target="_blank"
37-
><p class="q-ml-md" v-text="chatLink"></p
38-
></a>
15+
<a :href="chatLink" class="text-white" style="color: #43a047" target="_blank">
16+
<p class="q-ml-md" v-text="chatLink"></p>
17+
</a>
3918
</div>
4019
</div>
4120
</q-card-section>
4221

4322
<q-separator dark inset></q-separator>
4423

4524
<q-card-actions>
46-
<div
47-
class="absolute-bottom q-ml-md q-mb-xs"
48-
style="
25+
<div class="absolute-bottom q-ml-md q-mb-xs" style="
4926
max-height: 360px;
5027
overflow: auto;
5128
display: flex;
5229
flex-direction: column-reverse;
53-
"
54-
>
55-
<p
56-
v-for="troll in chatCompute"
57-
style="margin-bottom: 5px; word-wrap: break-word"
58-
v-text="troll"
59-
></p>
30+
">
31+
<p v-for="troll in chatCompute" style="margin-bottom: 5px; word-wrap: break-word" v-text="troll"></p>
6032
</div>
6133
</q-card-actions>
6234
</q-card>
6335

64-
<div
65-
v-if="copilot.lnurl_toggle == 1"
66-
id="draggableqr"
67-
class="rounded-borders"
68-
style="
36+
<div v-if="copilot.lnurl_toggle == 1" id="draggableqr" class="rounded-borders" style="
6937
width: 250px;
7038
background-color: white;
7139
height: 300px;
7240
margin-top: 10%;
73-
"
74-
>
41+
">
7542
<div class="col">
7643
<a class="text-secondary" :href="'lightning:' + copilot.lnurl">
77-
<lnbits-qrcode
78-
:value="'lightning:' + copilot.lnurl"
79-
class="rounded-borders"
80-
></lnbits-qrcode>
81-
<center
82-
class="absolute-bottom"
83-
style="color: black; font-size: 20px"
84-
v-text="copilot.lnurl_title"
85-
></center>
44+
<lnbits-qrcode :value="'lightning:' + copilot.lnurl" class="rounded-borders"></lnbits-qrcode>
45+
<center class="absolute-bottom" style="color: black; font-size: 20px" v-text="copilot.lnurl_title"></center>
8646
</a>
8747
</div>
8848
</div>
8949

90-
<h2
91-
id="draggableprice"
92-
v-if="copilot.show_price != 0"
93-
class="text-bold"
94-
style="
50+
<h2 id="draggableprice" v-if="copilot.show_price != 0" class="text-bold" style="
9551
margin: 60px 60px;
9652
font-size: 110px;
9753
text-shadow: 4px 8px 4px black;
9854
color: white;
99-
"
100-
v-text="price"
101-
></h2>
55+
" v-text="price"></h2>
10256

103-
<p
104-
v-if="copilot.show_ack != 0"
105-
class="fixed-top"
106-
style="
57+
<p v-if="copilot.show_ack != 0" class="fixed-top" style="
10758
font-size: 22px;
10859
text-shadow: 2px 4px 1px black;
10960
color: white;
11061
padding-left: 40%;
111-
"
112-
>
62+
">
11363
Powered by LNbits/StreamerCopilot
11464
</p>
11565
</q-page>
@@ -123,24 +73,29 @@
12373
.q-header {
12474
display: none;
12575
}
76+
12677
.q-page {
12778
padding: 0px;
12879
}
80+
12981
#draggableqr {
13082
width: 250px;
13183
height: 300px;
13284
cursor: grab;
13385
}
86+
13487
#draggableprice {
13588
width: 550px;
13689
height: 60px;
13790
cursor: grab;
13891
}
92+
13993
#draggabletroll {
14094
width: 300px;
14195
height: 300px;
14296
cursor: grab;
14397
}
98+
14499
#videoCamera {
145100
cursor: grab;
146101
}
@@ -193,7 +148,7 @@
193148

194149
if (navigator.mediaDevices.getUserMedia) {
195150
navigator.mediaDevices
196-
.getUserMedia({video: true})
151+
.getUserMedia({ video: true })
197152
.then(stream => {
198153
video.srcObject = stream
199154
})
@@ -203,7 +158,7 @@
203158
initScreenShare() {
204159
const video = document.querySelector('#videoScreen')
205160
navigator.mediaDevices
206-
.getDisplayMedia({video: true})
161+
.getDisplayMedia({ video: true })
207162
.then(stream => {
208163
video.srcObject = stream
209164
})
@@ -252,13 +207,31 @@
252207
document.getElementById('animations').src = ''
253208
}, 5000)
254209
},
210+
getFiat() {
211+
if (this.copilot.show_price) {
212+
LNbits.api
213+
.request('GET', `/api/v1/rate/` + this.copilot.show_price, null)
214+
.then(response => {
215+
this.price = LNbits.utils.formatCurrency(response.data.price.toFixed(2), this.copilot.show_price)
216+
})
217+
.catch(e => console.error(e))
218+
this.fiatInterval = setInterval(() => {
219+
LNbits.api
220+
.request('GET', `/api/v1/rate/` + this.copilot.show_price, null)
221+
.then(response => {
222+
this.price = LNbits.utils.formatCurrency(response.data.price.toFixed(2), this.copilot.show_price)
223+
})
224+
.catch(e => console.error(e))
225+
}, 30000)
226+
}
227+
},
255228
launch() {
256229
LNbits.api
257230
.request(
258231
'GET',
259232
'/copilot/api/v1/copilot/ws/' +
260-
this.copilot.id +
261-
'/launching/rocket'
233+
this.copilot.id +
234+
'/launching/rocket'
262235
)
263236
.then(response1 => {
264237
Quasar.Notify.create({
@@ -292,42 +265,7 @@
292265
.catch(err => {
293266
LNbits.utils.notifyApiError(err)
294267
})
295-
296-
this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net')
297-
298-
const obj = JSON.stringify({
299-
event: 'bts:subscribe',
300-
data: {channel: 'live_trades_' + this.copilot.show_price}
301-
})
302-
303-
this.connectionBitStamp.onmessage = e => {
304-
if (this.copilot.show_price) {
305-
if (this.copilot.show_price == 'btcusd') {
306-
this.price = String(
307-
new Intl.NumberFormat('en-US', {
308-
style: 'currency',
309-
currency: 'USD'
310-
}).format(JSON.parse(e.data).data.price)
311-
)
312-
} else if (this.copilot.show_price == 'btceur') {
313-
this.price = String(
314-
new Intl.NumberFormat('en-US', {
315-
style: 'currency',
316-
currency: 'EUR'
317-
}).format(JSON.parse(e.data).data.price)
318-
)
319-
} else if (this.copilot.show_price == 'btcgbp') {
320-
this.price = String(
321-
new Intl.NumberFormat('en-US', {
322-
style: 'currency',
323-
currency: 'GBP'
324-
}).format(JSON.parse(e.data).data.price)
325-
)
326-
}
327-
}
328-
}
329-
this.connectionBitStamp.onopen = () => this.connectionBitStamp.send(obj)
330-
268+
this.getFiat()
331269
const fetch = data =>
332270
new Promise(resolve => setTimeout(resolve, 5000, this.pushAnim(data)))
333271

@@ -403,4 +341,4 @@
403341
}
404342
})
405343
</script>
406-
{% endblock %}
344+
{% endblock %}

views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
from lnbits.core.models import User
44
from lnbits.decorators import check_user_exists
55
from lnbits.helpers import template_renderer
6+
from ...utils.exchange_rates import allowed_currencies
67

78
copilot_generic_router: APIRouter = APIRouter()
89

@@ -14,7 +15,7 @@ def copilot_renderer():
1415
@copilot_generic_router.get("/", response_class=HTMLResponse)
1516
async def index(request: Request, user: User = Depends(check_user_exists)):
1617
return copilot_renderer().TemplateResponse(
17-
"copilot/index.html", {"request": request, "user": user.json()}
18+
"copilot/index.html", {"request": request, "user": user.json(), "currencies": allowed_currencies()}
1819
)
1920

2021

0 commit comments

Comments
 (0)