mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-16 23:37:52 +00:00
feat: fetch documents
This commit is contained in:
parent
8a36558559
commit
85272f5d34
68
datacenter/app/datastores/documents/page.tsx
Normal file
68
datacenter/app/datastores/documents/page.tsx
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
"use client";
|
||||||
|
|
||||||
|
import { withRouter } from 'next/router'
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { Table } from 'antd';
|
||||||
|
import moment from 'moment';
|
||||||
|
|
||||||
|
const Documents = ({ router }) => {
|
||||||
|
const [documents, setDocuments] = useState<any>([]);
|
||||||
|
useEffect(() => {
|
||||||
|
async function fetchDocuments() {
|
||||||
|
const res = await fetch(`http://localhost:8000/knowledge/${router.query.name}/document/list`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({}),
|
||||||
|
});
|
||||||
|
const data = await res.json();
|
||||||
|
if (data.success) {
|
||||||
|
setDocuments(data.data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fetchDocuments();
|
||||||
|
}, []);
|
||||||
|
return (
|
||||||
|
<div className='p-4'>
|
||||||
|
<Table
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
title: 'Name',
|
||||||
|
dataIndex: 'doc_name',
|
||||||
|
key: 'doc_name',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Type',
|
||||||
|
dataIndex: 'doc_type',
|
||||||
|
key: 'doc_type',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Size',
|
||||||
|
dataIndex: 'chunk_size',
|
||||||
|
key: 'chunk_size',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Last Synch',
|
||||||
|
dataIndex: 'last_sync',
|
||||||
|
key: 'last_sync',
|
||||||
|
align: 'center',
|
||||||
|
render: (text: string) => moment(text).format('YYYY-MM-DD HH:MM:SS')
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'Status',
|
||||||
|
dataIndex: 'status',
|
||||||
|
key: 'status',
|
||||||
|
align: 'center',
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
dataSource={documents}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withRouter(Documents);
|
@ -1,5 +1,6 @@
|
|||||||
'use client'
|
'use client'
|
||||||
|
|
||||||
|
import Router from 'next/router'
|
||||||
import type { ProFormInstance } from '@ant-design/pro-components';
|
import type { ProFormInstance } from '@ant-design/pro-components';
|
||||||
import React, { useState, useRef, useEffect } from 'react'
|
import React, { useState, useRef, useEffect } from 'react'
|
||||||
import {
|
import {
|
||||||
@ -55,7 +56,7 @@ const Index = () => {
|
|||||||
key: 'name',
|
key: 'name',
|
||||||
align: 'center',
|
align: 'center',
|
||||||
render: (text: string) => {
|
render: (text: string) => {
|
||||||
return <a href='javascript:;'>{text}</a>
|
return <a href='javascript:;' onClick={() => Router.push(`/datastores/documents?name=${text}`)}>{text}</a>
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -103,7 +104,6 @@ const Index = () => {
|
|||||||
if (knowledgeSpaceName === '') {
|
if (knowledgeSpaceName === '') {
|
||||||
props.onSubmit?.()
|
props.onSubmit?.()
|
||||||
} else {
|
} else {
|
||||||
props.onSubmit?.();
|
|
||||||
const res = await fetch('http://localhost:8000/knowledge/space/add', {
|
const res = await fetch('http://localhost:8000/knowledge/space/add', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
|
14
datacenter/package-lock.json
generated
14
datacenter/package-lock.json
generated
@ -30,6 +30,7 @@
|
|||||||
"cuid": "^3.0.0",
|
"cuid": "^3.0.0",
|
||||||
"eslint": "8.43.0",
|
"eslint": "8.43.0",
|
||||||
"eslint-config-next": "13.4.7",
|
"eslint-config-next": "13.4.7",
|
||||||
|
"moment": "^2.29.4",
|
||||||
"next": "13.4.7",
|
"next": "13.4.7",
|
||||||
"next-auth": "^4.20.1",
|
"next-auth": "^4.20.1",
|
||||||
"postcss": "8.4.24",
|
"postcss": "8.4.24",
|
||||||
@ -5487,6 +5488,14 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz",
|
"resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz",
|
||||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
||||||
},
|
},
|
||||||
|
"node_modules/moment": {
|
||||||
|
"version": "2.29.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
||||||
|
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w==",
|
||||||
|
"engines": {
|
||||||
|
"node": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/mri": {
|
"node_modules/mri": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmmirror.com/mri/-/mri-1.2.0.tgz",
|
"resolved": "https://registry.npmmirror.com/mri/-/mri-1.2.0.tgz",
|
||||||
@ -12413,6 +12422,11 @@
|
|||||||
"resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz",
|
"resolved": "https://registry.npmmirror.com/minimist/-/minimist-1.2.8.tgz",
|
||||||
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA=="
|
||||||
},
|
},
|
||||||
|
"moment": {
|
||||||
|
"version": "2.29.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/moment/-/moment-2.29.4.tgz",
|
||||||
|
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
|
||||||
|
},
|
||||||
"mri": {
|
"mri": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmmirror.com/mri/-/mri-1.2.0.tgz",
|
"resolved": "https://registry.npmmirror.com/mri/-/mri-1.2.0.tgz",
|
||||||
|
@ -31,6 +31,7 @@
|
|||||||
"cuid": "^3.0.0",
|
"cuid": "^3.0.0",
|
||||||
"eslint": "8.43.0",
|
"eslint": "8.43.0",
|
||||||
"eslint-config-next": "13.4.7",
|
"eslint-config-next": "13.4.7",
|
||||||
|
"moment": "^2.29.4",
|
||||||
"next": "13.4.7",
|
"next": "13.4.7",
|
||||||
"next-auth": "^4.20.1",
|
"next-auth": "^4.20.1",
|
||||||
"postcss": "8.4.24",
|
"postcss": "8.4.24",
|
||||||
|
Loading…
Reference in New Issue
Block a user