zmiany ux i w panelu

This commit is contained in:
Mateusz Gruszczyński
2025-07-03 12:50:09 +02:00
parent 79301398dd
commit 5d5779c09e
9 changed files with 302 additions and 66 deletions

View File

@ -7,53 +7,93 @@
<a href="/" class="btn btn-outline-secondary">← Powrót do strony głównej</a>
</div>
<div class="d-flex flex-wrap gap-2 mb-4">
<a href="/admin/add_user" class="btn btn-success"> Dodaj użytkownika</a>
<a href="/admin/users" class="btn btn-outline-light">👥 Lista użytkowników</a>
<a href="/admin/receipts" class="btn btn-outline-light">📸 Wszystkie paragony</a>
<a href="/admin/delete_all_lists" class="btn btn-danger">🗑️ Usuń wszystkie listy</a>
<a href="/admin/delete_all_items" class="btn btn-danger">❌ Usuń wszystkie produkty</a>
</div>
<div class="card bg-dark text-white mb-4">
<div class="card-body">
<p><strong>👤 Liczba użytkowników:</strong> {{ user_count }}</p>
<p><strong>📝 Liczba list:</strong> {{ list_count }}</p>
<p><strong>📝 Liczba list zakupowych:</strong> {{ list_count }}</p>
<p><strong>🛒 Liczba produktów:</strong> {{ item_count }}</p>
<p><strong>✅ Zakupionych produktów:</strong> {{ purchased_items_count }}</p>
</div>
</div>
<div class="d-flex flex-wrap gap-2 mb-4">
<a href="/admin/users" class="btn btn-outline-light">👥 Lista użytkowników</a>
<a href="/admin/add_user" class="btn btn-success"> Dodaj użytkownika</a>
<a href="/admin/receipts" class="btn btn-outline-light">📸 Wszystkie paragony</a>
<a href="/admin/delete_all_lists" class="btn btn-danger">🗑️ Usuń wszystkie listy</a>
{% if top_products %}
<div class="card bg-dark text-white mb-4">
<div class="card-body">
<h5>🔥 Najczęściej kupowane produkty:</h5>
<ul class="mb-0">
{% for name, count in top_products %}
<li>{{ name }} — {{ count }}×</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<h3 class="mt-4">📄 Wszystkie listy zakupowe</h3>
<div class="table-responsive">
<table class="table table-dark table-striped align-middle">
<thead>
<tr>
<th>ID</th>
<th>Tytuł</th>
<th>Utworzono</th>
<th>Właściciel (ID / nazwa)</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
{% for l in all_lists %}
<tr>
<td>{{ l.id }}</td>
<td class="fw-bold">{{ l.title }}</td>
<td>{{ l.created_at.strftime('%Y-%m-%d %H:%M') if l.created_at else '-' }}</td>
<td>
{% if l.owner_id %}
{{ l.owner_id }} / {{ l.owner.username if l.owner else 'Brak użytkownika' }}
{% else %}
-
{% endif %}
</td>
<td>
<a href="{{ url_for('delete_list', list_id=l.id) }}" class="btn btn-sm btn-outline-danger">🗑️ Usuń</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<form method="post" action="{{ url_for('delete_selected_lists') }}">
<div class="table-responsive">
<table class="table table-dark table-striped align-middle">
<thead>
<tr>
<th><input type="checkbox" id="select-all"></th>
<th>ID</th>
<th>Tytuł</th>
<th>Utworzono</th>
<th>Właściciel</th>
<th>Produkty</th>
<th>Wypełnienie</th>
<th>Komentarze</th>
<th>Paragony</th>
<th>Akcje</th>
</tr>
</thead>
<tbody>
{% for e in enriched_lists %}
{% set l = e.list %}
<tr>
<td><input type="checkbox" name="list_ids" value="{{ l.id }}"></td>
<td>{{ l.id }}</td>
<td class="fw-bold">
<a href="{{ url_for('view_list', list_id=l.id) }}" class="text-white">{{ l.title }}</a>
</td>
<td>{{ l.created_at.strftime('%Y-%m-%d %H:%M') if l.created_at else '-' }}</td>
<td>
{% if l.owner_id %}
{{ l.owner_id }} / {{ l.owner.username if l.owner else 'Brak użytkownika' }}
{% else %}
-
{% endif %}
</td>
<td>{{ e.total_count }}</td>
<td>{{ e.purchased_count }}/{{ e.total_count }} ({{ e.percent }}%)</td>
<td>{{ e.comments_count }}</td>
<td>{{ e.receipts_count }}</td>
<td class="d-flex flex-wrap gap-1">
<a href="{{ url_for('edit_list', list_id=l.id) }}" class="btn btn-sm btn-outline-primary">✏️ Edytuj</a>
<a href="{{ url_for('archive_list', list_id=l.id) }}" class="btn btn-sm btn-outline-secondary">📥 Archiwizuj</a>
<a href="{{ url_for('delete_list', list_id=l.id) }}" class="btn btn-sm btn-outline-danger">🗑️ Usuń</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
<button type="submit" class="btn btn-danger mt-2">🗑️ Usuń zaznaczone listy</button>
</form>
<script>
document.getElementById('select-all').addEventListener('click', function(){
const checkboxes = document.querySelectorAll('input[name="list_ids"]');
checkboxes.forEach(cb => cb.checked = this.checked);
});
</script>
{% endblock %}

View File

@ -0,0 +1,18 @@
{% extends 'base.html' %}
{% block title %}Edytuj listę{% endblock %}
{% block content %}
<div class="d-flex justify-content-between align-items-center flex-wrap mb-4">
<h2 class="mb-2">✏️ Edytuj tytuł listy</h2>
<a href="{{ url_for('admin_panel') }}" class="btn btn-outline-secondary">← Powrót</a>
</div>
<form method="post">
<div class="mb-3">
<label for="title" class="form-label">Nowy tytuł</label>
<input type="text" class="form-control" id="title" name="title" value="{{ list.title }}" required>
</div>
<button type="submit" class="btn btn-success">💾 Zapisz</button>
</form>
{% endblock %}

View File

@ -14,8 +14,18 @@
<body class="bg-dark text-white">
<nav class="navbar navbar-dark bg-dark mb-3">
<div class="container-fluid d-flex justify-content-between">
<a class="navbar-brand" href="/">Live Lista Zakupów</a>
<div class="container-fluid">
<a class="navbar-brand fw-bold fs-4 text-success" href="/">
🛒 Live <span class="text-warning">Lista</span> Zakupów
</a>
{% if current_user.is_authenticated %}
<span class="mx-auto text-white">Zalogowany jako: <strong>{{ current_user.username }}</strong></span>
{% else %}
<span class="mx-auto text-white">Przeglądasz jako <strong>gość</strong></span>
{% endif %}
<div class="d-flex align-items-center gap-2">
{% if current_user.is_authenticated and current_user.is_admin %}
<a href="{{ url_for('admin_panel') }}" class="btn btn-outline-warning btn-sm">⚙️ Panel admina</a>
@ -28,6 +38,8 @@
</div>
</div>
</nav>
<div id="toast-container" class="toast-container position-fixed bottom-0 end-0 p-3"></div>
<div class="container px-2">

View File

@ -3,26 +3,28 @@
{% block content %}
<div class="d-flex justify-content-between align-items-center flex-wrap mb-4">
<h2 class="mb-2">Twoje listy zakupów</h2>
<a href="{{ url_for('index_guest') }}" class="btn btn-outline-secondary">← Powrót do panelu</a>
<h2 class="mb-2">Stwórz nową listę</h2>
</div>
<div class="card bg-dark text-white mb-4">
<div class="card-body">
<form action="/create" method="post">
<div class="mb-3">
<label for="title" class="form-label">Nazwa listy</label>
<input type="text" name="title" id="title" placeholder="Wprowadź nazwę listy" required class="form-control">
</div>
<div class="form-check mb-3">
<input type="checkbox" name="temporary" class="form-check-input" id="tempCheck">
<label for="tempCheck" class="form-check-label">Tymczasowa (7 dni)</label>
<div class="input-group mb-3">
<input type="text" name="title" id="title" placeholder="Wprowadź nazwę nowej listy" required class="form-control">
<div class="input-group-text">
<input type="checkbox" name="temporary" class="form-check-input m-0" id="tempCheck">
<label for="tempCheck" class="ms-2 mb-0">Tymczasowa (7 dni)</label>
</div>
</div>
<button type="submit" class="btn btn-success w-100"> Utwórz nową listę</button>
</form>
</div>
</div>
<div class="d-flex justify-content-between align-items-center flex-wrap mb-4">
<h2 class="mb-2">Listy zakupów</h2>
</div>
{% if lists %}
<ul class="list-group">
{% for l in lists %}
@ -31,7 +33,7 @@
{% set percent = (purchased_count / total_count * 100) if total_count > 0 else 0 %}
<li class="list-group-item bg-dark text-white">
<div class="d-flex justify-content-between align-items-center flex-wrap w-100">
<span class="fw-bold">{{ l.title }}</span>
<span class="fw-bold">{{ l.title }} (Autor: {{ l.owner.username }})</span>
<div class="mt-2 mt-md-0">
{% if current_user.is_authenticated %}
<a href="/list/{{ l.id }}" class="btn btn-sm btn-outline-light me-1">📄 Otwórz</a>
@ -42,7 +44,7 @@
</div>
</div>
<div class="progress mt-2" style="height: 20px;">
<div class="progress-bar bg-success" role="progressbar" style="width: {{ percent }}%" aria-valuenow="{{ percent }}" aria-valuemin="0" aria-valuemax="100">{{ purchased_count }}/{{ total_count }} ({{ percent|round(0) }}%)</div>
<div class="progress-bar bg-warning" role="progressbar" style="width: {{ percent }}%" aria-valuenow="{{ percent }}" aria-valuemin="0" aria-valuemax="100">Produkty: {{ purchased_count }}/{{ total_count }} ({{ percent|round(0) }}%)</div>
</div>
</li>
{% endfor %}

View File

@ -3,27 +3,37 @@
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-3 flex-wrap">
<h2 class="mb-2">{{ list.title }}</h2>
<h2 class="mb-2">Lista: <strong>{{ list.title }}</strong></h2>
<a href="/" class="btn btn-outline-secondary">← Powrót do list</a>
</div>
<div class="card bg-dark text-white mb-4">
<div class="card-body d-flex flex-wrap justify-content-between align-items-center">
<div class="mb-2 mb-md-0">
<strong>Udostępnij link:</strong>
<span class="badge bg-secondary">{{ request.url_root }}share/{{ list.share_token }}</span>
<div class="card-body d-flex flex-column flex-md-row justify-content-between align-items-start align-items-md-center gap-2">
<div>
<strong>🔗 Udostępnij link:</strong><br>
<span class="badge bg-secondary text-wrap" style="font-size: 0.9rem;">
{{ request.url_root }}share/{{ list.share_token }}
</span>
</div>
<button class="btn btn-outline-light btn-sm" onclick="copyLink('{{ request.url_root }}share/{{ list.share_token }}')">
📋 Skopiuj lub udostępnij
<button class="btn btn-success btn-sm mt-2 mt-md-0" onclick="copyLink('{{ request.url_root }}share/{{ list.share_token }}')">
📋 udostępnij link
</button>
</div>
</div>
<!-- Progress bar (dynamic) -->
<div class="progress mb-3">
<div id="progress-bar" class="progress-bar bg-success" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">0%</div>
<h5 id="progress-title" class="mb-2">
📊 Postęp listy — {{ purchased_count }}/{{ total_count }} kupionych ({{ percent|round(0) }}%)
</h5>
<div class="progress mb-3" style="height: 25px;">
<div id="progress-bar" class="progress-bar bg-warning" role="progressbar"
style="width: {{ percent }}%;" aria-valuenow="{{ percent }}"
aria-valuemin="0" aria-valuemax="100">
{{ percent|round(0) }}%
</div>
</div>
<ul id="items" class="list-group mb-3">
{% for item in items %}
<li class="list-group-item d-flex justify-content-between align-items-center flex-wrap {% if item.purchased %}bg-success text-white{% else %}bg-light text-white{% endif %}" id="item-{{ item.id }}">

View File

@ -4,7 +4,6 @@
<div class="d-flex justify-content-between align-items-center flex-wrap mb-3">
<h2 class="mb-2">🛍️ {{ list.title }} <small class="text-muted">(Gość)</small></h2>
<a href="/" class="btn btn-outline-secondary btn-sm">← Powrót</a>
</div>
<ul id="items" class="list-group mb-3">