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

293 lines
15 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">Import Complete</h1>
<p class="mt-2 text-sm text-gray-700">
The Playnite import has been completed. Here's a summary of what was imported.
</p>
</div>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none space-x-3">
<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">
Import More Games
</a>
<a href="{{ path_for('games.index') }}" class="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
View Games
</a>
</div>
</div>
<!-- Import Results 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 Results</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">Games Imported</dt>
<dd class="mt-1 text-2xl font-semibold text-green-600">{{ import_result.imported }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Games Updated</dt>
<dd class="mt-1 text-2xl font-semibold text-blue-600">{{ import_result.updated }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Games Skipped</dt>
<dd class="mt-1 text-2xl font-semibold text-gray-600">{{ import_result.skipped }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Errors</dt>
<dd class="mt-1 text-2xl font-semibold text-red-600">{{ import_result.errors|length }}</dd>
</div>
</dl>
</div>
</div>
{% if import_result.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">
<p class="font-medium">The following games could not be imported:</p>
<ul class="mt-2 space-y-1">
{% for error in import_result.errors %}
<li class="flex items-start">
<span class="flex-shrink-0 w-1.5 h-1.5 bg-red-400 rounded-full mt-2 mr-2"></span>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if import_result.imported > 0 or import_result.updated > 0 %}
<!-- Successfully Imported Games -->
<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">
{% if import_result.imported > 0 %}Imported Games{% endif %}
{% if import_result.imported > 0 and import_result.updated > 0 %} & {% endif %}
{% if import_result.updated > 0 %}Updated Games{% endif %}
</h3>
<div class="flex space-x-2">
<button type="button" onclick="toggleImportDetails()" 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 Details
</button>
</div>
</div>
</div>
<div id="import-details" class="hidden">
<div class="divide-y divide-gray-200">
{% for game in preview_data.games %}
<div class="px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
{% if game.cover_image %}
<img class="h-12 w-12 rounded-lg object-cover" src="{{ game.cover_image }}" alt="{{ game.title }}">
{% else %}
<div class="h-12 w-12 rounded-lg bg-gray-200 flex items-center justify-center">
<svg class="h-6 w-6 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-sm font-medium text-gray-900">{{ game.title }}</h4>
<div class="flex items-center space-x-2 text-xs text-gray-500">
{% if game.platform %}
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">
{{ game.platform }}
</span>
{% endif %}
{% if game.genre %}
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800">
{{ game.genre }}
</span>
{% endif %}
</div>
</div>
</div>
<div class="flex items-center space-x-2">
{% if import_result.imported > 0 %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
New
</span>
{% endif %}
{% if import_result.updated > 0 %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
Updated
</span>
{% endif %}
</div>
</div>
{% if game.description %}
<div class="mt-2">
<p class="text-xs text-gray-600 line-clamp-2">{{ game.description|striptags|slice(0, 150) }}{% if game.description|length > 150 %}...{% endif %}</p>
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
<!-- Import Statistics -->
<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">Import Statistics</h3>
</div>
<div class="px-6 py-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h4 class="text-sm font-medium text-gray-900 mb-3">Data Imported</h4>
<dl class="space-y-2">
{% set totalGames = import_result.imported + import_result.updated %}
{% if totalGames > 0 %}
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Games with descriptions:</dt>
<dd class="text-gray-900">
{% set withDescriptions = 0 %}
{% for game in preview_data.games %}
{% if game.description %}
{% set withDescriptions = withDescriptions + 1 %}
{% endif %}
{% endfor %}
{{ withDescriptions }}
</dd>
</div>
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Games with cover images:</dt>
<dd class="text-gray-900">
{% set withCovers = 0 %}
{% for game in preview_data.games %}
{% if game.cover_image %}
{% set withCovers = withCovers + 1 %}
{% endif %}
{% endfor %}
{{ withCovers }}
</dd>
</div>
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Games with ratings:</dt>
<dd class="text-gray-900">
{% set withRatings = 0 %}
{% for game in preview_data.games %}
{% if game.rating %}
{% set withRatings = withRatings + 1 %}
{% endif %}
{% endfor %}
{{ withRatings }}
</dd>
</div>
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Total playtime:</dt>
<dd class="text-gray-900">
{% set totalPlaytime = 0 %}
{% for game in preview_data.games %}
{% if game.playtime_minutes %}
{% set totalPlaytime = totalPlaytime + game.playtime_minutes %}
{% endif %}
{% endfor %}
{{ (totalPlaytime / 60)|round(1) }} hours
</dd>
</div>
{% endif %}
</dl>
</div>
<div>
<h4 class="text-sm font-medium text-gray-900 mb-3">Platform Distribution</h4>
<dl class="space-y-2">
{% set platforms = {} %}
{% for game in preview_data.games %}
{% if game.platform %}
{% set platformKey = game.platform %}
{% if platforms[platformKey] is defined %}
{% set platforms = platforms|merge({(platformKey): platforms[platformKey] + 1}) %}
{% else %}
{% set platforms = platforms|merge({(platformKey): 1}) %}
{% endif %}
{% endif %}
{% endfor %}
{% for platform, count in platforms %}
<div class="flex justify-between text-sm">
<dt class="text-gray-500">{{ platform }}:</dt>
<dd class="text-gray-900">{{ count }} games</dd>
</div>
{% endfor %}
</dl>
</div>
</div>
</div>
</div>
<!-- Next Steps -->
<div class="mt-6 bg-blue-50 border border-blue-200 rounded-md">
<div class="px-6 py-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-blue-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-blue-800">What happens next?</h3>
<div class="mt-2 text-sm text-blue-700">
<ul class="list-disc list-inside space-y-1">
<li>The imported games are now available in your Games library</li>
<li>Games are automatically grouped by title across different platforms</li>
<li>Rich metadata including descriptions, ratings, and images are preserved</li>
<li>You can update playtime and other statistics directly in the games interface</li>
<li>Background sync processes will keep the data current if configured</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function toggleImportDetails() {
const details = document.getElementById('import-details');
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';
}
}
// Auto-hide details after 5 seconds
setTimeout(function() {
const button = document.querySelector('button[onclick="toggleImportDetails()"]');
if (button && !document.getElementById('import-details').classList.contains('hidden')) {
// Details are already visible, leave them as is
}
}, 5000);
</script>
{% endblock %}