Ready For 1.1

This commit is contained in:
nocci 2025-05-10 16:14:22 +02:00
parent c23f2f88e8
commit 7a221acb8e
11 changed files with 297 additions and 146 deletions

BIN
GameManager1_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 KiB

View File

@ -7,7 +7,7 @@ No more confusion about whether a key is redeemed, gifted, or still unused n
You can even gift your keys via a unique 24-hour website link just mark a game as "Gifted" and copy the link from your overview. (HTTPS recommended)
![Screenshot](GameManager.png)
![Screenshot](GameManager1_1.png)
---

171
setup.sh
View File

@ -144,18 +144,18 @@ DEFAULT_LANGUAGE="en"
SUPPORTED_LANGUAGES="de,en"
# Timezone
TZ=Europe/Berlin
TZ="Europe/Berlin"
# Security
FORCE_HTTPS=False
SESSION_COOKIE_SECURE=auto
FORCE_HTTPS="False"
SESSION_COOKIE_SECURE="auto"
CSRF_ENABLED="True"
# Account registration
REGISTRATION_ENABLED="True"
# checking interval if keys have to be redeemed before a specific date
CHECK_EXPIRING_KEYS_INTERVAL_HOURS=6
CHECK_EXPIRING_KEYS_INTERVAL_HOURS="6"
# Want to check prices? Here you are!
ITAD_API_KEY="your-secret-key-here"
@ -170,7 +170,7 @@ APPRISE_URLS=""
#matrixs://TOKEN@matrix.org/!ROOM_ID"
# Redis URL
REDIS_URL=redis://redis:6379/0
REDIS_URL="redis://redis:6379/0"
# Enable Debug (e.g. for VS Code)
FLASK_DEBUG=1
@ -253,6 +253,7 @@ from sqlalchemy.engine import Engine
from sqlalchemy.exc import IntegrityError, LegacyAPIWarning
from sqlalchemy.orm import joinedload
from werkzeug.security import check_password_hash, generate_password_hash
from werkzeug.middleware.proxy_fix import ProxyFix
from wtforms import SelectField, StringField, TextAreaField, validators
# Config
@ -281,6 +282,11 @@ app.jinja_env.globals['getattr'] = getattr
def not_found_error(error):
return render_template('404.html'), 404
app.wsgi_app = ProxyFix(
app.wsgi_app,
x_proto=1, # Trust X-Forwarded-Proto Header
x_host=1 # Trust X-Forwarded-Host Header
)
# UNIX-Systems (Linux, Docker)
try:
@ -1162,7 +1168,7 @@ def generate_redeem(game_id):
)
db.session.add(new_token)
db.session.commit()
redeem_url = url_for('redeem', token=token, _external=True)
redeem_url = url_for('redeem', token=token, _external=True, _scheme='https')
message = translate(
'Redeem link generated: <a href="{url}" target="_blank">{url}</a>',
url=redeem_url
@ -1186,22 +1192,25 @@ def redeem_page(token):
redeem_token.used = True
db.session.commit()
# which Plattform
if game.platform == "steam" or game.steam_appid:
if game.platform == 'steam':
platform_link = 'https://store.steampowered.com/account/registerkey?key='
platform_label = "Steam"
elif game.platform == "gog":
platform_name = 'Steam'
elif game.platform == 'gog':
platform_link = 'https://www.gog.com/redeem/'
platform_label = "GOG"
elif game.platform == "xbox":
platform_name = 'GOG'
elif game.platform == 'xbox':
platform_link = 'https://redeem.microsoft.com/'
platform_label = "XBOX"
elif game.platform == "playstation":
platform_link = 'https://store.playstation.com/redeem'
platform_label = "PlayStation"
platform_name = 'Xbox'
elif game.platform == 'playstation':
platform_link = 'https://redeem.playstation.com/'
platform_name = 'PlayStation'
elif game.platform == 'switch':
platform_link = 'https://ec.nintendo.com/redeem/'
platform_name = 'Nintendo Switch'
else:
platform_link = '#'
platform_label = game.platform.capitalize() if game.platform else "Unknown"
# Fallback für benutzerdefinierte Keys
platform_link = ''
platform_name = 'Key'
return render_template(
'redeem.html',
@ -1209,9 +1218,10 @@ def redeem_page(token):
redeem_token=redeem_token,
expires_timestamp=int(expires_utc.timestamp() * 1000),
platform_link=platform_link,
platform_label=platform_label
platform_name=platform_name
)
@app.route('/admin/users')
@login_required
@admin_required
@ -1524,6 +1534,7 @@ cat <<HTML_END > templates/base.html
<meta name="theme-color" content="#212529">
<link rel="manifest" href="{{ url_for('static', filename='manifest.json') }}">
<title>{{ _('Game Key Manager') }}</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
<!-- Preload Bootstrap CSS for better LCP -->
<link rel="preload" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"></noscript>
@ -1565,25 +1576,33 @@ cat <<HTML_END > templates/base.html
<input class="form-control me-2" type="search" name="q" id="searchInput" placeholder="{{ _('Search') }}" value="{{ search_query }}">
<button class="btn btn-outline-success" type="submit" aria-label="{{ _('Search') }}">🔍</button>
</form>
<ul class="navbar-nav ms-lg-3 mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="langDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<div class="dropdown ms-3">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{% if session.get('lang', 'en') == 'de' %} Deutsch {% elif session.get('lang', 'en') == 'en' %} English {% else %} Sprache {% endif %}
</a>
<ul class="dropdown-menu" aria-labelledby="langDropdown">
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item {% if session.get('lang', 'en') == 'de' %}active{% endif %}" href="{{ url_for('set_lang', lang='de') }}">Deutsch</a></li>
<li><a class="dropdown-item {% if session.get('lang', 'en') == 'en' %}active{% endif %}" href="{{ url_for('set_lang', lang='en') }}">English</a></li>
</ul>
</li>
</div>
{% if current_user.is_authenticated %}
{% if current_user.is_admin %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin_users') }}">⚙️ {{ _('Admin') }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin_audit_logs') }}">📜 {{ _('Audit Logs') }}</a></li>
{% endif %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('change_password') }}">🔒 {{ _('Password') }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('logout') }}">🚪 {{ _('Logout') }}</a></li>
{% endif %}
<div class="dropdown ms-3">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ _('Import/Export') }}
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="{{ url_for('export_games') }}">⬇️ {{ _('Export CSV') }}</a></li>
<li><a class="dropdown-item" href="{{ url_for('export_pdf') }}">⬇️ Export PDF (for sharing)</a></li>
<li><a class="dropdown-item" href="{{ url_for('import_games') }}">⬆️ {{ _('Import CSV') }}</a></li>
</ul>
</div>
{% if current_user.is_admin %}
<a class="btn btn-outline-secondary ms-3" href="{{ url_for('admin_users') }}">⚙️ {{ _('Admin') }}</a>
<a class="btn btn-outline-secondary ms-1" href="{{ url_for('admin_audit_logs') }}">📜 {{ _('Audit Logs') }}</a>
{% endif %}
<a class="btn btn-outline-secondary ms-3" href="{{ url_for('change_password') }}">🔒 {{ _('Password') }}</a>
<a class="btn btn-outline-danger ms-1" href="{{ url_for('logout') }}">🚪 {{ _('Logout') }}</a>
{% endif %}
</div>
</div>
</nav>
@ -1652,16 +1671,7 @@ HTML_END
cat <<'HTML_END' > templates/index.html
{% extends "base.html" %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>{{ _('My Games') }}</h1>
<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>
<button id="toggle-keys" class="btn btn-sm btn-outline-secondary mb-2">{{ _('Show/Hide Keys') }}</button>
{% if games %}
<div class="table-responsive">
<table class="table table-hover align-middle">
@ -1669,7 +1679,7 @@ cat <<'HTML_END' > templates/index.html
<tr>
<th>{{ _('Cover') }}</th>
<th>{{ _('Name') }}</th>
<th>{{ _('Key') }}</th>
<th class="key-col d-md-table-cell">{{ _('Key') }}</th>
<th>{{ _('Status') }}</th>
<th>{{ _('Created') }}</th>
<th>{{ _('Redeem by') }}</th>
@ -1702,7 +1712,7 @@ cat <<'HTML_END' > templates/index.html
</a>
</td>
<td>{{ game.name }}</td>
<td class="font-monospace">{{ game.steam_key }}</td>
<td class="font-monospace key-col d-none d-md-table-cell">{{ game.steam_key }}</td>
<td>
{% if game.status == 'nicht eingelöst' %}
<span class="badge bg-warning text-dark">{{ _('Not redeemed') }}</span>
@ -1774,7 +1784,7 @@ cat <<'HTML_END' > templates/index.html
document.querySelectorAll('.generate-redeem').forEach(btn => {
btn.addEventListener('click', async function() {
const gameId = this.dataset.gameId;
const flashContainer = document.querySelector('.flash-container');
const flashContainer = document.querySelector('.flash-container')
try {
const response = await fetch(`/generate_redeem/${gameId}`, {
@ -1792,16 +1802,30 @@ document.querySelectorAll('.generate-redeem').forEach(btn => {
}
if (data.url) {
await navigator.clipboard.writeText(data.url);
// Erfolgsmeldung mit übersetztem Text
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(data.url)
.then(() => {
// Succcess ?? maybe
flashContainer.innerHTML = `
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ _("Link copied") }}: <a href="${data.url}" target="_blank">${data.url}</a>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
`;
})
.catch(err => {
flashContainer.innerHTML = `
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ _("Clipboard error") }}: ${err.message}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
`;
});
} else {
alert("Clipboard API is not supported in your browser or context.");
}
}
} catch (error) {
// Fehlermeldung mit übersetztem Text
flashContainer.innerHTML = `
@ -1814,10 +1838,29 @@ document.querySelectorAll('.generate-redeem').forEach(btn => {
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
console.log("DOM ist geladen!"); // Überprüfe, ob DOMContentLoaded überhaupt ausgeführt wird
const toggleKeysButton = document.getElementById('toggle-keys');
if (toggleKeysButton) {
console.log("Button with ID 'toggle-keys' found!");
toggleKeysButton.addEventListener('click', function() {
console.log("Button clicked!");
const keyCols = document.querySelectorAll('.key-col');
keyCols.forEach(function(el) {
el.classList.toggle('hidden');
});
});
} else {
console.log("Button with ID 'toggle-keys' not found!");
}
});
</script>
{% else %}
<div class="alert alert-info">{{ _('No games yet') }}</div>
{% endif %}
{% endblock %}
HTML_END
# Login Template
@ -2287,11 +2330,17 @@ cat <<'HTML_END' > templates/redeem.html
<h4>{{ _('Your Key:') }}</h4>
<code class="fs-3">{{ game.steam_key }}</code>
</div>
{% if platform_link %}
<a href="{{ platform_link }}{{ game.steam_key }}"
class="btn btn-primary btn-lg mb-3"
target="_blank">
{{ _('Redeem now on') }} {{ platform_label }}
{{ _('Redeem now on') }} {{ platform_name }}
</a>
{% else %}
<div class="alert alert-info">
{{ _('Your key:') }} <code class="fs-3">{{ game.steam_key }}</code>
</div>
{% endif %}
<div class="mt-4 text-muted">
<small>
{{ _('This page will expire in') }}
@ -2554,6 +2603,7 @@ cat <<HTML_END > templates/admin_audit_logs.html
HTML_END
# Error Sites
# 403 Tempate
cat <<HTML_END > templates/403.html
{% extends "base.html" %}
{% block content %}
@ -2582,6 +2632,7 @@ cat <<HTML_END > templates/403.html
{% endblock %}
HTML_END
# 404 Template
cat <<HTML_END > templates/404.html
{% extends "base.html" %}
{% block content %}
@ -2778,6 +2829,28 @@ td.font-monospace {
overflow-wrap: break-word;
}
.key-col.hidden {
display: none !important;
}
@media (max-width: 768px) {
.key-col {
display: none;
}
}
.navbar .btn,
.navbar .dropdown-toggle,
.navbar .nav-link {
min-height: 40px;
line-height: 1.5 !important;
padding-top: 6px;
padding-bottom: 6px;
display: flex;
align-items: center;
font-size: 0.95em;
}
.alert-error { background-color: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.alert-success { background-color: #d4edda; border-color: #c3e6cb; color: #155724; }
.alert-info { background: #d9edf7; color: #31708f; }

View File

@ -1,25 +1,25 @@
# Flask-Configuration
SECRET_KEY=""
REDEEM_SECRET=""
WTF_CSRF_SECRET_KEY=""
SECRET_KEY="1dc3d95006f7466670ac2d705ce43dc4a5ad8e2189dbe539"
REDEEM_SECRET="a50a961667ded234b1e59532ab7e27e1"
WTF_CSRF_SECRET_KEY="845ae46bd1bea30311e98df232d78b4e"
# Language Settings
DEFAULT_LANGUAGE="en"
SUPPORTED_LANGUAGES="de,en"
# Timezone
TZ=Europe/Berlin
TZ="Europe/Berlin"
# Security
FORCE_HTTPS=False
SESSION_COOKIE_SECURE=auto
FORCE_HTTPS="False"
SESSION_COOKIE_SECURE="auto"
CSRF_ENABLED="True"
# Account registration
REGISTRATION_ENABLED="True"
# checking interval if keys have to be redeemed before a specific date
CHECK_EXPIRING_KEYS_INTERVAL_HOURS=6
CHECK_EXPIRING_KEYS_INTERVAL_HOURS="6"
# Want to check prices? Here you are!
ITAD_API_KEY="your-secret-key-here"
@ -34,7 +34,7 @@ APPRISE_URLS=""
#matrixs://TOKEN@matrix.org/!ROOM_ID"
# Redis URL
REDIS_URL=redis://redis:6379/0
REDIS_URL="redis://redis:6379/0"
# Enable Debug (e.g. for VS Code)
FLASK_DEBUG=1

View File

@ -72,6 +72,7 @@ from sqlalchemy.engine import Engine
from sqlalchemy.exc import IntegrityError, LegacyAPIWarning
from sqlalchemy.orm import joinedload
from werkzeug.security import check_password_hash, generate_password_hash
from werkzeug.middleware.proxy_fix import ProxyFix
from wtforms import SelectField, StringField, TextAreaField, validators
# Config
@ -100,6 +101,11 @@ app.jinja_env.globals['getattr'] = getattr
def not_found_error(error):
return render_template('404.html'), 404
app.wsgi_app = ProxyFix(
app.wsgi_app,
x_proto=1, # Trust X-Forwarded-Proto Header
x_host=1 # Trust X-Forwarded-Host Header
)
# UNIX-Systems (Linux, Docker)
try:
@ -981,7 +987,7 @@ def generate_redeem(game_id):
)
db.session.add(new_token)
db.session.commit()
redeem_url = url_for('redeem', token=token, _external=True)
redeem_url = url_for('redeem', token=token, _external=True, _scheme='https')
message = translate(
'Redeem link generated: <a href="{url}" target="_blank">{url}</a>',
url=redeem_url
@ -1005,22 +1011,25 @@ def redeem_page(token):
redeem_token.used = True
db.session.commit()
# which Plattform
if game.platform == "steam" or game.steam_appid:
if game.platform == 'steam':
platform_link = 'https://store.steampowered.com/account/registerkey?key='
platform_label = "Steam"
elif game.platform == "gog":
platform_name = 'Steam'
elif game.platform == 'gog':
platform_link = 'https://www.gog.com/redeem/'
platform_label = "GOG"
elif game.platform == "xbox":
platform_name = 'GOG'
elif game.platform == 'xbox':
platform_link = 'https://redeem.microsoft.com/'
platform_label = "XBOX"
elif game.platform == "playstation":
platform_link = 'https://store.playstation.com/redeem'
platform_label = "PlayStation"
platform_name = 'Xbox'
elif game.platform == 'playstation':
platform_link = 'https://redeem.playstation.com/'
platform_name = 'PlayStation'
elif game.platform == 'switch':
platform_link = 'https://ec.nintendo.com/redeem/'
platform_name = 'Nintendo Switch'
else:
platform_link = '#'
platform_label = game.platform.capitalize() if game.platform else "Unknown"
# Fallback für benutzerdefinierte Keys
platform_link = ''
platform_name = 'Key'
return render_template(
'redeem.html',
@ -1028,9 +1037,10 @@ def redeem_page(token):
redeem_token=redeem_token,
expires_timestamp=int(expires_utc.timestamp() * 1000),
platform_link=platform_link,
platform_label=platform_label
platform_name=platform_name
)
@app.route('/admin/users')
@login_required
@admin_required

View File

@ -164,6 +164,28 @@ td.font-monospace {
overflow-wrap: break-word;
}
.key-col.hidden {
display: none !important;
}
@media (max-width: 768px) {
.key-col {
display: none;
}
}
.navbar .btn,
.navbar .dropdown-toggle,
.navbar .nav-link {
min-height: 40px;
line-height: 1.5 !important;
padding-top: 6px;
padding-bottom: 6px;
display: flex;
align-items: center;
font-size: 0.95em;
}
.alert-error { background-color: #f8d7da; border-color: #f5c6cb; color: #721c24; }
.alert-success { background-color: #d4edda; border-color: #c3e6cb; color: #155724; }
.alert-info { background: #d9edf7; color: #31708f; }

View File

@ -8,6 +8,7 @@
<meta name="theme-color" content="#212529">
<link rel="manifest" href="{{ url_for('static', filename='manifest.json') }}">
<title>{{ _('Game Key Manager') }}</title>
<link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}">
<!-- Preload Bootstrap CSS for better LCP -->
<link rel="preload" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" as="style" onload="this.onload=null;this.rel='stylesheet'">
<noscript><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"></noscript>
@ -49,25 +50,33 @@
<input class="form-control me-2" type="search" name="q" id="searchInput" placeholder="{{ _('Search') }}" value="{{ search_query }}">
<button class="btn btn-outline-success" type="submit" aria-label="{{ _('Search') }}">🔍</button>
</form>
<ul class="navbar-nav ms-lg-3 mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="#" id="langDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<div class="dropdown ms-3">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{% if session.get('lang', 'en') == 'de' %} Deutsch {% elif session.get('lang', 'en') == 'en' %} English {% else %} Sprache {% endif %}
</a>
<ul class="dropdown-menu" aria-labelledby="langDropdown">
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item {% if session.get('lang', 'en') == 'de' %}active{% endif %}" href="{{ url_for('set_lang', lang='de') }}">Deutsch</a></li>
<li><a class="dropdown-item {% if session.get('lang', 'en') == 'en' %}active{% endif %}" href="{{ url_for('set_lang', lang='en') }}">English</a></li>
</ul>
</li>
</div>
{% if current_user.is_authenticated %}
{% if current_user.is_admin %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin_users') }}">⚙️ {{ _('Admin') }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin_audit_logs') }}">📜 {{ _('Audit Logs') }}</a></li>
{% endif %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('change_password') }}">🔒 {{ _('Password') }}</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('logout') }}">🚪 {{ _('Logout') }}</a></li>
{% endif %}
<div class="dropdown ms-3">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
{{ _('Import/Export') }}
</button>
<ul class="dropdown-menu">
<li><a class="dropdown-item" href="{{ url_for('export_games') }}">⬇️ {{ _('Export CSV') }}</a></li>
<li><a class="dropdown-item" href="{{ url_for('export_pdf') }}">⬇️ Export PDF (for sharing)</a></li>
<li><a class="dropdown-item" href="{{ url_for('import_games') }}">⬆️ {{ _('Import CSV') }}</a></li>
</ul>
</div>
{% if current_user.is_admin %}
<a class="btn btn-outline-secondary ms-3" href="{{ url_for('admin_users') }}">⚙️ {{ _('Admin') }}</a>
<a class="btn btn-outline-secondary ms-1" href="{{ url_for('admin_audit_logs') }}">📜 {{ _('Audit Logs') }}</a>
{% endif %}
<a class="btn btn-outline-secondary ms-3" href="{{ url_for('change_password') }}">🔒 {{ _('Password') }}</a>
<a class="btn btn-outline-danger ms-1" href="{{ url_for('logout') }}">🚪 {{ _('Logout') }}</a>
{% endif %}
</div>
</div>
</nav>

View File

@ -1,15 +1,6 @@
{% extends "base.html" %}
{% block content %}
<div class="d-flex justify-content-between align-items-center mb-4">
<h1>{{ _('My Games') }}</h1>
<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>
<button id="toggle-keys" class="btn btn-sm btn-outline-secondary mb-2">{{ _('Show/Hide Keys') }}</button>
{% if games %}
<div class="table-responsive">
<table class="table table-hover align-middle">
@ -17,7 +8,7 @@
<tr>
<th>{{ _('Cover') }}</th>
<th>{{ _('Name') }}</th>
<th>{{ _('Key') }}</th>
<th class="key-col d-md-table-cell">{{ _('Key') }}</th>
<th>{{ _('Status') }}</th>
<th>{{ _('Created') }}</th>
<th>{{ _('Redeem by') }}</th>
@ -50,7 +41,7 @@
</a>
</td>
<td>{{ game.name }}</td>
<td class="font-monospace">{{ game.steam_key }}</td>
<td class="font-monospace key-col d-none d-md-table-cell">{{ game.steam_key }}</td>
<td>
{% if game.status == 'nicht eingelöst' %}
<span class="badge bg-warning text-dark">{{ _('Not redeemed') }}</span>
@ -122,7 +113,7 @@
document.querySelectorAll('.generate-redeem').forEach(btn => {
btn.addEventListener('click', async function() {
const gameId = this.dataset.gameId;
const flashContainer = document.querySelector('.flash-container');
const flashContainer = document.querySelector('.flash-container')
try {
const response = await fetch(`/generate_redeem/${gameId}`, {
@ -140,16 +131,30 @@ document.querySelectorAll('.generate-redeem').forEach(btn => {
}
if (data.url) {
await navigator.clipboard.writeText(data.url);
// Erfolgsmeldung mit übersetztem Text
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(data.url)
.then(() => {
// Succcess ?? maybe
flashContainer.innerHTML = `
<div class="alert alert-success alert-dismissible fade show" role="alert">
{{ _("Link copied") }}: <a href="${data.url}" target="_blank">${data.url}</a>
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
`;
})
.catch(err => {
flashContainer.innerHTML = `
<div class="alert alert-danger alert-dismissible fade show" role="alert">
{{ _("Clipboard error") }}: ${err.message}
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
</div>
`;
});
} else {
alert("Clipboard API is not supported in your browser or context.");
}
}
} catch (error) {
// Fehlermeldung mit übersetztem Text
flashContainer.innerHTML = `
@ -162,7 +167,26 @@ document.querySelectorAll('.generate-redeem').forEach(btn => {
});
});
</script>
<script>
document.addEventListener('DOMContentLoaded', function() {
console.log("DOM ist geladen!"); // Überprüfe, ob DOMContentLoaded überhaupt ausgeführt wird
const toggleKeysButton = document.getElementById('toggle-keys');
if (toggleKeysButton) {
console.log("Button with ID 'toggle-keys' found!");
toggleKeysButton.addEventListener('click', function() {
console.log("Button clicked!");
const keyCols = document.querySelectorAll('.key-col');
keyCols.forEach(function(el) {
el.classList.toggle('hidden');
});
});
} else {
console.log("Button with ID 'toggle-keys' not found!");
}
});
</script>
{% else %}
<div class="alert alert-info">{{ _('No games yet') }}</div>
{% endif %}
{% endblock %}

View File

@ -16,11 +16,17 @@
<h4>{{ _('Your Key:') }}</h4>
<code class="fs-3">{{ game.steam_key }}</code>
</div>
{% if platform_link %}
<a href="{{ platform_link }}{{ game.steam_key }}"
class="btn btn-primary btn-lg mb-3"
target="_blank">
{{ _('Redeem now on') }} {{ platform_label }}
{{ _('Redeem now on') }} {{ platform_name }}
</a>
{% else %}
<div class="alert alert-info">
{{ _('Your key:') }} <code class="fs-3">{{ game.steam_key }}</code>
</div>
{% endif %}
<div class="mt-4 text-muted">
<small>
{{ _('This page will expire in') }}

View File

@ -11,6 +11,7 @@
"Cancel": "Abbrechen",
"Change Password": "Passwort ändern",
"Change password form": "Passwort ändern Formular",
"Clipboard error": "Ablagefehler",
"Confirm New Password": "Neues Passwort bestätigen",
"Confirm Password": "Passwort bestätigen",
"Copied!": "Kopiert!",
@ -28,6 +29,7 @@
"Expires at": "Läuft ab am",
"Export CSV": "CSV exportieren",
"Externe Daten": "Externe Daten",
"External Data": "Externe Daten",
"For GOG games: Enter the Steam AppID here to enable price tracking.": "Für GOG-Spiele: Gib hier die Steam AppID ein, um die Preisüberwachung zu aktivieren.",
"Game Description": "Spielbeschreibung",
"Game Key": "Spielschlüssel",
@ -36,6 +38,7 @@
"Gifted": "Verschenkt",
"Hist. Low": "Historischer Tiefstpreis",
"Import": "Importieren",
"Import/Export": "Import/Export",
"Import CSV": "CSV importieren",
"Import Games": "Spiele importieren",
"Key": "Schlüssel",
@ -74,6 +77,7 @@
"Select CSV file": "CSV-Datei auswählen",
"Shop": "Shop",
"Shop URL": "Shop-URL",
"Show/Hide Keys": "Zeige/Verstecke Keys",
"Sorry, you are not allowed to access this page.": "Du bist nicht berechtigt, diese Seite zu betreten.",
"Spiel bearbeiten": "Spiel bearbeiten",
"Status": "Status",
@ -90,5 +94,6 @@
"Release Date:": "Veröffentlichung:",
"View Details": "Details anzeigen",
"View on IsThereAnyDeal": "Auf IsThereAnyDeal ansehen",
"Your Key:": "Dein Schlüssel:"
"Your Key:": "Dein Key:",
"Your key:": "Dein Key"
}

View File

@ -3,7 +3,6 @@
"Action": "",
"Actions": "",
"Add Game": "",
"Add New Game": "",
"Admin": "",
"Already have an account? Login!": "",
"Audit Logs": "",
@ -11,6 +10,7 @@
"Cancel": "",
"Change Password": "",
"Change password form": "",
"Clipboard error": "",
"Confirm New Password": "",
"Confirm Password": "",
"Copied!": "",
@ -36,13 +36,13 @@
"Hist. Low": "",
"Import": "",
"Import CSV": "",
"Import/Export": "",
"Import Games": "",
"Key": "",
"Link copied": "",
"Login": "",
"Login form": "",
"Logout": "",
"My Games": "",
"Name": "",
"New Password": "",
"Next": "",
@ -75,6 +75,7 @@
"Select CSV file": "",
"Shop": "",
"Shop URL": "",
"Show/Hide Keys": "",
"Sorry, you are not allowed to access this page.": "",
"Spiel bearbeiten": "",
"Status": "",
@ -90,5 +91,6 @@
"Username": "",
"View Details": "",
"View on IsThereAnyDeal": "",
"Your key:": "",
"Your Key:": ""
}