Commit 163bd31f by zhaochengxiang

采集

parent 34a4c1ca
...@@ -11,13 +11,15 @@ const ScheduleAction = (props) => { ...@@ -11,13 +11,15 @@ const ScheduleAction = (props) => {
useEffect(() => { useEffect(() => {
reset(); reset();
console.log('action', action);
console.log('tid', tid);
if (action === 'add' && tid) { if (action === 'add' && tid) {
getScheduleForm(); getScheduleForm();
} else { } else if (action === 'edit' && id) {
getScheduleById(); getScheduleById();
} }
//eslint-disable-next-line react-hooks/exhaustive-deps //eslint-disable-next-line react-hooks/exhaustive-deps
}, [ action, id]) }, [action, tid, id])
const getScheduleForm = () => { const getScheduleForm = () => {
dispatch({ dispatch({
......
import React, { useState, useEffect, useContext, useMemo, useReducer } from 'react'; import React, { useState, useEffect, useContext, useMemo, useReducer } from 'react';
import { Space, Button, TreeSelect, Select, Pagination } from 'antd'; import { Space, Button, TreeSelect, Select, Pagination, Typography } from 'antd';
import { AppContext } from '../../../../App'; import { AppContext } from '../../../../App';
import { dispatch } from '../../../../model'; import { dispatch } from '../../../../model';
...@@ -58,6 +58,27 @@ const FC = (props) => { ...@@ -58,6 +58,27 @@ const FC = (props) => {
title: '表黑名单', title: '表黑名单',
dataIndex: 'tableBlackList', dataIndex: 'tableBlackList',
}, },
{
title: '操作',
dataIndex: 'action',
width: 120,
fixed: 'right',
render: (_, record) => {
return (
<Space>
<a onClick={() =>{}}>执行</a>
<a onClick={() => {
setUpdateTaskParam({ visible: true, action: 'edit', id: record.id });
}}>
修改
</a>
<a onClick={() => {}}>
删除
</a>
</Space>
)
}
}
] ]
useEffect(() => { useEffect(() => {
...@@ -177,7 +198,7 @@ export const reducer = (prevState, action) => { ...@@ -177,7 +198,7 @@ export const reducer = (prevState, action) => {
return prevState return prevState
} }
export function Config({ onState }) { export function Config({ onState, autoSelect }) {
// const { env } = useContext(AppContext); // const { env } = useContext(AppContext);
const [treeData, setTreeData] = useState([]); const [treeData, setTreeData] = useState([]);
const [treeExpandKeys, setTreeExpandKeys] = useState([]); const [treeExpandKeys, setTreeExpandKeys] = useState([]);
...@@ -225,6 +246,12 @@ export function Config({ onState }) { ...@@ -225,6 +246,12 @@ export function Config({ onState }) {
}, [scope]) }, [scope])
useEffect(() => { useEffect(() => {
if (autoSelect && (datasources||[]).length > 0) {
dispatchState({type: 'selectDatasource', payload: [datasources[0].id]});
}
}, [autoSelect, datasources])
useEffect(() => {
dispatchState({type: 'selectDatasource', payload: [undefined]}) dispatchState({type: 'selectDatasource', payload: [undefined]})
}, [scope, targetType]) }, [scope, targetType])
......
import React, { useEffect, useState } from 'react'; import React, { useEffect, useMemo, useState } from 'react';
import { Modal, Checkbox, Row, Col, Divider, Input, Typography, Form, Switch } from 'antd'; import { Modal, Checkbox, Row, Col, Divider, Input, Typography, Form, Switch, Spin } from 'antd';
import { Config } from './Task'; import { Config } from './Task';
import ScheduleAction from '../../DatasourceManage/Component/ScheduleAction'; import ScheduleAction from '../../DatasourceManage/Component/ScheduleAction';
...@@ -13,10 +13,16 @@ const FC = (props) => { ...@@ -13,10 +13,16 @@ const FC = (props) => {
const [taskSettings, setTaskSettings] = useState({}); const [taskSettings, setTaskSettings] = useState({});
const [currentTask, setCurrentTask] = useState({}); const [currentTask, setCurrentTask] = useState({});
const [keyword, setKeyword] = useState(''); const [keyword, setKeyword] = useState('');
const [loading, setLoading] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false); const [confirmLoading, setConfirmLoading] = useState(false);
const [checkAllValue, setCheckAllValue] = useState(false); const [checkAllValue, setCheckAllValue] = useState(false);
const [configState, setConfigState] = useState(undefined); const [configState, setConfigState] = useState(undefined);
const [step, setStep] = useState(1); const [step, setStep] = useState(1);
const [scheduleParam, setScheduleParam] = useState({
action: undefined,
id: undefined,
tid: undefined
});
const [ form ] = Form.useForm(); const [ form ] = Form.useForm();
const [ scheduleForm ] = Form.useForm(); const [ scheduleForm ] = Form.useForm();
...@@ -39,27 +45,45 @@ const FC = (props) => { ...@@ -39,27 +45,45 @@ const FC = (props) => {
setFilterSchemas((schemas||[]).filter(schema => (schema||'').indexOf(keyword)!==-1)); setFilterSchemas((schemas||[]).filter(schema => (schema||'').indexOf(keyword)!==-1));
}, [keyword, schemas]) }, [keyword, schemas])
const isNeo4jTarget = useMemo(() => {
if (action === 'add' && configState?.targetType==='Neo4jTarget') {
return true;
} else if (action === 'edit' && currentTask?.target?.type === 'Neo4jTarget') {
return true;
}
return false;
}, [action, currentTask, configState])
const getTask = () => { const getTask = () => {
setLoading(true);
dispatch({ dispatch({
type: 'datasource.getTask', type: 'datasource.getTask',
payload: { payload: {
harvestingTaskId: id harvestingTaskId: id
}, },
callback: data => { callback: data => {
setLoading(false);
setCurrentTask(data); setCurrentTask(data);
getSchedules();
getTaskSettings(data?.target?.id); getTaskSettings(data?.target?.id);
},
error: () => {
setLoading(false);
} }
}) })
} }
const getTaskSettings = (id) => { const getTaskSettings = (id) => {
setCurrentTask((prevTask) => { setCurrentTask((prevTask) => {
setLoading(true);
dispatch({ dispatch({
type: 'datasource.getTaskSettingsByDatasource', type: 'datasource.getTaskSettingsByDatasource',
payload: { payload: {
datasourceId: id datasourceId: id
}, },
callback: data => { callback: data => {
setLoading(false);
setTaskSettings(data); setTaskSettings(data);
let recentSchemas = []; let recentSchemas = [];
...@@ -82,6 +106,9 @@ const FC = (props) => { ...@@ -82,6 +106,9 @@ const FC = (props) => {
form.setFieldsValue(_fieldsValue); form.setFieldsValue(_fieldsValue);
} }
},
error: () => {
setLoading(false);
} }
}); });
...@@ -89,6 +116,34 @@ const FC = (props) => { ...@@ -89,6 +116,34 @@ const FC = (props) => {
}); });
} }
const getSchedules = () => {
setCurrentTask(prevTask => {
setLoading(true);
dispatch({
type: 'datasource.getScheduleListByTaskId',
payload: {
params: {
targetConfId: prevTask.id
}
},
callback: data => {
if ((data?.datas||[]).length === 0) {
setScheduleParam({action: 'add', tid: prevTask.id});
} else {
setScheduleParam({action: 'edit', id: data?.datas[0].id});
}
setLoading(false);
},
error: () => {
setLoading(false);
}
})
return prevTask;
})
}
const onOk = async() => { const onOk = async() => {
try { try {
const row = await form.validateFields(); const row = await form.validateFields();
...@@ -118,6 +173,7 @@ const FC = (props) => { ...@@ -118,6 +173,7 @@ const FC = (props) => {
if (action === 'add') { if (action === 'add') {
setCurrentTask({id: data}); setCurrentTask({id: data});
setStep(2); setStep(2);
setScheduleParam({action, tid: data});
} }
// reset(); // reset();
// onCancel && onCancel(true); // onCancel && onCancel(true);
...@@ -197,76 +253,92 @@ const FC = (props) => { ...@@ -197,76 +253,92 @@ const FC = (props) => {
> >
{ {
step === 1 && <React.Fragment> step === 1 && <React.Fragment>
<Config onState={(state) => { {
setConfigState(state); (action === 'add') && <div className='flex' style={{ justifyContent: 'end' }}>
}} /> <Config autoSelect onState={(state) => {
<Divider>{(configState?.targetType==="Neo4jTarget")?'neo4j数据库信息':'schema信息'}</Divider> setConfigState(state);
<div className='d-flex mb-3' style={{ alignItems: 'center' }}> }} />
<span className='mr-3'>{(configState?.targetType==="Neo4jTarget")?'neo4j数据库搜索':'schema搜索'}:</span> </div>
<Input }
placeholder={`请输入${(configState?.targetType==="Neo4jTarget")?'neo4j数据库':'schema'}名称`} <Spin spinning={loading}>
allowClear <Divider>{isNeo4jTarget?'neo4j数据库信息':'schema信息'}</Divider>
value={keyword} <div className='d-flex mb-3' style={{ alignItems: 'center' }}>
onChange={onSearchInputChange} <span className='mr-3'>{isNeo4jTarget?'neo4j数据库搜索':'schema搜索'}:</span>
style={{ width: 230 }} <Input
/> placeholder={`请输入${isNeo4jTarget?'neo4j数据库':'schema'}名称`}
<Switch allowClear
checkedChildren="全不选" value={keyword}
unCheckedChildren="全选" onChange={onSearchInputChange}
checked={ checkAllValue } style={{ width: 230 }}
onChange={ onCheckAll } />
style={{ marginLeft: 'auto' }} <Switch
/> checkedChildren="全不选"
</div> unCheckedChildren="全选"
<div style={{ maxHeight: 300, overflow: 'auto' }}> checked={ checkAllValue }
<Row className='mb-3'> onChange={ onCheckAll }
style={{ marginLeft: 'auto' }}
/>
</div>
<div style={{ maxHeight: 300, overflow: 'auto' }}>
<Row className='mb-3'>
{
(filterSchemas||[]).map((schema, index) => {
return (
<Col className='mt-1' key={index} md={8}>
<div className='d-flex'>
<Checkbox checked={ selectedSchemas.indexOf(schema)!==-1 } value={schema||''} onChange={onCheckChange} >
</Checkbox>
<Typography.Paragraph className='ml-1' title={schema||''} ellipsis>
{schema||''}
</Typography.Paragraph>
</div>
</Col>
);
})
}
</Row>
</div>
<Divider>过滤信息</Divider>
<Form {...formItemLayout} form={form}>
{ {
(filterSchemas||[]).map((schema, index) => { taskSettings && (taskSettings.targetConfParameters||[]).filter(item => item.name!=='schema').map((param, index) => {
return ( return (
<Col className='mt-1' key={index} md={8}> <Form.Item
<div className='d-flex'> label={param.cnName||''}
<Checkbox checked={ selectedSchemas.indexOf(schema)!==-1 } value={schema||''} onChange={onCheckChange} > name={param.name||''}
</Checkbox> key={index}
<Typography.Paragraph className='ml-1' title={schema||''} ellipsis> rules={[{ required: param.required, message: '必填项'}]}
{schema||''} >
</Typography.Paragraph> {
</div> ( param.show ? <Input placeholder={param.explain||''} /> : <Input.Password placeholder={param.explain||''} visibilityToggle={false} /> )
</Col> }
); </Form.Item>
)
}) })
} }
</Row> </Form>
</div> </Spin>
<Divider>过滤信息</Divider>
<Form {...formItemLayout} form={form}>
{ {
taskSettings && (taskSettings.targetConfParameters||[]).filter(item => item.name!=='schema').map((param, index) => { action === 'edit' && <React.Fragment>
return ( <Divider>定时调度</Divider>
<Form.Item <ScheduleAction
label={param.cnName||''} action={scheduleParam.action}
name={param.name||''} id={scheduleParam.id}
key={index} form={scheduleForm}
rules={[{ required: param.required, message: '必填项'}]} tid={scheduleParam.tid}
> />
{ </React.Fragment>
( param.show ? <Input placeholder={param.explain||''} /> : <Input.Password placeholder={param.explain||''} visibilityToggle={false} /> )
}
</Form.Item>
)
})
} }
</Form>
</React.Fragment> </React.Fragment>
} }
{ {
step === 2 && <React.Fragment> step === 2 && <React.Fragment>
<Divider>定时调度</Divider> <Divider>定时调度</Divider>
<ScheduleAction <ScheduleAction
action={action} action={scheduleParam.action}
// id={currentSchedule.id} id={scheduleParam.id}
form={scheduleForm} form={scheduleForm}
tid={currentTask.id} tid={scheduleParam.tid}
// onChange={onActionChange}
/> />
</React.Fragment> </React.Fragment>
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment