feat(03-05): 3-step presigned upload + quota state in auth store + progress UI

- api/client.js: extend request() to attach .status and .payload on 413 structured errors; remove legacy uploadDocument multipart function
- stores/auth.js: add quota ref({used_bytes:0, limit_bytes:0}) and fetchQuota() action (silent catch); expose in store return
- stores/documents.js: replace single upload() with uploadToMinIO XHR helper + 3-step async action (getUploadUrl→XHR PUT→confirmUpload); track uploadProgress map keyed by filename+timestamp (T-03-25); call fetchQuota after upload success and document delete
- components/upload/UploadProgress.vue: add aria progressbar per row, percentage label, quota rejection error block (role=alert, red-50/red-200) from item.quotaError; use plain anchor for Manage storage link
This commit is contained in:
curo1305
2026-05-23 20:46:24 +02:00
parent 6bd57629ce
commit eb18428d07
4 changed files with 172 additions and 18 deletions
+14 -9
View File
@@ -34,21 +34,26 @@ async function request(path, options = {}) {
if (!res.ok) {
let msg = `HTTP ${res.status}`
try { msg = (await res.json()).detail || msg } catch {}
throw new Error(msg)
let payload = null
try {
const body = await res.json()
if (typeof body.detail === 'object' && body.detail !== null) {
payload = body.detail
msg = body.detail.message || `HTTP ${res.status}`
} else {
msg = body.detail || msg
}
} catch {}
const err = new Error(msg)
err.status = res.status
if (payload) err.payload = payload
throw err
}
return res.json()
}
// ── Documents ────────────────────────────────────────────────────────────────
export function uploadDocument(file, autoClassify = true) {
const form = new FormData()
form.append('file', file)
form.append('auto_classify', autoClassify ? 'true' : 'false')
return request('/api/documents/upload', { method: 'POST', body: form })
}
export function listDocuments({ topic, page = 1, perPage = 20 } = {}) {
const params = new URLSearchParams({ page, per_page: perPage })
if (topic) params.set('topic', topic)