feat(web): add Vue 3 frontend scaffold -- LibraryView, DocumentCard, IngestProgress
Vue 3 + Vite + TypeScript scaffold with theme-aware CSS variables, router, LibraryView (PDF library grid), DocumentCard (per-doc status + actions), IngestProgress (polling progress bar), and ChatView stub for Task 9.
This commit is contained in:
parent
17cdb552a3
commit
b4837163d5
21 changed files with 3519 additions and 0 deletions
39
web/.gitignore
vendored
Normal file
39
web/.gitignore
vendored
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
pnpm-debug.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
node_modules
|
||||||
|
.DS_Store
|
||||||
|
dist
|
||||||
|
dist-ssr
|
||||||
|
coverage
|
||||||
|
*.local
|
||||||
|
|
||||||
|
# Editor directories and files
|
||||||
|
.vscode/*
|
||||||
|
!.vscode/extensions.json
|
||||||
|
.idea
|
||||||
|
*.suo
|
||||||
|
*.ntvs*
|
||||||
|
*.njsproj
|
||||||
|
*.sln
|
||||||
|
*.sw?
|
||||||
|
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Cypress
|
||||||
|
/cypress/videos/
|
||||||
|
/cypress/screenshots/
|
||||||
|
|
||||||
|
# Vitest
|
||||||
|
__screenshots__/
|
||||||
|
|
||||||
|
# Vite
|
||||||
|
*.timestamp-*-*.mjs
|
||||||
3
web/.vscode/extensions.json
vendored
Normal file
3
web/.vscode/extensions.json
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"recommendations": ["Vue.volar"]
|
||||||
|
}
|
||||||
42
web/README.md
Normal file
42
web/README.md
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
# web
|
||||||
|
|
||||||
|
This template should help get you started developing with Vue 3 in Vite.
|
||||||
|
|
||||||
|
## Recommended IDE Setup
|
||||||
|
|
||||||
|
[VS Code](https://code.visualstudio.com/) + [Vue (Official)](https://marketplace.visualstudio.com/items?itemName=Vue.volar) (and disable Vetur).
|
||||||
|
|
||||||
|
## Recommended Browser Setup
|
||||||
|
|
||||||
|
- Chromium-based browsers (Chrome, Edge, Brave, etc.):
|
||||||
|
- [Vue.js devtools](https://chromewebstore.google.com/detail/vuejs-devtools/nhdogjmejiglipccpnnnanhbledajbpd)
|
||||||
|
- [Turn on Custom Object Formatter in Chrome DevTools](http://bit.ly/object-formatters)
|
||||||
|
- Firefox:
|
||||||
|
- [Vue.js devtools](https://addons.mozilla.org/en-US/firefox/addon/vue-js-devtools/)
|
||||||
|
- [Turn on Custom Object Formatter in Firefox DevTools](https://fxdx.dev/firefox-devtools-custom-object-formatters/)
|
||||||
|
|
||||||
|
## Type Support for `.vue` Imports in TS
|
||||||
|
|
||||||
|
TypeScript cannot handle type information for `.vue` imports by default, so we replace the `tsc` CLI with `vue-tsc` for type checking. In editors, we need [Volar](https://marketplace.visualstudio.com/items?itemName=Vue.volar) to make the TypeScript language service aware of `.vue` types.
|
||||||
|
|
||||||
|
## Customize configuration
|
||||||
|
|
||||||
|
See [Vite Configuration Reference](https://vite.dev/config/).
|
||||||
|
|
||||||
|
## Project Setup
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
### Compile and Hot-Reload for Development
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run dev
|
||||||
|
```
|
||||||
|
|
||||||
|
### Type-Check, Compile and Minify for Production
|
||||||
|
|
||||||
|
```sh
|
||||||
|
npm run build
|
||||||
|
```
|
||||||
1
web/env.d.ts
vendored
Normal file
1
web/env.d.ts
vendored
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
/// <reference types="vite/client" />
|
||||||
13
web/index.html
Normal file
13
web/index.html
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Pagepiper</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="app"></div>
|
||||||
|
<script type="module" src="/src/main.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
2898
web/package-lock.json
generated
Normal file
2898
web/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load diff
31
web/package.json
Normal file
31
web/package.json
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
{
|
||||||
|
"name": "web",
|
||||||
|
"version": "0.0.0",
|
||||||
|
"private": true,
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"dev": "vite",
|
||||||
|
"build": "run-p type-check \"build-only {@}\" --",
|
||||||
|
"preview": "vite preview",
|
||||||
|
"build-only": "vite build",
|
||||||
|
"type-check": "vue-tsc --build"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"vue": "^3.5.32",
|
||||||
|
"vue-router": "^5.0.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@tsconfig/node24": "^24.0.4",
|
||||||
|
"@types/node": "^24.12.2",
|
||||||
|
"@vitejs/plugin-vue": "^6.0.6",
|
||||||
|
"@vue/tsconfig": "^0.9.1",
|
||||||
|
"npm-run-all2": "^8.0.4",
|
||||||
|
"typescript": "~6.0.0",
|
||||||
|
"vite": "^8.0.8",
|
||||||
|
"vite-plugin-vue-devtools": "^8.1.1",
|
||||||
|
"vue-tsc": "^3.2.6"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": "^20.19.0 || >=22.12.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
web/public/favicon.ico
Normal file
BIN
web/public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.2 KiB |
33
web/src/App.vue
Normal file
33
web/src/App.vue
Normal file
|
|
@ -0,0 +1,33 @@
|
||||||
|
<template>
|
||||||
|
<div id="app">
|
||||||
|
<nav class="nav">
|
||||||
|
<span class="nav-brand">Pagepiper</span>
|
||||||
|
<RouterLink to="/" class="nav-link">Library</RouterLink>
|
||||||
|
<RouterLink to="/chat" class="nav-link">Chat</RouterLink>
|
||||||
|
</nav>
|
||||||
|
<RouterView />
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { RouterLink, RouterView } from "vue-router"
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
@import "@/theme.css";
|
||||||
|
|
||||||
|
.nav {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 1.5rem;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
background: var(--color-surface);
|
||||||
|
border-bottom: 1px solid var(--color-border);
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 100;
|
||||||
|
}
|
||||||
|
.nav-brand { font-weight: 700; color: var(--color-accent); }
|
||||||
|
.nav-link { color: var(--color-text-muted); text-decoration: none; }
|
||||||
|
.nav-link:hover, .nav-link.router-link-active { color: var(--color-text); }
|
||||||
|
</style>
|
||||||
95
web/src/api.ts
Normal file
95
web/src/api.ts
Normal file
|
|
@ -0,0 +1,95 @@
|
||||||
|
// web/src/api.ts
|
||||||
|
const BASE = import.meta.env.VITE_API_BASE ?? ""
|
||||||
|
|
||||||
|
export interface Document {
|
||||||
|
id: string
|
||||||
|
title: string
|
||||||
|
file_path: string
|
||||||
|
status: "pending" | "processing" | "ready" | "error"
|
||||||
|
task_id: string | null
|
||||||
|
page_count: number | null
|
||||||
|
created_at: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SearchResult {
|
||||||
|
chunk_id: string
|
||||||
|
doc_id: string
|
||||||
|
page_number: number
|
||||||
|
text_snippet: string
|
||||||
|
bm25_score: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Citation {
|
||||||
|
doc_id: string
|
||||||
|
page_number: number
|
||||||
|
snippet: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ChatResponse {
|
||||||
|
answer: string
|
||||||
|
citations: Citation[]
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TaskStatus {
|
||||||
|
status: string
|
||||||
|
progress?: number
|
||||||
|
error?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export const api = {
|
||||||
|
async getLibrary(): Promise<Document[]> {
|
||||||
|
const r = await fetch(`${BASE}/api/library`)
|
||||||
|
if (!r.ok) throw new Error(await r.text())
|
||||||
|
return r.json()
|
||||||
|
},
|
||||||
|
async scanLibrary(): Promise<{ discovered: number; queued: number; tasks: { doc_id: string; task_id: string }[] }> {
|
||||||
|
const r = await fetch(`${BASE}/api/library/scan`, { method: "POST" })
|
||||||
|
if (!r.ok) throw new Error(await r.text())
|
||||||
|
return r.json()
|
||||||
|
},
|
||||||
|
async reingestDocument(docId: string): Promise<{ task_id: string }> {
|
||||||
|
const r = await fetch(`${BASE}/api/library/${docId}/reingest`, { method: "POST" })
|
||||||
|
if (!r.ok) throw new Error(await r.text())
|
||||||
|
return r.json()
|
||||||
|
},
|
||||||
|
async deleteDocument(docId: string): Promise<void> {
|
||||||
|
const r = await fetch(`${BASE}/api/library/${docId}`, { method: "DELETE" })
|
||||||
|
if (!r.ok) throw new Error(await r.text())
|
||||||
|
},
|
||||||
|
async getTaskStatus(taskId: string): Promise<TaskStatus> {
|
||||||
|
const r = await fetch(`${BASE}/api/ingest/${taskId}`)
|
||||||
|
if (!r.ok) throw new Error(await r.text())
|
||||||
|
return r.json()
|
||||||
|
},
|
||||||
|
async search(query: string, topK = 10, docIds?: string[]): Promise<SearchResult[]> {
|
||||||
|
const r = await fetch(`${BASE}/api/search`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ query, top_k: topK, doc_ids: docIds ?? null }),
|
||||||
|
})
|
||||||
|
if (!r.ok) throw new Error(await r.text())
|
||||||
|
return r.json()
|
||||||
|
},
|
||||||
|
async chat(
|
||||||
|
message: string,
|
||||||
|
history: { role: string; content: string }[],
|
||||||
|
docIds?: string[],
|
||||||
|
topK = 5,
|
||||||
|
): Promise<ChatResponse> {
|
||||||
|
const r = await fetch(`${BASE}/api/chat`, {
|
||||||
|
method: "POST",
|
||||||
|
headers: { "Content-Type": "application/json" },
|
||||||
|
body: JSON.stringify({ message, history, doc_ids: docIds ?? null, top_k: topK }),
|
||||||
|
})
|
||||||
|
if (!r.ok) {
|
||||||
|
const body = await r.json().catch(() => ({}))
|
||||||
|
const err: Error & { status?: number; detail?: unknown } = new Error(
|
||||||
|
(body as { detail?: { message?: string } }).detail?.message ?? "Request failed"
|
||||||
|
)
|
||||||
|
err.status = r.status
|
||||||
|
err.detail = (body as { detail?: unknown }).detail
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
return r.json()
|
||||||
|
},
|
||||||
|
}
|
||||||
68
web/src/components/DocumentCard.vue
Normal file
68
web/src/components/DocumentCard.vue
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
<template>
|
||||||
|
<div class="doc-card" :class="`status-${doc.status}`">
|
||||||
|
<div class="doc-status-badge">{{ doc.status }}</div>
|
||||||
|
<div class="doc-title">{{ doc.title }}</div>
|
||||||
|
<div class="doc-meta" v-if="doc.page_count">{{ doc.page_count }} pages</div>
|
||||||
|
<div class="doc-meta path">{{ shortPath }}</div>
|
||||||
|
|
||||||
|
<IngestProgress
|
||||||
|
v-if="doc.status === 'processing' && doc.task_id"
|
||||||
|
:task-id="doc.task_id"
|
||||||
|
@done="emit('refresh')"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div class="doc-actions">
|
||||||
|
<button class="btn-sm" @click="emit('reingest', doc.id)" :disabled="doc.status === 'processing'">
|
||||||
|
Re-index
|
||||||
|
</button>
|
||||||
|
<button class="btn-sm danger" @click="emit('delete', doc.id)">Remove</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed } from "vue"
|
||||||
|
import type { Document } from "@/api"
|
||||||
|
import IngestProgress from "@/components/IngestProgress.vue"
|
||||||
|
|
||||||
|
const props = defineProps<{ doc: Document }>()
|
||||||
|
const emit = defineEmits<{ reingest: [id: string]; delete: [id: string]; refresh: [] }>()
|
||||||
|
|
||||||
|
const shortPath = computed(() => {
|
||||||
|
const parts = props.doc.file_path.split("/")
|
||||||
|
return parts.slice(-2).join("/")
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.doc-card {
|
||||||
|
background: var(--color-surface);
|
||||||
|
border: 1px solid var(--color-border);
|
||||||
|
border-radius: var(--radius-md);
|
||||||
|
padding: 1rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.4rem;
|
||||||
|
box-shadow: var(--shadow-card);
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
.doc-card.status-error { border-color: var(--color-error); }
|
||||||
|
.doc-card.status-ready { border-color: var(--color-success); }
|
||||||
|
.doc-title { font-weight: 600; font-size: 1rem; }
|
||||||
|
.doc-meta { font-size: 0.8rem; color: var(--color-text-muted); }
|
||||||
|
.doc-meta.path { font-family: var(--font-mono); word-break: break-all; }
|
||||||
|
.doc-status-badge {
|
||||||
|
position: absolute; top: 0.5rem; right: 0.75rem;
|
||||||
|
font-size: 0.7rem; font-weight: 700; text-transform: uppercase;
|
||||||
|
padding: 2px 6px; border-radius: var(--radius-sm);
|
||||||
|
background: var(--color-surface-alt);
|
||||||
|
}
|
||||||
|
.doc-actions { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
|
||||||
|
.btn-sm {
|
||||||
|
padding: 4px 10px; border: 1px solid var(--color-border); border-radius: var(--radius-sm);
|
||||||
|
background: var(--color-surface-alt); color: var(--color-text); cursor: pointer; font-size: 0.8rem;
|
||||||
|
}
|
||||||
|
.btn-sm:hover { border-color: var(--color-accent); }
|
||||||
|
.btn-sm.danger:hover { border-color: var(--color-error); color: var(--color-error); }
|
||||||
|
.btn-sm:disabled { opacity: 0.4; cursor: default; }
|
||||||
|
</style>
|
||||||
73
web/src/components/IngestProgress.vue
Normal file
73
web/src/components/IngestProgress.vue
Normal file
|
|
@ -0,0 +1,73 @@
|
||||||
|
<template>
|
||||||
|
<div class="ingest-progress" v-if="visible">
|
||||||
|
<div class="progress-label">
|
||||||
|
<span>{{ statusLabel }}</span>
|
||||||
|
<span class="progress-pct" v-if="status?.progress != null">{{ status.progress }}%</span>
|
||||||
|
</div>
|
||||||
|
<div class="progress-bar">
|
||||||
|
<div class="progress-fill" :style="{ width: barWidth }" />
|
||||||
|
</div>
|
||||||
|
<p class="progress-error" v-if="status?.status === 'error'">{{ status.error }}</p>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, onMounted, onUnmounted, ref } from "vue"
|
||||||
|
import { api, type TaskStatus } from "@/api"
|
||||||
|
|
||||||
|
const props = defineProps<{ taskId: string | null }>()
|
||||||
|
const emit = defineEmits<{ done: [] }>()
|
||||||
|
|
||||||
|
const status = ref<TaskStatus | null>(null)
|
||||||
|
let timer: ReturnType<typeof setInterval> | null = null
|
||||||
|
|
||||||
|
const visible = computed(() => props.taskId !== null && status.value?.status !== "complete")
|
||||||
|
|
||||||
|
const statusLabel = computed(() => {
|
||||||
|
if (!status.value) return "Queued..."
|
||||||
|
const map: Record<string, string> = {
|
||||||
|
running: "Indexing...",
|
||||||
|
complete: "Done",
|
||||||
|
error: "Error",
|
||||||
|
}
|
||||||
|
return map[status.value.status] ?? "Processing..."
|
||||||
|
})
|
||||||
|
|
||||||
|
const barWidth = computed(() => {
|
||||||
|
const p = status.value?.progress ?? 0
|
||||||
|
return `${Math.min(p, 100)}%`
|
||||||
|
})
|
||||||
|
|
||||||
|
async function poll() {
|
||||||
|
if (!props.taskId) return
|
||||||
|
try {
|
||||||
|
status.value = await api.getTaskStatus(props.taskId)
|
||||||
|
if (status.value.status === "complete") {
|
||||||
|
stopPoll()
|
||||||
|
emit("done")
|
||||||
|
} else if (status.value.status === "error") {
|
||||||
|
stopPoll()
|
||||||
|
}
|
||||||
|
} catch (_e: unknown) { /* task not yet registered */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
function stopPoll() {
|
||||||
|
if (timer) { clearInterval(timer); timer = null }
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(() => {
|
||||||
|
if (props.taskId) {
|
||||||
|
poll()
|
||||||
|
timer = setInterval(poll, 2000)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
onUnmounted(stopPoll)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.ingest-progress { margin-top: 0.5rem; }
|
||||||
|
.progress-label { display: flex; justify-content: space-between; font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 4px; }
|
||||||
|
.progress-bar { height: 4px; background: var(--color-border); border-radius: 2px; overflow: hidden; }
|
||||||
|
.progress-fill { height: 100%; background: var(--color-accent); transition: width 0.3s ease; }
|
||||||
|
.progress-error { color: var(--color-error); font-size: 0.8rem; margin-top: 4px; }
|
||||||
|
</style>
|
||||||
5
web/src/main.ts
Normal file
5
web/src/main.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
import { createApp } from "vue"
|
||||||
|
import App from "./App.vue"
|
||||||
|
import router from "./router"
|
||||||
|
|
||||||
|
createApp(App).use(router).mount("#app")
|
||||||
11
web/src/router/index.ts
Normal file
11
web/src/router/index.ts
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
import { createRouter, createWebHistory } from "vue-router"
|
||||||
|
import LibraryView from "@/views/LibraryView.vue"
|
||||||
|
import ChatView from "@/views/ChatView.vue"
|
||||||
|
|
||||||
|
export default createRouter({
|
||||||
|
history: createWebHistory(import.meta.env.VITE_BASE_URL),
|
||||||
|
routes: [
|
||||||
|
{ path: "/", name: "library", component: LibraryView },
|
||||||
|
{ path: "/chat", name: "chat", component: ChatView },
|
||||||
|
],
|
||||||
|
})
|
||||||
47
web/src/theme.css
Normal file
47
web/src/theme.css
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
/* web/src/theme.css */
|
||||||
|
:root {
|
||||||
|
--color-bg: #1a1a2e;
|
||||||
|
--color-surface: #16213e;
|
||||||
|
--color-surface-alt: #0f3460;
|
||||||
|
--color-accent: #e94560;
|
||||||
|
--color-accent-dim: #a83050;
|
||||||
|
--color-text: #e8e8e8;
|
||||||
|
--color-text-muted: #9e9e9e;
|
||||||
|
--color-success: #4caf50;
|
||||||
|
--color-warning: #ff9800;
|
||||||
|
--color-error: #f44336;
|
||||||
|
--color-border: #2a2a4a;
|
||||||
|
|
||||||
|
--font-base: system-ui, -apple-system, sans-serif;
|
||||||
|
--font-mono: "Fira Code", "Cascadia Code", monospace;
|
||||||
|
|
||||||
|
--radius-sm: 4px;
|
||||||
|
--radius-md: 8px;
|
||||||
|
--radius-lg: 16px;
|
||||||
|
--shadow-card: 0 2px 8px rgba(0,0,0,0.4);
|
||||||
|
--transition-fast: 150ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: light) {
|
||||||
|
:root {
|
||||||
|
--color-bg: #f5f5f5;
|
||||||
|
--color-surface: #ffffff;
|
||||||
|
--color-surface-alt: #e8eaf6;
|
||||||
|
--color-accent: #c62828;
|
||||||
|
--color-accent-dim: #e57373;
|
||||||
|
--color-text: #212121;
|
||||||
|
--color-text-muted: #757575;
|
||||||
|
--color-border: #e0e0e0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: var(--color-bg);
|
||||||
|
color: var(--color-text);
|
||||||
|
font-family: var(--font-base);
|
||||||
|
font-size: 1rem;
|
||||||
|
line-height: 1.6;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
2
web/src/views/ChatView.vue
Normal file
2
web/src/views/ChatView.vue
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
<template><div>Chat coming soon.</div></template>
|
||||||
|
<script setup lang="ts"></script>
|
||||||
84
web/src/views/LibraryView.vue
Normal file
84
web/src/views/LibraryView.vue
Normal file
|
|
@ -0,0 +1,84 @@
|
||||||
|
<template>
|
||||||
|
<main class="library">
|
||||||
|
<header class="library-header">
|
||||||
|
<h1>Library</h1>
|
||||||
|
<button class="btn-primary" @click="scan" :disabled="scanning">
|
||||||
|
{{ scanning ? "Scanning..." : "Scan for PDFs" }}
|
||||||
|
</button>
|
||||||
|
</header>
|
||||||
|
|
||||||
|
<p class="empty-state" v-if="!loading && docs.length === 0">
|
||||||
|
No books indexed yet. Click "Scan for PDFs" to discover PDFs in your books directory.<br>
|
||||||
|
Make sure your PDF directory is mounted at <code>/books</code> inside the container.
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<div class="doc-grid" v-else>
|
||||||
|
<DocumentCard
|
||||||
|
v-for="doc in docs"
|
||||||
|
:key="doc.id"
|
||||||
|
:doc="doc"
|
||||||
|
@reingest="reingest"
|
||||||
|
@delete="remove"
|
||||||
|
@refresh="load"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="scan-result" v-if="scanResult">
|
||||||
|
Found {{ scanResult.discovered }} PDFs, queued {{ scanResult.queued }} for indexing.
|
||||||
|
</p>
|
||||||
|
</main>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { onMounted, ref } from "vue"
|
||||||
|
import { api, type Document } from "@/api"
|
||||||
|
import DocumentCard from "@/components/DocumentCard.vue"
|
||||||
|
|
||||||
|
const docs = ref<Document[]>([])
|
||||||
|
const loading = ref(true)
|
||||||
|
const scanning = ref(false)
|
||||||
|
const scanResult = ref<{ discovered: number; queued: number } | null>(null)
|
||||||
|
|
||||||
|
async function load() {
|
||||||
|
loading.value = true
|
||||||
|
docs.value = await api.getLibrary().finally(() => (loading.value = false))
|
||||||
|
}
|
||||||
|
|
||||||
|
async function scan() {
|
||||||
|
scanning.value = true
|
||||||
|
try {
|
||||||
|
scanResult.value = await api.scanLibrary()
|
||||||
|
await load()
|
||||||
|
} finally {
|
||||||
|
scanning.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function reingest(id: string) {
|
||||||
|
await api.reingestDocument(id)
|
||||||
|
await load()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function remove(id: string) {
|
||||||
|
if (!confirm("Remove this book from the library? The PDF file is not deleted.")) return
|
||||||
|
await api.deleteDocument(id)
|
||||||
|
await load()
|
||||||
|
}
|
||||||
|
|
||||||
|
onMounted(load)
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style scoped>
|
||||||
|
.library { padding: 1.5rem; max-width: 1200px; margin: 0 auto; }
|
||||||
|
.library-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
|
||||||
|
h1 { font-size: 1.5rem; }
|
||||||
|
.btn-primary {
|
||||||
|
background: var(--color-accent); color: #fff; border: none; padding: 0.6rem 1.2rem;
|
||||||
|
border-radius: var(--radius-sm); cursor: pointer; font-size: 0.95rem;
|
||||||
|
}
|
||||||
|
.btn-primary:disabled { opacity: 0.5; cursor: default; }
|
||||||
|
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
|
||||||
|
.empty-state { color: var(--color-text-muted); line-height: 1.8; }
|
||||||
|
.empty-state code { font-family: var(--font-mono); background: var(--color-surface-alt); padding: 2px 6px; border-radius: 3px; }
|
||||||
|
.scan-result { margin-top: 1rem; color: var(--color-text-muted); font-size: 0.9rem; }
|
||||||
|
</style>
|
||||||
18
web/tsconfig.app.json
Normal file
18
web/tsconfig.app.json
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
{
|
||||||
|
"extends": "@vue/tsconfig/tsconfig.dom.json",
|
||||||
|
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
|
||||||
|
"exclude": ["src/**/__tests__/*"],
|
||||||
|
"compilerOptions": {
|
||||||
|
// Extra safety for array and object lookups, but may have false positives.
|
||||||
|
"noUncheckedIndexedAccess": true,
|
||||||
|
|
||||||
|
// Path mapping for cleaner imports.
|
||||||
|
"paths": {
|
||||||
|
"@/*": ["./src/*"]
|
||||||
|
},
|
||||||
|
|
||||||
|
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
||||||
|
// Specified here to keep it out of the root directory.
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
web/tsconfig.json
Normal file
11
web/tsconfig.json
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"files": [],
|
||||||
|
"references": [
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"path": "./tsconfig.app.json"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
27
web/tsconfig.node.json
Normal file
27
web/tsconfig.node.json
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
// TSConfig for modules that run in Node.js environment via either transpilation or type-stripping.
|
||||||
|
{
|
||||||
|
"extends": "@tsconfig/node24/tsconfig.json",
|
||||||
|
"include": [
|
||||||
|
"vite.config.*",
|
||||||
|
"vitest.config.*",
|
||||||
|
"cypress.config.*",
|
||||||
|
"playwright.config.*",
|
||||||
|
"eslint.config.*"
|
||||||
|
],
|
||||||
|
"compilerOptions": {
|
||||||
|
// Most tools use transpilation instead of Node.js's native type-stripping.
|
||||||
|
// Bundler mode provides a smoother developer experience.
|
||||||
|
"module": "preserve",
|
||||||
|
"moduleResolution": "bundler",
|
||||||
|
|
||||||
|
// Include Node.js types and avoid accidentally including other `@types/*` packages.
|
||||||
|
"types": ["node"],
|
||||||
|
|
||||||
|
// Disable emitting output during `vue-tsc --build`, which is used for type-checking only.
|
||||||
|
"noEmit": true,
|
||||||
|
|
||||||
|
// `vue-tsc --build` produces a .tsbuildinfo file for incremental type-checking.
|
||||||
|
// Specified here to keep it out of the root directory.
|
||||||
|
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.node.tsbuildinfo"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
web/vite.config.ts
Normal file
18
web/vite.config.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { fileURLToPath, URL } from 'node:url'
|
||||||
|
|
||||||
|
import { defineConfig } from 'vite'
|
||||||
|
import vue from '@vitejs/plugin-vue'
|
||||||
|
import vueDevTools from 'vite-plugin-vue-devtools'
|
||||||
|
|
||||||
|
// https://vite.dev/config/
|
||||||
|
export default defineConfig({
|
||||||
|
plugins: [
|
||||||
|
vue(),
|
||||||
|
vueDevTools(),
|
||||||
|
],
|
||||||
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
Loading…
Reference in a new issue