mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
### What problem does this PR solve? feat: Test the database connection of the ExeSQL operator #1739 ### Type of change - [x] New Feature (non-breaking change which adds functionality)
This commit is contained in:
@ -30,7 +30,7 @@ export default defineConfig({
|
|||||||
copy: ['src/conf.json'],
|
copy: ['src/conf.json'],
|
||||||
proxy: {
|
proxy: {
|
||||||
'/v1': {
|
'/v1': {
|
||||||
target: 'http://123.60.95.134:9380/',
|
target: 'http://localhost:9380/',
|
||||||
changeOrigin: true,
|
changeOrigin: true,
|
||||||
ws: true,
|
ws: true,
|
||||||
logger: console,
|
logger: console,
|
||||||
|
|||||||
@ -191,3 +191,24 @@ export const useResetFlow = () => {
|
|||||||
|
|
||||||
return { data, loading, resetFlow: mutateAsync };
|
return { data, loading, resetFlow: mutateAsync };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const useTestDbConnect = () => {
|
||||||
|
const {
|
||||||
|
data,
|
||||||
|
isPending: loading,
|
||||||
|
mutateAsync,
|
||||||
|
} = useMutation({
|
||||||
|
mutationKey: ['testDbConnect'],
|
||||||
|
mutationFn: async (params: any) => {
|
||||||
|
const ret = await flowService.testDbConnect(params);
|
||||||
|
if (ret?.retcode === 0) {
|
||||||
|
message.success(ret?.data?.data);
|
||||||
|
} else {
|
||||||
|
message.error(ret?.data?.data);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return { data, loading, testDbConnect: mutateAsync };
|
||||||
|
};
|
||||||
|
|||||||
@ -1,11 +1,19 @@
|
|||||||
import TopNItem from '@/components/top-n-item';
|
import TopNItem from '@/components/top-n-item';
|
||||||
import { useTranslate } from '@/hooks/common-hooks';
|
import { useTranslate } from '@/hooks/common-hooks';
|
||||||
import { Form, Input, InputNumber, Select } from 'antd';
|
import { useTestDbConnect } from '@/hooks/flow-hooks';
|
||||||
|
import { Button, Flex, Form, Input, InputNumber, Select } from 'antd';
|
||||||
|
import { useCallback } from 'react';
|
||||||
import { ExeSQLOptions } from '../constant';
|
import { ExeSQLOptions } from '../constant';
|
||||||
import { IOperatorForm } from '../interface';
|
import { IOperatorForm } from '../interface';
|
||||||
|
|
||||||
const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => {
|
const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => {
|
||||||
const { t } = useTranslate('flow');
|
const { t } = useTranslate('flow');
|
||||||
|
const { testDbConnect, loading } = useTestDbConnect();
|
||||||
|
|
||||||
|
const handleTest = useCallback(async () => {
|
||||||
|
const ret = await form?.validateFields();
|
||||||
|
testDbConnect(ret);
|
||||||
|
}, [form, testDbConnect]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Form
|
<Form
|
||||||
@ -59,6 +67,11 @@ const ExeSQLForm = ({ onValuesChange, form }: IOperatorForm) => {
|
|||||||
<InputNumber></InputNumber>
|
<InputNumber></InputNumber>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<TopNItem initialValue={30} max={1000}></TopNItem>
|
<TopNItem initialValue={30} max={1000}></TopNItem>
|
||||||
|
<Flex justify={'end'}>
|
||||||
|
<Button type={'primary'} loading={loading} onClick={handleTest}>
|
||||||
|
Test
|
||||||
|
</Button>
|
||||||
|
</Flex>
|
||||||
</Form>
|
</Form>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -10,6 +10,7 @@ const {
|
|||||||
removeCanvas,
|
removeCanvas,
|
||||||
runCanvas,
|
runCanvas,
|
||||||
listTemplates,
|
listTemplates,
|
||||||
|
testDbConnect,
|
||||||
} = api;
|
} = api;
|
||||||
|
|
||||||
const methods = {
|
const methods = {
|
||||||
@ -41,6 +42,10 @@ const methods = {
|
|||||||
url: listTemplates,
|
url: listTemplates,
|
||||||
method: 'get',
|
method: 'get',
|
||||||
},
|
},
|
||||||
|
testDbConnect: {
|
||||||
|
url: testDbConnect,
|
||||||
|
method: 'post',
|
||||||
|
},
|
||||||
} as const;
|
} as const;
|
||||||
|
|
||||||
const chatService = registerServer<keyof typeof methods>(methods, request);
|
const chatService = registerServer<keyof typeof methods>(methods, request);
|
||||||
|
|||||||
@ -94,4 +94,5 @@ export default {
|
|||||||
setCanvas: `${api_host}/canvas/set`,
|
setCanvas: `${api_host}/canvas/set`,
|
||||||
resetCanvas: `${api_host}/canvas/reset`,
|
resetCanvas: `${api_host}/canvas/reset`,
|
||||||
runCanvas: `${api_host}/canvas/completion`,
|
runCanvas: `${api_host}/canvas/completion`,
|
||||||
|
testDbConnect: `${api_host}/canvas/test_db_connect`,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user