mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
impoort stuff!
This commit is contained in:
@@ -254,6 +254,12 @@
|
||||
<span>Sync Media</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ path_for('admin.playnite.import') }}">
|
||||
<i class="bi bi-upload"></i>
|
||||
<span>Playnite Import</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{{ path_for('home') }}" target="_blank">
|
||||
<i bi bi-house-door"></i>
|
||||
|
||||
190
resources/views/admin/playnite/import.twig
Normal file
190
resources/views/admin/playnite/import.twig
Normal file
@@ -0,0 +1,190 @@
|
||||
{% 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 Playnite Games</h1>
|
||||
<p class="mt-2 text-sm text-gray-700">
|
||||
Import games from Playnite export files. Playnite is a game library management application that can export your game library to JSON format.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if error %}
|
||||
<div class="mt-6 rounded-md bg-red-50 p-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 Error</h3>
|
||||
<div class="mt-2 text-sm text-red-700">
|
||||
<p>{{ error }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="mt-8 bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-6">
|
||||
<div class="space-y-6">
|
||||
<!-- Import Instructions -->
|
||||
<div class="bg-blue-50 border border-blue-200 rounded-md p-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">How to Export from Playnite</h3>
|
||||
<div class="mt-2 text-sm text-blue-700">
|
||||
<ol class="list-decimal list-inside space-y-1">
|
||||
<li>Open Playnite and go to Library → Export Library</li>
|
||||
<li>Choose "JSON" as the export format</li>
|
||||
<li>Select the games you want to export (or export all)</li>
|
||||
<li>Save the JSON file to your computer</li>
|
||||
<li>Upload the file using the form below</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Upload Form -->
|
||||
<form action="{{ path_for('admin.playnite.upload') }}" method="post" enctype="multipart/form-data" class="space-y-6">
|
||||
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
|
||||
<div>
|
||||
<label for="playnite_file" class="block text-sm font-medium text-gray-700">
|
||||
Playnite Export File
|
||||
</label>
|
||||
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
|
||||
<div class="space-y-1 text-center">
|
||||
<svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48">
|
||||
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="flex text-sm text-gray-600">
|
||||
<label for="playnite_file" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
|
||||
<span>Upload a file</span>
|
||||
<input id="playnite_file" name="playnite_file" type="file" class="sr-only" accept=".json">
|
||||
</label>
|
||||
<p class="pl-1">or drag and drop</p>
|
||||
</div>
|
||||
<p class="text-xs text-gray-500">JSON files only</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Import Options -->
|
||||
<div class="bg-gray-50 rounded-lg p-4">
|
||||
<h3 class="text-sm font-medium text-gray-900 mb-3">Import Options</h3>
|
||||
<div class="space-y-3">
|
||||
<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>
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<div class="flex justify-end space-x-3">
|
||||
<a href="{{ path_for('admin.index') }}" 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">
|
||||
Upload & Preview
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Recent Imports -->
|
||||
<div class="mt-8">
|
||||
<h2 class="text-lg font-medium text-gray-900 mb-4">Recent Playnite Imports</h2>
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-4">
|
||||
<p class="text-sm text-gray-500">No recent imports found. Import history will appear here.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
// File upload preview
|
||||
document.getElementById('playnite_file').addEventListener('change', function(e) {
|
||||
const file = e.target.files[0];
|
||||
if (file) {
|
||||
const fileName = file.name;
|
||||
const fileSize = (file.size / 1024 / 1024).toFixed(2) + ' MB';
|
||||
|
||||
// Update the UI to show file info without destroying the file input
|
||||
const uploadArea = document.querySelector('.border-dashed');
|
||||
const textElements = uploadArea.querySelectorAll('span, p');
|
||||
|
||||
// Update the text content instead of replacing HTML
|
||||
if (textElements.length >= 2) {
|
||||
textElements[0].textContent = fileName;
|
||||
textElements[1].textContent = `${fileSize} - Ready to import`;
|
||||
}
|
||||
|
||||
// Change the SVG to a success icon
|
||||
const svg = uploadArea.querySelector('svg');
|
||||
if (svg) {
|
||||
svg.innerHTML = '<path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />';
|
||||
svg.className = 'mx-auto h-12 w-12 text-green-400';
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Drag and drop functionality
|
||||
const uploadArea = document.querySelector('.border-dashed');
|
||||
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
||||
uploadArea.addEventListener(eventName, preventDefaults, false);
|
||||
document.body.addEventListener(eventName, preventDefaults, false);
|
||||
});
|
||||
|
||||
['dragenter', 'dragover'].forEach(eventName => {
|
||||
uploadArea.addEventListener(eventName, highlight, false);
|
||||
});
|
||||
|
||||
['dragleave', 'drop'].forEach(eventName => {
|
||||
uploadArea.addEventListener(eventName, unhighlight, false);
|
||||
});
|
||||
|
||||
uploadArea.addEventListener('drop', handleDrop, false);
|
||||
|
||||
function preventDefaults(e) {
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
|
||||
function highlight(e) {
|
||||
uploadArea.classList.add('border-indigo-500');
|
||||
}
|
||||
|
||||
function unhighlight(e) {
|
||||
uploadArea.classList.remove('border-indigo-500');
|
||||
}
|
||||
|
||||
function handleDrop(e) {
|
||||
const dt = e.dataTransfer;
|
||||
const files = dt.files;
|
||||
|
||||
if (files.length > 0) {
|
||||
document.getElementById('playnite_file').files = files;
|
||||
document.getElementById('playnite_file').dispatchEvent(new Event('change'));
|
||||
}
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
333
resources/views/admin/playnite/preview.twig
Normal file
333
resources/views/admin/playnite/preview.twig
Normal file
@@ -0,0 +1,333 @@
|
||||
{% 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 %}
|
||||
292
resources/views/admin/playnite/result.twig
Normal file
292
resources/views/admin/playnite/result.twig
Normal file
@@ -0,0 +1,292 @@
|
||||
{% 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 %}
|
||||
Reference in New Issue
Block a user