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
bec4a91d
Commit
bec4a91d
authored
Jun 14, 2023
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
采集
parent
25c0900a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
178 additions
and
161 deletions
+178
-161
ScheduleAction.jsx
...view/Manage/DatasourceManage/Component/ScheduleAction.jsx
+10
-7
Task.jsx
src/view/Manage/MetadataHarvester/Component/Task.jsx
+12
-16
TaskReport.jsx
src/view/Manage/MetadataHarvester/Component/TaskReport.jsx
+6
-3
UpdateTask.jsx
src/view/Manage/MetadataHarvester/Component/UpdateTask.jsx
+148
-134
index.less
src/view/Manage/MetadataHarvester/index.less
+2
-1
No files found.
src/view/Manage/DatasourceManage/Component/ScheduleAction.jsx
View file @
bec4a91d
...
...
@@ -4,6 +4,12 @@ import moment from 'moment';
import
{
dispatch
}
from
'../../../../model'
;
function
compare
(
val1
,
val2
)
{
var
a
=
val1
.
seq
;
var
b
=
val2
.
seq
;
return
(
a
-
b
);
}
const
ScheduleAction
=
(
props
)
=>
{
const
{
action
,
id
,
form
,
tid
,
onChange
}
=
props
;
...
...
@@ -11,7 +17,7 @@ const ScheduleAction = (props) => {
useEffect
(()
=>
{
reset
();
if
(
action
===
'add'
&&
tid
)
{
if
(
action
===
'add'
)
{
getScheduleForm
();
}
else
if
(
action
===
'edit'
&&
id
)
{
getScheduleById
();
...
...
@@ -26,6 +32,9 @@ const ScheduleAction = (props) => {
targetConfId
:
tid
},
callback
:
data
=>
{
(
data
?.
targetParameters
||
[]).
sort
(
compare
);
(
data
?.
scheduleParameters
||
[]).
sort
(
compare
);
setSchedule
(
data
||
{});
onChange
&&
onChange
(
data
||
{});
}
...
...
@@ -39,12 +48,6 @@ const ScheduleAction = (props) => {
id
},
callback
:
data
=>
{
function
compare
(
val1
,
val2
)
{
var
a
=
val1
.
seq
;
var
b
=
val2
.
seq
;
return
(
a
-
b
);
}
(
data
?.
targetParameters
||
[]).
sort
(
compare
);
(
data
?.
scheduleParameters
||
[]).
sort
(
compare
);
...
...
src/view/Manage/MetadataHarvester/Component/Task.jsx
View file @
bec4a91d
...
...
@@ -170,7 +170,7 @@ const FC = (props) => {
return
()
=>
{
clearInterval
(
interval
);
}
},
[])
},
[
env
])
const
_columns
=
useMemo
(()
=>
{
if
(
visibleCols
)
{
...
...
@@ -191,6 +191,7 @@ const FC = (props) => {
&&
(
configState
.
datasourceId
===
undefined
||
item
.
target
?.
id
===
configState
.
datasourceId
)
&&
(
configState
.
targetType
===
undefined
||
item
.
target
?.
type
===
configState
.
targetType
)
&&
(
!
keyword
||
(
item
.
taskCode
||
''
).
indexOf
(
keyword
)
!==-
1
||
(
item
.
schema
||
''
).
indexOf
(
keyword
)
!==-
1
)
&&
item
.
target
?.
namespace
===
env
?.
domainId
?.
toString
()
});
newTasks
?.
forEach
(
item
=>
{
const
index
=
(
supportedTargetTypes
||
[]).
findIndex
(
_item
=>
_item
.
targetType
===
item
.
type
);
...
...
@@ -216,7 +217,7 @@ const FC = (props) => {
}
return
[]
},
[
tasks
,
pagination
,
configState
,
supportedTargetTypes
,
sortedInfo
,
keyword
])
},
[
tasks
,
pagination
,
configState
,
supportedTargetTypes
,
sortedInfo
,
keyword
,
env
])
const
total
=
useMemo
(()
=>
{
if
(
tasks
)
{
...
...
@@ -225,13 +226,14 @@ const FC = (props) => {
&&
(
configState
.
datasourceId
===
undefined
||
item
.
target
?.
id
===
configState
.
datasourceId
)
&&
(
configState
.
targetType
===
undefined
||
item
.
target
?.
type
===
configState
.
targetType
)
&&
(
!
keyword
||
item
.
taskCode
?.
indexOf
(
keyword
)
!==-
1
||
item
.
schema
?.
indexOf
(
keyword
)
!==-
1
)
&&
item
.
target
?.
namespace
===
env
?.
domainId
?.
toString
()
});
return
(
newTasks
||
[]).
length
;
}
return
0
;
},
[
tasks
,
pagination
,
configState
,
keyword
])
},
[
tasks
,
pagination
,
configState
,
keyword
,
env
])
const
getAllTasks
=
()
=>
{
setLoadingTasks
(
true
);
...
...
@@ -299,12 +301,9 @@ const FC = (props) => {
setPagination
({
pageNum
:
page
,
pageSize
:
size
});
}
const
onUpdateTaskCancel
=
()
=>
{
const
onUpdateTaskCancel
=
(
refresh
=
false
)
=>
{
setUpdateTaskParam
({
visible
:
false
,
action
:
undefined
,
id
:
undefined
});
}
const
onUpdateTaskChange
=
()
=>
{
getAllTasks
();
refresh
&&
getAllTasks
();
}
const
onColConfigCancel
=
(
refresh
=
false
)
=>
{
...
...
@@ -444,7 +443,7 @@ const FC = (props) => {
dataSource=
{
_tasks
||
[]
}
pagination=
{
false
}
onChange=
{
onTableChange
}
scroll=
{
{
y
:
'calc(100vh - 3
30
px)'
}
}
scroll=
{
{
y
:
'calc(100vh - 3
15
px)'
}
}
sticky
/>
<
Pagination
...
...
@@ -466,7 +465,6 @@ const FC = (props) => {
action=
{
updateTaskParam
.
action
}
id=
{
updateTaskParam
.
id
}
onCancel=
{
onUpdateTaskCancel
}
onChange=
{
onUpdateTaskChange
}
/>
<
ColConfig
...
...
@@ -481,8 +479,6 @@ const FC = (props) => {
export
default
FC
;
export
const
reducer
=
(
prevState
,
action
)
=>
{
const
scope
=
undefined
,
targetType
=
undefined
,
datasourceId
=
undefined
;
if
(
action
.
type
===
'selectScope'
)
{
const
[
scope
]
=
action
.
payload
return
{
...
prevState
,
scope
}
...
...
@@ -493,7 +489,7 @@ export const reducer = (prevState, action) => {
const
[
datasourceId
]
=
action
.
payload
return
{
...
prevState
,
datasourceId
}
}
else
if
(
action
.
type
===
'init'
)
{
return
{
...
prevState
,
scope
,
targetType
,
datasourceI
d
}
return
{
...
prevState
,
scope
:
undefined
,
targetType
:
undefined
,
datasourceId
:
undefine
d
}
}
return
prevState
...
...
@@ -531,10 +527,10 @@ export function Config({ onState, autoSelect, setTargetTypes }) {
setTreeData
(
env
.
children
);
setTreeExpandKeys
(
newExpandKeys
);
dispatchState
(
'init'
);
dispatchState
(
{
type
:
'init'
}
);
}
else
{
setTreeData
([]);
dispatchState
(
'init'
);
dispatchState
(
{
type
:
'init'
}
);
}
},
[
env
])
...
...
@@ -544,7 +540,7 @@ export function Config({ onState, autoSelect, setTargetTypes }) {
useEffect
(()
=>
{
getDatasources
();
},
[
scope
])
},
[
scope
,
env
])
useEffect
(()
=>
{
if
(
autoSelect
&&
(
datasources
||
[]).
length
>
0
)
{
...
...
src/view/Manage/MetadataHarvester/Component/TaskReport.jsx
View file @
bec4a91d
...
...
@@ -79,10 +79,13 @@ const FC = (props) => {
},
[
reportData
])
const
taskCodes
=
useMemo
(()
=>
{
return
tasks
?.
filter
(
item
=>
item
.
taskCode
).
map
(
item
=>
item
.
taskCode
)
},
[
tasks
])
return
tasks
?.
filter
(
item
=>
item
.
ta
rget
?.
namespace
===
env
?.
domainId
?.
toString
()
&&
item
.
ta
skCode
).
map
(
item
=>
item
.
taskCode
)
},
[
tasks
,
env
])
useEffect
(()
=>
{
setTaskCode
(
undefined
);
setDatasourceName
(
undefined
);
setReportState
(
undefined
);
getAllTasks
();
getDatasources
();
},
[
env
])
...
...
@@ -377,7 +380,7 @@ const FC = (props) => {
},
}
}
pagination=
{
false
}
scroll=
{
{
y
:
'calc(100vh - 4
15
px)'
}
}
scroll=
{
{
y
:
'calc(100vh - 4
00
px)'
}
}
sticky
/>
<
Pagination
...
...
src/view/Manage/MetadataHarvester/Component/UpdateTask.jsx
View file @
bec4a91d
import
React
,
{
useEffect
,
useMemo
,
useState
}
from
'react'
;
import
{
Modal
,
Checkbox
,
Row
,
Col
,
Divider
,
Input
,
Typography
,
Form
,
Switch
,
Spin
}
from
'antd'
;
import
{
Modal
,
Checkbox
,
Row
,
Col
,
Divider
,
Input
,
Typography
,
Form
,
Switch
,
Spin
,
Space
}
from
'antd'
;
import
{
Config
}
from
'./Task'
;
import
ScheduleAction
from
'../../DatasourceManage/Component/ScheduleAction'
;
import
{
dispatch
}
from
'../../../../model'
;
const
FC
=
(
props
)
=>
{
const
{
visible
,
onCancel
,
onChange
,
action
,
id
}
=
props
;
const
{
visible
,
onCancel
,
action
,
id
}
=
props
;
const
[
schemas
,
setSchemas
]
=
useState
([]);
const
[
filterSchemas
,
setFilterSchemas
]
=
useState
([]);
const
[
selectedSchemas
,
setSelectedSchemas
]
=
useState
([]);
...
...
@@ -17,21 +17,25 @@ const FC = (props) => {
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
checkAllValue
,
setCheckAllValue
]
=
useState
(
false
);
const
[
configState
,
setConfigState
]
=
useState
(
undefined
);
const
[
step
,
setStep
]
=
useState
(
1
);
const
[
scheduleParam
,
setScheduleParam
]
=
useState
({
action
:
undefined
,
id
:
undefined
,
tid
:
undefined
});
const
[
editSchedule
,
setEditSchedule
]
=
useState
(
undefined
);
const
[
notConfigSchedule
,
setNotConfigSchedule
]
=
useState
(
false
);
const
[
showScheduleCheckbox
,
setShowScheduleCheckbox
]
=
useState
(
true
);
const
[
form
]
=
Form
.
useForm
();
const
[
scheduleForm
]
=
Form
.
useForm
();
useEffect
(()
=>
{
if
(
visible
)
{
if
(
action
===
'edit'
&&
id
)
{
if
(
action
===
'add'
)
{
setScheduleParam
({
action
,
id
:
undefined
,
tid
:
undefined
});
}
else
if
(
action
===
'edit'
&&
id
)
{
getTask
();
getSchedules
(
id
);
}
}
},
[
visible
,
action
])
...
...
@@ -126,10 +130,11 @@ const FC = (props) => {
}
},
callback
:
data
=>
{
setStep
(
2
);
if
((
data
?.
datas
||
[]).
length
===
0
)
{
setNotConfigSchedule
(
true
);
setScheduleParam
({
action
:
'add'
,
tid
});
}
else
{
setShowScheduleCheckbox
(
false
);
setScheduleParam
({
action
:
'edit'
,
id
:
data
?.
datas
[
0
].
id
});
}
...
...
@@ -143,62 +148,59 @@ const FC = (props) => {
const
onOk
=
async
()
=>
{
try
{
if
(
step
===
1
)
{
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
]
||
''
;
}
});
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.saveTask'
,
payload
:
{
data
:
newTask
},
callback
:
data
=>
{
setConfirmLoading
(
false
);
onChange
?.();
if
(
action
===
'add'
)
{
setStep
(
2
);
setScheduleParam
({
action
,
tid
:
data
});
}
else
{
getSchedules
(
data
);
}
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
}
else
{
const
row
=
await
form
.
validateFields
();
if
(
!
notConfigSchedule
)
{
await
scheduleForm
.
validateFields
();
}
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.saveAndStartSchedule'
,
payload
:
{
data
:
editSchedule
},
callback
:
()
=>
{
//深拷贝
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
]
||
''
;
}
});
setConfirmLoading
(
true
);
dispatch
({
type
:
'datasource.saveTask'
,
payload
:
{
data
:
newTask
},
callback
:
data
=>
{
if
(
!
notConfigSchedule
)
{
dispatch
({
type
:
'datasource.saveAndStartSchedule'
,
payload
:
{
data
:
{...
editSchedule
,
targetConfId
:
data
}
},
callback
:
()
=>
{
setConfirmLoading
(
false
);
reset
();
onCancel
?.(
true
);
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
}
else
{
setConfirmLoading
(
false
);
reset
();
onCancel
?.();
},
error
:
()
=>
{
setConfirmLoading
(
false
);
onCancel
?.(
true
);
}
})
}
},
error
:
()
=>
{
setConfirmLoading
(
false
);
}
})
}
catch
(
errInfo
)
{
console
.
log
(
'Validate Failed:'
,
errInfo
);
}
...
...
@@ -212,8 +214,12 @@ const FC = (props) => {
setConfigState
(
undefined
);
setKeyword
(
''
);
setCheckAllValue
(
false
);
setStep
(
1
);
setEditSchedule
(
undefined
);
setNotConfigSchedule
(
false
);
setShowScheduleCheckbox
(
true
);
setScheduleParam
({
action
:
undefined
,
id
:
undefined
,
tid
:
undefined
});
form
.
resetFields
();
scheduleForm
.
resetFields
();
}
const
onSearchInputChange
=
(
e
)
=>
{
...
...
@@ -242,6 +248,10 @@ const FC = (props) => {
}
}
const
onScheduleCheckChange
=
(
e
)
=>
{
setNotConfigSchedule
(
e
.
target
.
checked
);
}
const
onScheduleChange
=
(
data
)
=>
{
setEditSchedule
(
data
);
}
...
...
@@ -271,87 +281,91 @@ const FC = (props) => {
onOk=
{
onOk
}
confirmLoading=
{
confirmLoading
}
>
{
step
===
1
&&
<
React
.
Fragment
>
{
(
action
===
'add'
)
&&
<
div
className=
'flex'
style=
{
{
justifyContent
:
'end'
}
}
>
<
Config
autoSelect
onState=
{
(
state
)
=>
{
setConfigState
(
state
);
}
}
/>
</
div
>
}
<
Spin
spinning=
{
loading
}
>
<
Divider
>
{
isNeo4jTarget
?
'neo4j数据库信息'
:
'schema信息'
}
</
Divider
>
<
div
className=
'd-flex mb-3'
style=
{
{
alignItems
:
'center'
}
}
>
<
span
className=
'mr-3'
>
{
isNeo4jTarget
?
'neo4j数据库搜索'
:
'schema搜索'
}
:
</
span
>
<
Input
placeholder=
{
`请输入${isNeo4jTarget?'neo4j数据库':'schema'}名称`
}
allowClear
value=
{
keyword
}
onChange=
{
onSearchInputChange
}
style=
{
{
width
:
230
}
}
/>
<
Switch
checkedChildren=
"全不选"
unCheckedChildren=
"全选"
checked=
{
checkAllValue
}
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
}
>
<
React
.
Fragment
>
{
(
action
===
'add'
)
&&
<
div
className=
'flex'
style=
{
{
justifyContent
:
'end'
}
}
>
<
Config
autoSelect
onState=
{
(
state
)
=>
{
setConfigState
(
state
);
}
}
/>
</
div
>
}
<
Spin
spinning=
{
loading
}
>
<
Divider
>
{
isNeo4jTarget
?
'neo4j数据库信息'
:
'schema信息'
}
</
Divider
>
<
div
className=
'd-flex mb-3'
style=
{
{
alignItems
:
'center'
}
}
>
<
span
className=
'mr-3'
>
{
isNeo4jTarget
?
'neo4j数据库搜索'
:
'schema搜索'
}
:
</
span
>
<
Input
placeholder=
{
`请输入${isNeo4jTarget?'neo4j数据库':'schema'}名称`
}
allowClear
value=
{
keyword
}
onChange=
{
onSearchInputChange
}
style=
{
{
width
:
230
}
}
/>
<
Switch
checkedChildren=
"全不选"
unCheckedChildren=
"全选"
checked=
{
checkAllValue
}
onChange=
{
onCheckAll
}
style=
{
{
marginLeft
:
'auto'
}
}
/>
</
div
>
<
div
style=
{
{
maxHeight
:
300
,
overflow
:
'auto'
}
}
>
<
Row
className=
'mb-3'
>
{
taskSettings
&&
(
taskSettings
.
targetConfParameters
||
[]).
filter
(
item
=>
item
.
name
!==
'schema'
).
map
((
param
,
index
)
=>
{
(
filterSchemas
||
[]).
map
((
schema
,
index
)
=>
{
return
(
<
Form
.
Item
label=
{
param
.
cnName
||
''
}
name=
{
param
.
name
||
''
}
key=
{
index
}
rules=
{
[{
required
:
param
.
required
,
message
:
'必填项'
}]
}
>
{
(
param
.
show
?
<
Input
placeholder=
{
param
.
explain
||
''
}
/>
:
<
Input
.
Password
placeholder=
{
param
.
explain
||
''
}
visibilityToggle=
{
false
}
/>
)
}
</
Form
.
Item
>
)
<
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
>
);
})
}
</
Form
>
</
Spin
>
</
React
.
Fragment
>
}
{
step
===
2
&&
<
React
.
Fragment
>
<
Divider
>
定时调度
</
Divider
>
<
ScheduleAction
action=
{
scheduleParam
.
action
}
id=
{
scheduleParam
.
id
}
form=
{
scheduleForm
}
tid=
{
scheduleParam
.
tid
}
onChange=
{
onScheduleChange
}
/>
</
React
.
Fragment
>
}
</
Row
>
</
div
>
<
Divider
>
过滤信息
</
Divider
>
<
Form
{
...
formItemLayout
}
form=
{
form
}
>
{
taskSettings
&&
(
taskSettings
.
targetConfParameters
||
[]).
filter
(
item
=>
item
.
name
!==
'schema'
).
map
((
param
,
index
)
=>
{
return
(
<
Form
.
Item
label=
{
param
.
cnName
||
''
}
name=
{
param
.
name
||
''
}
key=
{
index
}
rules=
{
[{
required
:
param
.
required
,
message
:
'必填项'
}]
}
>
{
(
param
.
show
?
<
Input
placeholder=
{
param
.
explain
||
''
}
/>
:
<
Input
.
Password
placeholder=
{
param
.
explain
||
''
}
visibilityToggle=
{
false
}
/>
)
}
</
Form
.
Item
>
)
})
}
</
Form
>
<
Divider
>
{
<
Space
>
<
span
>
定时调度
</
span
>
{
showScheduleCheckbox
&&
<
Checkbox
checked=
{
notConfigSchedule
}
onChange=
{
onScheduleCheckChange
}
>
暂不设置
</
Checkbox
>
}
</
Space
>
}
</
Divider
>
{
!
notConfigSchedule
&&
<
ScheduleAction
action=
{
scheduleParam
.
action
}
id=
{
scheduleParam
.
id
}
form=
{
scheduleForm
}
tid=
{
scheduleParam
.
tid
}
onChange=
{
onScheduleChange
}
/>
}
</
Spin
>
</
React
.
Fragment
>
</
Modal
>
);
}
...
...
src/view/Manage/MetadataHarvester/index.less
View file @
bec4a91d
.metadata-harvester {
height: calc(100vh - 124px);
padding: 20px;
padding:
5px 20px
20px;
background: #fff;
overflow: hidden;
}
\ No newline at end of file
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