Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
szse
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhaochengxiang
szse
Commits
8a40fb16
Commit
8a40fb16
authored
Jun 13, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
采集
parent
163bd31f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
336 additions
and
81 deletions
+336
-81
datasource.js
src/model/datasource.js
+8
-0
datasourcemanager.js
src/service/datasourcemanager.js
+10
-2
ScheduleAction.jsx
...view/Manage/DatasourceManage/Component/ScheduleAction.jsx
+0
-2
ColConfig.jsx
src/view/Manage/MetadataHarvester/Component/ColConfig.jsx
+153
-0
Task.jsx
src/view/Manage/MetadataHarvester/Component/Task.jsx
+86
-7
UpdateTask.jsx
src/view/Manage/MetadataHarvester/Component/UpdateTask.jsx
+79
-70
No files found.
src/model/datasource.js
View file @
8a40fb16
...
...
@@ -84,6 +84,14 @@ export function* getTaskTracerByStateId(payload) {
return
yield
call
(
service
.
getTaskTracerByStateId
,
payload
);
}
export
function
*
setTaskCols
(
payload
)
{
return
yield
call
(
service
.
setTaskCols
,
payload
);
}
export
function
*
getTaskCols
(
payload
)
{
return
yield
call
(
service
.
getTaskCols
,
payload
);
}
export
function
*
deleteSchedule
(
payload
)
{
return
yield
call
(
service
.
deleteSchedule
,
payload
);
}
...
...
src/service/datasourcemanager.js
View file @
8a40fb16
...
...
@@ -80,6 +80,14 @@ export function getTaskTracerByStateId(payload) {
return
GetJSON
(
"/metadataharvester/task/getTaskTracerByStateId"
,
payload
);
}
export
function
setTaskCols
(
payload
)
{
return
PostJSON
(
"/metadataharvester/task/setDisplayTitle"
,
payload
);
}
export
function
getTaskCols
(
payload
)
{
return
GetJSON
(
"/metadataharvester/task/getDisplayTitle"
,
payload
);
}
export
function
deleteSchedule
(
payload
)
{
return
Delete
(
"/metadataharvester/schedule/deleteSchedule"
,
payload
);
}
...
...
@@ -110,5 +118,4 @@ export function getEtlSystemMappingList(payload) {
export
function
updateEtlSystemMapping
(
payload
)
{
return
PostJSON
(
"/metadataharvester/etlSystemMapping/update"
,
payload
);
}
}
\ No newline at end of file
src/view/Manage/DatasourceManage/Component/ScheduleAction.jsx
View file @
8a40fb16
...
...
@@ -11,8 +11,6 @@ const ScheduleAction = (props) => {
useEffect
(()
=>
{
reset
();
console
.
log
(
'action'
,
action
);
console
.
log
(
'tid'
,
tid
);
if
(
action
===
'add'
&&
tid
)
{
getScheduleForm
();
}
else
if
(
action
===
'edit'
&&
id
)
{
...
...
src/view/Manage/MetadataHarvester/Component/ColConfig.jsx
0 → 100644
View file @
8a40fb16
import
{
useState
,
useEffect
}
from
'react'
;
import
{
Modal
,
Button
,
Switch
,
Row
,
Col
,
Checkbox
,
Typography
}
from
'antd'
;
import
{
dispatch
}
from
'../../../../model'
;
const
cols
=
[
{
title
:
'任务编号'
},
{
title
:
'类型'
},
{
title
:
'数据库中文名'
},
{
title
:
'数据库英文名'
},
{
title
:
'抽取Schema'
},
{
title
:
'表白名单'
},
{
title
:
'表黑名单'
},
];
const
menuName
=
'taskColConfig'
;
const
FC
=
(
props
)
=>
{
const
{
visible
,
onCancel
}
=
props
;
const
[
checkedKeys
,
setCheckedKeys
]
=
useState
([]);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
useEffect
(()
=>
{
if
(
visible
)
{
getTaskCols
();
}
},
[
visible
]);
const
getTaskCols
=
()
=>
{
dispatch
({
type
:
'datasource.getTaskCols'
,
payload
:
{
menuName
},
callback
:
data
=>
{
// if ((data.cols||'') === '') {
// onCheckAllChange(true);
// } else {
// setCheckedKeys(data.cols.split(','));
// }
}
})
}
const
onCheckAllChange
=
(
checked
)
=>
{
const
newCheckedKeys
=
[];
if
(
checked
)
{
cols
.
forEach
(
col
=>
{
newCheckedKeys
.
push
(
col
.
title
);
});
}
else
{
cols
.
forEach
(
col
=>
{
if
(
col
.
require
)
{
newCheckedKeys
.
push
(
col
.
title
);
}
});
}
setCheckedKeys
(
newCheckedKeys
);
}
const
onCheckChange
=
(
e
)
=>
{
if
(
e
.
target
.
checked
)
{
setCheckedKeys
([...
checkedKeys
,
e
.
target
.
value
]);
}
else
{
const
index
=
checkedKeys
.
findIndex
(
key
=>
key
===
e
.
target
.
value
);
const
newCheckedKeys
=
[...
checkedKeys
];
newCheckedKeys
.
splice
(
index
,
1
)
setCheckedKeys
(
newCheckedKeys
);
}
}
const
onModalCancel
=
()
=>
{
onCancel
&&
onCancel
();
}
const
onModalOk
=
()
=>
{
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.setTaskCols'
,
payload
:
{
params
:
{
menuName
,
titles
:
checkedKeys
.
join
(
','
)
}
},
callback
:
()
=>
{
setConfirmLoading
(
false
);
onCancel
?.(
true
);
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
}
return
(
<
Modal
title=
'可见列设置'
visible=
{
visible
}
onCancel=
{
onModalCancel
}
footer=
{
[
<
Button
key=
"0"
onClick=
{
onModalCancel
}
>
取消
</
Button
>,
<
Button
key=
"1"
type=
"primary"
onClick=
{
onModalOk
}
loading=
{
confirmLoading
}
>
确定
</
Button
>,
]
}
>
<
div
className=
'd-flex'
>
<
Switch
checkedChildren=
"全不选"
unCheckedChildren=
"全选"
onChange=
{
onCheckAllChange
}
style=
{
{
marginLeft
:
'auto'
}
}
/>
</
div
>
<
div
className=
'mt-3'
style=
{
{
maxHeight
:
450
,
overflow
:
'auto'
}
}
>
<
Row
>
{
cols
.
map
((
col
,
index
)
=>
{
return
(
<
Col
className=
'mb-3'
key=
{
index
}
md=
{
6
}
>
<
div
className=
'd-flex'
>
<
Checkbox
checked=
{
checkedKeys
.
indexOf
(
col
.
title
||
''
)
!==-
1
}
value=
{
col
.
title
}
onChange=
{
onCheckChange
}
disabled=
{
col
.
require
}
>
</
Checkbox
>
<
Typography
.
Paragraph
className=
'ml-1'
title=
{
col
.
title
}
ellipsis
>
{
col
.
title
}
</
Typography
.
Paragraph
>
</
div
>
</
Col
>
)
})
}
</
Row
>
</
div
>
</
Modal
>
)
}
export
default
FC
;
\ No newline at end of file
src/view/Manage/MetadataHarvester/Component/Task.jsx
View file @
8a40fb16
...
...
@@ -6,6 +6,7 @@ import { dispatch } from '../../../../model';
import
{
paginate
}
from
'../../../../util'
;
import
Table
from
'../../ResizeableTable'
;
import
UpdateTask
from
'./UpdateTask'
;
import
ColConfig
from
'./ColConfig'
;
import
env
from
'../../../../service/samples/env.json'
;
const
FC
=
(
props
)
=>
{
...
...
@@ -13,11 +14,18 @@ const FC = (props) => {
const
[
loadingTasks
,
setLoadingTasks
]
=
useState
(
false
);
const
[
tasks
,
setTasks
]
=
useState
(
undefined
);
const
[
pagination
,
setPagination
]
=
useState
({
pageNum
:
1
,
pageSize
:
20
});
const
[
configState
,
setConfigState
]
=
useState
(
undefined
);
const
[
supportedTargetTypes
,
setSupportedTargetTypes
]
=
useState
([]);
const
[
sortedInfo
,
setSortedInfo
]
=
useState
({});
const
[
updateTaskParam
,
setUpdateTaskParam
]
=
useState
({
visible
:
false
,
action
:
undefined
,
id
:
undefined
});
const
[
colConfigParam
,
setColConfigParam
]
=
useState
({
visible
:
false
,
});
const
{
pageNum
,
pageSize
}
=
pagination
;
...
...
@@ -36,19 +44,23 @@ const FC = (props) => {
},
{
title
:
'类型'
,
dataIndex
:
'type'
,
dataIndex
:
'typeName'
,
sorter
:
true
,
},
{
title
:
'数据库中文名'
,
dataIndex
:
'cnName'
,
sorter
:
true
,
},
{
title
:
'数据库英文名'
,
dataIndex
:
'name'
,
sorter
:
true
,
},
{
title
:
'抽取Schema'
,
dataIndex
:
'schema'
,
sorter
:
true
,
},
{
title
:
'表白名单'
,
...
...
@@ -85,6 +97,52 @@ const FC = (props) => {
getAllTasks
();
},
[])
const
_tasks
=
useMemo
(()
=>
{
if
(
tasks
)
{
let
newTasks
=
tasks
?.
filter
(
item
=>
{
return
(
configState
.
scope
===
undefined
||
item
.
target
?.
scope
===
configState
.
scope
?.
toString
())
&&
(
configState
.
datasourceId
===
undefined
||
item
.
target
?.
id
===
configState
.
datasourceId
)
&&
(
configState
.
targetType
===
undefined
||
item
.
target
?.
type
===
configState
.
targetType
)
});
newTasks
?.
forEach
(
item
=>
{
const
index
=
(
supportedTargetTypes
||
[]).
findIndex
(
_item
=>
_item
.
targetType
===
item
.
type
);
if
(
index
!==
-
1
)
{
item
.
typeName
=
supportedTargetTypes
[
index
].
targetName
;
}
});
if
(
sortedInfo
.
field
&&
sortedInfo
.
order
)
{
newTasks
?.
sort
((
item1
,
item2
)
=>
{
if
(
sortedInfo
.
order
===
'ascend'
)
{
return
item1
[
sortedInfo
.
field
]?.
localeCompare
(
item2
[
sortedInfo
.
field
]);
}
else
if
(
sortedInfo
.
order
===
'descend'
)
{
return
item2
[
sortedInfo
.
field
]?.
localeCompare
(
item1
[
sortedInfo
.
field
]);
}
})
}
newTasks
=
paginate
(
newTasks
,
pagination
.
pageNum
,
pagination
.
pageSize
);
return
newTasks
;
}
return
[]
},
[
tasks
,
pagination
,
configState
,
supportedTargetTypes
,
sortedInfo
])
const
total
=
useMemo
(()
=>
{
if
(
tasks
)
{
const
newTasks
=
tasks
?.
filter
(
item
=>
{
return
(
configState
.
scope
===
undefined
||
item
.
target
?.
scope
===
configState
.
scope
?.
toString
())
&&
(
configState
.
datasourceId
===
undefined
||
item
.
target
?.
id
===
configState
.
datasourceId
)
&&
(
configState
.
targetType
===
undefined
||
item
.
target
?.
type
===
configState
.
targetType
)
});
return
(
newTasks
||
[]).
length
;
}
return
0
;
},
[
tasks
,
pagination
,
configState
])
const
getAllTasks
=
()
=>
{
setLoadingTasks
(
true
);
dispatch
({
...
...
@@ -121,6 +179,11 @@ const FC = (props) => {
})
}
const
onTableChange
=
(
pagination
,
filters
,
sorter
)
=>
{
console
.
log
(
'sorter'
,
sorter
);
setSortedInfo
(
sorter
);
}
const
onPaginationChange
=
(
page
,
size
)
=>
{
setPagination
({
pageNum
:
page
,
pageSize
:
size
});
}
...
...
@@ -129,6 +192,10 @@ const FC = (props) => {
setUpdateTaskParam
({
visible
:
false
,
action
:
undefined
,
id
:
undefined
});
refresh
&&
getAllTasks
();
}
const
onColConfigCancel
=
(
refresh
=
false
)
=>
{
setColConfigParam
({
visible
:
false
});
}
return
(
<
div
>
...
...
@@ -137,11 +204,15 @@ const FC = (props) => {
<
Button
onClick=
{
()
=>
{
setUpdateTaskParam
({
visible
:
true
,
action
:
'add'
,
id
:
undefined
});
}
}
>
新增任务
</
Button
>
<
Button
>
可见列设置
</
Button
>
<
Button
onClick=
{
()
=>
{
setColConfigParam
({
visible
:
true
});
}
}
>
可见列设置
</
Button
>
<
Button
>
删除
</
Button
>
</
Space
>
<
Config
onState=
{
(
state
)
=>
{
<
Config
setTargetTypes=
{
setSupportedTargetTypes
}
onState=
{
(
state
)
=>
{
console
.
log
(
'state'
,
state
);
setConfigState
(
state
);
setPagination
({...
pagination
,
pageNum
:
1
});
}
}
/>
</
div
>
<
Table
...
...
@@ -149,8 +220,9 @@ const FC = (props) => {
loading=
{
loadingTasks
}
columns=
{
columns
||
[]
}
rowKey=
'id'
dataSource=
{
tasks
||
[]
}
dataSource=
{
_
tasks
||
[]
}
pagination=
{
false
}
onChange=
{
onTableChange
}
sticky
/>
<
Pagination
...
...
@@ -163,8 +235,8 @@ const FC = (props) => {
current=
{
pageNum
}
pageSize=
{
pageSize
}
defaultCurrent=
{
1
}
total=
{
(
tasks
||
[]).
length
}
showTotal=
{
total
=>
`共 ${
(tasks||[]).length
} 条`
}
total=
{
total
}
showTotal=
{
total
=>
`共 ${
total
} 条`
}
/>
<
UpdateTask
...
...
@@ -173,6 +245,12 @@ const FC = (props) => {
id=
{
updateTaskParam
.
id
}
onCancel=
{
onUpdateTaskCancel
}
/>
<
ColConfig
visible=
{
colConfigParam
.
visible
}
onCancel=
{
onColConfigCancel
}
/>
</
div
>
)
}
...
...
@@ -198,7 +276,7 @@ export const reducer = (prevState, action) => {
return
prevState
}
export
function
Config
({
onState
,
autoSelect
})
{
export
function
Config
({
onState
,
autoSelect
,
setTargetTypes
})
{
// const { env } = useContext(AppContext);
const
[
treeData
,
setTreeData
]
=
useState
([]);
const
[
treeExpandKeys
,
setTreeExpandKeys
]
=
useState
([]);
...
...
@@ -270,6 +348,7 @@ export function Config({ onState, autoSelect }) {
callback
:
data
=>
{
setLoadingSupportedTargetTypes
(
false
);
setSupportedTargetTypes
(
data
||
[]);
setTargetTypes
?.(
data
||
[]);
},
error
:
()
=>
{
setLoadingSupportedTargetTypes
(
false
);
...
...
src/view/Manage/MetadataHarvester/Component/UpdateTask.jsx
View file @
8a40fb16
...
...
@@ -23,6 +23,7 @@ const FC = (props) => {
id
:
undefined
,
tid
:
undefined
});
const
[
editSchedule
,
setEditSchedule
]
=
useState
(
undefined
);
const
[
form
]
=
Form
.
useForm
();
const
[
scheduleForm
]
=
Form
.
useForm
();
...
...
@@ -65,7 +66,6 @@ const FC = (props) => {
callback
:
data
=>
{
setLoading
(
false
);
setCurrentTask
(
data
);
getSchedules
();
getTaskSettings
(
data
?.
target
?.
id
);
},
error
:
()
=>
{
...
...
@@ -116,73 +116,88 @@ 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
);
const
getSchedules
=
(
tid
)
=>
{
setLoading
(
true
);
dispatch
({
type
:
'datasource.getScheduleListByTaskId'
,
payload
:
{
params
:
{
targetConfId
:
tid
}
})
return
prevTask
;
},
callback
:
data
=>
{
setStep
(
2
);
if
((
data
?.
datas
||
[]).
length
===
0
)
{
setScheduleParam
({
action
:
'add'
,
tid
});
}
else
{
setScheduleParam
({
action
:
'edit'
,
id
:
data
?.
datas
[
0
].
id
});
}
setLoading
(
false
);
},
error
:
()
=>
{
setLoading
(
false
);
}
})
}
const
onOk
=
async
()
=>
{
try
{
const
row
=
await
form
.
validateFields
();
//深拷贝
let
newTask
=
JSON
.
parse
(
JSON
.
stringify
(
taskSettings
));
if
(
action
===
'edit'
)
{
newTask
=
{...
newTask
,
...
currentTask
};
}
newTask
?.
targetConfParameters
?.
forEach
(
item
=>
{
if
(
item
.
name
===
'schema'
)
{
item
.
value
=
selectedSchemas
.
join
(
','
);
}
else
{
item
.
value
=
row
[
item
.
name
]
||
''
;
if
(
step
===
1
)
{
const
row
=
await
form
.
validateFields
();
//深拷贝
let
newTask
=
JSON
.
parse
(
JSON
.
stringify
(
taskSettings
));
if
(
action
===
'edit'
)
{
newTask
=
{...
newTask
,
...
currentTask
};
}
});
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.saveTask'
,
payload
:
{
data
:
newTask
},
callback
:
data
=>
{
setConfirmLoading
(
false
);
if
(
action
===
'add'
)
{
setCurrentTask
({
id
:
data
});
setStep
(
2
);
setScheduleParam
({
action
,
tid
:
data
});
newTask
?.
targetConfParameters
?.
forEach
(
item
=>
{
if
(
item
.
name
===
'schema'
)
{
item
.
value
=
selectedSchemas
.
join
(
','
);
}
else
{
item
.
value
=
row
[
item
.
name
]
||
''
;
}
// reset();
// onCancel && onCancel(true);
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
});
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.saveTask'
,
payload
:
{
data
:
newTask
},
callback
:
data
=>
{
setConfirmLoading
(
false
);
if
(
action
===
'add'
)
{
setStep
(
2
);
setScheduleParam
({
action
,
tid
:
data
});
}
else
{
getSchedules
(
data
);
}
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
}
else
{
await
scheduleForm
.
validateFields
();
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.saveAndStartSchedule'
,
payload
:
{
data
:
editSchedule
},
callback
:
()
=>
{
setConfirmLoading
(
false
);
reset
();
onCancel
?.();
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
}
}
catch
(
errInfo
)
{
console
.
log
(
'Validate Failed:'
,
errInfo
);
}
...
...
@@ -226,6 +241,10 @@ const FC = (props) => {
}
}
const
onScheduleChange
=
(
data
)
=>
{
setEditSchedule
(
data
);
}
const
formItemLayout
=
{
labelCol
:
{
xs
:
{
span
:
24
},
...
...
@@ -318,17 +337,6 @@ const FC = (props) => {
}
</
Form
>
</
Spin
>
{
action
===
'edit'
&&
<
React
.
Fragment
>
<
Divider
>
定时调度
</
Divider
>
<
ScheduleAction
action=
{
scheduleParam
.
action
}
id=
{
scheduleParam
.
id
}
form=
{
scheduleForm
}
tid=
{
scheduleParam
.
tid
}
/>
</
React
.
Fragment
>
}
</
React
.
Fragment
>
}
{
...
...
@@ -339,6 +347,7 @@ const FC = (props) => {
id=
{
scheduleParam
.
id
}
form=
{
scheduleForm
}
tid=
{
scheduleParam
.
tid
}
onChange=
{
onScheduleChange
}
/>
</
React
.
Fragment
>
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment