mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-24 15:36:50 +08:00
### What problem does this PR solve? Feat: Filter the agent list by owner and category #9869 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -147,7 +147,6 @@ export default {
|
||||
// flow
|
||||
listTemplates: `${api_host}/canvas/templates`,
|
||||
listCanvas: `${api_host}/canvas/list`,
|
||||
listCanvasTeam: `${api_host}/canvas/list`,
|
||||
getCanvas: `${api_host}/canvas/get`,
|
||||
getCanvasSSE: `${api_host}/canvas/getsse`,
|
||||
removeCanvas: `${api_host}/canvas/rm`,
|
||||
|
||||
@ -7,27 +7,3 @@ export function isKnowledgeGraphParser(parserId: DocumentParserType) {
|
||||
export function isNaiveParser(parserId: DocumentParserType) {
|
||||
return parserId === DocumentParserType.Naive;
|
||||
}
|
||||
|
||||
export type FilterType = {
|
||||
id: string;
|
||||
label: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export function groupListByType<T extends Record<string, any>>(
|
||||
list: T[],
|
||||
idField: string,
|
||||
labelField: string,
|
||||
) {
|
||||
const fileTypeList: FilterType[] = [];
|
||||
list.forEach((x) => {
|
||||
const item = fileTypeList.find((y) => y.id === x[idField]);
|
||||
if (!item) {
|
||||
fileTypeList.push({ id: x[idField], label: x[labelField], count: 1 });
|
||||
} else {
|
||||
item.count += 1;
|
||||
}
|
||||
});
|
||||
|
||||
return fileTypeList;
|
||||
}
|
||||
|
||||
29
web/src/utils/list-filter-util.ts
Normal file
29
web/src/utils/list-filter-util.ts
Normal file
@ -0,0 +1,29 @@
|
||||
export type FilterType = {
|
||||
id: string;
|
||||
label: string;
|
||||
count: number;
|
||||
};
|
||||
|
||||
export function groupListByType<T extends Record<string, any>>(
|
||||
list: T[],
|
||||
idField: string,
|
||||
labelField: string,
|
||||
) {
|
||||
const fileTypeList: FilterType[] = [];
|
||||
list.forEach((x) => {
|
||||
const item = fileTypeList.find((y) => y.id === x[idField]);
|
||||
if (!item) {
|
||||
fileTypeList.push({ id: x[idField], label: x[labelField], count: 1 });
|
||||
} else {
|
||||
item.count += 1;
|
||||
}
|
||||
});
|
||||
|
||||
return fileTypeList;
|
||||
}
|
||||
|
||||
export function buildOwnersFilter<T extends Record<string, any>>(list: T[]) {
|
||||
const owners = groupListByType(list, 'tenant_id', 'nickname');
|
||||
|
||||
return { field: 'owner', list: owners, label: 'Owner' };
|
||||
}
|
||||
Reference in New Issue
Block a user