diff --git a/templates/boltcards/display.html b/templates/boltcards/display.html
new file mode 100644
index 0000000..96b42f5
--- /dev/null
+++ b/templates/boltcards/display.html
@@ -0,0 +1,146 @@
+{% extends "public.html" %} {% block toolbar_title %} Boltcard: ${
+card.card_name }{% endblock %} {% block page %}
+
+
+
+
+ Card Info
+ This card is ${enabled}
+
+
+
+
+
+
+
+
+ ${item.label}
+ ${card[item.value]}
+
+
+ Click to copy
+
+
+
+
+
+
+
+
+
+
+ Transactions
+ Latest transactions
+
+
+
+
+
+
+
+
+
+
+
+ ID: ${hit.id} ${refunds.some(r => r.hit_id == hit.id) ?
+ '(Refunded)' : null}
+ IP: ${hit.ip}
+
+
+
+ ${hit.date}
+ ${hit.amount} sats
+
+
+
+
+
+
+
+
+{% endblock %}{% block scripts %}
+
+{% endblock %}
diff --git a/templates/boltcards/index.html b/templates/boltcards/index.html
index 2091718..136b8fd 100644
--- a/templates/boltcards/index.html
+++ b/templates/boltcards/index.html
@@ -42,6 +42,7 @@
{% raw %}
+
{{ col.label }}
@@ -64,6 +65,19 @@
Card key credentials
+
+
+ Card Stats
+
+
{{ col.value }}
diff --git a/views.py b/views.py
index 273cfcb..d328bef 100644
--- a/views.py
+++ b/views.py
@@ -1,11 +1,15 @@
+from http import HTTPStatus
+
from fastapi import Depends, Request
from fastapi.templating import Jinja2Templates
+from starlette.exceptions import HTTPException
from starlette.responses import HTMLResponse
from lnbits.core.models import User
from lnbits.decorators import check_user_exists
from . import boltcards_ext, boltcards_renderer
+from .crud import get_card_by_external_id, get_hits, get_refunds
templates = Jinja2Templates(directory="templates")
@@ -15,3 +19,24 @@ async def index(request: Request, user: User = Depends(check_user_exists)):
return boltcards_renderer().TemplateResponse(
"boltcards/index.html", {"request": request, "user": user.dict()}
)
+
+
+@boltcards_ext.get("/{card_id}", response_class=HTMLResponse)
+async def display(request: Request, card_id: str):
+ card = await get_card_by_external_id(card_id)
+ if not card:
+ raise HTTPException(
+ status_code=HTTPStatus.NOT_FOUND, detail="Card does not exist."
+ )
+ hits = [hit.dict() for hit in await get_hits([card.id])]
+ refunds = [
+ refund.hit_id for refund in await get_refunds([hit["id"] for hit in hits])
+ ]
+ card = card.dict()
+ # Remove wallet id from card dict
+ del card["wallet"]
+
+ return boltcards_renderer().TemplateResponse(
+ "boltcards/display.html",
+ {"request": request, "card": card, "hits": hits, "refunds": refunds},
+ )
diff --git a/views_api.py b/views_api.py
index 1f77e78..9861931 100644
--- a/views_api.py
+++ b/views_api.py
@@ -23,7 +23,7 @@ from .models import Card, CreateCardData
@boltcards_ext.get("/api/v1/cards")
async def api_cards(
- g: WalletTypeInfo = Depends(get_key_type), all_wallets: bool = Query(False)
+ g: WalletTypeInfo = Depends(get_key_type), all_wallets: bool = False
):
wallet_ids = [g.wallet.id]