diff --git a/datacenter/app/datastores/documents/page.tsx b/datacenter/app/datastores/documents/page.tsx index 668313c99..23ee57bf3 100644 --- a/datacenter/app/datastores/documents/page.tsx +++ b/datacenter/app/datastores/documents/page.tsx @@ -2,14 +2,60 @@ import { useRouter, useSearchParams } from 'next/navigation' import React, { useState, useEffect } from 'react' -import { Button, Table } from '@/lib/mui' +import { + Button, + Table, + Sheet, + Modal, + Box, + Stack, + Input, + styled +} from '@/lib/mui' import moment from 'moment' import { message } from 'antd' +const stepsOfAddingDocument = [ + 'Choose a Datasource type', + 'Setup the Datasource' +] +const documentTypeList = [ + { + type: 'text', + title: 'Text', + subTitle: 'Paste some text' + }, + { + type: 'webPage', + title: 'Web Page', + subTitle: 'Crawl text from a web page' + }, + { + type: 'file', + title: 'File', + subTitle: 'It can be: PDF, CSV, JSON, Text, PowerPoint, Word, Excel' + } +] +const Item = styled(Sheet)(({ theme }) => ({ + width: '50%', + backgroundColor: + theme.palette.mode === 'dark' ? theme.palette.background.level1 : '#fff', + ...theme.typography.body2, + padding: theme.spacing(1), + textAlign: 'center', + borderRadius: 4, + color: theme.vars.palette.text.secondary +})) + const Documents = () => { const router = useRouter() const spaceName = useSearchParams().get('name') + const [isAddDocumentModalShow, setIsAddDocumentModalShow] = + useState(false) + const [activeStep, setActiveStep] = useState(0) const [documents, setDocuments] = useState([]) + const [webPageUrl, setWebPageUrl] = useState('') + const [documentName, setDocumentName] = useState('') useEffect(() => { async function fetchDocuments() { const res = await fetch( @@ -31,6 +77,19 @@ const Documents = () => { }, []) return (
+ + + @@ -70,9 +129,9 @@ const Documents = () => { ) const data = await res.json() if (data.success) { - message.success('success'); + message.success('success') } else { - message.error(data.err_msg || 'failed'); + message.error(data.err_msg || 'failed') } }} > @@ -95,6 +154,137 @@ const Documents = () => { ))}
+ setIsAddDocumentModalShow(false)} + > + + + + {stepsOfAddingDocument.map((item: any, index: number) => ( + + {item} + + ))} + + + {activeStep === 0 ? ( + <> + + {documentTypeList.map((item: any) => ( + { + if (item.type === 'webPage') { + setActiveStep(1) + } + }} + > + + {item.title} + + {item.subTitle} + + ))} + + + ) : ( + <> + + Name: + setDocumentName(e.target.value)} + sx={{ marginBottom: '20px' }} + /> + Web Page URL: + setWebPageUrl(e.target.value)} + /> + + + + )} + +
) } diff --git a/datacenter/app/datastores/page.tsx b/datacenter/app/datastores/page.tsx index fec9eae40..06f96cdbd 100644 --- a/datacenter/app/datastores/page.tsx +++ b/datacenter/app/datastores/page.tsx @@ -75,15 +75,21 @@ const Index = () => { }, []) return ( <> -
-
Knowledge Spaces
+ + Knowledge Spaces -
+
@@ -116,7 +122,6 @@ const Index = () => {
{ )} - ) }