Skip to content

Commit 1932cc4

Browse files
Status source and type filtering (#664)
* status source * Name change * type change
1 parent d115c89 commit 1932cc4

File tree

1 file changed

+66
-19
lines changed

1 file changed

+66
-19
lines changed

frontend/src/components/FileTable.tsx

Lines changed: 66 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
5858
const [isLoading, setIsLoading] = useState<boolean>(false);
5959
const [statusFilter, setstatusFilter] = useState<string>('');
6060
const [filetypeFilter, setFiletypeFilter] = useState<string>('');
61+
const [fileSourceFilter, setFileSourceFilter] = useState<string>('');
6162
const [llmtypeFilter, setLLmtypeFilter] = useState<string>('');
6263
const skipPageResetRef = useRef<boolean>(false);
6364
const [alertDetails, setalertDetails] = useState<alertStateType>({
@@ -326,21 +327,61 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
326327
<span>
327328
<TextLink externalLink href={info.row.original.source_url}>
328329
{info.row.original.fileSource}
329-
</TextLink>{' '}
330-
/
330+
</TextLink>
331331
</span>
332-
<Typography variant='body-medium'>{info.row.original.type}</Typography>
333332
</Flex>
334333
);
335334
}
336335
return (
337336
<div>
338-
<span>{info.row.original.fileSource} / </span>
337+
<span>{info.row.original.fileSource}</span>
338+
</div>
339+
);
340+
},
341+
header: () => <span>Source</span>,
342+
footer: (info) => info.column.id,
343+
filterFn: 'fileSourceFilter' as any,
344+
meta: {
345+
columnActions: {
346+
actions: [
347+
{
348+
title: (
349+
<span className={`${fileSourceFilter === 'All' ? 'n-bg-palette-primary-bg-selected' : ''} p-2`}>
350+
All Sources
351+
</span>
352+
),
353+
onClick: () => {
354+
setFileSourceFilter('All');
355+
table.getColumn('source')?.setFilterValue(true);
356+
},
357+
},
358+
...Array.from(new Set(filesData.map((f) => f.fileSource))).map((t) => {
359+
return {
360+
title: (
361+
<span className={`${t === fileSourceFilter ? 'n-bg-palette-primary-bg-selected' : ''} p-2`}>{t}</span>
362+
),
363+
onClick: () => {
364+
setFileSourceFilter(t as string);
365+
table.getColumn('source')?.setFilterValue(true);
366+
skipPageResetRef.current = true;
367+
},
368+
};
369+
}),
370+
],
371+
defaultSortingActions: false,
372+
},
373+
},
374+
}),
375+
columnHelper.accessor((row) => row, {
376+
id: 'type',
377+
cell: (info) => {
378+
return (
379+
<div>
339380
<span>{info.row.original.type}</span>
340381
</div>
341382
);
342383
},
343-
header: () => <span>Source/Type</span>,
384+
header: () => <span>Type</span>,
344385
footer: (info) => info.column.id,
345386
filterFn: 'fileTypeFilter' as any,
346387
meta: {
@@ -349,12 +390,12 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
349390
{
350391
title: (
351392
<span className={`${filetypeFilter === 'All' ? 'n-bg-palette-primary-bg-selected' : ''} p-2`}>
352-
All types
393+
All Types
353394
</span>
354395
),
355396
onClick: () => {
356397
setFiletypeFilter('All');
357-
table.getColumn('source')?.setFilterValue(true);
398+
table.getColumn('type')?.setFilterValue(true);
358399
},
359400
},
360401
...Array.from(new Set(filesData.map((f) => f.type))).map((t) => {
@@ -364,7 +405,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
364405
),
365406
onClick: () => {
366407
setFiletypeFilter(t as string);
367-
table.getColumn('source')?.setFilterValue(true);
408+
table.getColumn('type')?.setFilterValue(true);
368409
skipPageResetRef.current = true;
369410
},
370411
};
@@ -457,7 +498,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
457498
footer: (info) => info.column.id,
458499
}),
459500
],
460-
[filesData.length, statusFilter, filetypeFilter, llmtypeFilter]
501+
[filesData.length, statusFilter, filetypeFilter, llmtypeFilter, fileSourceFilter]
461502
);
462503

463504
const table = useReactTable({
@@ -486,6 +527,12 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
486527
}
487528
return row.original.type === filetypeFilter;
488529
},
530+
fileSourceFilter: (row) => {
531+
if (fileSourceFilter === 'All') {
532+
return true;
533+
}
534+
return row.original.fileSource === fileSourceFilter;
535+
},
489536
llmTypeFilter: (row) => {
490537
if (llmtypeFilter === 'All') {
491538
return true;
@@ -532,14 +579,14 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
532579
item?.fileSource === 's3 bucket' && localStorage.getItem('accesskey') === item?.awsAccessKeyId
533580
? item?.status
534581
: item?.fileSource === 'local file'
535-
? item?.status
536-
: item?.status === 'Completed' || item.status === 'Failed'
537-
? item?.status
538-
: item?.fileSource == 'Wikipedia' ||
539-
item?.fileSource == 'youtube' ||
540-
item?.fileSource == 'gcs bucket'
541-
? item?.status
542-
: 'N/A',
582+
? item?.status
583+
: item?.status === 'Completed' || item.status === 'Failed'
584+
? item?.status
585+
: item?.fileSource == 'Wikipedia' ||
586+
item?.fileSource == 'youtube' ||
587+
item?.fileSource == 'gcs bucket'
588+
? item?.status
589+
: 'N/A',
543590
model: item?.model ?? model,
544591
id: uuidv4(),
545592
source_url: item?.url != 'None' && item?.url != '' ? item.url : '',
@@ -552,8 +599,8 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
552599
language: item?.language ?? '',
553600
processingProgress:
554601
item?.processed_chunk != undefined &&
555-
item?.total_chunks != undefined &&
556-
!isNaN(Math.floor((item?.processed_chunk / item?.total_chunks) * 100))
602+
item?.total_chunks != undefined &&
603+
!isNaN(Math.floor((item?.processed_chunk / item?.total_chunks) * 100))
557604
? Math.floor((item?.processed_chunk / item?.total_chunks) * 100)
558605
: undefined,
559606
// total_pages: item?.total_pages ?? 0,

0 commit comments

Comments
 (0)