Files
Lars Behrends 218d0c28c0 impoort stuff!
2025-10-24 16:04:34 +02:00

334 lines
17 KiB
Twig

{% extends "admin/layout.twig" %}
{% block content %}
<div class="px-4 py-6 sm:px-6 lg:px-8">
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="text-2xl font-semibold text-gray-900">Preview Playnite Import</h1>
<p class="mt-2 text-sm text-gray-700">
Review the games that will be imported from "{{ filename }}". Check the details below and click "Import Games" to proceed.
</p>
</div>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<a href="{{ path_for('admin.playnite.import') }}" class="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
← Back to Import
</a>
</div>
</div>
<!-- Import Summary -->
<div class="mt-8 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<h3 class="text-lg font-medium text-gray-900">Import Summary</h3>
</div>
<div class="px-6 py-4">
<dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-4">
<div>
<dt class="text-sm font-medium text-gray-500">Total Games</dt>
<dd class="mt-1 text-2xl font-semibold text-gray-900">{{ preview.total }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Valid Games</dt>
<dd class="mt-1 text-2xl font-semibold text-green-600">{{ preview.valid }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Invalid Games</dt>
<dd class="mt-1 text-2xl font-semibold text-red-600">{{ preview.invalid }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Sources</dt>
<dd class="mt-1 text-2xl font-semibold text-gray-900">{{ preview.games|length > 0 ? (preview.games|first).source_name : 'N/A' }}</dd>
</div>
</dl>
</div>
</div>
{% if preview.errors %}
<!-- Import Errors -->
<div class="mt-6 bg-red-50 border border-red-200 rounded-md">
<div class="px-6 py-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">Import Errors</h3>
<div class="mt-2 text-sm text-red-700">
<ul class="space-y-1">
{% for error in preview.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
{% endif %}
<!-- Games Preview -->
<div class="mt-6 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex items-center justify-between">
<h3 class="text-lg font-medium text-gray-900">Games to Import</h3>
<div class="flex space-x-2">
<button type="button" onclick="toggleAllDetails()" class="inline-flex items-center px-3 py-1 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Toggle All Details
</button>
</div>
</div>
</div>
<div class="divide-y divide-gray-200">
{% for game in preview.games %}
<div class="px-6 py-4 game-item" data-game-index="{{ loop.index }}">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
{% if game.cover_image %}
<img class="h-16 w-16 rounded-lg object-cover" src="{{ game.cover_image }}" alt="{{ game.title }}">
{% else %}
<div class="h-16 w-16 rounded-lg bg-gray-200 flex items-center justify-center">
<svg class="h-8 w-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-7 8h12a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
</div>
{% endif %}
<div>
<h4 class="text-lg font-medium text-gray-900">{{ game.title }}</h4>
<div class="flex items-center space-x-4 text-sm text-gray-500">
{% if game.genre %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
{{ game.genre }}
</span>
{% endif %}
{% if game.platform %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
{{ game.platform }}
</span>
{% endif %}
{% if game.release_date %}
<span>{{ game.release_date|date('Y') }}</span>
{% endif %}
</div>
</div>
</div>
<button type="button" onclick="toggleGameDetails('game-{{ loop.index }}')"
class="text-indigo-600 hover:text-indigo-900 text-sm font-medium">
Show Details
</button>
</div>
<!-- Game Details (hidden by default) -->
<div id="details-game-{{ loop.index }}" class="hidden mt-4 bg-gray-50 rounded-lg p-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Game Information -->
<div>
<h5 class="text-sm font-medium text-gray-900 mb-3">Game Information</h5>
<dl class="space-y-2">
{% if game.developer %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Developer:</dt>
<dd class="text-sm text-gray-900">{{ game.developer }}</dd>
</div>
{% endif %}
{% if game.publisher %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Publisher:</dt>
<dd class="text-sm text-gray-900">{{ game.publisher }}</dd>
</div>
{% endif %}
{% if game.release_date %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Release Date:</dt>
<dd class="text-sm text-gray-900">{{ game.release_date|date('M j, Y') }}</dd>
</div>
{% endif %}
{% if game.rating %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Rating:</dt>
<dd class="text-sm text-gray-900">{{ game.rating }}/10</dd>
</div>
{% endif %}
{% if game.playtime_minutes %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Playtime:</dt>
<dd class="text-sm text-gray-900">{{ (game.playtime_minutes / 60)|round(1) }} hours</dd>
</div>
{% endif %}
{% if game.critic_score %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Critic Score:</dt>
<dd class="text-sm text-gray-900">{{ game.critic_score }}%</dd>
</div>
{% endif %}
</dl>
</div>
<!-- Platform & Status -->
<div>
<h5 class="text-sm font-medium text-gray-900 mb-3">Platform & Status</h5>
<dl class="space-y-2">
{% if game.source_name %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Source:</dt>
<dd class="text-sm text-gray-900">{{ game.source_name }}</dd>
</div>
{% endif %}
{% if game.is_installed %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Status:</dt>
<dd class="text-sm">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
Installed
</span>
</dd>
</div>
{% endif %}
{% if game.is_favorite %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Favorite:</dt>
<dd class="text-sm">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
Yes
</span>
</dd>
</div>
{% endif %}
{% if game.completion_percentage > 0 %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Completion:</dt>
<dd class="text-sm text-gray-900">{{ game.completion_percentage }}%</dd>
</div>
{% endif %}
</dl>
</div>
</div>
{% if game.description %}
<div class="mt-4">
<h5 class="text-sm font-medium text-gray-900 mb-2">Description</h5>
<p class="text-sm text-gray-600 line-clamp-3">{{ game.description|striptags|slice(0, 200) }}{% if game.description|length > 200 %}...{% endif %}</p>
</div>
{% endif %}
{% if game.genres_json %}
<div class="mt-4">
<h5 class="text-sm font-medium text-gray-900 mb-2">Genres</h5>
<div class="flex flex-wrap gap-1">
{% for genre in game.genres_json %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
{{ genre.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% if game.tags_json %}
<div class="mt-4">
<h5 class="text-sm font-medium text-gray-900 mb-2">Tags</h5>
<div class="flex flex-wrap gap-1">
{% for tag in game.tags_json|slice(0, 10) %}
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800">
{{ tag.Name }}
</span>
{% endfor %}
{% if game.tags_json|length > 10 %}
<span class="text-xs text-gray-500">+{{ game.tags_json|length - 10 }} more</span>
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
<!-- Import Form -->
<div class="mt-6 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<h3 class="text-lg font-medium text-gray-900">Confirm Import</h3>
</div>
<div class="px-6 py-4">
<form action="{{ path_for('admin.playnite.confirm') }}" method="post" class="space-y-4">
<div class="flex items-start">
<div class="flex items-center h-5">
<input id="update_existing" name="update_existing" type="checkbox" class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" checked>
</div>
<div class="ml-3 text-sm">
<label for="update_existing" class="font-medium text-gray-700">Update existing games</label>
<p class="text-gray-500">If a game with the same Playnite ID already exists, update it with the new data instead of creating a duplicate.</p>
</div>
</div>
<div class="flex justify-end space-x-3">
<a href="{{ path_for('admin.playnite.cancel') }}" class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Cancel
</a>
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Import {{ preview.valid }} Games
</button>
</div>
</form>
</div>
</div>
</div>
<script>
function toggleGameDetails(gameIndex) {
const details = document.getElementById('details-game-' + gameIndex);
const button = event.target;
if (details.classList.contains('hidden')) {
details.classList.remove('hidden');
button.textContent = 'Hide Details';
} else {
details.classList.add('hidden');
button.textContent = 'Show Details';
}
}
function toggleAllDetails() {
const gameItems = document.querySelectorAll('.game-item');
const allHidden = Array.from(gameItems).every(item => {
const index = item.dataset.gameIndex;
const details = document.getElementById('details-game-' + index);
return details.classList.contains('hidden');
});
gameItems.forEach(item => {
const index = item.dataset.gameIndex;
const details = document.getElementById('details-game-' + index);
const button = item.querySelector('button');
if (allHidden) {
details.classList.remove('hidden');
button.textContent = 'Hide Details';
} else {
details.classList.add('hidden');
button.textContent = 'Show Details';
}
});
}
// Show first game's details by default
document.addEventListener('DOMContentLoaded', function() {
const firstGameItem = document.querySelector('.game-item');
if (firstGameItem) {
const gameIndex = firstGameItem.dataset.gameIndex;
const details = document.getElementById('details-game-' + gameIndex);
if (details) {
details.classList.remove('hidden');
const button = firstGameItem.querySelector('button');
if (button) {
button.textContent = 'Hide Details';
}
}
}
});
</script>
{% endblock %}