@@ -188,6 +188,7 @@ const loadingRequests = ref(true)
let interval: ReturnType | null = null
async function fetchSettings() {
+ if (!auth.isAdmin) return
const res = await fetch('/api/settings', { credentials: 'include' })
if (res.ok) {
const s = await res.json()
@@ -203,10 +204,9 @@ async function fetchDebug() {
async function fetchStats() {
try {
- const [statusRes, seriesRes, downloadsRes] = await Promise.all([
+ const [statusRes, seriesRes] = await Promise.all([
fetch('/api/torrents/status', { credentials: 'include' }),
fetch('/api/series', { credentials: 'include' }),
- fetch('/api/downloads', { credentials: 'include' }),
])
if (statusRes.ok) { const s = await statusRes.json(); stats.value.catalogue = s.count ?? 0 }
if (seriesRes.ok) {
@@ -214,15 +214,20 @@ async function fetchStats() {
const list = Array.isArray(s) ? s : (s.series ?? [])
stats.value.imported = list.filter((s: any) => s.download_state === 'complete').length
}
- if (downloadsRes.ok) {
- const torrents = await downloadsRes.json()
- stats.value.downloading = torrents.filter((t: any) => t.state === 'downloading').length
- stats.value.errors = torrents.filter((t: any) => t.state === 'error').length
+ // Stats téléchargements : admin uniquement
+ if (auth.isAdmin) {
+ const downloadsRes = await fetch('/api/downloads', { credentials: 'include' })
+ if (downloadsRes.ok) {
+ const torrents = await downloadsRes.json()
+ stats.value.downloading = torrents.filter((t: any) => t.state === 'downloading').length
+ stats.value.errors = torrents.filter((t: any) => t.state === 'error').length
+ }
}
} catch {}
}
async function fetchTorrents() {
+ if (!auth.isAdmin) { loadingTorrents.value = false; return }
const isFirst = loadingTorrents.value
try {
const res = await fetch('/api/downloads', { credentials: 'include' })
@@ -236,6 +241,7 @@ async function fetchTorrents() {
}
async function fetchNotifs() {
+ if (!auth.isAdmin) { loadingNotifs.value = false; return }
loadingNotifs.value = true
try {
const res = await fetch('/api/organize/recent', { credentials: 'include' })
diff --git a/src/views/SeriesView.vue b/src/views/SeriesView.vue
index 7599aeb..0f0d751 100644
--- a/src/views/SeriesView.vue
+++ b/src/views/SeriesView.vue
@@ -88,8 +88,9 @@
import { ref, computed, onMounted, onUnmounted, onActivated } from 'vue'
import { RouterLink } from 'vue-router'
import { Tv } from 'lucide-vue-next'
-import { useSeriesStore } from '@/stores/series'
+import { useSeriesStore } from '@/stores/series'
import { useDownloadsStore } from '@/stores/downloads'
+import { useAuthStore } from '@/stores/auth'
import { useToast } from '@/composables/useToast'
import { usePosterSize } from '@/composables/usePosterSize'
import SeriesToolbar from '@/components/series/SeriesToolbar.vue'
@@ -98,6 +99,7 @@ defineOptions({ name: 'SeriesView' })
const store = useSeriesStore()
const dlStore = useDownloadsStore()
+const auth = useAuthStore()
const { add: toast } = useToast()
const { current: posterSize, sizes: posterSizes } = usePosterSize()
@@ -198,17 +200,19 @@ async function fetchOrganizeNotifs() {
onMounted(async () => {
if (store.series.length === 0) await store.fetchSeries()
- dlStore.refresh()
- fetchOrganizeNotifs()
- dlInterval = setInterval(() => {
+ if (auth.isAdmin) {
dlStore.refresh()
fetchOrganizeNotifs()
- }, 10000)
+ dlInterval = setInterval(() => {
+ dlStore.refresh()
+ fetchOrganizeNotifs()
+ }, 10000)
+ }
})
onActivated(async () => {
store.fetchSeries()
- dlStore.refresh()
+ if (auth.isAdmin) dlStore.refresh()
})
onUnmounted(() => {