This commit is contained in:
Lars Behrends
2025-10-18 22:03:30 +02:00
parent f4c1cfc164
commit ca2d3a6960
45 changed files with 4827 additions and 326 deletions

View File

@@ -0,0 +1,20 @@
// Import required modules
import Alpine from 'alpinejs';
import axios from 'axios';
// Initialize Alpine.js
window.Alpine = Alpine;
Alpine.start();
// Set up axios defaults
axios.defaults.headers.common['X-Requested-With'] = 'XMLHttpRequest';
axios.defaults.withCredentials = true;
// Global error handler
window.onerror = function(message, source, lineno, colno, error) {
console.error('Global error:', { message, source, lineno, colno, error });
return false;
};
// Export for potential future use
export { Alpine, axios };

View File

@@ -0,0 +1,126 @@
// Import Tailwind CSS
@tailwind base;
@tailwind components;
@tailwind utilities;
// Custom styles
body {
@apply antialiased text-gray-900 bg-gray-50;
}
// Card styles
.card {
@apply bg-white rounded-lg shadow overflow-hidden;
&-header {
@apply px-6 py-4 border-b border-gray-200;
h2 {
@apply text-lg font-medium text-gray-900;
}
}
&-body {
@apply p-6;
}
}
// Button styles
.btn {
@apply px-4 py-2 rounded-md text-sm font-medium transition-colors duration-150 focus:outline-none focus:ring-2 focus:ring-offset-2;
&-primary {
@apply bg-indigo-600 text-white hover:bg-indigo-700 focus:ring-indigo-500;
}
&-secondary {
@apply bg-gray-100 text-gray-700 hover:bg-gray-200 focus:ring-gray-500;
}
&-danger {
@apply bg-red-600 text-white hover:bg-red-700 focus:ring-red-500;
}
}
// Form styles
.form-group {
@apply mb-4;
label {
@apply block text-sm font-medium text-gray-700 mb-1;
}
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
@apply mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 sm:text-sm;
}
.form-error {
@apply mt-1 text-sm text-red-600;
}
}
// Alert styles
.alert {
@apply p-4 rounded-md;
&-success {
@apply bg-green-50 text-green-800;
}
&-error {
@apply bg-red-50 text-red-800;
}
&-info {
@apply bg-blue-50 text-blue-800;
}
&-warning {
@apply bg-yellow-50 text-yellow-800;
}
}
// Animation utilities
.fade-enter-active,
.fade-leave-active {
transition: opacity 0.2s ease;
}
.fade-enter-from,
.fade-leave-to {
opacity: 0;
}
// Responsive table
.table-responsive {
@apply overflow-x-auto;
table {
@apply min-w-full divide-y divide-gray-200;
thead {
@apply bg-gray-50;
th {
@apply px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider;
}
}
tbody {
@apply bg-white divide-y divide-gray-200;
tr {
@apply hover:bg-gray-50;
td {
@apply px-6 py-4 whitespace-nowrap text-sm text-gray-900;
}
}
}
}
}

View File

@@ -0,0 +1,248 @@
{% extends 'layouts/app.twig' %}
{% block content %}
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Admin Dashboard</h1>
<p class="mt-2 text-sm text-gray-600">Manage your media sources and synchronization</p>
</div>
<!-- Source Management -->
<div class="bg-white shadow rounded-lg mb-8">
<div class="px-6 py-4 border-b border-gray-200">
<h2 class="text-lg font-medium text-gray-900">Source Management</h2>
<p class="mt-1 text-sm text-gray-600">Configure and sync your media sources</p>
</div>
<div class="p-6">
<div class="grid grid-cols-1 gap-6 sm:grid-cols-2 lg:grid-cols-4">
{% for source in sources %}
<div class="border border-gray-200 rounded-lg p-4">
<div class="flex items-center justify-between mb-4">
<h3 class="text-sm font-medium text-gray-900">{{ source.display_name }}</h3>
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
{% if source.is_active %}
bg-green-100 text-green-800
{% else %}
bg-red-100 text-red-800
{% endif %}">
{% if source.is_active %}Active{% else %}Inactive{% endif %}
</span>
</div>
<div class="space-y-3">
<!-- Sync Buttons -->
<div class="flex space-x-2">
<button onclick="startSync({{ source.id }}, 'full')"
class="flex-1 bg-indigo-600 text-white px-3 py-1 rounded text-xs hover:bg-indigo-700 transition-colors">
Full Sync
</button>
<button onclick="startSync({{ source.id }}, 'incremental')"
class="flex-1 bg-gray-600 text-white px-3 py-1 rounded text-xs hover:bg-gray-700 transition-colors">
Incremental
</button>
</div>
<!-- Last Sync Status -->
{% if source.last_sync_at %}
<div class="text-xs text-gray-500">
Last sync: {{ source.last_sync_at|date('M j, Y H:i') }}
</div>
{% else %}
<div class="text-xs text-gray-400">
Never synced
</div>
{% endif %}
<!-- Sync Progress (hidden by default) -->
<div id="sync-progress-{{ source.id }}" class="hidden">
<div class="w-full bg-gray-200 rounded-full h-2">
<div id="sync-progress-bar-{{ source.id }}"
class="bg-indigo-600 h-2 rounded-full transition-all duration-300"
style="width: 0%"></div>
</div>
<div id="sync-status-{{ source.id }}" class="text-xs text-gray-600 mt-1">
Preparing sync...
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
</div>
<!-- Recent Sync Activity -->
<div class="bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<h2 class="text-lg font-medium text-gray-900">Recent Sync Activity</h2>
<p class="mt-1 text-sm text-gray-600">Latest synchronization logs and status</p>
</div>
<div class="overflow-hidden">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Source
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Type
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Status
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Progress
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Started
</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">
Duration
</th>
</tr>
</thead>
<tbody class="bg-white divide-y divide-gray-200">
{% for sync in recent_syncs %}
<tr class="hover:bg-gray-50">
<td class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900">
{{ sync.source_name }}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{{ sync.sync_type|title }}
</td>
<td class="px-6 py-4 whitespace-nowrap">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
{% if sync.status == 'completed' %}
bg-green-100 text-green-800
{% elseif sync.status == 'failed' %}
bg-red-100 text-red-800
{% elseif sync.status == 'running' %}
bg-yellow-100 text-yellow-800
{% else %}
bg-gray-100 text-gray-800
{% endif %}">
{{ sync.status|title }}
</span>
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{% if sync.total_items > 0 %}
{{ sync.processed_items }} / {{ sync.total_items }}
{% else %}
-
{% endif %}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{% if sync.started_at %}
{{ sync.started_at|date('M j, H:i') }}
{% else %}
-
{% endif %}
</td>
<td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
{% if sync.started_at and sync.completed_at %}
{{ sync.started_at|date('U') - sync.completed_at|date('U') }}s
{% else %}
-
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
<script>
let syncIntervals = {};
function startSync(sourceId, syncType) {
// Show progress indicator
const progressDiv = document.getElementById(`sync-progress-${sourceId}`);
const progressBar = document.getElementById(`sync-progress-bar-${sourceId}`);
const statusDiv = document.getElementById(`sync-status-${sourceId}`);
progressDiv.classList.remove('hidden');
progressBar.style.width = '0%';
statusDiv.textContent = 'Starting sync...';
// Start sync via API
fetch(`/admin/sync/${sourceId}?type=${syncType}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.getAttribute('content')
}
})
.then(response => response.json())
.then(data => {
if (data.success) {
// Start monitoring sync status
monitorSyncStatus(data.sync_log_id, sourceId, progressBar, statusDiv);
} else {
statusDiv.textContent = 'Error: ' + (data.message || 'Unknown error');
progressDiv.classList.add('hidden');
}
})
.catch(error => {
statusDiv.textContent = 'Error: ' + error.message;
progressDiv.classList.add('hidden');
});
}
function monitorSyncStatus(syncLogId, sourceId, progressBar, statusDiv) {
const interval = setInterval(() => {
fetch(`/admin/sync/status/${syncLogId}`)
.then(response => response.json())
.then(data => {
// Update progress
if (data.total_items > 0) {
const progress = (data.processed_items / data.total_items) * 100;
progressBar.style.width = progress + '%';
}
// Update status
statusDiv.textContent = getStatusMessage(data);
// Stop monitoring if sync is complete or failed
if (['completed', 'failed'].includes(data.status)) {
clearInterval(interval);
delete syncIntervals[sourceId];
if (data.status === 'completed') {
setTimeout(() => {
document.getElementById(`sync-progress-${sourceId}`).classList.add('hidden');
// Refresh page to show updated sync log
location.reload();
}, 2000);
}
}
})
.catch(error => {
console.error('Error monitoring sync:', error);
clearInterval(interval);
delete syncIntervals[sourceId];
});
}, 1000);
syncIntervals[sourceId] = interval;
}
function getStatusMessage(data) {
if (data.status === 'completed') {
return `Completed: ${data.new_items} new, ${data.updated_items} updated`;
} else if (data.status === 'failed') {
return 'Failed: ' + (data.errors.join(', ') || 'Unknown error');
} else if (data.status === 'running') {
return `Processing: ${data.processed_items}/${data.total_items} items`;
} else {
return data.message || 'Unknown status';
}
}
// Cleanup intervals on page unload
window.addEventListener('beforeunload', () => {
Object.values(syncIntervals).forEach(interval => clearInterval(interval));
});
</script>
{% endblock %}

View File

@@ -0,0 +1,78 @@
{% extends 'layouts/app.twig' %}
{% block content %}
<div class="min-h-screen flex items-center justify-center bg-gray-50 py-12 px-4 sm:px-6 lg:px-8">
<div class="max-w-md w-full space-y-8">
<div>
<h2 class="mt-6 text-center text-3xl font-extrabold text-gray-900">
Sign in to Media Collector
</h2>
<p class="mt-2 text-center text-sm text-gray-600">
Access your media dashboard
</p>
</div>
{% if error %}
<div class="bg-red-50 border border-red-200 rounded-md p-4">
<div class="text-sm text-red-800">{{ error }}</div>
</div>
{% endif %}
<form class="mt-8 space-y-6" action="/login" method="POST">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div class="rounded-md shadow-sm -space-y-px">
<div>
<label for="username" class="sr-only">Username</label>
<input id="username" name="username" type="text" required
class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-t-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
placeholder="Username">
</div>
<div>
<label for="password" class="sr-only">Password</label>
<input id="password" name="password" type="password" required
class="appearance-none rounded-none relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 rounded-b-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm"
placeholder="Password">
</div>
</div>
<div class="flex items-center justify-between">
<div class="flex items-center">
<input id="remember-me" name="remember-me" type="checkbox"
class="h-4 w-4 text-indigo-600 focus:ring-indigo-500 border-gray-300 rounded">
<label for="remember-me" class="ml-2 block text-sm text-gray-900">
Remember me
</label>
</div>
<div class="text-sm">
<a href="#" class="font-medium text-indigo-600 hover:text-indigo-500">
Forgot your password?
</a>
</div>
</div>
<div>
<button type="submit"
class="group relative w-full flex justify-center py-2 px-4 border border-transparent 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">
<span class="absolute left-0 inset-y-0 flex items-center pl-3">
<svg class="h-5 w-5 text-indigo-500 group-hover:text-indigo-400" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
<path fill-rule="evenodd" d="M5 9V7a5 5 0 0110 0v2a2 2 0 012 2v5a2 2 0 01-2 2H5a2 2 0 01-2-2v-5a2 2 0 012-2zm8-2v2H7V7a3 3 0 016 0z" clip-rule="evenodd" />
</svg>
</span>
Sign in
</button>
</div>
<div class="text-center">
<p class="text-sm text-gray-600">
Don't have an account?
<a href="#" class="font-medium text-indigo-600 hover:text-indigo-500">
Contact your administrator
</a>
</p>
</div>
</form>
</div>
</div>
{% endblock %}

View File

@@ -0,0 +1,316 @@
{% extends 'layouts/app.twig' %}
{% block content %}
<div class="mb-8">
<h1 class="text-3xl font-bold text-gray-900">Dashboard</h1>
<p class="mt-2 text-sm text-gray-600">Overview of your media collection</p>
</div>
{% if error %}
<div class="mb-6 bg-red-50 border border-red-200 rounded-md p-4">
<div class="text-sm text-red-800">{{ error }}</div>
</div>
{% endif %}
<!-- Stats Grid -->
<div class="grid grid-cols-1 gap-5 mt-6 sm:grid-cols-2 lg:grid-cols-4">
<!-- Total Media -->
<div class="overflow-hidden bg-white rounded-lg shadow">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-indigo-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 20h16a1 1 0 001-1V5a1 1 0 00-1-1H4a1 1 0 00-1 1v14a1 1 0 001 1z"></path>
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Total Media</dt>
<dd>
<div class="text-lg font-medium text-gray-900">{{ stats.total_media|number_format }}</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
<!-- Games -->
<div class="overflow-hidden bg-white rounded-lg shadow">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Games</dt>
<dd>
<div class="text-lg font-medium text-gray-900">{{ stats.total_games|number_format }}</div>
<div class="text-xs text-gray-500">{{ stats.favorite_games }} favorites</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
<!-- Movies & TV -->
<div class="overflow-hidden bg-white rounded-lg shadow">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 20h16a1 1 0 001-1V5a1 1 0 00-1-1H4a1 1 0 00-1 1v14a1 1 0 001 1z"></path>
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Movies & TV</dt>
<dd>
<div class="text-lg font-medium text-gray-900">
{{ (stats.total_movies + stats.total_tv_shows)|number_format }}
</div>
<div class="text-xs text-gray-500">{{ stats.watched_movies }} watched</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
<!-- Music -->
<div class="overflow-hidden bg-white rounded-lg shadow">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-yellow-500" fill="none" stroke="currentColor" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19V6l12-3v13M9 19c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zm12-3c0 1.105-1.343 2-3 2s-3-.895-3-2 1.343-2 3-2 3 .895 3 2zM9 10l12-3"></path>
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Music</dt>
<dd>
<div class="text-lg font-medium text-gray-900">{{ stats.total_music|number_format }}</div>
<div class="text-xs text-gray-500">{{ stats.favorite_music }} favorites</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
<!-- Additional Stats -->
<div class="mt-8 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3">
<!-- Total Playtime -->
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Total Playtime</dt>
<dd>
<div class="text-lg font-medium text-gray-900">
{% if stats.total_playtime %}
{{ (stats.total_playtime / 60)|round }}h
{% else %}
0h
{% endif %}
</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
<!-- Total Episodes -->
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-purple-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"></path>
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">TV Episodes</dt>
<dd>
<div class="text-lg font-medium text-gray-900">{{ stats.total_episodes|number_format }}</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
<!-- Sync Status -->
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="p-5">
<div class="flex items-center">
<div class="flex-shrink-0">
<svg class="w-6 h-6 text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"></path>
</svg>
</div>
<div class="ml-5 w-0 flex-1">
<dl>
<dt class="text-sm font-medium text-gray-500 truncate">Sync Status</dt>
<dd>
<div class="text-lg font-medium text-gray-900">
{% if sync_stats.successful_syncs > 0 %}
{{ sync_stats.successful_syncs }}/{{ sync_stats.total_syncs }} Success
{% else %}
No syncs yet
{% endif %}
</div>
</dd>
</dl>
</div>
</div>
</div>
</div>
</div>
<!-- Recent Activity -->
<div class="mt-8">
<h2 class="text-xl font-medium text-gray-900">Recent Activity</h2>
<!-- Recent Games -->
{% if recent_games %}
<div class="mt-4">
<h3 class="text-lg font-medium text-gray-900 mb-3">Recently Played Games</h3>
<div class="bg-white shadow overflow-hidden sm:rounded-md">
<ul class="divide-y divide-gray-200">
{% for game in recent_games %}
<li class="px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center">
{% if game.image_url %}
<img class="h-10 w-10 rounded-lg object-cover" src="{{ game.image_url }}" alt="">
{% else %}
<div class="h-10 w-10 rounded-lg bg-gray-200 flex items-center justify-center">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.75 17L9 20l-1 1h8l-1-1-.75-3M3 13h18M5 17h14a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v10a2 2 0 002 2z"></path>
</svg>
</div>
{% endif %}
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">{{ game.title }}</p>
<p class="text-sm text-gray-500">{{ game.source_name }}</p>
</div>
</div>
<div class="text-sm text-gray-500">
{% if game.playtime_minutes %}
{{ (game.playtime_minutes / 60)|round }}h played
{% endif %}
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<!-- Recent Movies -->
{% if recent_movies %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Recently Watched Movies</h3>
<div class="bg-white shadow overflow-hidden sm:rounded-md">
<ul class="divide-y divide-gray-200">
{% for movie in recent_movies %}
<li class="px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center">
{% if movie.poster_url %}
<img class="h-10 w-10 rounded-lg object-cover" src="{{ movie.poster_url }}" alt="">
{% else %}
<div class="h-10 w-10 rounded-lg bg-gray-200 flex items-center justify-center">
<svg class="w-5 h-5 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4v16M17 4v16M3 8h4m10 0h4M3 12h18M3 16h4m10 0h4M4 20h16a1 1 0 001-1V5a1 1 0 00-1-1H4a1 1 0 00-1 1v14a1 1 0 001 1z"></path>
</svg>
</div>
{% endif %}
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">{{ movie.title }}</p>
<p class="text-sm text-gray-500">{{ movie.source_name }}</p>
</div>
</div>
<div class="text-sm text-gray-500">
{% if movie.watch_count %}
Watched {{ movie.watch_count }} times
{% endif %}
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
<!-- Recent Syncs -->
{% if recent_syncs %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Recent Sync Activities</h3>
<div class="bg-white shadow overflow-hidden sm:rounded-md">
<ul class="divide-y divide-gray-200">
{% for sync in recent_syncs %}
<li class="px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center">
<div class="flex-shrink-0">
{% if sync.status == 'completed' %}
<svg class="w-5 h-5 text-green-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"></path>
</svg>
{% elseif sync.status == 'failed' %}
<svg class="w-5 h-5 text-red-400" fill="currentColor" viewBox="0 0 20 20">
<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"></path>
</svg>
{% else %}
<svg class="w-5 h-5 text-yellow-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M4 4a2 2 0 00-2 2v8a2 2 0 002 2h12a2 2 0 002-2V6a2 2 0 00-2-2H4zm2 6a2 2 0 114 0 2 2 0 01-4 0zm8 0a2 2 0 114 0 2 2 0 01-4 0z" clip-rule="evenodd"></path>
</svg>
{% endif %}
</div>
<div class="ml-3">
<p class="text-sm font-medium text-gray-900">{{ sync.source_name }}</p>
<p class="text-sm text-gray-500">{{ sync.sync_type|title }} sync</p>
</div>
</div>
<div class="text-sm text-gray-500">
{{ sync.processed_items }} items • {{ sync.created_at|date('M j, Y') }}
</div>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endif %}
{% if not recent_games and not recent_movies and not recent_syncs %}
<div class="mt-4 bg-white shadow overflow-hidden sm:rounded-md">
<div class="p-6 text-center">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">No recent activity</h3>
<p class="mt-1 text-sm text-gray-500">Start adding media to see your activity here.</p>
</div>
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -0,0 +1,76 @@
{% extends "layouts/app.twig" %}
{% block content %}
<div class="px-4 py-6 sm:px-0">
<div class="flex justify-between items-center mb-6">
<h1 class="text-3xl font-bold text-gray-900">Games</h1>
<div class="text-sm text-gray-500">
{{ games|length }} games from {{ games|reduce((carry, game) => carry + game.platform_count, 0) }} platforms
</div>
</div>
{% if games is empty %}
<div class="text-center py-12">
<svg class="mx-auto h-12 w-12 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>
<h3 class="mt-2 text-sm font-medium text-gray-900">No games found</h3>
<p class="mt-1 text-sm text-gray-500">Start syncing your gaming libraries to see your games here.</p>
</div>
{% else %}
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
{% for game in games %}
<div class="bg-white overflow-hidden shadow rounded-lg">
<div class="p-6">
<div class="flex items-center">
<div class="flex-shrink-0">
{% if game.image_url %}
<img class="h-12 w-12 rounded-lg object-cover" src="{{ game.image_url }}" 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>
<div class="ml-4 flex-1">
<h3 class="text-lg font-medium text-gray-900 truncate">
<a href="{{ path_for('games.show', {'game_key': game.game_key}) }}" class="hover:text-indigo-600">
{{ game.title }}
</a>
</h3>
<p class="text-sm text-gray-500">
{{ game.platform_count }} platform{{ game.platform_count > 1 ? 's' : '' }}
{% if game.platforms %}
<span class="ml-2 inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800">
{{ game.platforms|join(', ') }}
</span>
{% endif %}
</p>
</div>
</div>
<div class="mt-4">
<div class="flex items-center justify-between text-sm text-gray-500">
<span>{{ game.total_playtime|format_duration }} played</span>
{% if game.max_completion > 0 %}
<span>{{ game.max_completion }}% complete</span>
{% endif %}
</div>
{% if game.genres %}
<div class="mt-2 flex flex-wrap gap-1">
{% for genre in game.genres %}
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-indigo-100 text-indigo-800">
{{ genre }}
</span>
{% endfor %}
</div>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
{% endif %}
</div>
{% endblock %}

View File

@@ -0,0 +1,212 @@
{% extends "layouts/app.twig" %}
{% block content %}
<div class="px-4 py-6 sm:px-0">
<!-- Game Header -->
<div class="bg-white shadow rounded-lg mb-6">
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex items-center justify-between">
<div class="flex items-center">
{% if main_game.image_url %}
<img class="h-16 w-16 rounded-lg object-cover mr-4" src="{{ main_game.image_url }}" alt="{{ main_game.title }}">
{% else %}
<div class="h-16 w-16 rounded-lg bg-gray-200 flex items-center justify-center mr-4">
<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>
<h1 class="text-2xl font-bold text-gray-900">{{ main_game.title }}</h1>
<div class="flex items-center space-x-4 mt-1">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
{{ platform_versions|length }} platform{{ platform_versions|length > 1 ? 's' : '' }}
</span>
{% if main_game.genre %}
<span class="text-sm text-gray-500">{{ main_game.genre }}</span>
{% endif %}
</div>
</div>
</div>
<a href="{{ path_for('games.index') }}" class="text-indigo-600 hover:text-indigo-900 text-sm font-medium">
← Back to Games
</a>
</div>
</div>
</div>
<!-- Platform Tabs -->
<div class="bg-white shadow rounded-lg">
<div class="border-b border-gray-200">
<nav class="-mb-px flex space-x-8 px-6" aria-label="Tabs">
{% for version in platform_versions %}
<button
class="platform-tab whitespace-nowrap py-4 px-1 border-b-2 font-medium text-sm {{ loop.first ? 'border-indigo-500 text-indigo-600' : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300' }}"
data-platform="{{ version.platform }}"
data-source="{{ version.source_id }}"
>
{{ version.platform }}
{% if version.source_name %}
<span class="ml-1 text-xs text-gray-400">({{ version.source_name }})</span>
{% endif %}
</button>
{% endfor %}
</nav>
</div>
<!-- Platform Content -->
{% for version in platform_versions %}
<div class="platform-content {{ loop.first ? '' : 'hidden' }}" data-platform="{{ version.platform }}" data-source="{{ version.source_id }}">
<div class="px-6 py-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Game Info -->
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">Game Information</h3>
<dl class="grid grid-cols-1 gap-x-4 gap-y-4 sm:grid-cols-2">
{% if version.developer %}
<div>
<dt class="text-sm font-medium text-gray-500">Developer</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.developer }}</dd>
</div>
{% endif %}
{% if version.publisher %}
<div>
<dt class="text-sm font-medium text-gray-500">Publisher</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.publisher }}</dd>
</div>
{% endif %}
{% if version.release_date %}
<div>
<dt class="text-sm font-medium text-gray-500">Release Date</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.release_date|date('M j, Y') }}</dd>
</div>
{% endif %}
<div>
<dt class="text-sm font-medium text-gray-500">Playtime</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.playtime_minutes|format_duration }}</dd>
</div>
{% if version.rating %}
<div>
<dt class="text-sm font-medium text-gray-500">Rating</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.rating }}/10</dd>
</div>
{% endif %}
{% if version.completion_percentage > 0 %}
<div>
<dt class="text-sm font-medium text-gray-500">Completion</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.completion_percentage }}%</dd>
</div>
{% endif %}
</dl>
</div>
<!-- Platform Stats -->
<div>
<h3 class="text-lg font-medium text-gray-900 mb-4">Platform Statistics</h3>
<dl class="grid grid-cols-1 gap-x-4 gap-y-4">
<div>
<dt class="text-sm font-medium text-gray-500">Source</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.source_name }}</dd>
</div>
{% if version.last_played_at %}
<div>
<dt class="text-sm font-medium text-gray-500">Last Played</dt>
<dd class="mt-1 text-sm text-gray-900">{{ version.last_played_at|date('M j, Y') }}</dd>
</div>
{% endif %}
{% if version.is_installed %}
<div>
<dt class="text-sm font-medium text-gray-500">Status</dt>
<dd class="mt-1">
<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 version.is_favorite %}
<div>
<dt class="text-sm font-medium text-gray-500">Favorite</dt>
<dd class="mt-1">
<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 %}
</dl>
<!-- Platform-specific metadata -->
{% set metadata = version.metadata|json_decode %}
{% if metadata %}
<div class="mt-6">
<h4 class="text-sm font-medium text-gray-900 mb-2">Platform Details</h4>
<div class="bg-gray-50 rounded-md p-3">
<dl class="grid grid-cols-1 gap-x-4 gap-y-2 text-sm">
{% if metadata.appid %}
<div>
<dt class="font-medium text-gray-500">App ID</dt>
<dd class="text-gray-900">{{ metadata.appid }}</dd>
</div>
{% endif %}
{% if metadata.playtime_windows or metadata.playtime_mac or metadata.playtime_linux %}
<div>
<dt class="font-medium text-gray-500">Platform Playtime</dt>
<dd class="text-gray-900">
{% if metadata.playtime_windows %}<span>Windows: {{ metadata.playtime_windows|format_duration }}</span>{% endif %}
{% if metadata.playtime_mac %}<span class="ml-2">Mac: {{ metadata.playtime_mac|format_duration }}</span>{% endif %}
{% if metadata.playtime_linux %}<span class="ml-2">Linux: {{ metadata.playtime_linux|format_duration }}</span>{% endif %}
</dd>
</div>
{% endif %}
</dl>
</div>
</div>
{% endif %}
</div>
</div>
{% if version.description %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-2">Description</h3>
<p class="text-sm text-gray-600">{{ version.description }}</p>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
<script>
// Platform tab switching functionality
document.addEventListener('DOMContentLoaded', function() {
const tabs = document.querySelectorAll('.platform-tab');
const contents = document.querySelectorAll('.platform-content');
tabs.forEach(tab => {
tab.addEventListener('click', function() {
const platform = this.dataset.platform;
const source = this.dataset.source;
// Update tab styles
tabs.forEach(t => {
t.classList.remove('border-indigo-500', 'text-indigo-600');
t.classList.add('border-transparent', 'text-gray-500');
});
this.classList.remove('border-transparent', 'text-gray-500');
this.classList.add('border-indigo-500', 'text-indigo-600');
// Update content visibility
contents.forEach(content => {
if (content.dataset.platform === platform && content.dataset.source === source) {
content.classList.remove('hidden');
} else {
content.classList.add('hidden');
}
});
});
});
});
</script>
{% endblock %}

View File

@@ -0,0 +1,74 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{ title }} - Media Collector</title>
{% if app_env == 'production' %}
<link rel="stylesheet" href="{{ base_url() }}/build/assets/app-{{ manifest['resources/js/app.js'].file|replace({'.js': '.css'}) }}">
{% else %}
<link rel="stylesheet" href="{{ base_url() }}/app.css">
{% endif %}
<!-- Favicon -->
<link rel="icon" type="image/svg+xml" href="{{ base_url() }}/favicon.svg">
<meta name="csrf-token" content="{{ csrf_token() }}">
</head>
<body class="bg-gray-100">
<!-- Navigation -->
<nav class="bg-indigo-600 text-white shadow-lg">
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
<div class="flex justify-between h-16">
<div class="flex">
<div class="flex-shrink-0 flex items-center">
<a href="{{ path_for('home') }}" class="text-xl font-bold">Media Collector</a>
</div>
<div class="hidden sm:ml-6 sm:flex sm:space-x-8">
<a href="{{ path_for('home') }}" class="border-indigo-500 text-white inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Dashboard</a>
<a href="{{ path_for('games.index') }}" class="border-transparent text-indigo-100 hover:border-indigo-300 hover:text-white inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Games</a>
<a href="{{ path_for('movies.index') }}" class="border-transparent text-indigo-100 hover:border-indigo-300 hover:text-white inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Movies</a>
<a href="{{ path_for('tvshows.index') }}" class="border-transparent text-indigo-100 hover:border-indigo-300 hover:text-white inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">TV Shows</a>
<a href="{{ path_for('music.index') }}" class="border-transparent text-indigo-100 hover:border-indigo-300 hover:text-white inline-flex items-center px-1 pt-1 border-b-2 text-sm font-medium">Music</a>
</div>
</div>
<div class="flex items-center space-x-4">
<!-- Admin Link (only for admins) -->
{% if is_admin() %}
<a href="/admin" class="text-indigo-100 hover:text-white text-sm font-medium">Admin</a>
{% endif %}
<!-- User Menu -->
<div class="relative" x-data="{ open: false }">
<button @click="open = !open" class="text-indigo-100 hover:text-white flex items-center space-x-1 text-sm font-medium">
<span>{{ current_user().username }}</span>
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"></path>
</svg>
</button>
<div x-show="open" @click.away="open = false" class="absolute right-0 mt-2 w-48 bg-white rounded-md shadow-lg py-1 z-50">
<div class="px-4 py-2 text-sm text-gray-700 border-b border-gray-200">
Signed in as<br>
<span class="font-medium">{{ current_user().username }}</span>
</div>
<a href="/logout" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100">Sign out</a>
</div>
</div>
</div>
</div>
</div>
</nav>
<!-- Page Content -->
<main class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
{% block content %}{% endblock %}
</main>
<!-- Scripts -->
{% if app_env == 'production' %}
<script type="module" src="{{ base_url() }}/build/assets/{{ manifest['resources/js/app.js'].file }}"></script>
{% else %}
<script type="module" src="{{ base_url() }}/resources/js/app.js"></script>
{% endif %}
</body>
</html>