feat(dashboard): add corpus dashboard at /dashboard/
Full private corpus dashboard for tools.dobetternorge.no users — each SSO
account gets an auto-provisioned CaveauAI tenant (clients row, corpus) on
first visit. Includes upload (file/paste/URL), RAG chat with SSE streaming
and citation chips, document CRUD, FalkorDB graph relations tab, and
improved save-from-tool flow with tag/preview support.
- dashboard/{index,documents,document,upload,chat,settings}.php
- api/dashboard/{corpus-init,documents,upload,ingest-status,chat-stream,
save-from-tool,graph}.php
- includes/{CorpusProvision,layout_dashboard,layout_dashboard_footer}.php
- assets/css/dashboard.css assets/js/corpus-save.js (routing upgrade)
- includes/{bootstrap,layout}.php extended for dashboard provisioning
Migration 141 (clients.dbn_sso_uid + import_method enum) applied on chloe.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
/**
|
||||
* GET /api/dashboard/ingest-status.php?ids=1,2,3
|
||||
*
|
||||
* Returns per-doc status for polling during URL ingest (background) or to
|
||||
* surface error messages after a failed sync upload.
|
||||
*
|
||||
* Response:
|
||||
* { ok, statuses: [ {id, status, chunk_count, error_message}, ... ] }
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__, 2) . '/includes/bootstrap.php';
|
||||
|
||||
dbnToolsRequireMethod('GET');
|
||||
dbnToolsRequireAuth();
|
||||
|
||||
try {
|
||||
$tenant = dbnToolsEnsureDashboardTenant();
|
||||
} catch (DbnToolsHttpException $e) {
|
||||
dbnToolsError($e->getMessage(), $e->status, $e->errorCode);
|
||||
}
|
||||
$clientId = (int)$tenant['client_id'];
|
||||
|
||||
$raw = (string)($_GET['ids'] ?? '');
|
||||
$ids = array_values(array_filter(
|
||||
array_map('intval', explode(',', $raw)),
|
||||
fn($v) => $v > 0
|
||||
));
|
||||
if (!$ids) {
|
||||
dbnToolsRespond(['ok' => true, 'statuses' => []]);
|
||||
}
|
||||
$ids = array_slice($ids, 0, 100);
|
||||
|
||||
$db = dbnToolsDb();
|
||||
$placeholders = implode(',', array_fill(0, count($ids), '?'));
|
||||
$sql = "SELECT id, status, chunk_count, error_message
|
||||
FROM client_documents
|
||||
WHERE client_id = ? AND id IN ({$placeholders})";
|
||||
$stmt = $db->prepare($sql);
|
||||
$stmt->execute(array_merge([$clientId], $ids));
|
||||
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
|
||||
|
||||
dbnToolsRespond([
|
||||
'ok' => true,
|
||||
'statuses' => array_map(fn($r) => [
|
||||
'id' => (int)$r['id'],
|
||||
'status' => (string)$r['status'],
|
||||
'chunk_count' => (int)$r['chunk_count'],
|
||||
'error_message' => $r['error_message'] ?? null,
|
||||
], $rows),
|
||||
]);
|
||||
Reference in New Issue
Block a user