Improve landing page.
It's possible to select which transactions to show
This commit is contained in:
@@ -9,12 +9,25 @@ templates = get_jinja_renderer()
|
||||
|
||||
|
||||
@root_router.get("/")
|
||||
async def landing_page(request: Request, user: UserDep, session: SessionDep):
|
||||
async def landing_page(
|
||||
request: Request, user: UserDep, session: SessionDep, account_id: int | None = None
|
||||
):
|
||||
focused_account = None
|
||||
transactions = []
|
||||
for account in user.accounts:
|
||||
if account_id is not None and account.id != account_id:
|
||||
continue
|
||||
if account_id is not None and account.id == account_id:
|
||||
focused_account = account
|
||||
transactions += account.transactions
|
||||
|
||||
transactions = sorted(transactions, key=lambda t: t.timestamp)
|
||||
return templates.TemplateResponse(
|
||||
"index.html.jinja",
|
||||
context={"request": request, "user": user, "transactions": transactions},
|
||||
context={
|
||||
"request": request,
|
||||
"user": user,
|
||||
"transactions": transactions,
|
||||
"focused_account": focused_account,
|
||||
},
|
||||
)
|
||||
|
||||
@@ -8,16 +8,17 @@
|
||||
{% if user.accounts|length > 0 %}
|
||||
{% for account in user.accounts %}
|
||||
<div class="col-md-6 col-lg-4">
|
||||
<div class="card">
|
||||
<div class="card{% if focused_account and focused_account.id == account.id %} border-primary border-3 shadow-lg{% endif %}">
|
||||
<div class="card-body">
|
||||
<h5 class="card-title">{{ account.name }}</h5>
|
||||
<p class="h3 mb-2 {% if account.balance < 0 %}text-danger{% else %}text-success{% endif %}">
|
||||
{{ '%.2f' | format(account.balance) }} €
|
||||
{{ account.balance | format_number }} €
|
||||
</p>
|
||||
{% if not focused_account or (focused_account.id != account.id) %}
|
||||
<div class="d-flex gap-2 mt-3">
|
||||
<a href="#" class="btn btn-sm btn-outline-primary">Transaktionen</a>
|
||||
<a href="#" class="btn btn-sm btn-success">Aufladen</a>
|
||||
<a href="/?account_id={{ account.id }}" class="btn btn-sm btn-outline-primary">Transaktionen ansehen</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,8 +36,8 @@
|
||||
<!-- Latest Transactions Section -->
|
||||
<div class="transactions-section">
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<h2 class="h3 mb-0">Letzte Buchungen</h2>
|
||||
<a href="#" class="btn btn-outline-primary btn-sm">Alle ansehen</a>
|
||||
<h2 class="h3 mb-0">Letzte Buchungen{% if focused_account %} auf Konto "{{ focused_account.name }}"{% endif %}</h2>
|
||||
{% if focused_account %}<a href="/" class="btn btn-primary btn-sm">Alle Konten ansehen</a>{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
@@ -57,7 +58,7 @@
|
||||
</div>
|
||||
<div class="text-end ms-3">
|
||||
<span class="fs-5 fw-bold {% if transaction.total_amount < 0 %}text-danger{% else %}text-success{% endif %}">
|
||||
{{ '%+.2f' | format(transaction.total_amount | default(0)) }} €
|
||||
{{ transaction.total_amount | format_number }} €
|
||||
</span>
|
||||
{% if transaction.quantity %}
|
||||
<div class="small text-muted">{{ transaction.quantity }} €</div>
|
||||
|
||||
Reference in New Issue
Block a user