1- import { Box , Divider , Link , Paper , styled , Table , TableBody , TableCell , TableHead , TableRow , Typography } from '@mui/material'
1+ import { Box , Divider , Link , styled , TableBody , TableCell , TableHead , TableRow , Typography } from '@mui/material'
22import { IngestionJobStatus , IngestionPipelineStageKey } from '@shared/ingestion'
33import { Link as RouterLink } from 'react-router-dom'
44import type { RagFileAttributes } from '@shared/types'
@@ -7,6 +7,7 @@ import DownloadDone from '@mui/icons-material/DownloadDone'
77import ErrorOutline from '@mui/icons-material/ErrorOutline'
88import PendingOutlined from '@mui/icons-material/PendingOutlined'
99import SettingsOutlined from '@mui/icons-material/SettingsOutlined'
10+ import AutoFixHigh from '@mui/icons-material/AutoFixHigh'
1011import { locales } from '../../locales/locales'
1112import { useTranslation } from 'react-i18next'
1213import { formatDistanceStrict } from 'date-fns'
@@ -36,13 +37,44 @@ const ProgressIcon: Record<FileStage, React.ReactNode> = {
3637 queued : < PendingOutlined /> ,
3738}
3839
40+ const HideOnSmall = styled ( TableCell ) ( ( { theme } ) => ( {
41+ [ theme . breakpoints . down ( 'md' ) ] : {
42+ display : 'none' ,
43+ } ,
44+ } ) )
45+
46+ const HideOnSmallHead = styled ( TableCell ) ( ( { theme } ) => ( {
47+ [ theme . breakpoints . down ( 'md' ) ] : {
48+ display : 'none' ,
49+ } ,
50+ } ) ) as typeof TableCell
51+
52+ export const RagFileTableHead : React . FC = ( ) => {
53+ const { t } = useTranslation ( )
54+ return (
55+ < TableHead >
56+ < TableRow >
57+ < TableCell > < strong > { t ( 'rag:fileName' ) } </ strong > </ TableCell >
58+ < HideOnSmallHead > < strong > { t ( 'common:fileType' ) } </ strong > </ HideOnSmallHead >
59+ < TableCell > < strong > { t ( 'rag:fileSizeKb' ) } </ strong > </ TableCell >
60+ < TableCell > < strong > { t ( 'rag:parsing' ) } </ strong > </ TableCell >
61+ < HideOnSmallHead > < strong > { t ( 'common:added' ) } </ strong > </ HideOnSmallHead >
62+ < TableCell > < strong > { t ( 'rag:fileStatus' ) } </ strong > </ TableCell >
63+ < TableCell />
64+ </ TableRow >
65+ </ TableHead >
66+ )
67+ }
68+
3969export const RagFileInfo : React . FC < {
4070 file : RagFileAttributes
4171 index : number
4272 status ?: IngestionJobStatus
4373 uploadProgress ?: number
4474} > = ( { file, index, status, uploadProgress } ) => {
4575 const { t, i18n } = useTranslation ( )
76+ const usedAdvancedParsing = ! ! ( file . metadata as Record < string , unknown > | null ) ?. advancedParsing
77+ const isPdf = file . fileType === 'application/pdf'
4678
4779 const pipelineStage = status ?. pipelineStage ?? file . pipelineStage
4880
@@ -60,55 +92,52 @@ export const RagFileInfo: React.FC<{
6092 const progressIcon = ProgressIcon [ fileStage ]
6193
6294 return (
63- < >
64- < Box display = "flex" alignItems = "center" gap = { 2 } >
65- < Box sx = { { flex : 3 } } >
66- < Box display = "flex" width = "100%" alignItems = "center" >
67- < Link to = { `?index=${ index } &file=${ file . id } ` } component = { RouterLink } >
68- < Typography variant = "subtitle1" > { file . filename } </ Typography >
69- </ Link >
70- < Typography variant = "body2" color = "text.secondary" sx = { { marginLeft : 'auto' } } >
71- { t ( 'common:added' ) } { new Date ( file . createdAt ) . toLocaleString ( locales [ i18n . language ] . code ) }
95+ < TableRow >
96+ < TableCell sx = { { maxWidth : 200 , wordBreak : 'break-word' } } >
97+ < Link to = { `?index=${ index } &file=${ file . id } ` } component = { RouterLink } >
98+ { file . filename }
99+ </ Link >
100+ </ TableCell >
101+ < HideOnSmall > { file . fileType } </ HideOnSmall >
102+ < TableCell > { ( file . fileSize / 1024 ) . toFixed ( ) } kB</ TableCell >
103+ < TableCell >
104+ { isPdf && (
105+ < Box display = "flex" alignItems = "center" gap = { 0.5 } >
106+ { usedAdvancedParsing && < AutoFixHigh sx = { { fontSize : 16 , color : 'primary.main' } } /> }
107+ < Typography variant = "body2" color = { usedAdvancedParsing ? 'primary.main' : 'text.secondary' } >
108+ { usedAdvancedParsing ? t ( 'rag:advancedParsing' ) : t ( 'rag:standardParsing' ) }
72109 </ Typography >
73110 </ Box >
74- < Table size = "small" >
75- < TableHead >
76- < TableRow >
77- < TableCell > { t ( 'common:fileType' ) } </ TableCell >
78- < TableCell > { t ( 'rag:fileSize' ) } </ TableCell >
79- </ TableRow >
80- </ TableHead >
81- < TableBody >
82- < TableRow >
83- < TableCell > { file . fileType } </ TableCell >
84- < TableCell > { ( file . fileSize / 1024 ) . toFixed ( ) } kB</ TableCell >
85- </ TableRow >
86- </ TableBody >
87- </ Table >
88- </ Box >
89- < Box sx = { { ml : '2rem' , flex : 1 , display : 'flex' , alignItems : 'center' , gap : 2 } } >
90- < Box display = "flex" alignItems = "center" gap = { 1 } color = { `${ accentColor } .main` } >
91- { progressIcon }
92- < div >
93- < Typography variant = "body2" sx = { { color : 'text.secondary' } } >
94- { message }
111+ ) }
112+ </ TableCell >
113+ < HideOnSmall >
114+ < Typography variant = "body2" color = "text.secondary" >
115+ { new Date ( file . createdAt ) . toLocaleString ( locales [ i18n . language ] . code ) }
116+ </ Typography >
117+ </ HideOnSmall >
118+ < TableCell >
119+ < Box display = "flex" alignItems = "center" gap = { 1 } color = { `${ accentColor } .main` } >
120+ { progressIcon }
121+ < div >
122+ < Typography variant = "body2" sx = { { color : 'text.secondary' } } >
123+ { message }
124+ </ Typography >
125+ { status ?. eta && (
126+ < Typography variant = "body2" component = "div" sx = { { color : 'text.secondary' } } >
127+ { formatDistanceStrict ( 0 , status ?. eta ) } left
95128 </ Typography >
96- { status ?. eta && (
97- < Typography variant = "body2" component = "div" sx = { { color : 'text.secondary' } } >
98- { formatDistanceStrict ( 0 , status ?. eta ) } left
99- </ Typography >
100- ) }
101- { error ?. length && (
102- < Typography variant = "body2" color = "error" >
103- { t ( 'error:errorMessage' ) } : { status ?. error ?? file . error }
104- </ Typography >
105- ) }
106- </ div >
107- </ Box >
129+ ) }
130+ { error ?. length && (
131+ < Typography variant = "body2" color = "error" >
132+ { t ( 'error:errorMessage' ) } : { status ?. error ?? file . error }
133+ </ Typography >
134+ ) }
135+ </ div >
108136 </ Box >
137+ </ TableCell >
138+ < TableCell >
109139 < CircularProgressWithLabel progress = { progress } accentColor = { accentColor } />
110- </ Box >
111- < Divider sx = { { my : 2 } } />
112- </ >
140+ </ TableCell >
141+ </ TableRow >
113142 )
114143}
0 commit comments