seems to be the last RC - this app is done - so am I
This commit is contained in:
		
							parent
							
								
									1506201913
								
							
						
					
					
						commit
						f5b184fe54
					
				
					 37 changed files with 1932 additions and 661 deletions
				
			
		| 
						 | 
				
			
			@ -22,6 +22,7 @@
 | 
			
		|||
                <th>{{ _('Created') }}</th>
 | 
			
		||||
                <th>{{ _('Redeem by') }}</th>
 | 
			
		||||
                <th>{{ _('Shop') }}</th>
 | 
			
		||||
                <th>{{ _('Price') }}</th>
 | 
			
		||||
                <th>{{ _('Actions') }}</th>
 | 
			
		||||
            </tr>
 | 
			
		||||
        </thead>
 | 
			
		||||
| 
						 | 
				
			
			@ -29,38 +30,40 @@
 | 
			
		|||
            {% for game in games %}
 | 
			
		||||
            <tr>
 | 
			
		||||
                <td>
 | 
			
		||||
                {% if game.steam_appid %}
 | 
			
		||||
                <img src="https://cdn.cloudflare.steamstatic.com/steam/apps/{{ game.steam_appid }}/header.jpg"
 | 
			
		||||
                     alt="Steam Header" 
 | 
			
		||||
                     class="game-cover"
 | 
			
		||||
                     {% if loop.first %}fetchpriority="high"{% endif %}
 | 
			
		||||
                     width="368" 
 | 
			
		||||
                     height="172"
 | 
			
		||||
                     loading="lazy">
 | 
			
		||||
                {% elif game.url and 'gog.com' in game.url %}
 | 
			
		||||
                <img src="{{ url_for('static', filename='gog_logo.webp') }}"
 | 
			
		||||
                     alt="GOG Logo" 
 | 
			
		||||
                     class="game-cover"
 | 
			
		||||
                     width="368"
 | 
			
		||||
                     height="172"
 | 
			
		||||
                     loading="lazy">
 | 
			
		||||
                {% endif %}
 | 
			
		||||
                  <a href="{{ url_for('game_details', game_id=game.id) }}" title="{{ _('Details') }}">
 | 
			
		||||
                    {% if game.steam_appid %}
 | 
			
		||||
                      <img src="https://cdn.cloudflare.steamstatic.com/steam/apps/{{ game.steam_appid }}/header.jpg"
 | 
			
		||||
                          alt="Steam Header" 
 | 
			
		||||
                          class="game-cover"
 | 
			
		||||
                          {% if loop.first %}fetchpriority="high"{% endif %}
 | 
			
		||||
                          width="368" 
 | 
			
		||||
                          height="172"
 | 
			
		||||
                          loading="lazy">
 | 
			
		||||
                    {% elif game.url and 'gog.com' in game.url %}
 | 
			
		||||
                      <img src="{{ url_for('static', filename='gog_logo.webp') }}"
 | 
			
		||||
                          alt="GOG Logo" 
 | 
			
		||||
                          class="game-cover"
 | 
			
		||||
                          width="368"
 | 
			
		||||
                          height="172"
 | 
			
		||||
                          loading="lazy">
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                  </a>
 | 
			
		||||
                </td>
 | 
			
		||||
                <td>{{ game.name }}</td>
 | 
			
		||||
                <td class="font-monospace">{{ game.steam_key }}</td>
 | 
			
		||||
                <td>
 | 
			
		||||
                    {% if game.status == 'nicht eingelöst' %}
 | 
			
		||||
                        <span class="badge bg-warning text-dark">{{ _('Not redeemed') }}</span>
 | 
			
		||||
                    {% elif game.status == 'verschenkt' %}
 | 
			
		||||
                    {% elif game.status == 'geschenkt' %}
 | 
			
		||||
                        <span class="badge bg-success">{{ _('Gifted') }}</span>
 | 
			
		||||
                    {% elif game.status == 'eingelöst' %}
 | 
			
		||||
                        <span class="badge bg-secondary">{{ _('Redeemed') }}</span>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                </td>
 | 
			
		||||
                <td>{{ format_date(game.created_at) }}</td>
 | 
			
		||||
                <td>{{ game.created_at|strftime('%d.%m.%Y') }}</td>
 | 
			
		||||
                <td>
 | 
			
		||||
                    {% if game.redeem_date %}
 | 
			
		||||
                        <span class="badge bg-danger">{{ format_date(game.redeem_date) }}</span>
 | 
			
		||||
                        <span class="badge bg-danger">{{ game.redeem_date|strftime('%d.%m.%Y') }}</span>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                </td>
 | 
			
		||||
                <td>
 | 
			
		||||
| 
						 | 
				
			
			@ -68,9 +71,37 @@
 | 
			
		|||
                        <a href="{{ game.url }}" target="_blank" class="btn btn-sm btn-outline-info">🔗 {{ _('Shop') }}</a>
 | 
			
		||||
                    {% endif %}
 | 
			
		||||
                </td>
 | 
			
		||||
                <td>
 | 
			
		||||
                  {% if game.current_price is not none %}
 | 
			
		||||
                  <div {% if game.historical_low is not none %}class="mb-2"{% endif %}>
 | 
			
		||||
                      <div class="text-body-secondary" style="font-size: 0.85em; line-height: 1.2;">
 | 
			
		||||
                          {{ _('Current Deal') }}
 | 
			
		||||
                      </div>
 | 
			
		||||
                      <div style="font-size: 1.05em; line-height: 1.2;">
 | 
			
		||||
                          {{ "%.2f"|format(game.current_price) }} €
 | 
			
		||||
                          {% if game.current_price_shop %}
 | 
			
		||||
                          <span class="d-block text-body-secondary" style="font-size: 0.75em; line-height: 1.1;">({{ game.current_price_shop }})</span>
 | 
			
		||||
                          {% endif %}
 | 
			
		||||
                      </div>
 | 
			
		||||
                  </div>
 | 
			
		||||
                  {% endif %}
 | 
			
		||||
 | 
			
		||||
                  {# Historical Low #}
 | 
			
		||||
                  {% if game.historical_low is not none %}
 | 
			
		||||
                  <div>
 | 
			
		||||
                      <div class="text-body-secondary" style="font-size: 0.85em; line-height: 1.2;">
 | 
			
		||||
                          {{ _('Hist. Low') }}
 | 
			
		||||
                      </div>
 | 
			
		||||
                      <div style="font-size: 1.05em; line-height: 1.2;">
 | 
			
		||||
                          {{ "%.2f"|format(game.historical_low) }} €
 | 
			
		||||
                      </div>
 | 
			
		||||
                  </div>
 | 
			
		||||
                  {% endif %}
 | 
			
		||||
                </td>
 | 
			
		||||
                <td class="text-nowrap">
 | 
			
		||||
                    {% if game.status == 'verschenkt' %}
 | 
			
		||||
                    <button class="btn btn-sm btn-success generate-redeem" 
 | 
			
		||||
                    {% if game.status == 'geschenkt' %}
 | 
			
		||||
                    <button type="button" 
 | 
			
		||||
                            class="btn btn-sm btn-success generate-redeem" 
 | 
			
		||||
                            data-game-id="{{ game.id }}"
 | 
			
		||||
                            title="{{ _('Generate redeem link') }}">
 | 
			
		||||
                        🔗
 | 
			
		||||
| 
						 | 
				
			
			@ -87,29 +118,46 @@
 | 
			
		|||
        </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;
 | 
			
		||||
        const flashContainer = document.querySelector('.flash-container');
 | 
			
		||||
        
 | 
			
		||||
        try {
 | 
			
		||||
            const response = await fetch('/generate_redeem/' + gameId, {
 | 
			
		||||
            const response = await fetch(`/generate_redeem/${gameId}`, {
 | 
			
		||||
                method: 'POST',
 | 
			
		||||
                headers: {
 | 
			
		||||
                    'X-CSRFToken': csrfToken
 | 
			
		||||
                    'X-CSRFToken': document.querySelector('meta[name="csrf-token"]').content,
 | 
			
		||||
                    'Accept': 'application/json'
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
            if (!response.ok) throw new Error('Network error');
 | 
			
		||||
 | 
			
		||||
            const data = await response.json();
 | 
			
		||||
            if(data.url) {
 | 
			
		||||
            
 | 
			
		||||
            if (!response.ok) {
 | 
			
		||||
                throw new Error(data.error || '{{ _("Unknown error") }}');
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (data.url) {
 | 
			
		||||
                await navigator.clipboard.writeText(data.url);
 | 
			
		||||
                alert('{{ _("Redeem link copied to clipboard!") }}');
 | 
			
		||||
                
 | 
			
		||||
                // Erfolgsmeldung mit übersetztem Text
 | 
			
		||||
                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 (error) {
 | 
			
		||||
            console.error('Error:', error);
 | 
			
		||||
            alert('{{ _("Error generating link") }}');
 | 
			
		||||
            // Fehlermeldung mit übersetztem Text
 | 
			
		||||
            flashContainer.innerHTML = `
 | 
			
		||||
                <div class="alert alert-danger alert-dismissible fade show" role="alert">
 | 
			
		||||
                    {{ _("Error") }}: ${error.message}
 | 
			
		||||
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
 | 
			
		||||
                </div>
 | 
			
		||||
            `;
 | 
			
		||||
        }
 | 
			
		||||
    });
 | 
			
		||||
});
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue