Version 1.0
This commit is contained in:
parent
4bebbb27e4
commit
eaa508a8df
33 changed files with 2822 additions and 994 deletions
|
@ -2,9 +2,12 @@
|
|||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<h1>{{ _('My Games') }}</h1>
|
||||
<a href="{{ url_for('add_game') }}" class="btn btn-primary">
|
||||
+ {{ _('Add New Game') }}
|
||||
</a>
|
||||
<div>
|
||||
<a href="{{ url_for('export_games') }}" class="btn btn-outline-secondary">⬇️ {{ _('Export CSV') }}</a>
|
||||
<a href="{{ url_for('export_pdf') }}" class="btn btn-outline-secondary">⬇️ Export PDF (for sharing)</a>
|
||||
<a href="{{ url_for('import_games') }}" class="btn btn-outline-secondary">⬆️ {{ _('Import CSV') }}</a>
|
||||
<a href="{{ url_for('add_game') }}" class="btn btn-primary">+ {{ _('Add New Game') }}</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if games %}
|
||||
|
@ -54,8 +57,16 @@
|
|||
{% endif %}
|
||||
</td>
|
||||
<td class="text-nowrap">
|
||||
{% if game.status == 'verschenkt' %}
|
||||
<button class="btn btn-sm btn-success generate-redeem"
|
||||
data-game-id="{{ game.id }}"
|
||||
title="{{ _('Generate redeem link') }}">
|
||||
🔗
|
||||
</button>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('edit_game', game_id=game.id) }}" class="btn btn-sm btn-warning">✏️</a>
|
||||
<form method="POST" action="{{ url_for('delete_game', game_id=game.id) }}" class="d-inline">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
|
||||
<button type="submit" class="btn btn-sm btn-danger" onclick="return confirm('{{ _('Really delete?') }}')">🗑️</button>
|
||||
</form>
|
||||
</td>
|
||||
|
@ -64,6 +75,33 @@
|
|||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
|
||||
|
||||
document.querySelectorAll('.generate-redeem').forEach(btn => {
|
||||
btn.addEventListener('click', async function() {
|
||||
const gameId = this.dataset.gameId;
|
||||
try {
|
||||
const response = await fetch('/generate_redeem/' + gameId, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRFToken': csrfToken
|
||||
}
|
||||
});
|
||||
if (!response.ok) throw new Error('Network error');
|
||||
const data = await response.json();
|
||||
if(data.url) {
|
||||
await navigator.clipboard.writeText(data.url);
|
||||
alert('{{ _("Redeem link copied to clipboard!") }}');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error:', error);
|
||||
alert('{{ _("Error generating link") }}');
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% else %}
|
||||
<div class="alert alert-info">{{ _('No games yet') }}</div>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue