localstorage paneltest

This commit is contained in:
Ben Arc
2021-04-20 14:33:41 +01:00
parent 8f3a8e4880
commit 1736198a7d
4 changed files with 34 additions and 30 deletions

View File

@@ -497,10 +497,29 @@
LNbits.utils.notifyApiError(error)
})
},
getCopilot: function (copilot_id) {
var self = this
LNbits.api
.request(
'GET',
'/copilot/api/v1/copilot/' + copilot_id,
this.g.user.wallets[0].inkey
)
.then(function (response) {
return response.data
})
.catch(function (error) {
LNbits.utils.notifyApiError(error)
})
},
opencopilotCompose: function (copilot_id) {
localStorage.setItem(
'copilot',
JSON.stringify(this.getCopilot(copilot_id))
)
let params =
'scrollbars=no, resizable=no,status=no,location=no,toolbar=no,menubar=no,width=1722,height=972,left=200,top=200'
open('../copilot/cp/' + copilot_id, 'test', params)
open('../copilot/cp/', 'test', params)
},
deleteCopilotLink: function (chargeId) {

View File

@@ -15,9 +15,7 @@
</center>
</div>
<center>
<div class="col" style="margin: 15px; font-size: 25px">
Title: {{ copilot.title }}
</div>
<div class="col" style="margin: 15px; font-size: 25px">Title:</div>
</center>
<q-separator></q-separator>
<div class="col">
@@ -120,7 +118,7 @@
openCompose: function () {
let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=1722,height=972,left=200,top=200`
open('../copilot/cp/{{ copilot.id }}', 'test', params)
open('../copilot/cp/', 'test', params)
},
animationBTN: function (name) {
this.connection.send(name)
@@ -130,7 +128,8 @@
}
},
created: function () {
console.log('{{ copilot.id }}')
var copilot = JSON.parse(localStorage.getItem('copilot'))
console.log(copilot.id)
if (location.protocol == 'https:') {
console.log(location.protocol)
@@ -139,7 +138,8 @@
document.domain +
':' +
location.port +
'/copilot/ws/panel/{{ copilot.id }}'
'/copilot/ws/panel/' +
copilot.id
)
} else {
this.connection = new WebSocket(
@@ -147,7 +147,8 @@
document.domain +
':' +
location.port +
'/copilot/ws/panel/{{ copilot.id }}'
'/copilot/ws/panel/' +
copilot.id
)
}
this.connection.addEventListener('open', function (event) {})

View File

@@ -21,29 +21,14 @@ async def index():
return await render_template("copilot/index.html", user=g.user)
@copilot_ext.route("/cp/<copilot_id>")
async def compose(copilot_id):
copilot = await get_copilot(copilot_id) or abort(
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
)
if copilot.lnurl_toggle:
return await render_template(
"copilot/compose.html",
copilot=copilot,
lnurl=copilot.lnurl,
lnurl_toggle=copilot.lnurl_toggle,
)
return await render_template(
"copilot/compose.html", copilot=copilot, lnurl_toggle=copilot.lnurl_toggle
)
@copilot_ext.route("/cp/")
async def compose():
return await render_template("copilot/compose.html")
@copilot_ext.route("/<copilot_id>")
async def panel(copilot_id):
copilot = await get_copilot(copilot_id) or abort(
HTTPStatus.NOT_FOUND, "Copilot link does not exist."
)
return await render_template("copilot/panel.html", copilot=copilot)
@copilot_ext.route("/pn/")
async def panel():
return await render_template("copilot/panel.html")
##################WEBSOCKET ROUTES########################

View File

@@ -103,4 +103,3 @@ async def api_copilot_ws_relay(copilot_id, comment, data):
await updater(data, comment, copilot_id)
print(comment)
return "", HTTPStatus.OK