Skip to content

Status source and type filtering #664

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 66 additions & 19 deletions frontend/src/components/FileTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
const [isLoading, setIsLoading] = useState<boolean>(false);
const [statusFilter, setstatusFilter] = useState<string>('');
const [filetypeFilter, setFiletypeFilter] = useState<string>('');
const [fileSourceFilter, setFileSourceFilter] = useState<string>('');
const [llmtypeFilter, setLLmtypeFilter] = useState<string>('');
const skipPageResetRef = useRef<boolean>(false);
const [alertDetails, setalertDetails] = useState<alertStateType>({
Expand Down Expand Up @@ -326,21 +327,61 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
<span>
<TextLink externalLink href={info.row.original.source_url}>
{info.row.original.fileSource}
</TextLink>{' '}
/
</TextLink>
</span>
<Typography variant='body-medium'>{info.row.original.type}</Typography>
</Flex>
);
}
return (
<div>
<span>{info.row.original.fileSource} / </span>
<span>{info.row.original.fileSource}</span>
</div>
);
},
header: () => <span>Source</span>,
footer: (info) => info.column.id,
filterFn: 'fileSourceFilter' as any,
meta: {
columnActions: {
actions: [
{
title: (
<span className={`${fileSourceFilter === 'All' ? 'n-bg-palette-primary-bg-selected' : ''} p-2`}>
All Sources
</span>
),
onClick: () => {
setFileSourceFilter('All');
table.getColumn('source')?.setFilterValue(true);
},
},
...Array.from(new Set(filesData.map((f) => f.fileSource))).map((t) => {
return {
title: (
<span className={`${t === fileSourceFilter ? 'n-bg-palette-primary-bg-selected' : ''} p-2`}>{t}</span>
),
onClick: () => {
setFileSourceFilter(t as string);
table.getColumn('source')?.setFilterValue(true);
skipPageResetRef.current = true;
},
};
}),
],
defaultSortingActions: false,
},
},
}),
columnHelper.accessor((row) => row, {
id: 'type',
cell: (info) => {
return (
<div>
<span>{info.row.original.type}</span>
</div>
);
},
header: () => <span>Source/Type</span>,
header: () => <span>Type</span>,
footer: (info) => info.column.id,
filterFn: 'fileTypeFilter' as any,
meta: {
Expand All @@ -349,12 +390,12 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
{
title: (
<span className={`${filetypeFilter === 'All' ? 'n-bg-palette-primary-bg-selected' : ''} p-2`}>
All types
All Types
</span>
),
onClick: () => {
setFiletypeFilter('All');
table.getColumn('source')?.setFilterValue(true);
table.getColumn('type')?.setFilterValue(true);
},
},
...Array.from(new Set(filesData.map((f) => f.type))).map((t) => {
Expand All @@ -364,7 +405,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
),
onClick: () => {
setFiletypeFilter(t as string);
table.getColumn('source')?.setFilterValue(true);
table.getColumn('type')?.setFilterValue(true);
skipPageResetRef.current = true;
},
};
Expand Down Expand Up @@ -457,7 +498,7 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
footer: (info) => info.column.id,
}),
],
[filesData.length, statusFilter, filetypeFilter, llmtypeFilter]
[filesData.length, statusFilter, filetypeFilter, llmtypeFilter, fileSourceFilter]
);

const table = useReactTable({
Expand Down Expand Up @@ -486,6 +527,12 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
}
return row.original.type === filetypeFilter;
},
fileSourceFilter: (row) => {
if (fileSourceFilter === 'All') {
return true;
}
return row.original.fileSource === fileSourceFilter;
},
llmTypeFilter: (row) => {
if (llmtypeFilter === 'All') {
return true;
Expand Down Expand Up @@ -532,14 +579,14 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
item?.fileSource === 's3 bucket' && localStorage.getItem('accesskey') === item?.awsAccessKeyId
? item?.status
: item?.fileSource === 'local file'
? item?.status
: item?.status === 'Completed' || item.status === 'Failed'
? item?.status
: item?.fileSource == 'Wikipedia' ||
item?.fileSource == 'youtube' ||
item?.fileSource == 'gcs bucket'
? item?.status
: 'N/A',
? item?.status
: item?.status === 'Completed' || item.status === 'Failed'
? item?.status
: item?.fileSource == 'Wikipedia' ||
item?.fileSource == 'youtube' ||
item?.fileSource == 'gcs bucket'
? item?.status
: 'N/A',
model: item?.model ?? model,
id: uuidv4(),
source_url: item?.url != 'None' && item?.url != '' ? item.url : '',
Expand All @@ -552,8 +599,8 @@ const FileTable = forwardRef<ChildRef, FileTableProps>((props, ref) => {
language: item?.language ?? '',
processingProgress:
item?.processed_chunk != undefined &&
item?.total_chunks != undefined &&
!isNaN(Math.floor((item?.processed_chunk / item?.total_chunks) * 100))
item?.total_chunks != undefined &&
!isNaN(Math.floor((item?.processed_chunk / item?.total_chunks) * 100))
? Math.floor((item?.processed_chunk / item?.total_chunks) * 100)
: undefined,
// total_pages: item?.total_pages ?? 0,
Expand Down