mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-14 06:26:18 +00:00
feat: auto sync after created
This commit is contained in:
parent
07df9369c9
commit
df9d4d2f38
@ -13,6 +13,8 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
Textarea,
|
Textarea,
|
||||||
Chip,
|
Chip,
|
||||||
|
Switch,
|
||||||
|
Typography,
|
||||||
styled
|
styled
|
||||||
} from '@/lib/mui'
|
} from '@/lib/mui'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
@ -72,6 +74,7 @@ const Documents = () => {
|
|||||||
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
||||||
const [total, setTotal] = useState<number>(0)
|
const [total, setTotal] = useState<number>(0)
|
||||||
const [current, setCurrent] = useState<number>(0)
|
const [current, setCurrent] = useState<number>(0)
|
||||||
|
const [synchChecked, setSynchChecked] = useState<boolean>(true)
|
||||||
const props: UploadProps = {
|
const props: UploadProps = {
|
||||||
name: 'file',
|
name: 'file',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
@ -422,6 +425,22 @@ const Documents = () => {
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<Typography
|
||||||
|
component="label"
|
||||||
|
sx={{
|
||||||
|
marginTop: '20px'
|
||||||
|
}}
|
||||||
|
endDecorator={
|
||||||
|
<Switch
|
||||||
|
checked={synchChecked}
|
||||||
|
onChange={(event: any) =>
|
||||||
|
setSynchChecked(event.target.checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Synch:
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
@ -450,6 +469,18 @@ const Documents = () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
|
data.success && fetch(
|
||||||
|
`${fetchBaseURL}/knowledge/${spaceName}/document/sync`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
doc_ids: [data.data]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddDocumentModalShow(false)
|
setIsAddDocumentModalShow(false)
|
||||||
@ -492,6 +523,18 @@ const Documents = () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
|
data.success && fetch(
|
||||||
|
`${fetchBaseURL}/knowledge/${spaceName}/document/sync`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
doc_ids: [data.data]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddDocumentModalShow(false)
|
setIsAddDocumentModalShow(false)
|
||||||
@ -538,6 +581,18 @@ const Documents = () => {
|
|||||||
}
|
}
|
||||||
)
|
)
|
||||||
const data = await res.json()
|
const data = await res.json()
|
||||||
|
data.success && fetch(
|
||||||
|
`${fetchBaseURL}/knowledge/${spaceName}/document/sync`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
doc_ids: [data.data]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
if (data.success) {
|
if (data.success) {
|
||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddDocumentModalShow(false)
|
setIsAddDocumentModalShow(false)
|
||||||
|
@ -16,6 +16,8 @@ import {
|
|||||||
Input,
|
Input,
|
||||||
Textarea,
|
Textarea,
|
||||||
Chip,
|
Chip,
|
||||||
|
Switch,
|
||||||
|
Typography,
|
||||||
styled
|
styled
|
||||||
} from '@/lib/mui'
|
} from '@/lib/mui'
|
||||||
import { fetchBaseURL } from '@/app/datastores/constants'
|
import { fetchBaseURL } from '@/app/datastores/constants'
|
||||||
@ -71,6 +73,7 @@ const Index = () => {
|
|||||||
const [textSource, setTextSource] = useState<string>('')
|
const [textSource, setTextSource] = useState<string>('')
|
||||||
const [text, setText] = useState<string>('')
|
const [text, setText] = useState<string>('')
|
||||||
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
const [originFileObj, setOriginFileObj] = useState<any>(null)
|
||||||
|
const [synchChecked, setSynchChecked] = useState<boolean>(true)
|
||||||
const props: UploadProps = {
|
const props: UploadProps = {
|
||||||
name: 'file',
|
name: 'file',
|
||||||
multiple: false,
|
multiple: false,
|
||||||
@ -214,7 +217,10 @@ const Index = () => {
|
|||||||
{stepsOfAddingSpace.map((item: any, index: number) => (
|
{stepsOfAddingSpace.map((item: any, index: number) => (
|
||||||
<Item
|
<Item
|
||||||
key={item}
|
key={item}
|
||||||
sx={{ fontWeight: activeStep === index ? 'bold' : '', color: activeStep === index ? '#814DDE' : '' }}
|
sx={{
|
||||||
|
fontWeight: activeStep === index ? 'bold' : '',
|
||||||
|
color: activeStep === index ? '#814DDE' : ''
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{item}
|
{item}
|
||||||
</Item>
|
</Item>
|
||||||
@ -361,9 +367,25 @@ const Index = () => {
|
|||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
|
<Typography
|
||||||
|
component="label"
|
||||||
|
sx={{
|
||||||
|
marginTop: '20px'
|
||||||
|
}}
|
||||||
|
endDecorator={
|
||||||
|
<Switch
|
||||||
|
checked={synchChecked}
|
||||||
|
onChange={(event: any) =>
|
||||||
|
setSynchChecked(event.target.checked)
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
Synch:
|
||||||
|
</Typography>
|
||||||
</Box>
|
</Box>
|
||||||
<Button
|
<Button
|
||||||
variant='outlined'
|
variant="outlined"
|
||||||
onClick={async () => {
|
onClick={async () => {
|
||||||
if (documentName === '') {
|
if (documentName === '') {
|
||||||
message.error('Please input the name')
|
message.error('Please input the name')
|
||||||
@ -392,6 +414,18 @@ const Index = () => {
|
|||||||
if (data.success) {
|
if (data.success) {
|
||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddKnowledgeSpaceModalShow(false)
|
setIsAddKnowledgeSpaceModalShow(false)
|
||||||
|
fetch(
|
||||||
|
`${fetchBaseURL}/knowledge/${knowledgeSpaceName}/document/sync`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
doc_ids: [data.data]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
message.error(data.err_msg || 'failed')
|
message.error(data.err_msg || 'failed')
|
||||||
}
|
}
|
||||||
@ -415,6 +449,18 @@ const Index = () => {
|
|||||||
if (data.success) {
|
if (data.success) {
|
||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddKnowledgeSpaceModalShow(false)
|
setIsAddKnowledgeSpaceModalShow(false)
|
||||||
|
fetch(
|
||||||
|
`${fetchBaseURL}/knowledge/${knowledgeSpaceName}/document/sync`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
doc_ids: [data.data]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
message.error(data.err_msg || 'failed')
|
message.error(data.err_msg || 'failed')
|
||||||
}
|
}
|
||||||
@ -442,6 +488,18 @@ const Index = () => {
|
|||||||
if (data.success) {
|
if (data.success) {
|
||||||
message.success('success')
|
message.success('success')
|
||||||
setIsAddKnowledgeSpaceModalShow(false)
|
setIsAddKnowledgeSpaceModalShow(false)
|
||||||
|
fetch(
|
||||||
|
`${fetchBaseURL}/knowledge/${knowledgeSpaceName}/document/sync`,
|
||||||
|
{
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
doc_ids: [data.data]
|
||||||
|
})
|
||||||
|
}
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
message.error(data.err_msg || 'failed')
|
message.error(data.err_msg || 'failed')
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user