mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
Stuff i guess ?
This commit is contained in:
222
resources/views/admin/shows/edit.twig
Normal file
222
resources/views/admin/shows/edit.twig
Normal file
@@ -0,0 +1,222 @@
|
||||
{% extends 'admin/layout.twig' %}
|
||||
|
||||
{% block title %}{{ title }} - Admin Panel - MediaLib{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h1 class="h3 mb-0">{{ title }}</h1>
|
||||
<p class="text-muted mb-0">{{ show ? 'Edit TV show details' : 'Add a new TV show to your library' }}</p>
|
||||
</div>
|
||||
<a href="{{ path_for('admin.shows.index') }}" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-left me-2"></i>Back to Shows
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
{% if flash.getMessage('success') %}
|
||||
<div class="alert alert-success">
|
||||
{{ flash.getMessage('success') | first }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">Title *</label>
|
||||
<input type="text" class="form-control" id="title" name="title" required
|
||||
value="{{ old.title ?? show.title ?? '' }}">
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="first_air_date" class="form-label">First Air Date</label>
|
||||
<input type="date" class="form-control" id="first_air_date" name="first_air_date"
|
||||
value="{{ old.first_air_date ?? (show.first_air_date ? show.first_air_date|date('Y-m-d') : '') }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="status" class="form-label">Status</label>
|
||||
<select class="form-select" id="status" name="status">
|
||||
<option value="Returning Series" {{ (old.status ?? show.status ?? '') == 'Returning Series' ? 'selected' : '' }}>Returning Series</option>
|
||||
<option value="Ended" {{ (old.status ?? show.status ?? '') == 'Ended' ? 'selected' : '' }}>Ended</option>
|
||||
<option value="In Production" {{ (old.status ?? show.status ?? '') == 'In Production' ? 'selected' : '' }}>In Production</option>
|
||||
<option value="Planned" {{ (old.status ?? show.status ?? '') == 'Planned' ? 'selected' : '' }}>Planned</option>
|
||||
<option value="Canceled" {{ (old.status ?? show.status ?? '') == 'Canceled' ? 'selected' : '' }}>Canceled</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="number_of_seasons" class="form-label">Number of Seasons</label>
|
||||
<input type="number" class="form-control" id="number_of_seasons" name="number_of_seasons" min="0"
|
||||
value="{{ old.number_of_seasons ?? show.number_of_seasons ?? '0' }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="number_of_episodes" class="form-label">Number of Episodes</label>
|
||||
<input type="number" class="form-control" id="number_of_episodes" name="number_of_episodes" min="0"
|
||||
value="{{ old.number_of_episodes ?? show.number_of_episodes ?? '0' }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="network" class="form-label">Network</label>
|
||||
<input type="text" class="form-control" id="network" name="network"
|
||||
value="{{ old.network ?? show.network ?? '' }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="mb-3">
|
||||
<label for="vote_average" class="form-label">Rating (0-10)</label>
|
||||
<input type="number" class="form-control" id="vote_average" name="vote_average"
|
||||
min="0" max="10" step="0.1"
|
||||
value="{{ old.vote_average ?? show.vote_average ?? '' }}">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="genres" class="form-label">Genres (comma-separated)</label>
|
||||
<input type="text" class="form-control" id="genres" name="genres"
|
||||
value="{{ old.genres ?? (show.genres ? show.genres|join(', ') : '') }}">
|
||||
<div class="form-text">Example: Drama, Crime, Mystery</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="overview" class="form-label">Overview</label>
|
||||
<textarea class="form-control" id="overview" name="overview" rows="4">{{ old.overview ?? show.overview ?? '' }}</textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="poster_url" class="form-label">Poster URL</label>
|
||||
<input type="text" class="form-control" id="poster_url" name="poster_url"
|
||||
value="{{ old.poster_url ?? show.poster_url ?? '' }}">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="backdrop_url" class="form-label">Backdrop URL</label>
|
||||
<input type="text" class="form-control" id="backdrop_url" name="backdrop_url"
|
||||
value="{{ old.backdrop_url ?? show.backdrop_url ?? '' }}">
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-between">
|
||||
<button type="submit" class="btn btn-primary">
|
||||
<i class="bi bi-save me-2"></i>Save Changes
|
||||
</button>
|
||||
|
||||
{% if show %}
|
||||
<button type="button" class="btn btn-outline-danger" data-bs-toggle="modal" data-bs-target="#deleteModal">
|
||||
<i class="bi bi-trash me-2"></i>Delete Show
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card mb-4">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Poster Preview</h5>
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
<div id="posterPreview" class="mb-3" style="min-height: 300px; display: flex; align-items: center; justify-content: center; background-color: #f8f9fa;">
|
||||
{% if show and show.poster_url %}
|
||||
<img src="{{ show.poster_url }}" alt="Poster" class="img-fluid" style="max-height: 300px;">
|
||||
{% else %}
|
||||
<div class="text-muted">No poster available</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h5 class="mb-0">Metadata</h5>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="mb-2">
|
||||
<span class="text-muted">Created:</span>
|
||||
<span class="float-end">{{ show ? show.created_at|date('Y-m-d H:i') : 'New' }}</span>
|
||||
</div>
|
||||
<div class="mb-2">
|
||||
<span class="text-muted">Last Updated:</span>
|
||||
<span class="float-end">{{ show ? show.updated_at|date('Y-m-d H:i') : 'N/A' }}</span>
|
||||
</div>
|
||||
{% if show and show.tmdb_id %}
|
||||
<div class="mt-3">
|
||||
<a href="https://www.themoviedb.org/tv/{{ show.tmdb_id }}" target="_blank" class="btn btn-sm btn-outline-primary w-100">
|
||||
<i class="bi bi-box-arrow-up-right me-1"></i> View on TMDb
|
||||
</a>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Delete Confirmation Modal -->
|
||||
{% if show %}
|
||||
<div class="modal fade" id="deleteModal" tabindex="-1" aria-labelledby="deleteModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="deleteModalLabel">Confirm Deletion</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Are you sure you want to delete "{{ show.title }}"? This action cannot be undone.</p>
|
||||
<p class="text-danger"><strong>Warning:</strong> This will remove all data associated with this show, including all seasons and episodes.</p>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
||||
<form action="{{ path_for('admin.shows.delete', {id: show.id}) }}" method="post" class="d-inline">
|
||||
<input type="hidden" name="_METHOD" value="DELETE">
|
||||
<button type="submit" class="btn btn-danger">Delete Show</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script>
|
||||
// Preview poster when URL changes
|
||||
document.getElementById('poster_url').addEventListener('input', function() {
|
||||
const preview = document.getElementById('posterPreview');
|
||||
const url = this.value.trim();
|
||||
|
||||
if (url) {
|
||||
preview.innerHTML = `<img src="${url}" alt="Poster Preview" class="img-fluid" style="max-height: 300px;">`;
|
||||
} else {
|
||||
preview.innerHTML = '<div class="text-muted">No poster available</div>';
|
||||
}
|
||||
});
|
||||
|
||||
// Handle form submission
|
||||
document.querySelector('form').addEventListener('submit', function(e) {
|
||||
const title = document.getElementById('title').value.trim();
|
||||
if (!title) {
|
||||
e.preventDefault();
|
||||
alert('Title is required');
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
202
resources/views/admin/shows/index.twig
Normal file
202
resources/views/admin/shows/index.twig
Normal file
@@ -0,0 +1,202 @@
|
||||
{% extends 'admin/layout.twig' %}
|
||||
|
||||
{% block title %}Manage TV Shows - Admin Panel - MediaLib{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between align-items-center mb-4">
|
||||
<div>
|
||||
<h1 class="h3 mb-0">Manage TV Shows</h1>
|
||||
<p class="text-muted mb-0">View and manage your TV show library</p>
|
||||
</div>
|
||||
<a href="{{ path_for('admin.shows.create') }}" class="btn btn-primary">
|
||||
<i class="bi bi-plus-circle me-2"></i>Add New Show
|
||||
</a>
|
||||
</div>
|
||||
|
||||
{# Search and Filters #}
|
||||
<div class="card mb-4">
|
||||
<div class="card-body">
|
||||
<form method="get" action="{{ path_for('admin.shows') }}" class="mb-0">
|
||||
<div class="row g-3">
|
||||
<div class="col-md-4">
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="bi bi-search"></i></span>
|
||||
<input type="text" name="search" class="form-control" placeholder="Search shows..." value="{{ filters.search }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select name="genre" class="form-select">
|
||||
<option value="">All Genres</option>
|
||||
{% for genre in genres %}
|
||||
<option value="{{ genre }}" {{ filters.genre == genre ? 'selected' : '' }}>{{ genre }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select name="status" class="form-select">
|
||||
<option value="">All Statuses</option>
|
||||
{% for status in statuses %}
|
||||
<option value="{{ status }}" {{ filters.status == status ? 'selected' : '' }}>{{ status }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<select name="sort" class="form-select">
|
||||
<option value="title_asc" {{ filters.sort == 'title_asc' ? 'selected' : '' }}>Title (A-Z)</option>
|
||||
<option value="title_desc" {{ filters.sort == 'title_desc' ? 'selected' : '' }}>Title (Z-A)</option>
|
||||
<option value="rating_desc" {{ filters.sort == 'rating_desc' ? 'selected' : '' }}>Highest Rated</option>
|
||||
<option value="rating_asc" {{ filters.sort == 'rating_asc' ? 'selected' : '' }}>Lowest Rated</option>
|
||||
<option value="newest" {{ filters.sort == 'newest' ? 'selected' : '' }}>Newest First</option>
|
||||
<option value="oldest" {{ filters.sort == 'oldest' ? 'selected' : '' }}>Oldest First</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2">
|
||||
<div class="d-flex">
|
||||
<button type="submit" class="btn btn-primary me-2">
|
||||
<i class="bi bi-funnel me-1"></i> Apply
|
||||
</button>
|
||||
<a href="{{ path_for('admin.shows') }}" class="btn btn-outline-secondary">
|
||||
<i class="bi bi-arrow-counterclockwise"></i>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
{% if flash.getMessage('success') %}
|
||||
<div class="alert alert-success">
|
||||
{{ flash.getMessage('success') | first }}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Poster</th>
|
||||
<th>Title</th>
|
||||
<th>First Aired</th>
|
||||
<th>Seasons</th>
|
||||
<th>Rating</th>
|
||||
<th>Status</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for show in shows %}
|
||||
<tr>
|
||||
<td>
|
||||
{% if show.poster_path %}
|
||||
<img src="{{ show.poster_path }}" alt="{{ show.title }}" style="width: 50px; height: 75px; object-fit: cover;">
|
||||
{% else %}
|
||||
<div class="bg-light d-flex align-items-center justify-content-center" style="width: 50px; height: 75px;">
|
||||
<i class="bi bi-tv text-muted"></i>
|
||||
</div>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="fw-medium">{{ show.title }}</div>
|
||||
<small class="text-muted">{{ show.network ? show.network : 'N/A' }}</small>
|
||||
</td>
|
||||
<td>{{ show.first_air_date ? show.first_air_date|date('Y') : 'N/A' }}</td>
|
||||
<td>{{ show.number_of_seasons ?? '0' }}</td>
|
||||
<td>
|
||||
{% if show.vote_average %}
|
||||
<span class="badge bg-primary">{{ show.vote_average|number_format(1) }}/10</span>
|
||||
{% else %}
|
||||
<span class="text-muted">N/A</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if show.status == 'Returning Series' %}
|
||||
<span class="badge bg-success">Ongoing</span>
|
||||
{% elseif show.status == 'Ended' %}
|
||||
<span class="badge bg-secondary">Ended</span>
|
||||
{% else %}
|
||||
<span class="badge bg-info">{{ show.status ?? 'N/A' }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="{{ path_for('admin.shows.edit', {id: show.id}) }}" class="btn btn-outline-primary">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
<form action="{{ path_for('admin.shows.delete', {id: show.id}) }}" method="post" class="d-inline" onsubmit="return confirm('Are you sure you want to delete this show?');">
|
||||
<input type="hidden" name="_METHOD" value="DELETE">
|
||||
<button type="submit" class="btn btn-outline-danger">
|
||||
<i class="bi bi-trash"></i>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="7" class="text-center py-4">
|
||||
<div class="text-muted">No TV shows found. <a href="{{ path_for('admin.shows.create') }}">Add your first show</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
{% if pagination.total > 1 %}
|
||||
<div class="d-flex justify-content-between align-items-center mt-4">
|
||||
<div class="text-muted">
|
||||
Showing {{ pagination.from }} to {{ pagination.to }} of {{ pagination.total_items }} shows
|
||||
</div>
|
||||
<nav>
|
||||
<ul class="pagination mb-0">
|
||||
{% if pagination.current > 1 %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ path_for('admin.shows', {'page': pagination.current - 1, 'search': filters.search, 'genre': filters.genre, 'status': filters.status, 'sort': filters.sort}) }}" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link" aria-hidden="true">«</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
|
||||
{% for i in 1..pagination.total %}
|
||||
{% if i == pagination.current %}
|
||||
<li class="page-item active" aria-current="page">
|
||||
<span class="page-link">{{ i }}</span>
|
||||
</li>
|
||||
{% else %}
|
||||
{% if (i >= pagination.current - 2 and i <= pagination.current + 2) or i == 1 or i == pagination.total %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ path_for('admin.shows', {'page': i, 'search': filters.search, 'genre': filters.genre, 'status': filters.status, 'sort': filters.sort}) }}">{{ i }}</a>
|
||||
</li>
|
||||
{% elseif (i == pagination.current - 3 or i == pagination.current + 3) %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link">...</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
|
||||
{% if pagination.current < pagination.total %}
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="{{ path_for('admin.shows', {'page': pagination.current + 1, 'search': filters.search, 'genre': filters.genre, 'status': filters.status, 'sort': filters.sort}) }}" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled">
|
||||
<span class="page-link" aria-hidden="true">»</span>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user