Stuff i guess ?

This commit is contained in:
Lars Behrends
2025-10-31 00:24:17 +01:00
parent db0fd4e728
commit 04140786a7
40 changed files with 5411 additions and 525 deletions

View 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 %}