mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-14 08:06:47 +02:00
197 lines
9.9 KiB
Twig
197 lines
9.9 KiB
Twig
{% 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">{{ movie ? 'Edit movie details' : 'Add a new movie to your library' }}</p>
|
|
</div>
|
|
<a href="{{ path_for('admin.movies.index') }}" class="btn btn-outline-secondary">
|
|
<i class="bi bi-arrow-left me-2"></i>Back to Movies
|
|
</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 ?? movie.title ?? '' }}">
|
|
</div>
|
|
|
|
<div class="row">
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label for="release_date" class="form-label">Release Date</label>
|
|
<input type="date" class="form-control" id="release_date" name="release_date"
|
|
value="{{ old.release_date ?? (movie.release_date ? movie.release_date|date('Y-m-d') : '') }}">
|
|
</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<div class="mb-3">
|
|
<label for="runtime" class="form-label">Runtime (minutes)</label>
|
|
<input type="number" class="form-control" id="runtime" name="runtime" min="1"
|
|
value="{{ old.runtime ?? movie.runtime ?? '' }}">
|
|
</div>
|
|
</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 ?? movie.overview ?? '' }}</textarea>
|
|
</div>
|
|
|
|
<div class="row">
|
|
<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 ?? movie.vote_average ?? '' }}">
|
|
</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="released" {{ (old.status ?? movie.status ?? '') == 'released' ? 'selected' : '' }}>Released</option>
|
|
<option value="upcoming" {{ (old.status ?? movie.status ?? '') == 'upcoming' ? 'selected' : '' }}>Upcoming</option>
|
|
<option value="post_production" {{ (old.status ?? movie.status ?? '') == 'post_production' ? 'selected' : '' }}>Post Production</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</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 ?? movie.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 ?? movie.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 movie %}
|
|
<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 Movie
|
|
</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 movie and movie.poster_url %}
|
|
<img src="/images/{{ movie.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">{{ movie ? movie.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">{{ movie ? movie.updated_at|date('Y-m-d H:i') : 'N/A' }}</span>
|
|
</div>
|
|
{% if movie and movie.tmdb_id %}
|
|
<div class="mt-3">
|
|
<a href="https://www.themoviedb.org/movie/{{ movie.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 movie %}
|
|
<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 "{{ movie.title }}"? This action cannot be undone.</p>
|
|
<p class="text-danger"><strong>Warning:</strong> This will remove all data associated with this movie.</p>
|
|
</div>
|
|
<div class="modal-footer">
|
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancel</button>
|
|
<form action="{{ path_for('admin.movies.delete', {id: movie.id}) }}" method="post" class="d-inline">
|
|
<input type="hidden" name="_METHOD" value="DELETE">
|
|
<button type="submit" class="btn btn-danger">Delete Movie</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 %}
|