feat(onboarding): assistant de configuration au premier lancement et visite guidée des écrans
This commit is contained in:
1 parent
6348cc40cb
commit
4b3c629ff9
43 files changed
+2498
-366
No files matched your search
@@ -4,10 +4,7 @@
|
||||
|
||||
<!-- Logo -->
|
||||
<div class="flex items-center justify-center gap-2.5 mb-8">
|
||||
<svg class="w-8 h-8" viewBox="0 0 130 135" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill="var(--gold)" d="m113.85,12.8c-1.94,3.57-3.8,7.09-5.76,10.55-3.6,6.35-7.31,12.65-10.9,19.01-1.69,3-3.22,6.08-4.44,9.49,3.25-2.46,6.44-5.03,9.78-7.36,2.92-2.04,5.95-3.96,9.07-5.67,8.59-4.72,19.29-1.78,24.4,6.54.42.68,1.3,1.16,1.52,1.87.26.83.05,2.62,0,2.62-3.94.13-3.45,5.79-7.59,5.89-3.46.08-6.9,1.25-10.37,1.37-6.78.25-13.48.64-19.32,4.57-1.91,1.29-3.5,3.05-4.97,4.36.21.86.19,1.13.3,1.2,4.42,2.7,8.79,5.49,13.31,8,2.11,1.17,3.66,3.77,2.82,6.63-1.18,3.97-2.64,7.86-4.04,11.76-.48,1.33-1.11,2.61-1.88,4.41,5.87,2.14,11.63,4.26,17.41,6.35,3.43,1.24,6.86,2.47,10.31,3.65,7.38,2.52,9.16,9.54,11.52,15.53,1.04,2.65-.75,6.75-2.11,9.81-.46,1.04-3.53,1.22-5.42,1.26-1.78.03-3.57-.64-4.46-.83-5.97-8.4-11.54-15.98-23.28-14.7.1-.32.21-.65.31-.97,2.32-.52,4.64-1.05,6.97-1.57.03-.22.06-.45.09-.67-2.97-1.18-5.94-2.37-8.92-3.52-1.33-.52-2.7-.93-4.03-1.45-4.83-1.9-4.79-1.89-8.26,2.27-4.31,5.17-10.22,8.13-16.3,11.01.69-.84,1.31-1.75,2.1-2.48.76-.71,1.69-1.22,2.26-2.29-4.9,1.87-9.81,3.74-14.71,5.61-.13-.22-.26-.45-.39-.67.86-.62,1.72-1.24,2.58-1.85-.04-.17-.08-.34-.12-.51-2.94.65-5.93,1.11-8.8,2-4.18,1.29-8.27,2.87-12.38,4.38-2.59.95-5.12,1.51-7.19-.14,11.84-9.4,25.16-17.2,36.59-28.93-4.21-3.65-8.1-7.01-11.98-10.38.15-.43.3-.87.45-1.3,1.61-.09,3.3-.55,4.81-.21,4.14.92,8.21,2.18,12.66,3.4,3.58-6.6,7.1-13.29,7.3-20.58-6.68-2.65-9.79,4.13-15.7,5.76,2.55-2.92,4.54-5.19,6.52-7.46-.2-.17-.39-.33-.59-.5-5.58,4.28-16.89,16.06-24.16,29.07-.19-.29-.37-.59-.55-.87-.81,1.46-1.57,2.83-2.33,4.21l-1.04-.35c1.58-5.71,2.86-11.53,4.81-17.11,2.67-7.67,6.32-15.02,8.71-22.76,4.87-15.8,13.75-29.67,20.7-44.45.65-1.38,1.28-2.77,1.88-4.17,1.58-3.68,3.97-7.37-.47-11.13.3-.16.59-.33.89-.49,7.13,4.08,14.25,8.15,22.38,12.8Z"/>
|
||||
<path fill="var(--gold)" d="m7.03,71.72c.25-.48.39-1.21.77-1.38,1.1-.49,2.62-1.38,3.41-.98,2.58,1.28,4.8.38,7.06-.48,2.76-1.04,5.57-2.05,8.14-3.47,1.22-.67,2.63-2.19,2.77-3.46,1.03-9.65,3.6-18.83,7.54-27.67.24-.53.3-1.14-.17-2.03-1.01,1.63-1.78,3.49-3.08,4.85-2.08,2.21-4.42,4.2-6.82,6.07-1.39,1.09-3.02,2.05-4.7,2.54-1.31.39-3.26.51-4.24-.2-4.32-3.13-8.38-6.6-12.71-10.09,2.03-2.48,3.73-4.2,7.18-3.5,1.74.36,4.04-.43,5.67-1.4,5.43-3.21,10.65-6.79,16.01-10.13,5.58-3.48,11.45-3.46,17.13-.53,4.5,2.32,8.73,5.19,13.03,7.9,1.47.93,2.35,2.23,1.34,4.11-2.08,3.88-4.01,7.85-6.22,11.66-1.95,3.37-4.2,6.56-6.47,10.06,2.04.96,3.78,1.67,5.4,2.58,2.25,1.27,3.25,3.24,2.97,5.87-.33,3.15-1.59,5.64-4.68,6.84-.84.33-1.83.72-2.65.56-5.8-1.1-9.79,2.93-14.43,5.04-1.2.54-2.19,1.83-2.95,2.99-3.3,5.08-8.83,6.7-13.83,9.17-.53.26-1.22.74-1.34,1.24-1.76,7.82-3.45,15.65-4.58,24.09,4.1-2.32,8.19-4.65,12.29-6.97.12.15.23.31.35.46-1.05,1.17-2.1,2.34-3.15,3.52l.5.66c5.73-2.61,10.97-5.98,15.24-10.87.28.22.57.43.85.65-1.83,3.39-3.78,6.72-5.44,10.2-.95,1.99-1.38,4.21-2.13,6.3-.48,1.33-.84,2.82-1.71,3.86-2.61,3.13-5.46,6.06-8.19,9.09-.45.5-.76,1.12-1.14,1.68-.66.99-1.21,2.09-2.02,2.94-.39.41-1.58.71-1.85.46-2.26-2.14-5.5,2.25-7.78-1.52-1.9-3.13-5.35-5.33-7.23-8.47-2.37-3.95-5.75-7.84-5.14-12.85.51-4.17,2.16-8.18,2.89-12.34,1.43-8.11,2.6-16.27,3.82-24.42.14-.95-.11-1.95-.19-2.93.14.09.29.17.43.26Z"/>
|
||||
</svg>
|
||||
<FankarrLogo class="w-8 h-8" />
|
||||
<span class="text-2xl font-bold text-primary tracking-wide">FanKarr</span>
|
||||
</div>
|
||||
|
||||
@@ -52,6 +49,7 @@
|
||||
import { ref, computed } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import FankarrLogo from '@/components/FankarrLogo.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
@@ -67,6 +65,7 @@ const isSetup = computed(() => !auth.setup)
|
||||
async function submit() {
|
||||
error.value = null
|
||||
if (!username.value || !password.value) { error.value = 'Tous les champs sont requis'; return }
|
||||
if (isSetup.value && password.value.length < 6) { error.value = 'Le mot de passe doit faire au moins 6 caractères'; return }
|
||||
if (isSetup.value && password.value !== confirm.value) { error.value = 'Les mots de passe ne correspondent pas'; return }
|
||||
|
||||
submitting.value = true
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<div class="px-8 py-8 max-w-4xl">
|
||||
|
||||
<!-- Stats -->
|
||||
<div class="grid gap-3 mb-6" :class="auth.isAdmin ? 'grid-cols-2 md:grid-cols-4' : 'grid-cols-2'">
|
||||
<div data-tour="dashboard-stats" class="grid gap-3 mb-6" :class="auth.isAdmin ? 'grid-cols-2 md:grid-cols-4' : 'grid-cols-2'">
|
||||
<div class="settings-card flex flex-col gap-1">
|
||||
<span class="text-xs text-muted">Catalogue</span>
|
||||
<span class="text-2xl font-semibold text-primary">{{ stats.catalogue }}</span>
|
||||
@@ -81,7 +81,7 @@
|
||||
</div>
|
||||
|
||||
<!-- Widget demandes -->
|
||||
<div class="settings-card flex flex-col gap-3 mb-6">
|
||||
<div data-tour="dashboard-requests" class="settings-card flex flex-col gap-3 mb-6">
|
||||
<div class="flex items-center justify-between">
|
||||
<h2 class="text-sm font-medium text-secondary">
|
||||
{{ auth.isAdmin ? 'Demandes en attente' : 'Mes demandes' }}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<div class="px-8 py-8 max-w-4xl">
|
||||
|
||||
<!-- Header -->
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<div data-tour="activity-header" class="flex items-center justify-between mb-6">
|
||||
<div class="flex items-center gap-3">
|
||||
<h1 class="text-lg font-semibold text-primary">Activité</h1>
|
||||
<div class="flex items-center gap-1.5">
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="px-4 md:px-8 py-8 max-w-4xl">
|
||||
|
||||
<div class="flex items-center justify-between mb-6">
|
||||
<div data-tour="requests-header" class="flex items-center justify-between mb-6">
|
||||
<div>
|
||||
<h1 class="text-lg font-semibold text-primary">Demandes</h1>
|
||||
<p class="text-sm text-muted mt-0.5">
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
/>
|
||||
|
||||
<!-- Grille -->
|
||||
<div class="px-4 md:px-6 py-6">
|
||||
<div data-tour="series-grid" class="px-4 md:px-6 py-6">
|
||||
|
||||
<div v-if="store.loadingSeries" class="flex flex-col items-center justify-center gap-3 h-64 text-muted">
|
||||
<div class="w-6 h-6 border border-border border-t-accent rounded-full animate-spin" />
|
||||
@@ -37,8 +37,9 @@
|
||||
<div v-else class="grid gap-4" :style="{ gridTemplateColumns: `repeat(auto-fill, minmax(${posterSizes[posterSize]}, 1fr))` }">
|
||||
<component
|
||||
:is="selecting ? 'div' : RouterLink"
|
||||
v-for="serie in filtered"
|
||||
v-for="(serie, i) in filtered"
|
||||
:key="serie.id"
|
||||
:data-tour="i === 0 ? 'series-poster' : undefined"
|
||||
v-bind="selecting ? {} : { to: `/series/${serie.id}` }"
|
||||
class="group flex flex-col gap-1.5 transition-transform duration-200 hover:-translate-y-0.5"
|
||||
:class="{
|
||||
|
||||
@@ -0,0 +1,315 @@
|
||||
<template>
|
||||
<div class="min-h-screen bg-shell flex flex-col md:flex-row">
|
||||
|
||||
<!-- Rail des étapes -->
|
||||
<aside class="md:w-72 md:h-screen md:sticky md:top-0 bg-sidebar border-b md:border-b-0 md:border-r border-border flex flex-col shrink-0">
|
||||
<div class="flex items-center gap-2.5 px-5 py-4 border-b border-border min-h-[56px]">
|
||||
<FankarrLogo class="w-7 h-7 shrink-0" />
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-[15px] font-semibold text-primary tracking-wide leading-tight">FanKarr</p>
|
||||
<p class="text-[11px] text-muted">Assistant de configuration</p>
|
||||
</div>
|
||||
<button
|
||||
v-if="context.relaunch"
|
||||
@click="close"
|
||||
title="Fermer l'assistant"
|
||||
class="text-muted hover:text-primary transition-colors p-1 rounded-md hover:bg-hover"
|
||||
>
|
||||
<X :size="16" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
@click="logout"
|
||||
title="Se déconnecter"
|
||||
class="text-muted hover:text-red-400 transition-colors p-1 rounded-md hover:bg-hover"
|
||||
>
|
||||
<LogOut :size="15" />
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Progression mobile -->
|
||||
<div class="md:hidden px-5 py-3">
|
||||
<p class="text-xs text-muted">Étape {{ index + 1 }} sur {{ steps.length }} · <span class="text-primary">{{ current.label }}</span></p>
|
||||
<div class="h-1 bg-border rounded-full mt-2 overflow-hidden">
|
||||
<div class="h-full bg-accent rounded-full transition-all duration-300" :style="{ width: `${((index + 1) / steps.length) * 100}%` }" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<nav aria-label="Étapes" class="hidden md:block flex-1 overflow-y-auto px-3 py-5">
|
||||
<ol class="flex flex-col gap-1">
|
||||
<li v-for="(step, i) in steps" :key="step.id">
|
||||
<button
|
||||
:disabled="!canVisit(i)"
|
||||
:aria-current="i === index ? 'step' : undefined"
|
||||
@click="visit(i)"
|
||||
class="w-full flex items-center gap-3 px-3 py-2.5 rounded-lg text-left transition-colors"
|
||||
:class="i === index ? 'bg-active' : canVisit(i) ? 'hover:bg-hover' : 'cursor-default'"
|
||||
>
|
||||
<span
|
||||
class="w-6 h-6 rounded-full flex items-center justify-center text-[11px] font-medium shrink-0 border"
|
||||
:class="stepBadgeClass(step.id, i)"
|
||||
>
|
||||
<TriangleAlert v-if="step.id === 'client' && context.clientSkipped && i !== index" :size="12" />
|
||||
<Check v-else-if="i < reached && i !== index" :size="12" />
|
||||
<template v-else>{{ i + 1 }}</template>
|
||||
</span>
|
||||
<span class="flex flex-col min-w-0">
|
||||
<span class="text-sm truncate" :class="i === index ? 'text-primary font-medium' : canVisit(i) ? 'text-secondary' : 'text-muted'">
|
||||
{{ step.label }}
|
||||
</span>
|
||||
<span class="text-[11px] text-muted truncate">{{ step.hint }}</span>
|
||||
</span>
|
||||
</button>
|
||||
</li>
|
||||
</ol>
|
||||
</nav>
|
||||
|
||||
<p class="hidden md:block px-5 py-4 text-[11px] text-muted border-t border-border leading-relaxed">
|
||||
Tout reste modifiable ensuite dans les Paramètres.
|
||||
</p>
|
||||
</aside>
|
||||
|
||||
<!-- Contenu -->
|
||||
<main class="flex-1 min-w-0">
|
||||
<div v-if="!loaded" class="flex items-center justify-center py-32">
|
||||
<div class="w-4 h-4 border border-border border-t-accent rounded-full animate-spin" />
|
||||
</div>
|
||||
|
||||
<div v-else class="max-w-2xl mx-auto px-5 md:px-8 py-8 md:py-12 flex flex-col gap-8">
|
||||
<header class="flex flex-col gap-1.5">
|
||||
<p class="text-xs text-accent font-medium">
|
||||
Étape {{ index + 1 }} sur {{ steps.length }}<template v-if="current.optional"> · optionnelle</template>
|
||||
</p>
|
||||
<h1 ref="titleRef" tabindex="-1" class="text-xl font-semibold text-primary outline-none">{{ current.title }}</h1>
|
||||
<p class="text-sm text-muted leading-relaxed">{{ current.description }}</p>
|
||||
</header>
|
||||
|
||||
<component
|
||||
:is="current.component"
|
||||
ref="stepRef"
|
||||
:key="current.id"
|
||||
:settings="settings"
|
||||
:is-docker="isDocker"
|
||||
:default-path="defaultPath"
|
||||
/>
|
||||
|
||||
<footer v-if="current.id !== 'recap'" class="flex items-center gap-2 pt-6 border-t border-border">
|
||||
<button v-if="index > 0" @click="visit(index - 1)" :disabled="busy" class="btn-secondary flex items-center gap-1.5">
|
||||
<ArrowLeft :size="14" /> Précédent
|
||||
</button>
|
||||
<div class="flex-1" />
|
||||
<button v-if="current.optional" @click="next(false)" :disabled="busy" class="btn-ghost">
|
||||
Passer
|
||||
</button>
|
||||
<button @click="next(true)" :disabled="busy" class="btn-primary flex items-center gap-1.5">
|
||||
{{ busy ? '...' : index === 0 ? 'Commencer' : 'Suivant' }}
|
||||
<ArrowRight v-if="!busy" :size="14" />
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, provide, nextTick, onMounted, type Component } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { ArrowLeft, ArrowRight, Check, LogOut, TriangleAlert, X } from 'lucide-vue-next'
|
||||
import FankarrLogo from '@/components/FankarrLogo.vue'
|
||||
import SetupWelcomeStep from '@/components/setup/SetupWelcomeStep.vue'
|
||||
import SetupPathsStep from '@/components/setup/SetupPathsStep.vue'
|
||||
import SetupClientStep from '@/components/setup/SetupClientStep.vue'
|
||||
import SetupImportStep from '@/components/setup/SetupImportStep.vue'
|
||||
import SetupMediaServerStep from '@/components/setup/SetupMediaServerStep.vue'
|
||||
import SetupCatalogStep from '@/components/setup/SetupCatalogStep.vue'
|
||||
import SetupRecapStep from '@/components/setup/SetupRecapStep.vue'
|
||||
import { setupContextKey, type SetupContext, type SetupSettings, type SetupStepId } from '@/components/setup/setup'
|
||||
import { useAuthStore } from '@/stores/auth'
|
||||
import { useTourStore } from '@/stores/tour'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
|
||||
interface StepDef {
|
||||
id : SetupStepId
|
||||
label : string
|
||||
hint : string
|
||||
title : string
|
||||
description: string
|
||||
component : Component
|
||||
optional? : boolean
|
||||
}
|
||||
|
||||
const steps: StepDef[] = [
|
||||
{
|
||||
id: 'welcome', label: 'Bienvenue', hint: 'Ce qui vous attend', component: SetupWelcomeStep,
|
||||
title: 'Bienvenue dans FanKarr',
|
||||
description: 'Quelques minutes pour préparer FanKarr : où ranger vos séries, quel client torrent utiliser et comment les retrouver dans votre lecteur.',
|
||||
},
|
||||
{
|
||||
id: 'paths', label: 'Dossiers', hint: 'Téléchargements et médiathèque', component: SetupPathsStep,
|
||||
title: 'Dossiers et mode d\'import',
|
||||
description: 'Indiquez où arrivent les téléchargements terminés et où FanKarr doit ranger vos séries.',
|
||||
},
|
||||
{
|
||||
id: 'client', label: 'Client torrent', hint: 'qBittorrent, Transmission…', component: SetupClientStep,
|
||||
title: 'Client de téléchargement',
|
||||
description: 'FanKarr envoie les torrents à votre client puis surveille leur progression pour les importer.',
|
||||
},
|
||||
{
|
||||
id: 'import', label: 'Import', hint: 'Automatisme et nommage', component: SetupImportStep,
|
||||
title: 'Options d\'import',
|
||||
description: 'Réglez ce qui se passe quand un téléchargement se termine.',
|
||||
},
|
||||
{
|
||||
id: 'media-server', label: 'Serveur multimédia', hint: 'Jellyfin, Plex', component: SetupMediaServerStep, optional: true,
|
||||
title: 'Jellyfin et Plex',
|
||||
description: 'Connectez votre serveur multimédia pour y retrouver vos séries. Vous pouvez passer cette étape.',
|
||||
},
|
||||
{
|
||||
id: 'catalog', label: 'Catalogue', hint: 'Séries Fankai', component: SetupCatalogStep,
|
||||
title: 'Catalogue Fankai',
|
||||
description: 'Le catalogue liste toutes les séries Fankai et leurs torrents. Il se met à jour tout seul ensuite.',
|
||||
},
|
||||
{
|
||||
id: 'recap', label: 'Récapitulatif', hint: 'Vérifier et terminer', component: SetupRecapStep,
|
||||
title: 'Tout est prêt ?',
|
||||
description: 'Vérifiez la configuration avant de commencer. Chaque point reste modifiable.',
|
||||
},
|
||||
]
|
||||
|
||||
const router = useRouter()
|
||||
const auth = useAuthStore()
|
||||
const tour = useTourStore()
|
||||
const { add: toast } = useToast()
|
||||
|
||||
const loaded = ref(false)
|
||||
const busy = ref(false)
|
||||
const index = ref(0)
|
||||
const reached = ref(0)
|
||||
const isDocker = ref(false)
|
||||
const defaultPath = ref('/')
|
||||
const titleRef = ref<HTMLElement | null>(null)
|
||||
const stepRef = ref<{ submit?: () => Promise<boolean> } | null>(null)
|
||||
|
||||
const settings = reactive<SetupSettings>({
|
||||
mediaPath : '',
|
||||
completePath : '',
|
||||
organizeMode : 'hardlink',
|
||||
nfoSupport : false,
|
||||
autoImport : true,
|
||||
deleteTorrentOnMove: false,
|
||||
autoUnimportMissing: false,
|
||||
englishDirectory : false,
|
||||
})
|
||||
|
||||
const context = reactive<SetupContext>({
|
||||
relaunch : false,
|
||||
clientSkipped: false,
|
||||
plexOpened : false,
|
||||
goto : (id) => visit(steps.findIndex(s => s.id === id)),
|
||||
finish: finish,
|
||||
})
|
||||
provide(setupContextKey, context)
|
||||
|
||||
const current = computed(() => steps[index.value]!)
|
||||
|
||||
function canVisit(i: number) {
|
||||
return i !== index.value && (context.relaunch || i <= reached.value)
|
||||
}
|
||||
|
||||
function stepBadgeClass(id: SetupStepId, i: number) {
|
||||
if (i === index.value) return 'border-accent text-accent bg-accent-muted'
|
||||
if (id === 'client' && context.clientSkipped) return 'border-yellow-500/50 text-yellow-500'
|
||||
if (i < reached.value) return 'border-green-500/50 text-green-400'
|
||||
return 'border-border text-muted'
|
||||
}
|
||||
|
||||
async function refreshSettings() {
|
||||
const res = await fetch('/api/settings', { credentials: 'include' })
|
||||
if (!res.ok) return
|
||||
const data = await res.json()
|
||||
for (const key of Object.keys(settings) as (keyof SetupSettings)[]) {
|
||||
if (data[key] !== undefined) (settings as any)[key] = data[key]
|
||||
}
|
||||
}
|
||||
|
||||
async function focusTitle() {
|
||||
await nextTick()
|
||||
window.scrollTo({ top: 0 })
|
||||
titleRef.value?.focus()
|
||||
}
|
||||
|
||||
function visit(i: number) {
|
||||
if (i < 0 || i >= steps.length || busy.value) return
|
||||
index.value = i
|
||||
focusTitle()
|
||||
}
|
||||
|
||||
async function next(submit: boolean) {
|
||||
busy.value = true
|
||||
try {
|
||||
if (submit && stepRef.value?.submit && !(await stepRef.value.submit())) return
|
||||
await refreshSettings()
|
||||
|
||||
const target = index.value + 1
|
||||
if (target > reached.value) {
|
||||
reached.value = target
|
||||
fetch('/api/settings/onboarding', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include',
|
||||
body: JSON.stringify({ step: steps[target]!.id }),
|
||||
}).catch(() => {})
|
||||
}
|
||||
index.value = target
|
||||
focusTitle()
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function finish(withTour: boolean) {
|
||||
if (!context.relaunch && !(await auth.completeOnboarding())) {
|
||||
toast('Impossible de terminer la configuration', 'error')
|
||||
return
|
||||
}
|
||||
if (withTour) {
|
||||
tour.start()
|
||||
await router.push('/dashboard')
|
||||
} else {
|
||||
if (!auth.tourSeen) auth.markTourSeen()
|
||||
await router.push(context.relaunch ? '/settings/advanced' : '/series')
|
||||
}
|
||||
}
|
||||
|
||||
function close() {
|
||||
router.push('/settings/advanced')
|
||||
}
|
||||
|
||||
async function logout() {
|
||||
await auth.logout()
|
||||
router.push('/auth')
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
const [onboardingRes, systemRes, infoRes] = await Promise.all([
|
||||
fetch('/api/settings/onboarding', { credentials: 'include' }),
|
||||
fetch('/api/system', { credentials: 'include' }),
|
||||
fetch('/api/system/info', { credentials: 'include' }),
|
||||
refreshSettings(),
|
||||
])
|
||||
if (systemRes.ok) isDocker.value = (await systemRes.json()).isDocker
|
||||
if (infoRes.ok) defaultPath.value = (await infoRes.json()).defaultPath ?? '/'
|
||||
if (onboardingRes.ok) {
|
||||
const { step, completedAt } = await onboardingRes.json()
|
||||
if (completedAt) {
|
||||
context.relaunch = true
|
||||
auth.onboardingDone = true
|
||||
reached.value = steps.length - 1
|
||||
} else {
|
||||
const i = steps.findIndex(s => s.id === step)
|
||||
reached.value = Math.max(0, i)
|
||||
index.value = reached.value
|
||||
}
|
||||
}
|
||||
loaded.value = true
|
||||
})
|
||||
</script>
|
||||
@@ -16,12 +16,28 @@
|
||||
|
||||
<div v-if="saved" class="text-xs text-green-400">Paramètre sauvegardé.</div>
|
||||
|
||||
<div class="settings-card flex flex-col sm:flex-row sm:items-center gap-4">
|
||||
<div class="flex-1">
|
||||
<p class="text-sm text-primary">Assistant de configuration</p>
|
||||
<p class="text-xs text-muted mt-0.5">
|
||||
Reprend pas à pas les dossiers, le client torrent, Jellyfin/Plex et le catalogue. La configuration actuelle est conservée.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2 shrink-0">
|
||||
<button @click="tour.start()" class="btn-ghost">Revoir la visite</button>
|
||||
<RouterLink to="/setup" class="btn-secondary">Relancer l'assistant</RouterLink>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, watch, onMounted } from 'vue'
|
||||
import SettingsToggle from '@/components/settings/SettingsToggle.vue'
|
||||
import { useTourStore } from '@/stores/tour'
|
||||
|
||||
const tour = useTourStore()
|
||||
|
||||
const devMode = ref(false)
|
||||
const saved = ref(false)
|
||||
|
||||
@@ -118,117 +118,16 @@
|
||||
<div class="bg-card border border-border rounded-xl w-full max-w-md p-6 flex flex-col gap-4">
|
||||
|
||||
<div class="flex items-center justify-between">
|
||||
<h3 class="text-sm font-semibold text-primary">{{ modal.uuid ? 'Modifier un client' : 'Ajouter un client' }}</h3>
|
||||
<h3 class="text-sm font-semibold text-primary">{{ modal.client ? 'Modifier un client' : 'Ajouter un client' }}</h3>
|
||||
<button @click="closeModal" class="text-muted hover:text-primary transition-colors">✕</button>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3">
|
||||
<div>
|
||||
<label class="settings-label">Nom</label>
|
||||
<input v-model="modal.name" placeholder="Mon client torrent" class="settings-input" />
|
||||
</div>
|
||||
<div>
|
||||
<label class="settings-label">Type</label>
|
||||
<select v-model="modal.type" @change="onTypeChange" class="settings-input">
|
||||
<option value="">Choisir un type...</option>
|
||||
<option v-for="def in availableClients" :key="def.id" :value="def.id">{{ def.label }}</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<!-- Champs principaux -->
|
||||
<template v-if="currentDefinition">
|
||||
<div v-for="field in basicFields" :key="field.key">
|
||||
<SettingsToggle
|
||||
v-if="field.type === 'boolean'"
|
||||
:model-value="toBool(modal.config[field.key])"
|
||||
:label="field.label"
|
||||
:description="fieldTooltip(field.key)"
|
||||
@update:model-value="modal.config[field.key] = $event"
|
||||
/>
|
||||
<template v-else>
|
||||
<label class="settings-label">
|
||||
{{ field.label }}
|
||||
<span v-if="field.required" class="text-red-400 ml-0.5">*</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="modal.config[field.key]"
|
||||
:type="field.type === 'password' ? 'password' : 'text'"
|
||||
:placeholder="field.placeholder ?? ''"
|
||||
class="settings-input"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<!-- Paramètres avancés -->
|
||||
<div v-if="advancedFields.length > 0">
|
||||
<button
|
||||
type="button"
|
||||
@click="advancedOpen = !advancedOpen"
|
||||
class="flex items-center gap-1.5 text-xs text-muted hover:text-primary transition-colors w-full py-1"
|
||||
>
|
||||
<ChevronDown
|
||||
:size="13"
|
||||
class="transition-transform duration-200 shrink-0"
|
||||
:class="advancedOpen ? 'rotate-180' : ''"
|
||||
/>
|
||||
Paramètres avancés
|
||||
</button>
|
||||
|
||||
<div v-if="advancedOpen" class="flex flex-col gap-3 mt-2 pl-3 border-l border-border">
|
||||
<div v-for="field in advancedFields" :key="field.key">
|
||||
<SettingsToggle
|
||||
v-if="field.type === 'boolean'"
|
||||
:model-value="toBool(modal.config[field.key])"
|
||||
:label="field.label"
|
||||
:description="fieldTooltip(field.key)"
|
||||
@update:model-value="modal.config[field.key] = $event"
|
||||
/>
|
||||
<template v-else>
|
||||
<label class="settings-label flex items-center gap-1.5">
|
||||
{{ field.label }}
|
||||
<span
|
||||
class="inline-flex items-center justify-center w-4 h-4 rounded-full border border-border text-[10px] text-muted cursor-default leading-none shrink-0 relative group"
|
||||
tabindex="-1"
|
||||
>
|
||||
i
|
||||
<span class="absolute bottom-full left-1/2 -translate-x-1/2 mb-1.5 w-56 text-[11px] text-secondary bg-card border border-border rounded-lg px-2.5 py-1.5 shadow-lg pointer-events-none opacity-0 group-hover:opacity-100 transition-opacity z-10 leading-relaxed">
|
||||
{{ fieldTooltip(field.key) }}
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<input
|
||||
v-model="modal.config[field.key]"
|
||||
:type="field.type === 'password' ? 'password' : 'text'"
|
||||
:placeholder="field.placeholder ?? ''"
|
||||
class="settings-input"
|
||||
/>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
|
||||
<p v-if="!modal.tested && modal.type" class="text-xs text-muted">
|
||||
Testez la connexion avant d'enregistrer.
|
||||
</p>
|
||||
|
||||
<div class="flex gap-2 pt-1">
|
||||
<button
|
||||
@click="saveClient"
|
||||
:disabled="modal.saving || !modal.tested"
|
||||
class="btn-primary"
|
||||
>
|
||||
{{ modal.saving ? '...' : 'Enregistrer' }}
|
||||
</button>
|
||||
<button
|
||||
@click="testNewClient"
|
||||
:disabled="modal.testing || !modal.type"
|
||||
class="btn-secondary"
|
||||
>
|
||||
{{ modal.testing ? '...' : modal.tested ? 'Testé ✓' : 'Tester' }}
|
||||
</button>
|
||||
</div>
|
||||
<TorrentClientForm
|
||||
:key="modal.key"
|
||||
:client="modal.client"
|
||||
:definitions="availableClients"
|
||||
@saved="onSaved"
|
||||
/>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -238,15 +137,15 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted } from 'vue'
|
||||
import { ChevronDown } from 'lucide-vue-next'
|
||||
import SettingsToggle from '@/components/settings/SettingsToggle.vue'
|
||||
import { ref, onMounted } from 'vue'
|
||||
import TorrentClientForm from '@/components/settings/TorrentClientForm.vue'
|
||||
import { useToast } from '@/composables/useToast'
|
||||
import type { TorrentClientDefinition, SavedTorrentClient } from '@/types/torrent-client'
|
||||
|
||||
const { add: toast } = useToast()
|
||||
|
||||
const clients = ref<any[]>([])
|
||||
const availableClients = ref<any[]>([])
|
||||
const clients = ref<SavedTorrentClient[]>([])
|
||||
const availableClients = ref<TorrentClientDefinition[]>([])
|
||||
const healthStatus = ref<Record<string, boolean | null>>({})
|
||||
|
||||
const clientMatrix = [
|
||||
@@ -276,48 +175,7 @@ const clientMatrix = [
|
||||
}
|
||||
]
|
||||
|
||||
const modal = ref({
|
||||
open : false,
|
||||
uuid : null as string | null,
|
||||
name : '',
|
||||
type : '',
|
||||
config : {} as Record<string, string | number | boolean>,
|
||||
testing: false,
|
||||
saving : false,
|
||||
tested : false,
|
||||
})
|
||||
|
||||
const ADVANCED_KEYS = ['savePath', 'remotePath', 'localPath', 'ignoreCertificateErrors']
|
||||
|
||||
const FIELD_TOOLTIPS: Record<string, string> = {
|
||||
savePath : 'Optionnel. Permet de placer les téléchargements dans un sous-dossier spécifique à l\'intérieur du dossier déjà configuré dans la gestion des médias.',
|
||||
remotePath : 'Si le client tourne sur une autre machine, indiquez ici le chemin qu\'il utilise (ex: /downloads). À associer avec le chemin local ci-dessous.',
|
||||
localPath : 'Chemin équivalent au chemin distant, mais vu par FanKarr sur sa machine (ex: /mnt/nas/downloads). Les deux champs fonctionnent en binôme pour faire la correspondance.',
|
||||
ignoreCertificateErrors: 'Accepte les certificats auto-signés ou invalides en HTTPS. À n\'utiliser que sur un réseau de confiance.',
|
||||
}
|
||||
|
||||
function fieldTooltip(key: string): string {
|
||||
return FIELD_TOOLTIPS[key] ?? ''
|
||||
}
|
||||
|
||||
// Tolère la forme string "true" en plus du booléen natif
|
||||
function toBool(v: unknown): boolean {
|
||||
return v === true || v === 'true'
|
||||
}
|
||||
|
||||
const advancedOpen = ref(false)
|
||||
|
||||
const currentDefinition = computed(() =>
|
||||
availableClients.value.find(d => d.id === modal.value.type) ?? null
|
||||
)
|
||||
|
||||
const basicFields = computed(() =>
|
||||
currentDefinition.value?.fields.filter((f: any) => !ADVANCED_KEYS.includes(f.key)) ?? []
|
||||
)
|
||||
|
||||
const advancedFields = computed(() =>
|
||||
currentDefinition.value?.fields.filter((f: any) => ADVANCED_KEYS.includes(f.key)) ?? []
|
||||
)
|
||||
const modal = ref({ open: false, key: 0, client: null as SavedTorrentClient | null })
|
||||
|
||||
function clientLabel(type: string) {
|
||||
return availableClients.value.find(d => d.id === type)?.label ?? type
|
||||
@@ -362,110 +220,23 @@ async function deleteClient(uuid: string) {
|
||||
}
|
||||
|
||||
function openAddModal() {
|
||||
modal.value = { open: true, uuid: null, name: '', type: '', config: {}, testing: false, saving: false, tested: false }
|
||||
advancedOpen.value = false
|
||||
modal.value = { open: true, key: modal.value.key + 1, client: null }
|
||||
}
|
||||
|
||||
function editClient(client: any) {
|
||||
modal.value = {
|
||||
open : true,
|
||||
uuid : client.uuid,
|
||||
name : client.name,
|
||||
type : client.type,
|
||||
config : JSON.parse(JSON.stringify(client.config)),
|
||||
testing: false,
|
||||
saving : false,
|
||||
tested : true,
|
||||
}
|
||||
function editClient(client: SavedTorrentClient) {
|
||||
modal.value = { open: true, key: modal.value.key + 1, client }
|
||||
}
|
||||
|
||||
function closeModal() { modal.value.open = false }
|
||||
|
||||
function onTypeChange() {
|
||||
modal.value.config = {}
|
||||
modal.value.tested = false
|
||||
advancedOpen.value = false
|
||||
const def = currentDefinition.value
|
||||
if (def) {
|
||||
for (const field of def.fields) {
|
||||
if (field.default === undefined) continue
|
||||
modal.value.config[field.key] = field.type === 'boolean' ? field.default : String(field.default)
|
||||
}
|
||||
function onSaved(client: SavedTorrentClient, isEdit: boolean) {
|
||||
if (isEdit) {
|
||||
const index = clients.value.findIndex(c => c.uuid === client.uuid)
|
||||
if (index !== -1) clients.value[index] = client
|
||||
} else {
|
||||
clients.value.push(client)
|
||||
}
|
||||
refreshHealth(client.uuid)
|
||||
closeModal()
|
||||
}
|
||||
|
||||
// Reset tested dès que l'utilisateur modifie un champ (nom ou config)
|
||||
// sauf si c'est un mot de passe masqué non touché
|
||||
watch(() => modal.value.name, () => {
|
||||
if (modal.value.uuid) modal.value.tested = false
|
||||
})
|
||||
|
||||
watch(() => modal.value.config, (newConfig) => {
|
||||
if (!modal.value.uuid) return
|
||||
const driver = currentDefinition.value
|
||||
if (!driver) return
|
||||
// Si au moins un champ non-password a changé → reset tested
|
||||
// Pour les passwords, on reset seulement si la valeur n'est plus le masque
|
||||
for (const [key, val] of Object.entries(newConfig)) {
|
||||
const field = driver.fields.find((f: any) => f.key === key)
|
||||
if (!field) continue
|
||||
if (field.type === 'password' && val === '••••••••') continue
|
||||
modal.value.tested = false
|
||||
return
|
||||
}
|
||||
}, { deep: true })
|
||||
|
||||
async function testNewClient() {
|
||||
modal.value.testing = true
|
||||
modal.value.tested = false
|
||||
try {
|
||||
const res = await fetch('/api/torrent-clients/test-config', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include',
|
||||
body: JSON.stringify({ type: modal.value.type, config: modal.value.config, uuid: modal.value.uuid }),
|
||||
})
|
||||
const { ok, message } = await res.json()
|
||||
modal.value.tested = ok
|
||||
toast(ok ? 'Connexion réussie ✓' : (message ?? 'Connexion échouée'), ok ? 'success' : 'error')
|
||||
} catch {
|
||||
toast('Impossible de contacter le serveur', 'error')
|
||||
} finally {
|
||||
modal.value.testing = false
|
||||
}
|
||||
}
|
||||
|
||||
async function saveClient() {
|
||||
if (!modal.value.tested) return
|
||||
modal.value.saving = true
|
||||
try {
|
||||
const isEdit = !!modal.value.uuid
|
||||
const method = isEdit ? 'PUT' : 'POST'
|
||||
const url = isEdit ? `/api/torrent-clients/${modal.value.uuid}` : '/api/torrent-clients'
|
||||
|
||||
const res = await fetch(url, {
|
||||
method, headers: { 'Content-Type': 'application/json' }, credentials: 'include',
|
||||
body: JSON.stringify({
|
||||
name : modal.value.name || clientLabel(modal.value.type),
|
||||
type : modal.value.type,
|
||||
config: modal.value.config,
|
||||
}),
|
||||
})
|
||||
if (res.ok) {
|
||||
const client = await res.json()
|
||||
if (isEdit) {
|
||||
const index = clients.value.findIndex(c => c.uuid === client.uuid)
|
||||
if (index !== -1) clients.value[index] = client
|
||||
} else {
|
||||
clients.value.push(client)
|
||||
}
|
||||
refreshHealth(client.uuid)
|
||||
closeModal()
|
||||
toast(isEdit ? 'Client modifié ✓' : 'Client enregistré ✓', 'success')
|
||||
} else {
|
||||
const { error } = await res.json()
|
||||
toast(error ?? "Erreur lors de l'enregistrement", 'error')
|
||||
}
|
||||
} finally {
|
||||
modal.value.saving = false
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</script>
|
||||
@@ -11,34 +11,7 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="settings-card flex flex-col gap-4">
|
||||
<div>
|
||||
<label class="settings-label mb-1.5">URL du serveur</label>
|
||||
<input v-model="jellyfinUrl" type="url" class="settings-input" placeholder="http://jellyfin:8096" />
|
||||
<p class="text-xs text-muted mt-1">URL accessible depuis FanKarr (réseau local ou Docker)</p>
|
||||
</div>
|
||||
<div>
|
||||
<label class="settings-label mb-1.5">Token admin Jellyfin</label>
|
||||
<input v-model="jellyfinAdminToken" type="password" class="settings-input"
|
||||
:placeholder="hasToken ? '••••••••••••••••••••• (configuré)' : 'Tableau de bord → Clés API'" />
|
||||
<p class="text-xs text-muted mt-1">
|
||||
Dans Jellyfin : Tableau de bord → Clés API → Créer une clé
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-3 flex-wrap">
|
||||
<button @click="save" :disabled="saving" class="btn-primary">
|
||||
{{ saving ? 'Enregistrement…' : 'Enregistrer' }}
|
||||
</button>
|
||||
<button @click="testConnection" :disabled="testing" class="btn-secondary">
|
||||
{{ testing ? 'Test…' : 'Tester la connexion' }}
|
||||
</button>
|
||||
<span v-if="testResult" class="text-xs" :class="testResult.ok ? 'text-green-400' : 'text-red-400'">
|
||||
{{ testResult.ok ? `Connecté — Jellyfin ${testResult.version}` : testResult.error }}
|
||||
</span>
|
||||
<span v-if="saved" class="text-xs text-green-400">Enregistré.</span>
|
||||
</div>
|
||||
</div>
|
||||
<JellyfinConnectionForm @change="hasToken = $event.hasToken" />
|
||||
</section>
|
||||
|
||||
<!-- ── Synchronisation des utilisateurs ──────────────────── -->
|
||||
@@ -102,15 +75,10 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted } from 'vue'
|
||||
import { ref } from 'vue'
|
||||
import JellyfinConnectionForm from '@/components/settings/JellyfinConnectionForm.vue'
|
||||
|
||||
const jellyfinUrl = ref('')
|
||||
const jellyfinAdminToken = ref('')
|
||||
const hasToken = ref(false)
|
||||
const saving = ref(false)
|
||||
const saved = ref(false)
|
||||
const testing = ref(false)
|
||||
const testResult = ref<{ ok: boolean; version?: string; error?: string } | null>(null)
|
||||
const syncing = ref(false)
|
||||
const syncResult = ref<{ created: number; skipped: number; users: string[] } | null>(null)
|
||||
const syncError = ref<string | null>(null)
|
||||
@@ -127,44 +95,6 @@ function methodClass(m: string) {
|
||||
return { GET: 'text-green-400', POST: 'text-blue-400', DELETE: 'text-red-400' }[m] ?? 'text-muted'
|
||||
}
|
||||
|
||||
async function loadSettings() {
|
||||
const res = await fetch('/api/jellyfin/settings', { credentials: 'include' })
|
||||
if (res.ok) {
|
||||
const d = await res.json()
|
||||
jellyfinUrl.value = d.jellyfinUrl ?? ''
|
||||
hasToken.value = d.hasToken ?? false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => { loadSettings() })
|
||||
|
||||
async function save() {
|
||||
saving.value = true
|
||||
saved.value = false
|
||||
const body: Record<string, string> = { jellyfinUrl: jellyfinUrl.value }
|
||||
if (jellyfinAdminToken.value) body.jellyfinAdminToken = jellyfinAdminToken.value
|
||||
const res = await fetch('/api/jellyfin/settings', {
|
||||
method: 'POST', headers: { 'Content-Type': 'application/json' }, credentials: 'include',
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
if (res.ok) {
|
||||
const d = await res.json()
|
||||
hasToken.value = d.hasToken
|
||||
jellyfinAdminToken.value = '' // vider le champ après sauvegarde
|
||||
saved.value = true
|
||||
setTimeout(() => { saved.value = false }, 2000)
|
||||
}
|
||||
saving.value = false
|
||||
}
|
||||
|
||||
async function testConnection() {
|
||||
testing.value = true
|
||||
testResult.value = null
|
||||
const res = await fetch('/api/jellyfin/test', { method: 'POST', credentials: 'include' })
|
||||
testResult.value = await res.json()
|
||||
testing.value = false
|
||||
}
|
||||
|
||||
async function syncUsers() {
|
||||
syncing.value = true
|
||||
syncError.value = null
|
||||
@@ -175,7 +105,4 @@ async function syncUsers() {
|
||||
else syncError.value = data.error ?? 'Erreur lors de la synchronisation'
|
||||
syncing.value = false
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@@ -57,7 +57,7 @@
|
||||
</section>
|
||||
|
||||
<!-- ── Token API personnel ──────────────────────────────── -->
|
||||
<section class="flex flex-col gap-4">
|
||||
<section data-tour="profile-token" class="flex flex-col gap-4">
|
||||
<div>
|
||||
<h2 class="text-base font-semibold text-primary">Token API personnel</h2>
|
||||
<p class="text-sm text-muted mt-1">
|
||||
|
||||
Reference in new issue
Block a user