A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
feat: basic server settings page
aminnausin3e4251d9b5a7
diff --git a/resources/js/components/cards/layout/SettingsCard.vue b/resources/js/components/cards/layout/SettingsCard.vueindex ed4d73ba..722b5ea9 100644--- a/resources/js/components/cards/layout/SettingsCard.vue+++ b/resources/js/components/cards/layout/SettingsCard.vue@@ -1,7 +1,9 @@<template>- <section class="flex gap-3 p-3 sm:p-6 flex-wrap sm:flex-nowrap rounded-xl shadow-md dark:bg-primary-dark-800/70 bg-white ring-1 ring-gray-900/5">+ <section class="dark:bg-primary-dark-800/70 flex flex-wrap gap-3 rounded-xl bg-white p-3 shadow-md ring-1 ring-gray-900/5 sm:flex-nowrap sm:p-6"><slot name="heading"></slot><slot name="content"></slot>++ <slot></slot></section></template>diff --git a/resources/js/components/settings/SettingToggleRow.vue b/resources/js/components/settings/SettingToggleRow.vuenew file mode 100644index 00000000..1637df77--- /dev/null+++ b/resources/js/components/settings/SettingToggleRow.vue@@ -0,0 +1,25 @@+<script setup lang="ts">+import SettingsFormLabel from '@/components/settings/SettingsFormLabel.vue';+import ToggleBase from '@/components/inputs/ToggleBase.vue';++defineProps<{+ id: string;+ label: string;+ description?: string;+ disabled?: boolean;+}>();++const model = defineModel<boolean>();+</script>++<template>+ <div class="xxs:flex-nowrap flex flex-wrap items-start justify-between gap-x-6 gap-y-2" :class="{ 'pointer-events-none opacity-40': disabled }">+ <SettingsFormLabel :for="id" :text="label" :subtext="description" class="my-auto cursor-pointer" />+ <div :class="['flex shrink-0 items-center gap-2', { 'pt-0.5': description }]">+ <ToggleBase v-model="model" :name="id" class="h-6 w-12 shrink-0 rounded-full dark:border-neutral-700/70 dark:has-checked:border-neutral-700" />+ <p class="text-foreground-1 w-7 shrink-0 text-end text-xs font-medium uppercase">+ {{ model ? 'On' : 'Off' }}+ </p>+ </div>+ </div>+</template>diff --git a/resources/js/components/settings/SettingsFormLabel.vue b/resources/js/components/settings/SettingsFormLabel.vuenew file mode 100644index 00000000..fc8d339c--- /dev/null+++ b/resources/js/components/settings/SettingsFormLabel.vue@@ -0,0 +1,14 @@+<script setup lang="ts">+import { FormLabel } from '@/components/cedar-ui/form';+const props = defineProps<{ for: string; text: string; subtext?: any }>();+</script>++<template>+ <FormLabel :for="props.for" :text="text" class="flex h-fit flex-col gap-1">+ <template #subtext v-if="subtext">+ <p class="text-foreground-2 3xl:text-sm text-xs leading-relaxed font-normal">+ {{ subtext }}+ </p>+ </template>+ </FormLabel>+</template>diff --git a/resources/js/components/settings/SettingsServer.vue b/resources/js/components/settings/SettingsServer.vuenew file mode 100644index 00000000..7cf08970--- /dev/null+++ b/resources/js/components/settings/SettingsServer.vue@@ -0,0 +1,38 @@+<script setup lang="ts">+import type { BreadCrumbItem } from '@/types/types';++import { BreadCrumbs } from '@/components/cedar-ui/breadcrumbs';+import { computed } from 'vue';++import SettingsServerPerformance from '@/components/settings/server/SettingsServerPerformance.vue';+import SettingsServerIndexing from '@/components/settings/server/SettingsServerIndexing.vue';+import SettingsServerPaths from '@/components/settings/server/SettingsServerPaths.vue';++import ProiconsSettings from '~icons/proicons/settings';++const breadCrumbs = computed(() => {+ const items: BreadCrumbItem[] = [+ {+ name: 'Settings',+ url: '/settings/preferences',+ icon: ProiconsSettings,+ },+ {+ name: 'Server Config',+ url: '/settings/server',+ icon: ProiconsSettings,+ },+ ];++ return items;+});+</script>++<template>+ <section class="flex flex-wrap items-center justify-between gap-2">+ <BreadCrumbs :bread-crumbs="breadCrumbs" />+ </section>+ <SettingsServerIndexing />+ <SettingsServerPaths />+ <SettingsServerPerformance />+</template>diff --git a/resources/js/components/settings/server/SettingsServerIndexing.vue b/resources/js/components/settings/server/SettingsServerIndexing.vuenew file mode 100644index 00000000..445c15ae--- /dev/null+++ b/resources/js/components/settings/server/SettingsServerIndexing.vue@@ -0,0 +1,87 @@+<script setup lang="ts">+import { toast, useForm } from '@aminnausin/cedar-ui';+import { ButtonForm } from '@/components/cedar-ui/button';++import SettingToggleRow from '@/components/settings/SettingToggleRow.vue';+import SettingsHeader from '@/components/settings/SettingsHeader.vue';+import SettingsCard from '@/components/cards/layout/SettingsCard.vue';++const mediaAPI = {+ updateServerConfig: async (type: string, data: any) => {},+};++interface ScannerConfigRequest {+ embed_uuid: boolean;+ embed_uuid_cache: boolean;+ extract_attachments: boolean;+ extract_thumbnails: boolean;+ extract_art: boolean;+}++const form = useForm<ScannerConfigRequest>({+ embed_uuid: false,+ embed_uuid_cache: false,+ extract_attachments: true,+ extract_thumbnails: true,+ extract_art: true,+});++const handleSaveScanner = () => {+ form.submit((fields) => mediaAPI.updateServerConfig('scanner', fields), {+ onSuccess: () => toast.success('Scanner settings saved.'),+ onError: () => toast.error('Failed to save scanner settings.'),+ });+};+</script>++<template>+ <SettingsCard class="flex-col gap-6">+ <SettingsHeader>+ <h3 class="text-base font-medium">File Scanner</h3>+ <p class="text-foreground-2">Control what gets extracted when files are indexed.</p>+ </SettingsHeader>++ <div class="divide-d space-y-4 divide-y *:pb-4 *:last:pb-0">+ <SettingToggleRow+ id="embed-uuid"+ label="Embed UUID in files"+ description="Links files to persistent metadata in the database. Increases index time and re-writes each file to disk."+ v-model="form.fields.embed_uuid"+ />++ <SettingToggleRow+ id="embed-uuid-cache"+ label="Use cache for UUID writes"+ description="Write temporary files to cache. Improves index speed when cache is on an SSD."+ v-model="form.fields.embed_uuid_cache"+ :disabled="!form.fields.embed_uuid"+ />++ <SettingToggleRow+ id="extract-attachments"+ label="Extract embedded attachments"+ description="Automatically extract fonts and subtitle files at index time."+ v-model="form.fields.extract_attachments"+ />++ <SettingToggleRow+ id="extract-thumbnails"+ label="Generate thumbnails"+ description="Automatically generate thumbnails at index time."+ v-model="form.fields.extract_thumbnails"+ />++ <SettingToggleRow+ id="extract-art"+ label="Extract album art"+ description="Automatically extract album art from music at index time."+ v-model="form.fields.extract_art"+ />+ </div>++ <div class="flex justify-end gap-2 *:h-8">+ <ButtonForm @click="form.reset(...Object.keys(form.fields))" type="button" variant="reset" :disabled="form.processing"> Reset </ButtonForm>+ <ButtonForm variant="submit" :disabled="form.processing" @click="handleSaveScanner"> Save </ButtonForm>+ </div>+ </SettingsCard>+</template>diff --git a/resources/js/components/settings/server/SettingsServerPaths.vue b/resources/js/components/settings/server/SettingsServerPaths.vuenew file mode 100644index 00000000..89a10f8a--- /dev/null+++ b/resources/js/components/settings/server/SettingsServerPaths.vue@@ -0,0 +1,54 @@+<script setup lang="ts">+import { toast, useForm } from '@aminnausin/cedar-ui';+import { ButtonForm } from '@/components/cedar-ui/button';+import { FormInput } from '@/components/cedar-ui/form';++import SettingsFormLabel from '@/components/settings/SettingsFormLabel.vue';+import SettingsHeader from '@/components/settings/SettingsHeader.vue';+import SettingsCard from '@/components/cards/layout/SettingsCard.vue';++const mediaAPI = {+ updateServerConfig: async (type: string, data: any) => {},+};++interface PathsConfigRequest {+ cache_path: string;+ metadata_path: string;+}++const form = useForm<PathsConfigRequest>({+ cache_path: '',+ metadata_path: '',+});++const handleSavePaths = () => {+ form.submit((fields) => mediaAPI.updateServerConfig('paths', fields), {+ onSuccess: () => toast.success('Path settings saved.'),+ onError: () => toast.error('Failed to save path settings.'),+ });+};+</script>++<template>+ <SettingsCard class="flex-col gap-6">+ <SettingsHeader>+ <h3 class="text-base font-medium">Storage Paths</h3>+ <p class="text-foreground-2">Override where the server writes data.</p>+ </SettingsHeader>++ <div class="flex flex-col gap-4">+ <div class="flex flex-col gap-1">+ <SettingsFormLabel for="cache-path" text="Cache path" :subtext="'Temporary files are written here. Point to an SSD to improve speed.'" />+ <FormInput v-model="form.fields.cache_path" :field="{ name: 'cache-path', type: 'text', placeholder: 'storage/cache/' }" class="h-8" />+ </div>+ <div class="flex flex-col gap-1">+ <SettingsFormLabel for="metadata-path" text="Metadata path" :subtext="'Metadata files (subtitles, thumbnails, art) are written here.'" />+ <FormInput v-model="form.fields.metadata_path" :field="{ name: 'metadata-path', type: 'text', placeholder: 'storage/metadata/' }" class="h-8" />+ </div>+ </div>++ <div class="flex justify-end">+ <ButtonForm variant="submit" class="h-8" :disabled="form.processing" @click="handleSavePaths"> Save </ButtonForm>+ </div>+ </SettingsCard>+</template>diff --git a/resources/js/components/settings/server/SettingsServerPerformance.vue b/resources/js/components/settings/server/SettingsServerPerformance.vuenew file mode 100644index 00000000..252cbfc6--- /dev/null+++ b/resources/js/components/settings/server/SettingsServerPerformance.vue@@ -0,0 +1,67 @@+<script setup lang="ts">+import { FormNumberField } from '@/components/cedar-ui/number-field';+import { toast, useForm } from '@aminnausin/cedar-ui';+import { ButtonForm } from '@/components/cedar-ui/button';++import SettingsFormLabel from '@/components/settings/SettingsFormLabel.vue';+import SettingsHeader from '@/components/settings/SettingsHeader.vue';+import SettingsCard from '@/components/cards/layout/SettingsCard.vue';++const mediaAPI = {+ updateServerConfig: async (type: string, data: any) => {},+};++interface PerformanceConfigRequest {+ max_queue_workers: number;+ max_websocket_workers: number;+}++const form = useForm<PerformanceConfigRequest>({+ max_queue_workers: 10,+ max_websocket_workers: 5,+});++const handleSavePerformance = () => {+ form.submit((fields) => mediaAPI.updateServerConfig('performance', fields), {+ onSuccess: () => toast.success('Performance settings saved.'),+ onError: () => toast.error('Failed to save performance settings.'),+ });+};+</script>++<template>+ <SettingsCard class="flex-col gap-6">+ <SettingsHeader>+ <h3 class="text-base font-medium">Performance</h3>+ <p class="text-foreground-2">Tune concurrency limits to match your hardware. Changes require the queue worker to restart.</p>+ </SettingsHeader>++ <div class="flex flex-col gap-4">+ <div class="flex flex-col gap-1">+ <SettingsFormLabel+ for="max-queue-workers"+ text="Max parallel scan workers"+ subtext="Number of processes handling file indexing, thumbnail generation, and UUID embedding."+ />+ <FormNumberField+ v-model="form.fields.max_queue_workers"+ :field="{ name: 'max-queue-workers', type: 'number', min: 1, max: 30, default: 10, placeholder: '10' }"+ class="h-8"+ />+ </div>+ <div class="flex flex-col gap-1">+ <SettingsFormLabel for="max-ws-workers" text="Max parallel event workers" subtext="Number of processes handling real-time notifications and page updates." />+ <FormNumberField+ v-model="form.fields.max_websocket_workers"+ :field="{ name: 'max-ws-workers', type: 'number', min: 1, max: 30, default: 5, placeholder: '5' }"+ class="h-8"+ />+ </div>+ </div>++ <div class="flex justify-end gap-2">+ <ButtonForm variant="reset" class="h-8" :disabled="form.processing" @click="form.reset(...Object.keys(form.fields))"> Reset </ButtonForm>+ <ButtonForm variant="submit" class="h-8" :disabled="form.processing" @click="handleSavePerformance"> Save </ButtonForm>+ </div>+ </SettingsCard>+</template>