Skip to content

A self-hosted media server and file management system

feat: add rating edit support and show it on preview

aminnausina47bac3a018d
diff --git a/app/Models/Series.php b/app/Models/Series.php
index c3082219..fc7ea4f4 100644
--- a/app/Models/Series.php
+++ b/app/Models/Series.php
@@ -17,6 +17,7 @@ class Series extends Model {
'title',
'description',
'studio',
+ 'rating',
'seasons',
'episodes',
'films',
diff --git a/database/migrations/2025_05_22_171824_change_series_rating_to_integer.php b/database/migrations/2025_05_22_171824_change_series_rating_to_integer.php
new file mode 100644
index 00000000..13de5449
--- /dev/null
+++ b/database/migrations/2025_05_22_171824_change_series_rating_to_integer.php
@@ -0,0 +1,25 @@
+<?php
+
+use Illuminate\Database\Migrations\Migration;
+use Illuminate\Database\Schema\Blueprint;
+use Illuminate\Support\Facades\Schema;
+
+return new class extends Migration {
+ /**
+ * Run the migrations.
+ */
+ public function up(): void {
+ Schema::table('series', function (Blueprint $table) {
+ $table->tinyInteger('rating')->nullable()->change();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void {
+ Schema::table('series', function (Blueprint $table) {
+ $table->decimal('rating')->nullable()->change();
+ });
+ }
+};
diff --git a/resources/js/components/forms/EditFolder.vue b/resources/js/components/forms/EditFolder.vue
index 98422521..091c9f89 100644
--- a/resources/js/components/forms/EditFolder.vue
+++ b/resources/js/components/forms/EditFolder.vue
@@ -4,7 +4,7 @@ import type { FormField, SelectItem } from '@/types/types';
import type { SeriesUpdateRequest } from '@/types/requests';
import { handleStorageURL, toCalendarFormattedDate } from '@/service/util';
-import { reactive, ref, watch } from 'vue';
+import { computed, reactive, ref, watch } from 'vue';
import { useGetAllTags } from '@/service/queries';
import { UseCreateTag } from '@/service/mutations';
import { toast } from '@/service/toaster/toastService';
@@ -24,6 +24,10 @@ const props = defineProps<{ folder: FolderResource }>();
const { data: tagsQuery } = useGetAllTags();
const createTag = UseCreateTag();
+const isAudio = computed(() => {
+ return props.folder?.is_majority_audio ?? false;
+});
+
const allTags = ref<TagResource[]>([]);
// 'title', 'description', 'studio', 'seasons', 'episodes', 'films', 'date_start', 'date_end', 'thumbnail_url', 'editor_id';
const fields = reactive<FormField[]>([
@@ -41,40 +45,48 @@ const fields = reactive<FormField[]>([
text: 'Description',
type: 'textArea',
value: props.folder?.series?.description,
+ placeholder: '',
default: '',
},
{
name: 'studio',
- text: 'Studio',
+ text: isAudio.value ? 'Album Artist' : 'Studio',
type: 'text',
value: props.folder?.series?.studio,
- subtext: 'The producer studio',
default: '',
},
+ {
+ name: 'rating',
+ text: 'Average Score',
+ type: 'number',
+ value: props.folder?.series?.rating,
+ subtext: 'Percentage out of 100%',
+ default: 0,
+ },
{
name: 'episodes',
- text: 'Episodes',
+ text: isAudio.value ? 'Tracks' : 'Episodes',
type: 'number',
value: props.folder?.series?.episodes ?? 1,
- subtext: 'The number of episodes in the series',
+ subtext: `The number of ${isAudio.value ? 'tracks in the album or folder' : 'episodes in the series'}`,
default: 0,
min: 0,
},
{
name: 'seasons',
- text: 'Seasons',
+ text: isAudio.value ? 'Discs' : 'Seasons',
type: 'number',
value: props.folder?.series?.seasons ?? 1,
- subtext: 'The number of seasons in the series',
+ subtext: `The number of ${isAudio.value ? 'discs in the album or folder' : 'seasons in the series'}`,
default: 0,
min: 0,
},
{
name: 'films',
- text: 'Films',
+ text: isAudio.value ? 'Singles' : 'Films',
type: 'number',
value: props.folder?.series?.films ?? 1,
- subtext: 'The number of films in the series',
+ subtext: `The number of ${isAudio.value ? 'singles in the folder' : 'films in the series'}`,
default: 0,
min: 0,
},
@@ -83,7 +95,7 @@ const fields = reactive<FormField[]>([
text: 'Start Date',
type: 'date',
value: props.folder?.series?.date_start ? toCalendarFormattedDate(props.folder?.series?.date_start) : null,
- subtext: 'The release date of the first item in the series',
+ subtext: `The release date of the first ${isAudio.value ? 'track' : 'item'}`,
default: null,
},
{
@@ -91,7 +103,7 @@ const fields = reactive<FormField[]>([
text: 'End Date',
type: 'date',
value: props.folder?.series?.date_end ? toCalendarFormattedDate(props.folder?.series?.date_end) : null,
- subtext: 'The release date of the last item in the series',
+ subtext: `The release date of the last ${isAudio.value ? 'track' : 'item'}`,
default: null,
},
{
@@ -99,7 +111,7 @@ const fields = reactive<FormField[]>([
text: 'Folder Thumbnail URL',
type: 'url',
value: handleStorageURL(props.folder?.series?.thumbnail_url),
- subtext: 'A thumbnail associated with the series',
+ subtext: `A thumbnail associated with the ${isAudio.value ? 'album or folder' : 'series'}`,
default: null,
},
{
@@ -108,7 +120,7 @@ const fields = reactive<FormField[]>([
type: 'multi',
value: props.folder?.series?.folder_tags ?? [],
default: props.folder?.series?.folder_tags ?? [],
- subtext: 'Tags that describe the folder',
+ subtext: `Tags that describe the ${isAudio.value ? 'album or ' : ''}folder`,
max: 24,
},
]);
@@ -118,6 +130,7 @@ const form = useForm<SeriesUpdateRequest>({
title: props.folder?.series?.title ?? props.folder?.name,
description: props.folder?.series?.description ?? '',
studio: props.folder?.series?.studio ?? '',
+ rating: props.folder?.series?.rating?.toString() ?? null,
episodes: props.folder?.series?.episodes?.toString() ?? null,
seasons: props.folder?.series?.seasons?.toString() ?? null,
films: props.folder?.series?.films?.toString() ?? null,
diff --git a/resources/js/types/types.ts b/resources/js/types/types.ts
index aa8c5a53..15ff8cf3 100644
--- a/resources/js/types/types.ts
+++ b/resources/js/types/types.ts
@@ -244,6 +244,7 @@ export interface FormField {
type: FieldType;
required?: boolean;
value?: any;
+ placeholder?: string;
default?: any;
min?: number;
max?: number;
diff --git a/resources/views/og-media-preview.blade.php b/resources/views/og-media-preview.blade.php
index fedbe8a4..da83982d 100644
--- a/resources/views/og-media-preview.blade.php
+++ b/resources/views/og-media-preview.blade.php
@@ -27,7 +27,10 @@
<span class="flex items-center gap-6">
@if ($rating ?? false)
<div class="flex items-center text-4xl font-semibold">
- ⭐ <span class="ml-1">{{$rating ?? 0}}%</span>
+ <svg xmlns="http://www.w3.org/2000/svg" width="1.2em" height="1.2em" viewBox="0 0 24 24" class="text-yellow-400">
+ <path fill="currentColor" fill-rule="evenodd" d="M10.788 3.21c.448-1.077 1.976-1.077 2.424 0l2.082 5.006l5.404.434c1.164.093 1.636 1.545.749 2.305l-4.117 3.527l1.257 5.273c.271 1.136-.964 2.033-1.96 1.425L12 18.354L7.373 21.18c-.996.608-2.231-.29-1.96-1.425l1.257-5.273l-4.117-3.527c-.887-.76-.415-2.212.749-2.305l5.404-.434z" clip-rule="evenodd" />
+ </svg>
+ <span class="ml-1 font-quicksand">{{$rating ?? 0}}%</span>
</div>
@endif
<p class="line-clamp-2 drop-shadow-lg whitespace-pre-wrap flex-1">{{ $description ?? ""}}</p>