mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? Fix (search): Search application list supports renaming function #3221 -Update the search application list page and add a renaming operation entry -Modify the search application details interface to support obtaining detailed information -Optimize search settings page layout and style ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -317,7 +317,11 @@ export function ChunkMethodDialog({
|
|||||||
</FormContainer>
|
</FormContainer>
|
||||||
)}
|
)}
|
||||||
{showGraphRagItems(selectedTag as DocumentParserType) &&
|
{showGraphRagItems(selectedTag as DocumentParserType) &&
|
||||||
useGraphRag && <UseGraphRagFormField></UseGraphRagFormField>}
|
useGraphRag && (
|
||||||
|
<FormContainer>
|
||||||
|
<UseGraphRagFormField></UseGraphRagFormField>
|
||||||
|
</FormContainer>
|
||||||
|
)}
|
||||||
{showEntityTypes && <EntityTypesFormField></EntityTypesFormField>}
|
{showEntityTypes && <EntityTypesFormField></EntityTypesFormField>}
|
||||||
</form>
|
</form>
|
||||||
</Form>
|
</Form>
|
||||||
|
|||||||
@ -50,10 +50,10 @@ export function DelimiterFormField() {
|
|||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
<FormItem className=" items-center space-y-0 ">
|
<FormItem className=" items-center space-y-0 ">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center gap-1">
|
||||||
<FormLabel
|
<FormLabel
|
||||||
tooltip={t('knowledgeDetails.delimiterTip')}
|
tooltip={t('knowledgeDetails.delimiterTip')}
|
||||||
className="text-sm text-muted-foreground whitespace-nowrap w-1/4"
|
className="text-sm text-muted-foreground whitespace-break-spaces w-1/4"
|
||||||
>
|
>
|
||||||
{t('knowledgeDetails.delimiter')}
|
{t('knowledgeDetails.delimiter')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|||||||
@ -25,10 +25,10 @@ export function ExcelToHtmlFormField() {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FormItem defaultChecked={false} className=" items-center space-y-0 ">
|
<FormItem defaultChecked={false} className=" items-center space-y-0 ">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center gap-1">
|
||||||
<FormLabel
|
<FormLabel
|
||||||
tooltip={t('html4excelTip')}
|
tooltip={t('html4excelTip')}
|
||||||
className="text-sm text-muted-foreground whitespace-nowrap w-1/4"
|
className="text-sm text-muted-foreground whitespace-break-spaces w-1/4"
|
||||||
>
|
>
|
||||||
{t('html4excel')}
|
{t('html4excel')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|||||||
@ -59,10 +59,10 @@ export function UseGraphRagFormField() {
|
|||||||
name="parser_config.graphrag.use_graphrag"
|
name="parser_config.graphrag.use_graphrag"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem defaultChecked={false} className=" items-center space-y-0 ">
|
<FormItem defaultChecked={false} className=" items-center space-y-0 ">
|
||||||
<div className="flex items-center">
|
<div className="flex items-center gap-1">
|
||||||
<FormLabel
|
<FormLabel
|
||||||
tooltip={t('useGraphRagTip')}
|
tooltip={t('useGraphRagTip')}
|
||||||
className="text-sm text-muted-foreground whitespace-nowrap w-1/4"
|
className="text-sm text-muted-foreground whitespace-break-spaces w-1/4"
|
||||||
>
|
>
|
||||||
{t('useGraphRag')}
|
{t('useGraphRag')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|||||||
@ -86,10 +86,10 @@ const RaptorFormFields = () => {
|
|||||||
defaultChecked={false}
|
defaultChecked={false}
|
||||||
className="items-center space-y-0 "
|
className="items-center space-y-0 "
|
||||||
>
|
>
|
||||||
<div className="flex items-center">
|
<div className="flex items-center gap-1">
|
||||||
<FormLabel
|
<FormLabel
|
||||||
tooltip={t('useRaptorTip')}
|
tooltip={t('useRaptorTip')}
|
||||||
className="text-sm text-muted-foreground whitespace-nowrap w-1/4"
|
className="text-sm text-muted-foreground w-1/4 whitespace-break-spaces"
|
||||||
>
|
>
|
||||||
{t('useRaptor')}
|
{t('useRaptor')}
|
||||||
</FormLabel>
|
</FormLabel>
|
||||||
|
|||||||
@ -3,6 +3,13 @@ import * as AvatarPrimitive from '@radix-ui/react-avatar';
|
|||||||
import { forwardRef, memo, useEffect, useRef, useState } from 'react';
|
import { forwardRef, memo, useEffect, useRef, useState } from 'react';
|
||||||
import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar';
|
import { Avatar, AvatarFallback, AvatarImage } from './ui/avatar';
|
||||||
|
|
||||||
|
const PREDEFINED_COLORS = [
|
||||||
|
{ from: '#4F6DEE', to: '#67BDF9' },
|
||||||
|
{ from: '#38A04D', to: '#93DCA2' },
|
||||||
|
{ from: '#C35F2B', to: '#EDB395' },
|
||||||
|
{ from: '#633897', to: '#CBA1FF' },
|
||||||
|
];
|
||||||
|
|
||||||
const getStringHash = (str: string): number => {
|
const getStringHash = (str: string): number => {
|
||||||
const normalized = str.trim().toLowerCase();
|
const normalized = str.trim().toLowerCase();
|
||||||
let hash = 104729;
|
let hash = 104729;
|
||||||
@ -17,16 +24,12 @@ const getStringHash = (str: string): number => {
|
|||||||
return Math.abs(hash);
|
return Math.abs(hash);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Generate a hash function with a fixed color
|
|
||||||
const getColorForName = (name: string): { from: string; to: string } => {
|
const getColorForName = (name: string): { from: string; to: string } => {
|
||||||
const hash = getStringHash(name);
|
const hash = getStringHash(name);
|
||||||
const hue = hash % 360;
|
const index = hash % PREDEFINED_COLORS.length;
|
||||||
|
return PREDEFINED_COLORS[index];
|
||||||
return {
|
|
||||||
to: `hsl(${hue}, 70%, 80%)`,
|
|
||||||
from: `hsl(${hue}, 60%, 30%)`,
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const RAGFlowAvatar = memo(
|
export const RAGFlowAvatar = memo(
|
||||||
forwardRef<
|
forwardRef<
|
||||||
React.ElementRef<typeof AvatarPrimitive.Root>,
|
React.ElementRef<typeof AvatarPrimitive.Root>,
|
||||||
@ -43,7 +46,7 @@ export const RAGFlowAvatar = memo(
|
|||||||
if (parts.length === 1) {
|
if (parts.length === 1) {
|
||||||
return parts[0][0].toUpperCase();
|
return parts[0][0].toUpperCase();
|
||||||
}
|
}
|
||||||
return parts[0][0].toUpperCase() + parts[1][0].toUpperCase();
|
return parts[0][0].toUpperCase();
|
||||||
};
|
};
|
||||||
|
|
||||||
const initials = getInitials(name);
|
const initials = getInitials(name);
|
||||||
@ -98,7 +101,7 @@ export const RAGFlowAvatar = memo(
|
|||||||
'bg-gradient-to-b',
|
'bg-gradient-to-b',
|
||||||
`from-[${from}] to-[${to}]`,
|
`from-[${from}] to-[${to}]`,
|
||||||
'flex items-center justify-center',
|
'flex items-center justify-center',
|
||||||
'text-white font-bold',
|
'text-white ',
|
||||||
{ 'rounded-md': !isPerson },
|
{ 'rounded-md': !isPerson },
|
||||||
)}
|
)}
|
||||||
style={{
|
style={{
|
||||||
|
|||||||
@ -49,12 +49,12 @@ export function SliderInputFormField({
|
|||||||
defaultValue={defaultValue || 0}
|
defaultValue={defaultValue || 0}
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem
|
<FormItem
|
||||||
className={cn({ 'flex items-center space-y-0': isHorizontal })}
|
className={cn({ 'flex items-center gap-1 space-y-0': isHorizontal })}
|
||||||
>
|
>
|
||||||
<FormLabel
|
<FormLabel
|
||||||
tooltip={tooltip}
|
tooltip={tooltip}
|
||||||
className={cn({
|
className={cn({
|
||||||
'text-sm text-muted-foreground whitespace-nowrap w-1/4':
|
'text-sm text-muted-foreground whitespace-break-spaces w-1/4':
|
||||||
isHorizontal,
|
isHorizontal,
|
||||||
})}
|
})}
|
||||||
>
|
>
|
||||||
|
|||||||
@ -126,7 +126,7 @@ export default function SearchPage() {
|
|||||||
// ></EmbedDialog>
|
// ></EmbedDialog>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div className="absolute right-5 top-12 ">
|
<div className="absolute right-5 top-4 ">
|
||||||
<Button
|
<Button
|
||||||
className="bg-text-primary text-bg-base border-b-[#00BEB4] border-b-2"
|
className="bg-text-primary text-bg-base border-b-[#00BEB4] border-b-2"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
|
|||||||
@ -30,18 +30,20 @@ interface LlmSettingFieldItemsProps {
|
|||||||
prefix?: string;
|
prefix?: string;
|
||||||
options?: any[];
|
options?: any[];
|
||||||
}
|
}
|
||||||
|
const LlmSettingEnableSchema = {
|
||||||
export const LlmSettingSchema = {
|
|
||||||
llm_id: z.string(),
|
|
||||||
parameter: z.string(),
|
|
||||||
temperature: z.coerce.number(),
|
|
||||||
top_p: z.coerce.number(),
|
|
||||||
presence_penalty: z.coerce.number(),
|
|
||||||
frequency_penalty: z.coerce.number(),
|
|
||||||
temperatureEnabled: z.boolean(),
|
temperatureEnabled: z.boolean(),
|
||||||
topPEnabled: z.boolean(),
|
topPEnabled: z.boolean(),
|
||||||
presencePenaltyEnabled: z.boolean(),
|
presencePenaltyEnabled: z.boolean(),
|
||||||
frequencyPenaltyEnabled: z.boolean(),
|
frequencyPenaltyEnabled: z.boolean(),
|
||||||
|
};
|
||||||
|
export const LlmSettingSchema = {
|
||||||
|
llm_id: z.string(),
|
||||||
|
parameter: z.string().optional(),
|
||||||
|
temperature: z.coerce.number().optional(),
|
||||||
|
top_p: z.coerce.number().optional(),
|
||||||
|
presence_penalty: z.coerce.number().optional(),
|
||||||
|
frequency_penalty: z.coerce.number().optional(),
|
||||||
|
...LlmSettingEnableSchema,
|
||||||
// maxTokensEnabled: z.boolean(),
|
// maxTokensEnabled: z.boolean(),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -65,6 +67,7 @@ export function LlmSettingFieldItems({
|
|||||||
settledModelVariableMap[
|
settledModelVariableMap[
|
||||||
parameter as keyof typeof settledModelVariableMap
|
parameter as keyof typeof settledModelVariableMap
|
||||||
];
|
];
|
||||||
|
const enabledKeys = Object.keys(LlmSettingEnableSchema);
|
||||||
|
|
||||||
// const nextValues = { ...currentValues, ...values };
|
// const nextValues = { ...currentValues, ...values };
|
||||||
|
|
||||||
@ -75,6 +78,11 @@ export function LlmSettingFieldItems({
|
|||||||
form.setValue(`${prefix}.${key}`, element);
|
form.setValue(`${prefix}.${key}`, element);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (enabledKeys && enabledKeys.length) {
|
||||||
|
for (const key of enabledKeys) {
|
||||||
|
form.setValue(`${prefix}.${key}`, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
[form, prefix],
|
[form, prefix],
|
||||||
);
|
);
|
||||||
|
|||||||
@ -38,11 +38,7 @@ import { useCallback, useEffect, useMemo, useState } from 'react';
|
|||||||
import { useForm, useWatch } from 'react-hook-form';
|
import { useForm, useWatch } from 'react-hook-form';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import {
|
import { LlmModelType } from '../dataset/dataset/constant';
|
||||||
LlmModelType,
|
|
||||||
ModelVariableType,
|
|
||||||
settledModelVariableMap,
|
|
||||||
} from '../dataset/dataset/constant';
|
|
||||||
import {
|
import {
|
||||||
ISearchAppDetailProps,
|
ISearchAppDetailProps,
|
||||||
IUpdateSearchProps,
|
IUpdateSearchProps,
|
||||||
@ -143,21 +139,11 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
chat_id: '',
|
chat_id: '',
|
||||||
llm_setting: {
|
llm_setting: {
|
||||||
llm_id: llm_setting?.llm_id || '',
|
llm_id: llm_setting?.llm_id || '',
|
||||||
parameter: llm_setting?.parameter || ModelVariableType.Improvise,
|
parameter: llm_setting?.parameter,
|
||||||
temperature:
|
temperature: llm_setting?.temperature,
|
||||||
llm_setting?.temperature ||
|
top_p: llm_setting?.top_p,
|
||||||
settledModelVariableMap[ModelVariableType.Improvise].temperature,
|
frequency_penalty: llm_setting?.frequency_penalty,
|
||||||
top_p:
|
presence_penalty: llm_setting?.presence_penalty,
|
||||||
llm_setting?.top_p ||
|
|
||||||
settledModelVariableMap[ModelVariableType.Improvise].top_p,
|
|
||||||
frequency_penalty:
|
|
||||||
llm_setting?.frequency_penalty ||
|
|
||||||
settledModelVariableMap[ModelVariableType.Improvise]
|
|
||||||
.frequency_penalty,
|
|
||||||
presence_penalty:
|
|
||||||
llm_setting?.presence_penalty ||
|
|
||||||
settledModelVariableMap[ModelVariableType.Improvise]
|
|
||||||
.presence_penalty,
|
|
||||||
temperatureEnabled: llm_setting?.temperature ? true : false,
|
temperatureEnabled: llm_setting?.temperature ? true : false,
|
||||||
topPEnabled: llm_setting?.top_p ? true : false,
|
topPEnabled: llm_setting?.top_p ? true : false,
|
||||||
presencePenaltyEnabled: llm_setting?.presence_penalty ? true : false,
|
presencePenaltyEnabled: llm_setting?.presence_penalty ? true : false,
|
||||||
@ -261,8 +247,13 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const { search_config, ...other_formdata } = formData;
|
const { search_config, ...other_formdata } = formData;
|
||||||
const { llm_setting, vector_similarity_weight, ...other_config } =
|
const {
|
||||||
search_config;
|
llm_setting,
|
||||||
|
vector_similarity_weight,
|
||||||
|
use_rerank,
|
||||||
|
rerank_id,
|
||||||
|
...other_config
|
||||||
|
} = search_config;
|
||||||
const llmSetting = {
|
const llmSetting = {
|
||||||
llm_id: llm_setting.llm_id,
|
llm_id: llm_setting.llm_id,
|
||||||
parameter: llm_setting.parameter,
|
parameter: llm_setting.parameter,
|
||||||
@ -289,6 +280,7 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
search_config: {
|
search_config: {
|
||||||
...other_config,
|
...other_config,
|
||||||
vector_similarity_weight: 1 - vector_similarity_weight,
|
vector_similarity_weight: 1 - vector_similarity_weight,
|
||||||
|
rerank_id: use_rerank ? rerank_id : '',
|
||||||
llm_setting: { ...llmSetting },
|
llm_setting: { ...llmSetting },
|
||||||
},
|
},
|
||||||
tenant_id: systemSetting.tenant_id,
|
tenant_id: systemSetting.tenant_id,
|
||||||
@ -302,7 +294,7 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={cn(
|
className={cn(
|
||||||
'text-text-primary border p-4 rounded-lg',
|
'text-text-primary border p-4 pb-12 rounded-lg',
|
||||||
{
|
{
|
||||||
'animate-fade-in-right': open,
|
'animate-fade-in-right': open,
|
||||||
'animate-fade-out-right': !open,
|
'animate-fade-out-right': !open,
|
||||||
@ -658,6 +650,7 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/> */}
|
/> */}
|
||||||
|
|
||||||
<FormField
|
<FormField
|
||||||
control={formMethods.control}
|
control={formMethods.control}
|
||||||
name="search_config.related_search"
|
name="search_config.related_search"
|
||||||
@ -690,7 +683,7 @@ const SearchSetting: React.FC<SearchSettingProps> = ({
|
|||||||
/>
|
/>
|
||||||
{/* Submit Button */}
|
{/* Submit Button */}
|
||||||
<div className="flex justify-end"></div>
|
<div className="flex justify-end"></div>
|
||||||
<div className="flex justify-end gap-2">
|
<div className="flex justify-end gap-2 absolute bottom-1 right-3 bg-bg-base w-[calc(100%-1em)] py-2">
|
||||||
<Button
|
<Button
|
||||||
type="reset"
|
type="reset"
|
||||||
variant={'transparent'}
|
variant={'transparent'}
|
||||||
|
|||||||
@ -89,7 +89,10 @@ export const useFetchSearchList = (params?: SearchListParams) => {
|
|||||||
...params,
|
...params,
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data, isLoading, isError } = useQuery<SearchListResponse, Error>({
|
const { data, isLoading, isError, refetch } = useQuery<
|
||||||
|
SearchListResponse,
|
||||||
|
Error
|
||||||
|
>({
|
||||||
queryKey: ['searchList', searchParams],
|
queryKey: ['searchList', searchParams],
|
||||||
queryFn: async () => {
|
queryFn: async () => {
|
||||||
const { data: response } =
|
const { data: response } =
|
||||||
@ -108,7 +111,14 @@ export const useFetchSearchList = (params?: SearchListParams) => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
return { data, isLoading, isError, searchParams, setSearchListParams };
|
return {
|
||||||
|
data,
|
||||||
|
isLoading,
|
||||||
|
isError,
|
||||||
|
searchParams,
|
||||||
|
setSearchListParams,
|
||||||
|
refetch,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
interface DeleteSearchProps {
|
interface DeleteSearchProps {
|
||||||
@ -150,6 +160,7 @@ export interface ISearchAppDetailProps {
|
|||||||
query_mindmap: boolean;
|
query_mindmap: boolean;
|
||||||
related_search: boolean;
|
related_search: boolean;
|
||||||
rerank_id: string;
|
rerank_id: string;
|
||||||
|
use_rerank?: boolean;
|
||||||
similarity_threshold: number;
|
similarity_threshold: number;
|
||||||
summary: boolean;
|
summary: boolean;
|
||||||
llm_setting: IllmSettingProps & IllmSettingEnableProps;
|
llm_setting: IllmSettingProps & IllmSettingEnableProps;
|
||||||
@ -191,6 +202,7 @@ export const useFetchSearchDetail = (tenantId?: string) => {
|
|||||||
const fetchSearchDetailFunc = shared_id
|
const fetchSearchDetailFunc = shared_id
|
||||||
? searchService.getSearchDetailShare
|
? searchService.getSearchDetailShare
|
||||||
: searchService.getSearchDetail;
|
: searchService.getSearchDetail;
|
||||||
|
|
||||||
const { data, isLoading, isError } = useQuery<SearchDetailResponse, Error>({
|
const { data, isLoading, isError } = useQuery<SearchDetailResponse, Error>({
|
||||||
queryKey: ['searchDetail', searchId],
|
queryKey: ['searchDetail', searchId],
|
||||||
enabled: !shared_id || !!tenantId,
|
enabled: !shared_id || !!tenantId,
|
||||||
|
|||||||
@ -13,13 +13,20 @@ import { Modal } from '@/components/ui/modal/modal';
|
|||||||
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
|
import { RAGFlowPagination } from '@/components/ui/ragflow-pagination';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
||||||
|
import searchService from '@/services/search-service';
|
||||||
import { zodResolver } from '@hookform/resolvers/zod';
|
import { zodResolver } from '@hookform/resolvers/zod';
|
||||||
import { pick } from 'lodash';
|
import { pick } from 'lodash';
|
||||||
import { Plus, Search } from 'lucide-react';
|
import { Plus, Search } from 'lucide-react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useForm } from 'react-hook-form';
|
import { useForm } from 'react-hook-form';
|
||||||
import { z } from 'zod';
|
import { z } from 'zod';
|
||||||
import { useCreateSearch, useFetchSearchList } from './hooks';
|
import {
|
||||||
|
ISearchAppProps,
|
||||||
|
IUpdateSearchProps,
|
||||||
|
useCreateSearch,
|
||||||
|
useFetchSearchList,
|
||||||
|
useUpdateSearch,
|
||||||
|
} from './hooks';
|
||||||
import { SearchCard } from './search-card';
|
import { SearchCard } from './search-card';
|
||||||
const searchFormSchema = z.object({
|
const searchFormSchema = z.object({
|
||||||
name: z.string().min(1, {
|
name: z.string().min(1, {
|
||||||
@ -27,16 +34,22 @@ const searchFormSchema = z.object({
|
|||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
type SearchFormValues = z.infer<typeof searchFormSchema>;
|
type SearchFormValues = z.infer<typeof searchFormSchema> & {
|
||||||
|
search_id?: string;
|
||||||
|
};
|
||||||
|
|
||||||
export default function SearchList() {
|
export default function SearchList() {
|
||||||
// const { data } = useFetchFlowList();
|
// const { data } = useFetchFlowList();
|
||||||
const { t } = useTranslate('search');
|
const { t } = useTranslate('search');
|
||||||
const { navigateToSearch } = useNavigatePage();
|
const { navigateToSearch } = useNavigatePage();
|
||||||
const { isLoading, createSearch } = useCreateSearch();
|
const { isLoading, createSearch } = useCreateSearch();
|
||||||
|
const [isEdit, setIsEdit] = useState(false);
|
||||||
|
const [searchData, setSearchData] = useState<ISearchAppProps | null>(null);
|
||||||
const {
|
const {
|
||||||
data: list,
|
data: list,
|
||||||
searchParams,
|
searchParams,
|
||||||
setSearchListParams,
|
setSearchListParams,
|
||||||
|
refetch: refetchList,
|
||||||
} = useFetchSearchList();
|
} = useFetchSearchList();
|
||||||
const [openCreateModal, setOpenCreateModal] = useState(false);
|
const [openCreateModal, setOpenCreateModal] = useState(false);
|
||||||
const form = useForm<SearchFormValues>({
|
const form = useForm<SearchFormValues>({
|
||||||
@ -48,10 +61,30 @@ export default function SearchList() {
|
|||||||
const handleSearchChange = (value: string) => {
|
const handleSearchChange = (value: string) => {
|
||||||
console.log(value);
|
console.log(value);
|
||||||
};
|
};
|
||||||
|
const { updateSearch } = useUpdateSearch();
|
||||||
const onSubmit = async (values: SearchFormValues) => {
|
const onSubmit = async (values: SearchFormValues) => {
|
||||||
const res = await createSearch({ name: values.name });
|
let res;
|
||||||
if (res) {
|
if (isEdit) {
|
||||||
|
try {
|
||||||
|
const reponse = await searchService.getSearchDetail({
|
||||||
|
search_id: searchData?.id,
|
||||||
|
});
|
||||||
|
const detail = reponse.data?.data;
|
||||||
|
console.log('detail-->', detail);
|
||||||
|
const { id, created_by, update_time, ...searchDataTemp } = detail;
|
||||||
|
res = await updateSearch({
|
||||||
|
...searchDataTemp,
|
||||||
|
name: values.name,
|
||||||
|
search_id: searchData?.id,
|
||||||
|
} as unknown as IUpdateSearchProps);
|
||||||
|
refetchList();
|
||||||
|
} catch (e) {
|
||||||
|
console.error('error', e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
res = await createSearch({ name: values.name });
|
||||||
|
}
|
||||||
|
if (res && !searchData?.id) {
|
||||||
navigateToSearch(res?.search_id);
|
navigateToSearch(res?.search_id);
|
||||||
}
|
}
|
||||||
if (!isLoading) {
|
if (!isLoading) {
|
||||||
@ -60,11 +93,23 @@ export default function SearchList() {
|
|||||||
form.reset({ name: '' });
|
form.reset({ name: '' });
|
||||||
};
|
};
|
||||||
const openCreateModalFun = () => {
|
const openCreateModalFun = () => {
|
||||||
|
setIsEdit(false);
|
||||||
setOpenCreateModal(true);
|
setOpenCreateModal(true);
|
||||||
};
|
};
|
||||||
const handlePageChange = (page: number, pageSize: number) => {
|
const handlePageChange = (page: number, pageSize: number) => {
|
||||||
|
setIsEdit(false);
|
||||||
setSearchListParams({ ...searchParams, page, page_size: pageSize });
|
setSearchListParams({ ...searchParams, page, page_size: pageSize });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const showSearchRenameModal = (data: ISearchAppProps) => {
|
||||||
|
form.setValue('name', data.name);
|
||||||
|
if (data.id) {
|
||||||
|
setIsEdit(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
setSearchData(data);
|
||||||
|
setOpenCreateModal(true);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<section className="w-full h-full flex flex-col">
|
<section className="w-full h-full flex flex-col">
|
||||||
<div className="px-8 pt-8">
|
<div className="px-8 pt-8">
|
||||||
@ -92,7 +137,13 @@ export default function SearchList() {
|
|||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="grid gap-6 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 max-h-[84vh] overflow-auto px-8">
|
<div className="grid gap-6 sm:grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-5 max-h-[84vh] overflow-auto px-8">
|
||||||
{list?.data.search_apps.map((x) => {
|
{list?.data.search_apps.map((x) => {
|
||||||
return <SearchCard key={x.id} data={x}></SearchCard>;
|
return (
|
||||||
|
<SearchCard
|
||||||
|
key={x.id}
|
||||||
|
data={x}
|
||||||
|
showSearchRenameModal={showSearchRenameModal}
|
||||||
|
></SearchCard>
|
||||||
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -8,8 +8,9 @@ import { SearchDropdown } from './search-dropdown';
|
|||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
data: ISearchAppProps;
|
data: ISearchAppProps;
|
||||||
|
showSearchRenameModal: (data: ISearchAppProps) => void;
|
||||||
}
|
}
|
||||||
export function SearchCard({ data }: IProps) {
|
export function SearchCard({ data, showSearchRenameModal }: IProps) {
|
||||||
const { navigateToSearch } = useNavigatePage();
|
const { navigateToSearch } = useNavigatePage();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -32,7 +33,10 @@ export function SearchCard({ data }: IProps) {
|
|||||||
<div className="text-[20px] font-bold w-80% leading-5">
|
<div className="text-[20px] font-bold w-80% leading-5">
|
||||||
{data.name}
|
{data.name}
|
||||||
</div>
|
</div>
|
||||||
<SearchDropdown dataset={data}>
|
<SearchDropdown
|
||||||
|
dataset={data}
|
||||||
|
showSearchRenameModal={showSearchRenameModal}
|
||||||
|
>
|
||||||
<MoreButton></MoreButton>
|
<MoreButton></MoreButton>
|
||||||
</SearchDropdown>
|
</SearchDropdown>
|
||||||
</section>
|
</section>
|
||||||
|
|||||||
@ -3,9 +3,10 @@ import {
|
|||||||
DropdownMenu,
|
DropdownMenu,
|
||||||
DropdownMenuContent,
|
DropdownMenuContent,
|
||||||
DropdownMenuItem,
|
DropdownMenuItem,
|
||||||
|
DropdownMenuSeparator,
|
||||||
DropdownMenuTrigger,
|
DropdownMenuTrigger,
|
||||||
} from '@/components/ui/dropdown-menu';
|
} from '@/components/ui/dropdown-menu';
|
||||||
import { Trash2 } from 'lucide-react';
|
import { PenLine, Trash2 } from 'lucide-react';
|
||||||
import { MouseEventHandler, PropsWithChildren, useCallback } from 'react';
|
import { MouseEventHandler, PropsWithChildren, useCallback } from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { ISearchAppProps, useDeleteSearch } from './hooks';
|
import { ISearchAppProps, useDeleteSearch } from './hooks';
|
||||||
@ -13,12 +14,21 @@ import { ISearchAppProps, useDeleteSearch } from './hooks';
|
|||||||
export function SearchDropdown({
|
export function SearchDropdown({
|
||||||
children,
|
children,
|
||||||
dataset,
|
dataset,
|
||||||
|
showSearchRenameModal,
|
||||||
}: PropsWithChildren & {
|
}: PropsWithChildren & {
|
||||||
dataset: ISearchAppProps;
|
dataset: ISearchAppProps;
|
||||||
|
showSearchRenameModal: (dataset: ISearchAppProps) => void;
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { deleteSearch } = useDeleteSearch();
|
const { deleteSearch } = useDeleteSearch();
|
||||||
|
const handleShowChatRenameModal: MouseEventHandler<HTMLDivElement> =
|
||||||
|
useCallback(
|
||||||
|
(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
showSearchRenameModal(dataset);
|
||||||
|
},
|
||||||
|
[dataset, showSearchRenameModal],
|
||||||
|
);
|
||||||
const handleDelete: MouseEventHandler<HTMLDivElement> = useCallback(() => {
|
const handleDelete: MouseEventHandler<HTMLDivElement> = useCallback(() => {
|
||||||
deleteSearch({ search_id: dataset.id });
|
deleteSearch({ search_id: dataset.id });
|
||||||
}, [dataset.id, deleteSearch]);
|
}, [dataset.id, deleteSearch]);
|
||||||
@ -27,10 +37,10 @@ export function SearchDropdown({
|
|||||||
<DropdownMenu>
|
<DropdownMenu>
|
||||||
<DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>
|
<DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>
|
||||||
<DropdownMenuContent>
|
<DropdownMenuContent>
|
||||||
{/* <DropdownMenuItem onClick={handleShowDatasetRenameModal}>
|
<DropdownMenuItem onClick={handleShowChatRenameModal}>
|
||||||
{t('common.rename')} <PenLine />
|
{t('common.rename')} <PenLine />
|
||||||
</DropdownMenuItem>
|
</DropdownMenuItem>
|
||||||
<DropdownMenuSeparator /> */}
|
<DropdownMenuSeparator />
|
||||||
<ConfirmDeleteDialog onOk={handleDelete}>
|
<ConfirmDeleteDialog onOk={handleDelete}>
|
||||||
<DropdownMenuItem
|
<DropdownMenuItem
|
||||||
className="text-text-delete-red"
|
className="text-text-delete-red"
|
||||||
|
|||||||
Reference in New Issue
Block a user