mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-28 09:03:53 +00:00
4.8.6 merge (#1943)
* Dataset collection forbid (#1885) * perf: tool call support same id * feat: collection forbid * feat: collection forbid * Inheritance Permission for apps (#1897) * feat: app schema define chore: references of authapp * feat: authApp method inheritance * feat: create and update api * feat: update * feat: inheritance Permission controller for app. * feat: abstract version of inheritPermission * feat: ancestorId for apps * chore: update app * fix: inheritPermission abstract version * feat: update folder defaultPermission * feat: app update api * chore: inheritance frontend * chore: app list api * feat: update defaultPermission in app deatil * feat: backend api finished * feat: app inheritance permission fe * fix: app update defaultpermission causes collaborator miss * fix: ts error * chore: adjust the codes * chore: i18n chore: i18n * chore: fe adjust and i18n * chore: adjust the code * feat: resume api; chore: rewrite update api and inheritPermission methods * chore: something * chore: fe code adjusting * feat: frontend adjusting * chore: fe code adjusting * chore: adjusting the code * perf: fe loading * format * Inheritance fix (#1908) * fix: SlideCard * fix: authapp did not return parent app for inheritance app * fix: fe adjusting * feat: fe adjusing * perf: inherit per ux * doc * fix: ts errors (#1916) * perf: inherit permission * fix: permission inherit * Workflow type (#1938) * perf: workflow type tmp workflow perf: workflow type feat: custom field config * perf: dynamic input * perf: node classify * perf: node classify * perf: node classify * perf: node classify * fix: workflow custom input * feat: text editor and customFeedback move to basic nodes * feat: community system plugin * fix: ts * feat: exprEval plugin * perf: workflow type * perf: plugin important * fix: default templates * perf: markdown hr css * lock * perf: fetch url * perf: new plugin version * fix: chat histories update * fix: collection paths invalid * perf: app card ui --------- Co-authored-by: Finley Ge <32237950+FinleyGe@users.noreply.github.com>
This commit is contained in:
@@ -13,12 +13,15 @@ import {
|
||||
DrawerHeader,
|
||||
DrawerOverlay,
|
||||
DrawerContent,
|
||||
useDisclosure
|
||||
useDisclosure,
|
||||
HStack,
|
||||
Switch
|
||||
} from '@chakra-ui/react';
|
||||
import {
|
||||
getDatasetDataList,
|
||||
delOneDatasetDataById,
|
||||
getDatasetCollectionById
|
||||
getDatasetCollectionById,
|
||||
putDatasetDataById
|
||||
} from '@/web/core/dataset/api';
|
||||
import { DeleteIcon } from '@chakra-ui/icons';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
@@ -47,6 +50,9 @@ import { useI18n } from '@/web/context/I18n';
|
||||
import EmptyTip from '@fastgpt/web/components/common/EmptyTip';
|
||||
import { DatasetPageContext } from '@/web/core/dataset/context/datasetPageContext';
|
||||
import { useContextSelector } from 'use-context-selector';
|
||||
import { useRequest2 } from '@fastgpt/web/hooks/useRequest';
|
||||
import MyTag from '@fastgpt/web/components/common/Tag/index';
|
||||
import MyBox from '@fastgpt/web/components/common/MyBox';
|
||||
|
||||
const DataCard = () => {
|
||||
const BoxRef = useRef<HTMLDivElement>(null);
|
||||
@@ -60,7 +66,6 @@ const DataCard = () => {
|
||||
};
|
||||
const datasetDetail = useContextSelector(DatasetPageContext, (v) => v.datasetDetail);
|
||||
|
||||
const { Loading, setIsLoading } = useLoading({ defaultLoading: true });
|
||||
const { t } = useTranslation();
|
||||
const { datasetT } = useI18n();
|
||||
const [searchText, setSearchText] = useState('');
|
||||
@@ -78,16 +83,17 @@ const DataCard = () => {
|
||||
total,
|
||||
getData,
|
||||
pageNum,
|
||||
pageSize
|
||||
pageSize,
|
||||
isLoading: isRequesting
|
||||
} = usePagination<DatasetDataListItemType>({
|
||||
api: getDatasetDataList,
|
||||
pageSize: 24,
|
||||
defaultRequest: false,
|
||||
params: {
|
||||
collectionId,
|
||||
searchText
|
||||
},
|
||||
onChange() {
|
||||
setIsLoading(false);
|
||||
if (BoxRef.current) {
|
||||
BoxRef.current.scrollTop = 0;
|
||||
}
|
||||
@@ -97,12 +103,16 @@ const DataCard = () => {
|
||||
const [editDataId, setEditDataId] = useState<string>();
|
||||
|
||||
// get first page data
|
||||
const getFirstData = useCallback(
|
||||
debounce(() => {
|
||||
useRequest2(
|
||||
async () => {
|
||||
getData(1);
|
||||
lastSearch.current = searchText;
|
||||
}, 300),
|
||||
[searchText]
|
||||
},
|
||||
{
|
||||
manual: false,
|
||||
debounceWait: 300,
|
||||
refreshDeps: [searchText]
|
||||
}
|
||||
);
|
||||
|
||||
// get file info
|
||||
@@ -182,9 +192,18 @@ const DataCard = () => {
|
||||
];
|
||||
}, [collection, datasetT, t]);
|
||||
|
||||
const { run: onUpdate, loading } = useRequest2(putDatasetDataById, {
|
||||
onSuccess() {
|
||||
getData(pageNum);
|
||||
}
|
||||
});
|
||||
|
||||
const isLoading = isRequesting || loading;
|
||||
|
||||
return (
|
||||
<Box position={'relative'} py={[1, 5]} h={'100%'}>
|
||||
<MyBox isLoading={isLoading} position={'relative'} py={[1, 5]} h={'100%'}>
|
||||
<Flex ref={BoxRef} flexDirection={'column'} h={'100%'}>
|
||||
{/* Header */}
|
||||
<Flex alignItems={'center'} px={5}>
|
||||
<IconButton
|
||||
mr={3}
|
||||
@@ -270,20 +289,10 @@ const DataCard = () => {
|
||||
value={searchText}
|
||||
onChange={(e) => {
|
||||
setSearchText(e.target.value);
|
||||
getFirstData();
|
||||
}}
|
||||
onBlur={() => {
|
||||
if (searchText === lastSearch.current) return;
|
||||
getFirstData();
|
||||
}}
|
||||
onKeyDown={(e) => {
|
||||
if (searchText === lastSearch.current) return;
|
||||
if (e.key === 'Enter') {
|
||||
getFirstData();
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</Flex>
|
||||
{/* data */}
|
||||
<Box flex={'1 0 0'} overflow={'auto'} px={5}>
|
||||
<Grid
|
||||
gridTemplateColumns={['1fr', 'repeat(2,1fr)', 'repeat(3,1fr)', 'repeat(4,1fr)']}
|
||||
@@ -304,29 +313,58 @@ const DataCard = () => {
|
||||
borderColor: 'myGray.200',
|
||||
boxShadow: 'lg',
|
||||
bg: 'white',
|
||||
'& .footer': { h: 'auto', p: 3 }
|
||||
'& .footer': { h: 'auto', p: 3 },
|
||||
'& .forbid-switch': { display: 'flex' }
|
||||
}}
|
||||
onClick={() => {
|
||||
if (!collection) return;
|
||||
setEditDataId(item._id);
|
||||
}}
|
||||
>
|
||||
<Flex zIndex={1} alignItems={'center'} justifyContent={'space-between'}>
|
||||
<Flex zIndex={1} alignItems={'center'}>
|
||||
<MyTag type="borderFill"># {item.chunkIndex ?? '-'}</MyTag>
|
||||
|
||||
<Box
|
||||
borderWidth={'1px'}
|
||||
borderColor={'primary.200'}
|
||||
bg={'primary.50'}
|
||||
color={'primary.600'}
|
||||
px={2}
|
||||
fontSize={'sm'}
|
||||
mr={1}
|
||||
borderRadius={'md'}
|
||||
className={'textEllipsis'}
|
||||
flex={'1 0 0'}
|
||||
w="0"
|
||||
fontSize={'mini'}
|
||||
textAlign={'right'}
|
||||
>
|
||||
# {item.chunkIndex ?? '-'}
|
||||
</Box>
|
||||
<Box className={'textEllipsis'} fontSize={'xs'}>
|
||||
ID:{item._id}
|
||||
</Box>
|
||||
{/* {item.forbid ? (
|
||||
<MyTag colorSchema="gray" bg={'transparent'} px={1} showDot>
|
||||
{datasetT('Disabled')}
|
||||
</MyTag>
|
||||
) : (
|
||||
<MyTag colorSchema="green" bg={'transparent'} px={1} showDot>
|
||||
{datasetT('Enabled')}
|
||||
</MyTag>
|
||||
)}
|
||||
<HStack
|
||||
borderLeftWidth={'1.5px'}
|
||||
className="forbid-switch"
|
||||
display={['flex', 'none']}
|
||||
borderLeftColor={'myGray.200'}
|
||||
pl={1}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
}}
|
||||
h={'12px'}
|
||||
>
|
||||
<Switch
|
||||
size={'sm'}
|
||||
isChecked={!item.forbid}
|
||||
onChange={(e) => {
|
||||
e.stopPropagation();
|
||||
onUpdate({
|
||||
dataId: item._id,
|
||||
forbid: !e.target.checked
|
||||
});
|
||||
}}
|
||||
/>
|
||||
</HStack> */}
|
||||
</Flex>
|
||||
<Box
|
||||
maxH={'135px'}
|
||||
@@ -335,13 +373,14 @@ const DataCard = () => {
|
||||
wordBreak={'break-all'}
|
||||
pt={1}
|
||||
pb={3}
|
||||
fontSize={'13px'}
|
||||
fontSize={'sm'}
|
||||
>
|
||||
<Box color={'black'} mb={1}>
|
||||
{item.q}
|
||||
</Box>
|
||||
<Box color={'myGray.700'}>{item.a}</Box>
|
||||
|
||||
{/* Mask */}
|
||||
<Flex
|
||||
className="footer"
|
||||
position={'absolute'}
|
||||
@@ -351,39 +390,43 @@ const DataCard = () => {
|
||||
right={0}
|
||||
h={'0'}
|
||||
overflow={'hidden'}
|
||||
p={0}
|
||||
bg={'linear-gradient(to top, white,white 20%, rgba(255,255,255,0) 60%)'}
|
||||
alignItems={'flex-end'}
|
||||
fontSize={'sm'}
|
||||
fontSize={'mini'}
|
||||
>
|
||||
<Flex alignItems={'center'}>
|
||||
<MyIcon name="common/text/t" w={'14px'} mr={1} color={'myGray.500'} />
|
||||
{item.q.length + (item.a?.length || 0)}
|
||||
</Flex>
|
||||
<Box flex={1} />
|
||||
{canWrite && (
|
||||
<IconButton
|
||||
display={'flex'}
|
||||
icon={<DeleteIcon />}
|
||||
variant={'whiteDanger'}
|
||||
size={'xsSquare'}
|
||||
aria-label={'delete'}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
openConfirm(async () => {
|
||||
try {
|
||||
await delOneDatasetDataById(item._id);
|
||||
getData(pageNum);
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: getErrText(error),
|
||||
status: 'error'
|
||||
});
|
||||
}
|
||||
})();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
<HStack p={0} flex={1}>
|
||||
<Flex alignItems={'center'}>
|
||||
<MyIcon name="common/text/t" w={'0.8rem'} mr={1} color={'myGray.500'} />
|
||||
<Box>{item.q.length + (item.a?.length || 0)}</Box>
|
||||
</Flex>
|
||||
<Box flex={1}></Box>
|
||||
{/* <Box className={'textEllipsis'} flex={'1 0 0'} w="0">
|
||||
ID:{item._id}
|
||||
</Box> */}
|
||||
{canWrite && (
|
||||
<IconButton
|
||||
display={'flex'}
|
||||
icon={<DeleteIcon />}
|
||||
variant={'whiteDanger'}
|
||||
size={'xsSquare'}
|
||||
aria-label={'delete'}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
openConfirm(async () => {
|
||||
try {
|
||||
await delOneDatasetDataById(item._id);
|
||||
getData(pageNum);
|
||||
} catch (error) {
|
||||
toast({
|
||||
title: getErrText(error),
|
||||
status: 'error'
|
||||
});
|
||||
}
|
||||
})();
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</HStack>
|
||||
</Flex>
|
||||
</Box>
|
||||
</Card>
|
||||
@@ -440,8 +483,7 @@ const DataCard = () => {
|
||||
/>
|
||||
)}
|
||||
<ConfirmModal />
|
||||
<Loading fixed={false} />
|
||||
</Box>
|
||||
</MyBox>
|
||||
);
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user