diff --git a/datacenter/app/datastores/documents/chunklist/page.tsx b/datacenter/app/datastores/documents/chunklist/page.tsx index eb191c676..2664ed1bd 100644 --- a/datacenter/app/datastores/documents/chunklist/page.tsx +++ b/datacenter/app/datastores/documents/chunklist/page.tsx @@ -1,12 +1,20 @@ 'use client' -import { useSearchParams } from 'next/navigation' +import { useSearchParams, useRouter } from 'next/navigation' import React, { useState, useEffect } from 'react' -import { useColorScheme, Table, Stack } from '@/lib/mui' +import { + useColorScheme, + Table, + Stack, + Typography, + Breadcrumbs, + Link +} from '@/lib/mui' import { Popover, Pagination } from 'antd' const page_size = 20 const ChunkList = () => { + const router = useRouter() const { mode } = useColorScheme() const spaceName = useSearchParams().get('spacename') const documentId = useSearchParams().get('documentid') @@ -40,99 +48,137 @@ const ChunkList = () => { }, []) return (
- {chunkList.length ? ( - <> - + + { + router.push('/datastores') }} + key="Knowledge Space" + underline="hover" + color="neutral" + fontSize="inherit" > - - - - - - - - - {chunkList.map((row: any) => ( - - - - - - ))} - -
NameContentMeta Data
{row.doc_name} - { - - {row.content.length > 10 - ? `${row.content.slice(0, 10)}...` - : row.content} - - } - - { - - {row.meta_info.length > 10 - ? `${row.meta_info.slice(0, 10)}...` - : row.meta_info} - - } -
- + { + router.push(`/datastores/documents?name=${spaceName}`) }} + key="Knowledge Space" + underline="hover" + color="neutral" + fontSize="inherit" > - { - const res = await fetch( - `${process.env.API_BASE_URL}/knowledge/${spaceName}/chunk/list`, - { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - document_id: documentId, - page, - page_size - }) - } - ) - const data = await res.json() - if (data.success) { - setChunkList(data.data.data) - setTotal(data.data.total) - setCurrent(data.data.page) + Documents + + Chunks + + +
+ {chunkList.length ? ( + <> + - - - ) : ( - <> - )} + > + + + + + + + + + {chunkList.map((row: any) => ( + + + + + + ))} + +
NameContentMeta Data
{row.doc_name} + { + + {row.content.length > 10 + ? `${row.content.slice(0, 10)}...` + : row.content} + + } + + { + + {row.meta_info.length > 10 + ? `${row.meta_info.slice(0, 10)}...` + : row.meta_info} + + } +
+ + { + const res = await fetch( + `${process.env.API_BASE_URL}/knowledge/${spaceName}/chunk/list`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + document_id: documentId, + page, + page_size + }) + } + ) + const data = await res.json() + if (data.success) { + setChunkList(data.data.data) + setTotal(data.data.total) + setCurrent(data.data.page) + } + }} + hideOnSinglePage + /> + + + ) : ( + <> + )} +
) } diff --git a/datacenter/app/datastores/documents/page.tsx b/datacenter/app/datastores/documents/page.tsx index 72ae15f3e..134fe5f4f 100644 --- a/datacenter/app/datastores/documents/page.tsx +++ b/datacenter/app/datastores/documents/page.tsx @@ -13,12 +13,18 @@ import { Input, Textarea, Chip, + Switch, + Typography, + Breadcrumbs, + Link, styled } from '@/lib/mui' import moment from 'moment' import { InboxOutlined } from '@ant-design/icons' +import CheckCircleOutlinedIcon from '@mui/icons-material/CheckCircleOutlined'; +import CachedIcon from '@mui/icons-material/Cached'; import type { UploadProps } from 'antd' -import { Upload, Pagination, message } from 'antd' +import { Upload, Pagination, Popover, message } from 'antd' const { Dragger } = Upload const Item = styled(Sheet)(({ theme }) => ({ @@ -71,6 +77,7 @@ const Documents = () => { const [originFileObj, setOriginFileObj] = useState(null) const [total, setTotal] = useState(0) const [current, setCurrent] = useState(0) + const [synchChecked, setSynchChecked] = useState(true) const props: UploadProps = { name: 'file', multiple: false, @@ -111,24 +118,38 @@ const Documents = () => { }, []) return (
- + + { + router.push('/datastores') + }} + key="Knowledge Space" + underline="hover" + color="neutral" + fontSize="inherit" + > + Knowledge Space + + Documents + - + {documents.length ? ( <> { + @@ -155,11 +177,7 @@ const Documents = () => { @@ -167,8 +185,8 @@ const Documents = () => { +
Size Last Synch StatusResult Operation
{row.doc_name} - + {row.doc_type} {moment(row.last_sync).format('YYYY-MM-DD HH:MM:SS')} { {row.status} + {(function () { + if (row.status === 'TODO' || row.status === 'RUNNING') { + return '' + } else if (row.status === 'FINISHED') { + return ( + + + SUCCESS + + + ) + } else { + return ( + + + FAILED + + + ) + } + })()} + { <> } @@ -296,9 +348,13 @@ const Documents = () => { {stepsOfAddingDocument.map((item: any, index: number) => ( - {item} + {index < activeStep ? : `${index + 1}.`} + {`${item}`} ))} @@ -386,151 +442,224 @@ const Documents = () => { /> )} + + setSynchChecked(event.target.checked) + } + /> + } + > + Synch: + - + + + )} diff --git a/datacenter/app/datastores/page.tsx b/datacenter/app/datastores/page.tsx index c8166c8c5..05033bca5 100644 --- a/datacenter/app/datastores/page.tsx +++ b/datacenter/app/datastores/page.tsx @@ -3,8 +3,9 @@ import { useRouter } from 'next/navigation' import React, { useState, useEffect } from 'react' import { InboxOutlined } from '@ant-design/icons' +import CheckCircleOutlinedIcon from '@mui/icons-material/CheckCircleOutlined'; import type { UploadProps } from 'antd' -import { message, Upload } from 'antd' +import { message, Upload, Popover } from 'antd' import { useColorScheme, Modal, @@ -16,6 +17,8 @@ import { Input, Textarea, Chip, + Switch, + Typography, styled } from '@/lib/mui' @@ -33,7 +36,7 @@ const Item = styled(Sheet)(({ theme }) => ({ })) const stepsOfAddingSpace = [ - 'Knowledge Space Configuration', + 'Knowledge Space Config', 'Choose a Datasource type', 'Setup the Datasource' ] @@ -70,6 +73,7 @@ const Index = () => { const [textSource, setTextSource] = useState('') const [text, setText] = useState('') const [originFileObj, setOriginFileObj] = useState(null) + const [synchChecked, setSynchChecked] = useState(true) const props: UploadProps = { name: 'file', multiple: false, @@ -127,8 +131,8 @@ const Index = () => {
{knowledgeSpaceList.length ? ( { }, '& tbody tr: hover a': { textDecoration: 'underline' + }, + '& tbody tr a': { + color: 'rgb(13, 96, 217)' } }} > @@ -145,6 +152,7 @@ const Index = () => { + @@ -164,23 +172,22 @@ const Index = () => { } + ))} @@ -213,9 +220,13 @@ const Index = () => { {stepsOfAddingSpace.map((item: any, index: number) => ( - {item} + {index < activeStep ? : `${index + 1}.`} + {`${item}`} ))} @@ -236,18 +247,21 @@ const Index = () => { message.error('please input the name') return } - const res = await fetch(`${process.env.API_BASE_URL}/knowledge/space/add`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json' - }, - body: JSON.stringify({ - name: knowledgeSpaceName, - vector_type: 'Chroma', - owner: 'keting', - desc: 'test1' - }) - }) + const res = await fetch( + `${process.env.API_BASE_URL}/knowledge/space/add`, + { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ + name: knowledgeSpaceName, + vector_type: 'Chroma', + owner: 'keting', + desc: 'test1' + }) + } + ) const data = await res.json() if (data.success) { message.success('success') @@ -357,94 +371,164 @@ const Index = () => { /> )} + + setSynchChecked(event.target.checked) + } + /> + } + > + Synch: + - + + + )} diff --git a/datacenter/app/globals.css b/datacenter/app/globals.css index 153cf633c..93095ccd9 100644 --- a/datacenter/app/globals.css +++ b/datacenter/app/globals.css @@ -12,28 +12,6 @@ body { background-color: var(--joy-palette-background-body); } -table { - border-collapse: collapse; - width: 100%; -} - -th, td { - border: 1px solid #ddd; - text-align: left; - padding: 8px; -} - -th { - background-color: #f2f2f2; -} - -tr:nth-child(even) { - background-color: #f2f2f2; -} -tr:hover { - background-color: #ddd; -} - body .ant-btn-primary { background-color: #1677ff; }
Name Vector OwnerDescription
- + {row.vector_type} - + {row.owner} + + {row.desc.length > 10 + ? `${row.desc.slice(0, 10)}...` + : row.desc} + +