- {{ copilot.title }}
+
+ {{ copilot.title }}
+
say what
- Open compose window
+ Open compose window
@@ -37,14 +41,16 @@
counter: 1,
newTimeLeft: '',
lnbtc: true,
- onbtc: false,
- charge_time_elapsed: '{{charge.time_elapsed}}',
- charge_amount: '{{charge.amount}}',
- charge_balance: '{{charge.balance}}',
- charge_paid: '{{charge.paid}}'
+ onbtc: false
+ }
+ },
+ methods: {
+ openCompose: function () {
+ let params = `scrollbars=no,resizable=no,status=no,location=no,toolbar=no,menubar=no,width=900,height=500,left=200,top=200`
+
+ open('../copilot/cp/{{ copilot.id }}', 'test', params)
}
},
- methods: {},
created: function () {}
})
diff --git a/lnbits/extensions/copilot/views.py b/lnbits/extensions/copilot/views.py
index 7d6408b0..e1bb4c54 100644
--- a/lnbits/extensions/copilot/views.py
+++ b/lnbits/extensions/copilot/views.py
@@ -14,9 +14,16 @@ async def index():
return await render_template("copilot/index.html", user=g.user)
-@copilot_ext.route("/
")
-async def display(copilot_id):
+@copilot_ext.route("/cp/")
+async def compose(copilot_id):
copilot = await get_copilot(copilot_id) or abort(
- HTTPStatus.NOT_FOUND, "Charge link does not exist."
+ HTTPStatus.NOT_FOUND, "Copilot link does not exist."
)
- return await render_template("copilot/panel.html", copilot=copilot)
+ return await render_template("copilot/compose.html", copilot=copilot)
+
+@copilot_ext.route("/")
+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)
\ No newline at end of file
diff --git a/lnbits/extensions/copilot/views_api.py b/lnbits/extensions/copilot/views_api.py
index 6d595ca2..e345e94f 100644
--- a/lnbits/extensions/copilot/views_api.py
+++ b/lnbits/extensions/copilot/views_api.py
@@ -24,15 +24,15 @@ from .crud import (
@api_validate_post_request(
schema={
"title": {"type": "string", "empty": False, "required": True},
- "animation1": {"type": "string"},
- "animation2": {"type": "string"},
- "animation3": {"type": "string"},
- "animation1threshold": {"type": "integer"},
- "animation2threshold": {"type": "integer"},
- "animation3threshold": {"type": "integer"},
- "animation1webhook": {"type": "string"},
- "animation2webhook": {"type": "string"},
- "animation3webhook": {"type": "string"},
+ "animation1": {"type": "string", "required": False},
+ "animation2": {"type": "string", "required": False},
+ "animation3": {"type": "string", "required": False},
+ "animation1threshold": {"type": "integer", "required": False},
+ "animation2threshold": {"type": "integer", "required": False},
+ "animation3threshold": {"type": "integer", "required": False},
+ "animation1webhook": {"type": "string", "required": False},
+ "animation2webhook": {"type": "string", "required": False},
+ "animation3webhook": {"type": "string", "required": False},
"lnurl_title": {"type": "string", "empty": False, "required": True},
"show_message": {"type": "integer", "empty": False, "required": True},
"show_ack": {"type": "integer", "empty": False, "required": True},
@@ -49,20 +49,21 @@ async def api_copilot_create_or_update(copilot_id=None):
@copilot_ext.route("/api/v1/copilot", methods=["GET"])
@api_check_wallet_key("invoice")
-async def api_copilots_retrieve(copilot_id):
- copilots = await get_copilots(user=g.wallet.user)
-
- if not copilots:
- return jsonify({"message": "copilot does not exist"}), HTTPStatus.NOT_FOUND
-
- return (
- jsonify(
- {
- copilots._asdict()
- }
- ),
- HTTPStatus.OK,
- )
+async def api_copilots_retrieve():
+ try:
+ return (
+ jsonify(
+ [
+ {
+ **copilot._asdict()
+ }
+ for copilot in await get_copilots(g.wallet.user)
+ ]
+ ),
+ HTTPStatus.OK,
+ )
+ except:
+ return ""
@copilot_ext.route("/api/v1/copilot/", methods=["GET"])
@api_check_wallet_key("invoice")