This commit is contained in:
2025-04-25 18:37:37 +02:00
commit c043c87029
11 changed files with 789 additions and 0 deletions

150
app/templates/admin.html Normal file
View File

@@ -0,0 +1,150 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Deck Admin</title>
<link href="https://cdn.jsdelivr.net/npm/tailwindcss@4.1.4/dist/tailwind.min.css" rel="stylesheet">
<link href="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.css" rel="stylesheet">
</head>
<body class="bg-gray-100">
<div class="container mx-auto p-6">
<!-- Add New Deck Form -->
<div class="grid grid-cols-1 lg:grid-cols-2 gap-6">
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-xl font-semibold mb-4">Add New Deck</h2>
<form method="POST">
{{ deck_form.hidden_tag() }}
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700">{{ deck_form.name.label }}</label>
{{ deck_form.name(class="form-input mt-1 block w-full") }}
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700">{{ deck_form.deck.label }}</label>
{{ deck_form.deck(multiple=True, class="form-input mt-1 block w-full") }}
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700">{{ deck_form.description.label }}</label>
{{ deck_form.description(class="form-input mt-1 block w-full") }}
</div>
<div class="mb-4">
{{ deck_form.submit_deck(class="bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 w-full") }}
</div>
</form>
<h2 class="text-xl font-semibold mb-4">Existing Decks</h2>
{% if decks %}
<table class="min-w-full table-auto text-left text-gray-700">
<thead>
<tr class="border-b">
<th class="px-4 py-2">Name</th>
<th class="px-4 py-2">Passwords</th>
<th class="px-4 py-2">Action</th>
</tr>
</thead>
<tbody>
{% for deck in decks %}
<tr class="border-b">
<td class="px-4 py-2">{{ deck.name }}</td>
<td class="px-4 py-2">
{% if deck.passwords %}
<ul class="list-disc pl-5">
{% for password in deck.passwords %}
<li>{{ password.value }}</li>
{% endfor %}
</ul>
{% else %}
<em>None</em>
{% endif %}
</td>
<td class="px-4 py-2">
<form method="POST" action="{{ url_for('main.delete_deck', deck_id=deck.id) }}" style="display:inline;">
<button type="submit" class="bg-red-500 text-white py-1 px-4 rounded-md hover:bg-red-600">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-center mt-4 text-gray-500 dark:text-gray-300">No decks available.</p>
{% endif %}
</div>
<!-- Add New Password Form -->
<div class="bg-white p-6 rounded-lg shadow-md">
<h2 class="text-xl font-semibold mb-4">Add New Password</h2>
<form method="POST">
{{ password_form.hidden_tag() }}
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700">{{ password_form.value.label }}</label>
{{ password_form.value(class="form-input mt-1 block w-full") }}
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700">{{ password_form.expires_at.label }}</label>
{{ password_form.expires_at(class="form-input mt-1 block w-full", type="datetime-local") }}
</div>
<div class="mb-4">
<label class="block text-sm font-medium text-gray-700">{{ password_form.decks.label }}</label>
{{ password_form.decks(class="form-input mt-1 block w-full") }}
</div>
<div class="mb-4">
{{ password_form.submit_password(class="bg-blue-500 text-white py-2 px-4 rounded-md hover:bg-blue-600 w-full") }}
</div>
</form>
<!-- Password Cards -->
<h2 class="text-xl font-semibold mb-4">Existing Passwords</h2>
{% if passwords %}
<table class="min-w-full table-auto text-left text-gray-700">
<thead>
<tr class="border-b">
<th class="px-4 py-2">Password</th>
<th class="px-4 py-2">Expired by</th>
<th class="px-4 py-2">Decks</th>
<th class="px-4 py-2">Action</th>
</tr>
</thead>
<tbody>
{% for password in passwords %}
<tr class="border-b">
<td class="px-4 py-2">{{ password.value }}</td>
<td class="px-4 py-2">{{ password.expires_at }}</td>
<td class="px-4 py-2">
{% if password.decks %}
<ul class="list-disc pl-5">
{% for deck in password.decks %}
<li>{{ deck.name }}</li>
{% endfor %}
</ul>
{% else %}
<em>None</em>
{% endif %}
</td>
<td class="px-4 py-2">
<form method="POST" action="{{ url_for('main.delete_password', password_id=password.id) }}" style="display:inline;">
<button type="submit" class="bg-red-500 text-white py-1 px-4 rounded-md hover:bg-red-600">Delete</button>
</form>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% else %}
<p class="text-center mt-4 text-gray-500 dark:text-gray-300">No passwords available.</p>
{% endif %}
</div>
<!-- Flowbite Script -->
<script src="https://cdn.jsdelivr.net/npm/flowbite@3.1.2/dist/flowbite.min.js"></script>
</body>
</html>