mirror of
https://github.com/labring/FastGPT.git
synced 2025-10-16 08:01:18 +00:00
fix bugs (#5087)
* fix metadata and forbid filter * team plan init * sync collection tags * fix json import * fix code * fix
This commit is contained in:
@@ -37,6 +37,7 @@ import {
|
|||||||
} from '@fastgpt/global/core/dataset/training/utils';
|
} from '@fastgpt/global/core/dataset/training/utils';
|
||||||
import { DatasetDataIndexTypeEnum } from '@fastgpt/global/core/dataset/data/constants';
|
import { DatasetDataIndexTypeEnum } from '@fastgpt/global/core/dataset/data/constants';
|
||||||
import { clearCollectionImages, removeDatasetImageExpiredTime } from '../image/utils';
|
import { clearCollectionImages, removeDatasetImageExpiredTime } from '../image/utils';
|
||||||
|
import { MongoDatasetCollectionTags } from '../tag/schema';
|
||||||
|
|
||||||
export const createCollectionAndInsertData = async ({
|
export const createCollectionAndInsertData = async ({
|
||||||
dataset,
|
dataset,
|
||||||
@@ -279,7 +280,7 @@ export async function createOneCollection({ session, ...props }: CreateOneCollec
|
|||||||
teamId,
|
teamId,
|
||||||
parentId,
|
parentId,
|
||||||
datasetId,
|
datasetId,
|
||||||
tags,
|
tags: tagIdList,
|
||||||
|
|
||||||
fileId,
|
fileId,
|
||||||
rawLink,
|
rawLink,
|
||||||
@@ -288,7 +289,18 @@ export async function createOneCollection({ session, ...props }: CreateOneCollec
|
|||||||
apiFileId
|
apiFileId
|
||||||
} = props;
|
} = props;
|
||||||
// Create collection tags
|
// Create collection tags
|
||||||
const collectionTags = await createOrGetCollectionTags({ tags, teamId, datasetId, session });
|
const tags = await MongoDatasetCollectionTags.find({
|
||||||
|
teamId,
|
||||||
|
datasetId,
|
||||||
|
_id: { $in: tagIdList }
|
||||||
|
});
|
||||||
|
|
||||||
|
const collectionTags = await createOrGetCollectionTags({
|
||||||
|
tags: tags.map((item) => item.tag),
|
||||||
|
teamId,
|
||||||
|
datasetId,
|
||||||
|
session
|
||||||
|
});
|
||||||
|
|
||||||
// Create collection
|
// Create collection
|
||||||
const [collection] = await MongoDatasetCollection.create(
|
const [collection] = await MongoDatasetCollection.create(
|
||||||
|
@@ -569,17 +569,18 @@ export async function searchDatasetData(
|
|||||||
...(filterCollectionIdList
|
...(filterCollectionIdList
|
||||||
? {
|
? {
|
||||||
collectionId: {
|
collectionId: {
|
||||||
$in: filterCollectionIdList.map((id) => new Types.ObjectId(id))
|
$in: filterCollectionIdList
|
||||||
|
.filter((id) => !forbidCollectionIdList.includes(id))
|
||||||
|
.map((id) => new Types.ObjectId(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
: {}),
|
: forbidCollectionIdList?.length
|
||||||
...(forbidCollectionIdList && forbidCollectionIdList.length > 0
|
? {
|
||||||
? {
|
collectionId: {
|
||||||
collectionId: {
|
$nin: forbidCollectionIdList.map((id) => new Types.ObjectId(id))
|
||||||
$nin: forbidCollectionIdList.map((id) => new Types.ObjectId(id))
|
}
|
||||||
}
|
}
|
||||||
}
|
: {})
|
||||||
: {})
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@@ -43,8 +43,15 @@ const ImportAppConfigEditor = ({ value, onChange, rows = 16 }: Props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (e.target) {
|
if (e.target) {
|
||||||
const res = JSON.parse(e.target.result as string);
|
try {
|
||||||
onChange(JSON.stringify(res, null, 2));
|
const res = JSON.parse(e.target.result as string);
|
||||||
|
onChange(JSON.stringify(res, null, 2));
|
||||||
|
} catch (error) {
|
||||||
|
toast({
|
||||||
|
title: t('app:invalid_json_format'),
|
||||||
|
status: 'error'
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
reader.readAsText(file);
|
reader.readAsText(file);
|
||||||
@@ -63,70 +70,75 @@ const ImportAppConfigEditor = ({ value, onChange, rows = 16 }: Props) => {
|
|||||||
const handleDrop = useCallback(
|
const handleDrop = useCallback(
|
||||||
async (e: DragEvent<HTMLDivElement>) => {
|
async (e: DragEvent<HTMLDivElement>) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
setIsDragging(false);
|
||||||
const file = e.dataTransfer.files[0];
|
const file = e.dataTransfer.files[0];
|
||||||
console.log(file);
|
console.log(file);
|
||||||
readJSONFile(file);
|
readJSONFile(file);
|
||||||
setIsDragging(false);
|
|
||||||
},
|
},
|
||||||
[readJSONFile]
|
[readJSONFile]
|
||||||
);
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Box w={['100%', '31rem']}>
|
<Box w={['100%', '31rem']} h={'full'} display={'flex'} flexDir={'column'}>
|
||||||
{isDragging ? (
|
<Flex justify={'space-between'} align={'center'} pb={3} flexShrink={0}>
|
||||||
<Flex
|
<Box fontSize={'sm'} color={'myGray.900'} fontWeight={'500'}>
|
||||||
align={'center'}
|
{t('common:json_config')}
|
||||||
justify={'center'}
|
|
||||||
w={'full'}
|
|
||||||
h={'17.5rem'}
|
|
||||||
borderRadius={'md'}
|
|
||||||
border={'1px dashed'}
|
|
||||||
borderColor={'myGray.400'}
|
|
||||||
onDragEnter={handleDragEnter}
|
|
||||||
onDragOver={(e) => e.preventDefault()}
|
|
||||||
onDrop={handleDrop}
|
|
||||||
onDragLeave={handleDragLeave}
|
|
||||||
>
|
|
||||||
<Flex align={'center'} justify={'center'} flexDir={'column'} gap={'0.62rem'}>
|
|
||||||
<MyIcon name={'configmap'} w={'2rem'} color={'primary.500'} />
|
|
||||||
<Box color={'primary.600'} fontSize={'sm'}>
|
|
||||||
{t('app:file_recover')}
|
|
||||||
</Box>
|
|
||||||
</Flex>
|
|
||||||
</Flex>
|
|
||||||
) : (
|
|
||||||
<Box>
|
|
||||||
<Flex justify={'space-between'} align={'center'} pb={3}>
|
|
||||||
<Box fontSize={'sm'} color={'myGray.900'} fontWeight={'500'}>
|
|
||||||
{t('common:json_config')}
|
|
||||||
</Box>
|
|
||||||
<Button onClick={onOpen} variant={'whiteBase'} p={0}>
|
|
||||||
<Flex px={'0.88rem'} py={'0.44rem'} color={'myGray.600'} fontSize={'mini'}>
|
|
||||||
<MyIcon name={'file/uploadFile'} w={'1rem'} mr={'0.38rem'} />
|
|
||||||
{t('common:upload_file')}
|
|
||||||
</Flex>
|
|
||||||
</Button>
|
|
||||||
</Flex>
|
|
||||||
<Box
|
|
||||||
onDragEnter={handleDragEnter}
|
|
||||||
onDragOver={(e) => e.preventDefault()}
|
|
||||||
onDrop={handleDrop}
|
|
||||||
onDragLeave={handleDragLeave}
|
|
||||||
>
|
|
||||||
<Textarea
|
|
||||||
bg={'myGray.50'}
|
|
||||||
border={'1px solid'}
|
|
||||||
borderRadius={'md'}
|
|
||||||
borderColor={'myGray.200'}
|
|
||||||
value={value}
|
|
||||||
placeholder={t('app:or_drag_JSON')}
|
|
||||||
rows={rows}
|
|
||||||
onChange={(e) => onChange(e.target.value)}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
</Box>
|
</Box>
|
||||||
)}
|
<Button onClick={onOpen} variant={'whiteBase'} p={0}>
|
||||||
|
<Flex px={'0.88rem'} py={'0.44rem'} color={'myGray.600'} fontSize={'mini'}>
|
||||||
|
<MyIcon name={'file/uploadFile'} w={'1rem'} mr={'0.38rem'} />
|
||||||
|
{t('common:upload_file')}
|
||||||
|
</Flex>
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
|
<Box
|
||||||
|
flex={1}
|
||||||
|
position={'relative'}
|
||||||
|
onDragEnter={handleDragEnter}
|
||||||
|
onDragOver={(e) => e.preventDefault()}
|
||||||
|
onDrop={handleDrop}
|
||||||
|
onDragLeave={handleDragLeave}
|
||||||
|
>
|
||||||
|
<Textarea
|
||||||
|
bg={'myGray.50'}
|
||||||
|
border={'1px solid'}
|
||||||
|
borderRadius={'md'}
|
||||||
|
borderColor={'myGray.200'}
|
||||||
|
value={value}
|
||||||
|
placeholder={t('app:or_drag_JSON')}
|
||||||
|
rows={rows}
|
||||||
|
onChange={(e) => onChange(e.target.value)}
|
||||||
|
h={'full'}
|
||||||
|
resize={'none'}
|
||||||
|
opacity={isDragging ? 0.3 : 1}
|
||||||
|
transition={'opacity 0.2s'}
|
||||||
|
/>
|
||||||
|
{isDragging && (
|
||||||
|
<Flex
|
||||||
|
position={'absolute'}
|
||||||
|
top={0}
|
||||||
|
left={0}
|
||||||
|
right={0}
|
||||||
|
bottom={0}
|
||||||
|
align={'center'}
|
||||||
|
justify={'center'}
|
||||||
|
bg={'rgba(255, 255, 255, 0.95)'}
|
||||||
|
borderRadius={'md'}
|
||||||
|
border={'2px dashed'}
|
||||||
|
borderColor={'primary.400'}
|
||||||
|
zIndex={1}
|
||||||
|
pointerEvents={'none'}
|
||||||
|
>
|
||||||
|
<Flex align={'center'} justify={'center'} flexDir={'column'} gap={'0.62rem'}>
|
||||||
|
<MyIcon name={'configmap'} w={'2rem'} color={'primary.500'} />
|
||||||
|
<Box color={'primary.600'} fontSize={'sm'} fontWeight={'medium'}>
|
||||||
|
{t('app:file_recover')}
|
||||||
|
</Box>
|
||||||
|
</Flex>
|
||||||
|
</Flex>
|
||||||
|
)}
|
||||||
|
</Box>
|
||||||
</Box>
|
</Box>
|
||||||
{File && <File onSelect={onSelectFile} />}
|
{File && <File onSelect={onSelectFile} />}
|
||||||
</>
|
</>
|
||||||
|
@@ -17,7 +17,6 @@ import { type UserUpdateParams } from '@/types/user';
|
|||||||
import { useToast } from '@fastgpt/web/hooks/useToast';
|
import { useToast } from '@fastgpt/web/hooks/useToast';
|
||||||
import { useUserStore } from '@/web/support/user/useUserStore';
|
import { useUserStore } from '@/web/support/user/useUserStore';
|
||||||
import type { UserType } from '@fastgpt/global/support/user/type.d';
|
import type { UserType } from '@fastgpt/global/support/user/type.d';
|
||||||
import { useQuery } from '@tanstack/react-query';
|
|
||||||
import dynamic from 'next/dynamic';
|
import dynamic from 'next/dynamic';
|
||||||
import { useSelectFile } from '@/web/common/file/hooks/useSelectFile';
|
import { useSelectFile } from '@/web/common/file/hooks/useSelectFile';
|
||||||
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
import { useSystemStore } from '@/web/common/system/useSystemStore';
|
||||||
@@ -26,7 +25,7 @@ import Avatar from '@fastgpt/web/components/common/Avatar';
|
|||||||
import MyIcon from '@fastgpt/web/components/common/Icon';
|
import MyIcon from '@fastgpt/web/components/common/Icon';
|
||||||
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
import MyTooltip from '@fastgpt/web/components/common/MyTooltip';
|
||||||
import { formatStorePrice2Read } from '@fastgpt/global/support/wallet/usage/tools';
|
import { formatStorePrice2Read } from '@fastgpt/global/support/wallet/usage/tools';
|
||||||
import { putUpdateMemberName, redeemCoupon } from '@/web/support/user/team/api';
|
import { putUpdateMemberName } from '@/web/support/user/team/api';
|
||||||
import { getDocPath } from '@/web/common/system/doc';
|
import { getDocPath } from '@/web/common/system/doc';
|
||||||
import {
|
import {
|
||||||
StandardSubLevelEnum,
|
StandardSubLevelEnum,
|
||||||
@@ -70,6 +69,10 @@ const Info = () => {
|
|||||||
const standardPlan = teamPlanStatus?.standardConstants;
|
const standardPlan = teamPlanStatus?.standardConstants;
|
||||||
const { isOpen: isOpenContact, onClose: onCloseContact, onOpen: onOpenContact } = useDisclosure();
|
const { isOpen: isOpenContact, onClose: onCloseContact, onOpen: onOpenContact } = useDisclosure();
|
||||||
|
|
||||||
|
useMount(() => {
|
||||||
|
initUserInfo();
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AccountContainer>
|
<AccountContainer>
|
||||||
<Box py={[3, '28px']} px={[5, 10]} mx={'auto'}>
|
<Box py={[3, '28px']} px={[5, 10]} mx={'auto'}>
|
||||||
@@ -353,12 +356,8 @@ const MyInfo = ({ onOpenContact }: { onOpenContact: () => void }) => {
|
|||||||
const PlanUsage = () => {
|
const PlanUsage = () => {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { userInfo, initUserInfo, teamPlanStatus, initTeamPlanStatus } = useUserStore();
|
const { userInfo, teamPlanStatus, initTeamPlanStatus } = useUserStore();
|
||||||
const { subPlans, feConfigs } = useSystemStore();
|
const { subPlans, feConfigs } = useSystemStore();
|
||||||
const { reset } = useForm<UserUpdateParams>({
|
|
||||||
defaultValues: userInfo as UserType
|
|
||||||
});
|
|
||||||
|
|
||||||
const {
|
const {
|
||||||
isOpen: isOpenStandardModal,
|
isOpen: isOpenStandardModal,
|
||||||
onClose: onCloseStandardModal,
|
onClose: onCloseStandardModal,
|
||||||
@@ -376,6 +375,7 @@ const PlanUsage = () => {
|
|||||||
return standardSubLevelMap[teamPlanStatus.standard.currentSubLevel].label;
|
return standardSubLevelMap[teamPlanStatus.standard.currentSubLevel].label;
|
||||||
}, [teamPlanStatus?.standard?.currentSubLevel]);
|
}, [teamPlanStatus?.standard?.currentSubLevel]);
|
||||||
const standardPlan = teamPlanStatus?.standard;
|
const standardPlan = teamPlanStatus?.standard;
|
||||||
|
|
||||||
const isFreeTeam = useMemo(() => {
|
const isFreeTeam = useMemo(() => {
|
||||||
if (!teamPlanStatus || !teamPlanStatus?.standardConstants) return false;
|
if (!teamPlanStatus || !teamPlanStatus?.standardConstants) return false;
|
||||||
const hasExtraDatasetSize =
|
const hasExtraDatasetSize =
|
||||||
@@ -392,12 +392,6 @@ const PlanUsage = () => {
|
|||||||
return false;
|
return false;
|
||||||
}, [teamPlanStatus]);
|
}, [teamPlanStatus]);
|
||||||
|
|
||||||
useQuery(['init'], initUserInfo, {
|
|
||||||
onSuccess(res) {
|
|
||||||
reset(res);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const valueColorSchema = useCallback((val: number) => {
|
const valueColorSchema = useCallback((val: number) => {
|
||||||
if (val < 50) return 'green';
|
if (val < 50) return 'green';
|
||||||
if (val < 80) return 'yellow';
|
if (val < 80) return 'yellow';
|
||||||
|
Reference in New Issue
Block a user