From 77e9e801027533599c86c192fb6c92665fb94ee7 Mon Sep 17 00:00:00 2001 From: "shiweisong.ssw" Date: Fri, 30 Jun 2023 16:15:29 +0800 Subject: [PATCH] feat: add Breadcrumbs --- .../datastores/documents/chunklist/page.tsx | 224 ++++++---- datacenter/app/datastores/documents/page.tsx | 404 ++++++++++-------- datacenter/app/datastores/page.tsx | 260 +++++------ 3 files changed, 488 insertions(+), 400 deletions(-) diff --git a/datacenter/app/datastores/documents/chunklist/page.tsx b/datacenter/app/datastores/documents/chunklist/page.tsx index c0a0b3538..804ef0cfe 100644 --- a/datacenter/app/datastores/documents/chunklist/page.tsx +++ b/datacenter/app/datastores/documents/chunklist/page.tsx @@ -1,13 +1,21 @@ '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' import { fetchBaseURL } from '@/app/datastores/constants' const page_size = 20 const ChunkList = () => { + const router = useRouter() const { mode } = useColorScheme() const spaceName = useSearchParams().get('spacename') const documentId = useSearchParams().get('documentid') @@ -41,99 +49,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( - `${fetchBaseURL}/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( + `${fetchBaseURL}/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 4936a2556..584e80daa 100644 --- a/datacenter/app/datastores/documents/page.tsx +++ b/datacenter/app/datastores/documents/page.tsx @@ -15,6 +15,8 @@ import { Chip, Switch, Typography, + Breadcrumbs, + Link, styled } from '@/lib/mui' import moment from 'moment' @@ -115,20 +117,33 @@ const Documents = () => { }, []) return (
- + + { + router.push('/datastores') + }} + key="Knowledge Space" + underline="hover" + color="neutral" + fontSize="inherit" + > + Knowledge Space + + Documents + - + {documents.length ? ( <> { Synch: - + + + )} diff --git a/datacenter/app/datastores/page.tsx b/datacenter/app/datastores/page.tsx index c1db62ecf..8884a93a5 100644 --- a/datacenter/app/datastores/page.tsx +++ b/datacenter/app/datastores/page.tsx @@ -144,7 +144,7 @@ const Index = () => { }, '& tbody tr a': { color: 'rgb(13, 96, 217)' - }, + } }} > @@ -387,130 +387,142 @@ const Index = () => { Synch: - + + + )}