Some checks failed
Deploy / Deploy Production (push) Has been skipped
Deploy / Cleanup Preview (push) Has been skipped
Deploy / Deploy Preview (push) Failing after 1s
CI / UI / Build (pull_request) Successful in 16s
CI / Scraper / Test (pull_request) Successful in 16s
CI / Scraper / Lint (pull_request) Successful in 19s
CI / Scraper / Build (pull_request) Successful in 16s
- Add /profile page with reading settings (voice, speed, auto-next) and password change form - Add /admin/scrape page showing scraping task history with live status polling and trigger controls - Add /admin/audio page showing audio cache entries with client-side search filter - Add changePassword(), listAudioCache(), listScrapingTasks() to pocketbase.ts - Add /api/admin/scrape and /api/browse-page server-side proxy routes - Replace browse page pagination with IntersectionObserver infinite scroll - Update nav: username becomes a /profile link; admin users see Scrape and Audio cache links
30 lines
848 B
TypeScript
30 lines
848 B
TypeScript
import { redirect } from '@sveltejs/kit';
|
|
import type { PageServerLoad } from './$types';
|
|
import { listScrapingTasks } from '$lib/server/pocketbase';
|
|
import { env } from '$env/dynamic/private';
|
|
import { log } from '$lib/server/logger';
|
|
|
|
const SCRAPER_URL = env.SCRAPER_API_URL ?? 'http://localhost:8080';
|
|
|
|
export const load: PageServerLoad = async ({ locals }) => {
|
|
if (locals.user?.role !== 'admin') {
|
|
redirect(302, '/');
|
|
}
|
|
|
|
const [tasks, statusRes] = await Promise.all([
|
|
listScrapingTasks().catch((e) => {
|
|
log.warn('admin/scrape', 'failed to load tasks', { err: String(e) });
|
|
return [];
|
|
}),
|
|
fetch(`${SCRAPER_URL}/api/scrape/status`).catch(() => null)
|
|
]);
|
|
|
|
let running = false;
|
|
if (statusRes?.ok) {
|
|
const body = await statusRes.json().catch(() => null);
|
|
running = body?.running ?? false;
|
|
}
|
|
|
|
return { tasks, running };
|
|
};
|