From 0d83048c50da2bccfb6fbeec523816d46932fa80 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Fri, 10 Oct 2025 12:46:26 +0200 Subject: [PATCH] Add tvshows management to admin area --- .../Admin/AdminShowsController.php | 74 +++--- resources/views/admin/shows/edit.blade.php | 229 ++++++++++++++++++ resources/views/admin/shows/index.blade.php | 205 ++++++++++++++++ resources/views/admin/shows/remove.blade.php | 117 +++++++++ resources/views/partials/admin-menu.blade.php | 13 + routes/web.php | 78 +++--- 6 files changed, 635 insertions(+), 81 deletions(-) create mode 100644 resources/views/admin/shows/edit.blade.php create mode 100644 resources/views/admin/shows/index.blade.php create mode 100644 resources/views/admin/shows/remove.blade.php diff --git a/app/Http/Controllers/Admin/AdminShowsController.php b/app/Http/Controllers/Admin/AdminShowsController.php index c4f97b419..a6a3b103b 100644 --- a/app/Http/Controllers/Admin/AdminShowsController.php +++ b/app/Http/Controllers/Admin/AdminShowsController.php @@ -5,86 +5,76 @@ namespace App\Http\Controllers\Admin; use App\Http\Controllers\BasePageController; use App\Models\Release; use App\Models\Video; +use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Illuminate\View\View; class AdminShowsController extends BasePageController { /** - * @throws \Exception + * Display a listing of TV shows */ - public function index(Request $request): void + public function index(Request $request): View { $this->setAdminPrefs(); $meta_title = $title = 'TV Shows List'; - $tvshowname = ($request->has('showname') && ! empty($request->input('showname')) ? $request->input('showname') : ''); + $showname = $request->input('showname', ''); + $tvshowlist = Video::getRange($showname); - $this->smarty->assign( - [ - 'showname' => $tvshowname, - 'tvshowlist' => Video::getRange($tvshowname), - ] - ); - - $content = $this->smarty->fetch('show-list.tpl'); - $this->smarty->assign(compact('title', 'meta_title', 'content')); - $this->adminrender(); + return view('admin.shows.index', compact('tvshowlist', 'showname', 'title', 'meta_title')); } /** - * @throws \Exception + * Show the form for editing a TV show */ - public function edit(Request $request): void + public function edit(Request $request): View|RedirectResponse { $this->setAdminPrefs(); - switch ($request->input('action') ?? 'view') { - case 'submit': - if ($request->has('from') && ! empty($request->input('from'))) { - header('Location:'.$request->input('from')); - exit; - } + $action = $request->input('action', 'view'); - header('Location:'.url('admin/show-list')); - break; + if ($action === 'submit') { + if ($request->has('from') && ! empty($request->input('from'))) { + return redirect($request->input('from')); + } - case 'view': - default: - if ($request->has('id')) { - $title = 'TV Show Edit'; - $show = Video::getByVideoID($request->input('id')); - } - break; + return redirect()->route('admin.show-list')->with('success', 'TV show updated successfully'); } - $this->smarty->assign('show', $show); + $show = null; + if ($request->has('id')) { + $show = Video::getByVideoID($request->input('id')); + } + + if (! $show) { + return redirect()->route('admin.show-list')->with('error', 'TV show not found'); + } $meta_title = $title = 'Edit TV Show Data'; - $content = $this->smarty->fetch('show-edit.tpl'); - $this->smarty->assign(compact('title', 'meta_title', 'content')); - $this->adminrender(); + + return view('admin.shows.edit', compact('show', 'title', 'meta_title')); } /** - * @throws \Exception + * Remove video ID from releases */ - public function destroy($id): void + public function destroy(Request $request): View { $this->setAdminPrefs(); + $id = $request->route('id'); $success = false; + $videoid = null; if ($id) { $success = Release::removeVideoIdFromReleases($id); - $this->smarty->assign('videoid', $id); + $videoid = $id; } - $this->smarty->assign('success', $success); - $meta_title = $title = 'Remove Video and Episode IDs from Releases'; - $content = $this->smarty->fetch('show-remove.tpl'); - $this->smarty->assign(compact('title', 'meta_title', 'content')); - $this->adminrender(); + + return view('admin.shows.remove', compact('success', 'videoid', 'title', 'meta_title')); } } diff --git a/resources/views/admin/shows/edit.blade.php b/resources/views/admin/shows/edit.blade.php new file mode 100644 index 000000000..98dfd41bd --- /dev/null +++ b/resources/views/admin/shows/edit.blade.php @@ -0,0 +1,229 @@ +@extends('layouts.admin') + +@section('content') +
+
+ +
+
+

+ {{ $title }} +

+ + Back to List + +
+
+ + +
+
+ @csrf + + + +
+ +
+ +
+ + +

Title is read-only

+
+ + +
+ + +

Type is read-only

+
+ + +
+ + +
+ + +
+ + +
+ + +
+

External IDs

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+ +
+ +
+ @if(!empty($show['image'])) + {{ $show['title'] }} + @else +
+ +

No cover image available

+
+ @endif +
+
+ + +
+ + +
+ + +
+ + +
+ + +
+

Show Information

+
+
+
ID:
+
{{ $show['id'] }}
+
+
+
Source:
+
+ @if(isset($show['source'])) + @if($show['source'] == 0) + TVDB + @elseif($show['source'] == 1) + TMDB + @elseif($show['source'] == 2) + Trakt + @elseif($show['source'] == 3) + TVMaze + @else + Unknown + @endif + @else + — + @endif +
+
+
+
+
+
+ + +
+ + Back to List + +
+ This is a view-only page. TV show data is automatically fetched from external sources. +
+
+
+
+
+
+@endsection + diff --git a/resources/views/admin/shows/index.blade.php b/resources/views/admin/shows/index.blade.php new file mode 100644 index 000000000..a35f9db14 --- /dev/null +++ b/resources/views/admin/shows/index.blade.php @@ -0,0 +1,205 @@ +@extends('layouts.admin') + +@section('content') +
+
+ +
+
+

+ {{ $title }} +

+
+ Total: {{ $tvshowlist->total() }} shows +
+
+
+ + +
+
+
+ + +
+
+ + @if($showname) + + Clear + + @endif +
+
+
+ + +
+ + + + + + + + + + + + + + @forelse($tvshowlist as $show) + + + + + + + + + + @empty + + + + @endforelse + +
CoverTitleTypeStartedIDsPublisherActions
+ @php + $coverPath = public_path('covers/tvshows/' . $show->id . '.jpg'); + $hasCover = file_exists($coverPath); + @endphp + @if($hasCover) + {{ $show->title }} + @else +
+ +
+ @endif +
+
+ {{ $show->title }} +
+ @if(!empty($show->summary)) +
+ {{ Str::limit($show->summary, 100) }} +
+ @endif +
+ @if($show->type == 0) + + TV + + @elseif($show->type == 1) + + Film + + @elseif($show->type == 2) + + Anime + + @endif + + {{ $show->started ?? '—' }} + +
+ @if($show->tvdb) +
+ TVDB: {{ $show->tvdb }} +
+ @endif + @if($show->imdb) +
+ IMDB: {{ $show->imdb }} +
+ @endif + @if($show->tmdb) +
+ TMDB: {{ $show->tmdb }} +
+ @endif + @if($show->trakt) +
+ Trakt: {{ $show->trakt }} +
+ @endif + @if($show->tvmaze) +
+ TVMaze: {{ $show->tvmaze }} +
+ @endif + @if($show->anidb) +
+ AniDB: {{ $show->anidb }} +
+ @endif +
+
+ {{ $show->publisher ?? '—' }} + + + + + + + +
+ @if($showname) +
+ +

No TV shows found for "{{ $showname }}"

+ + Clear search and view all + +
+ @else +
+ +

No TV shows available

+
+ @endif +
+
+ + +
+
+
+ Showing {{ $tvshowlist->firstItem() ?? 0 }} to {{ $tvshowlist->lastItem() ?? 0 }} of {{ $tvshowlist->total() }} shows +
+
+ {{ $tvshowlist->appends(['showname' => $showname])->links() }} +
+
+
+
+
+ +@push('styles') + +@endpush +@endsection + diff --git a/resources/views/admin/shows/remove.blade.php b/resources/views/admin/shows/remove.blade.php new file mode 100644 index 000000000..8e978679a --- /dev/null +++ b/resources/views/admin/shows/remove.blade.php @@ -0,0 +1,117 @@ +@extends('layouts.admin') + +@section('content') +
+
+ +
+
+

+ {{ $title }} +

+ + Back to List + +
+
+ + +
+ @if($success) +
+
+
+ +
+
+

+ Successfully Removed Video IDs +

+
+

Video ID {{ $videoid }} and its associated episode IDs have been successfully removed from all releases.

+
+
+
+
+ +
+

+ What was removed? +

+
    +
  • + + All releases linked to video ID {{ $videoid }} have been unlinked +
  • +
  • + + All episode IDs associated with this video have been removed from releases +
  • +
  • + + The TV show data itself remains in the database and can be re-linked if needed +
  • +
+
+ @else +
+
+
+ +
+
+

+ Operation Failed +

+
+

Failed to remove video IDs from releases. This could be due to:

+
    +
  • Invalid video ID provided
  • +
  • No releases linked to this video ID
  • +
  • Database error
  • +
+
+
+
+
+ @endif + + +
+
+
+ +
+
+

+ About This Operation +

+
+

This operation removes the association between TV show data and releases in your database. It's useful when:

+
    +
  • Incorrect TV show data has been linked to releases
  • +
  • You want to force releases to be re-processed for TV show matching
  • +
  • You're cleaning up orphaned or incorrect associations
  • +
+

Note: This does not delete the TV show from the database, only unlinks it from releases.

+
+
+
+
+ + + +
+
+
+@endsection + diff --git a/resources/views/partials/admin-menu.blade.php b/resources/views/partials/admin-menu.blade.php index 05b8c86a7..489902880 100644 --- a/resources/views/partials/admin-menu.blade.php +++ b/resources/views/partials/admin-menu.blade.php @@ -79,6 +79,19 @@ + +
+ + +