@@ -38,6 +38,7 @@ import {
3838 Typography ,
3939 Upload ,
4040 UploadProps ,
41+ Tooltip ,
4142} from 'antd' ;
4243import byteSize from 'byte-size' ;
4344import alpha from 'color-alpha' ;
@@ -91,41 +92,35 @@ export default () => {
9192 [ collectionId ] ,
9293 ) ;
9394
94- const rebuildIndexes = useCallback (
95- async ( documentId : string , indexTypes : string [ ] ) => {
96- if ( ! collectionId || ! documentId || indexTypes . length === 0 ) return ;
97-
98- try {
99- await api . collectionsCollectionIdDocumentsDocumentIdRebuildIndexesPost ( {
100- collectionId,
101- documentId,
102- rebuildIndexesRequest : {
103- index_types : indexTypes as any ,
104- } ,
105- } ) ;
106- toast . success ( formatMessage ( { id : 'document.index.rebuild.success' } ) ) ;
107- getDocuments ( ) ;
108- } catch ( error ) {
109- toast . error ( formatMessage ( { id : 'document.index.rebuild.failed' } ) ) ;
110- }
111- } ,
112- [ collectionId , formatMessage ] ,
113- ) ;
114-
115- const handleRebuildIndex = useCallback ( ( record : ApeDocument ) => {
116- setRebuildSelectedDocument ( record ) ;
117- setRebuildSelectedTypes ( [ ] ) ;
95+ const handleRebuildIndex = ( document : ApeDocument ) => {
96+ setRebuildSelectedDocument ( document ) ;
97+ setRebuildSelectedTypes ( [ 'vector' , 'fulltext' , 'graph' ] ) ;
11898 setRebuildModalVisible ( true ) ;
119- } , [ ] ) ;
99+ } ;
100+
101+ const handleRebuildConfirm = async ( ) => {
102+ if ( ! rebuildSelectedDocument || rebuildSelectedTypes . length === 0 ) return ;
120103
121- const handleRebuildConfirm = useCallback ( ( ) => {
122- if ( rebuildSelectedDocument && rebuildSelectedTypes . length > 0 ) {
123- rebuildIndexes ( rebuildSelectedDocument . id ! , rebuildSelectedTypes ) ;
104+ try {
105+ setLoading ( true ) ;
106+ await api . collectionsCollectionIdDocumentsDocumentIdRebuildIndexesPost ( {
107+ collectionId : collectionId ! ,
108+ documentId : rebuildSelectedDocument . id ! ,
109+ rebuildIndexesRequest : {
110+ index_types : rebuildSelectedTypes as ( 'vector' | 'fulltext' | 'graph' ) [ ] ,
111+ } ,
112+ } ) ;
113+ toast . success ( formatMessage ( { id : 'document.index.rebuild.success' } ) ) ;
124114 setRebuildModalVisible ( false ) ;
125115 setRebuildSelectedDocument ( null ) ;
126116 setRebuildSelectedTypes ( [ ] ) ;
117+ getDocuments ( ) ;
118+ } catch ( error ) {
119+ toast . error ( formatMessage ( { id : 'document.index.rebuild.failed' } ) ) ;
120+ } finally {
121+ setLoading ( false ) ;
127122 }
128- } , [ rebuildSelectedDocument , rebuildSelectedTypes , rebuildIndexes ] ) ;
123+ } ;
129124
130125 const indexTypeOptions = [
131126 { label : formatMessage ( { id : 'document.index.type.vector' } ) , value : 'vector' } ,
@@ -134,62 +129,25 @@ export default () => {
134129 ] ;
135130
136131 const renderIndexStatus = (
137- vectorStatus ?: DocumentVectorIndexStatusEnum ,
138- fulltextStatus ?: DocumentFulltextIndexStatusEnum ,
139- graphStatus ?: DocumentGraphIndexStatusEnum ,
132+ status ?: DocumentVectorIndexStatusEnum | DocumentFulltextIndexStatusEnum | DocumentGraphIndexStatusEnum ,
133+ updatedTime ?: string
140134 ) => {
141- const indexTypes = [
142- { nameKey : 'document.index.type.vector' , status : vectorStatus } ,
143- { nameKey : 'document.index.type.fulltext' , status : fulltextStatus } ,
144- { nameKey : 'document.index.type.graph' , status : graphStatus } ,
145- ] ;
146- return (
147- < Space direction = "vertical" size = "small" >
148- { indexTypes . map ( ( { nameKey, status } , index ) => (
149- < div
150- key = { index }
151- style = { {
152- fontSize : '12px' ,
153- lineHeight : '18px' ,
154- display : 'flex' ,
155- alignItems : 'center' ,
156- whiteSpace : 'nowrap'
157- } }
158- >
159- < span
160- style = { {
161- color : '#666' ,
162- width : '100px' ,
163- textAlign : 'right' ,
164- display : 'inline-block'
165- } }
166- >
167- { formatMessage ( { id : nameKey } ) }
168- </ span >
169- < span
170- style = { {
171- color : '#666' ,
172- width : '12px' ,
173- textAlign : 'center' ,
174- display : 'inline-block'
175- } }
176- >
177- :
178- </ span >
179- < div style = { { width : '80px' } } >
180- < Badge
181- status = { UI_INDEX_STATUS [ status as keyof typeof UI_INDEX_STATUS ] }
182- text = {
183- < span style = { { display : 'inline-block' , width : '70px' } } >
184- { formatMessage ( { id : `document.index.status.${ status } ` } ) }
185- </ span >
186- }
187- />
188- </ div >
189- </ div >
190- ) ) }
191- </ Space >
135+ const statusBadge = (
136+ < Badge
137+ status = { UI_INDEX_STATUS [ status as keyof typeof UI_INDEX_STATUS ] }
138+ text = { formatMessage ( { id : `document.index.status.${ status } ` } ) }
139+ />
192140 ) ;
141+
142+ if ( updatedTime ) {
143+ return (
144+ < Tooltip title = { `${ formatMessage ( { id : 'text.updatedAt' } ) } : ${ moment ( updatedTime ) . format ( DATETIME_FORMAT ) } ` } >
145+ { statusBadge }
146+ </ Tooltip >
147+ ) ;
148+ }
149+
150+ return statusBadge ;
193151 } ;
194152
195153 const columns : TableProps < ApeDocument > [ 'columns' ] = [
@@ -224,16 +182,30 @@ export default () => {
224182 } ,
225183 } ,
226184 {
227- title : formatMessage ( { id : 'document.status ' } ) ,
228- dataIndex : 'status ' ,
229- width : 190 ,
185+ title : formatMessage ( { id : 'document.index.type.vector ' } ) ,
186+ dataIndex : 'vector_index_status ' ,
187+ width : 120 ,
230188 align : 'center' ,
231189 render : ( value , record ) => {
232- return renderIndexStatus (
233- record . vector_index_status ,
234- record . fulltext_index_status ,
235- record . graph_index_status ,
236- ) ;
190+ return renderIndexStatus ( record . vector_index_status , record . vector_index_updated ) ;
191+ } ,
192+ } ,
193+ {
194+ title : formatMessage ( { id : 'document.index.type.fulltext' } ) ,
195+ dataIndex : 'fulltext_index_status' ,
196+ width : 120 ,
197+ align : 'center' ,
198+ render : ( value , record ) => {
199+ return renderIndexStatus ( record . fulltext_index_status , record . fulltext_index_updated ) ;
200+ } ,
201+ } ,
202+ {
203+ title : formatMessage ( { id : 'document.index.type.graph' } ) ,
204+ dataIndex : 'graph_index_status' ,
205+ width : 120 ,
206+ align : 'center' ,
207+ render : ( value , record ) => {
208+ return renderIndexStatus ( record . graph_index_status , record . graph_index_updated ) ;
237209 } ,
238210 } ,
239211 {
0 commit comments