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
05f9d326
Commit
05f9d326
authored
May 17, 2021
by
zhaochengxiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完成数据源管理的功能
parent
6f815c16
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
236 additions
and
23 deletions
+236
-23
UpdateDatasourceModal.jsx
...nage/DatasourceManage/Component/UpdateDatasourceModal.jsx
+156
-10
UpdateTaskModal.jsx
...iew/Manage/DatasourceManage/Component/UpdateTaskModal.jsx
+53
-8
index.jsx
src/view/Manage/DatasourceManage/index.jsx
+25
-5
ImportExcel.jsx
src/view/Manage/Model/Component/ImportExcel.jsx
+2
-0
No files found.
src/view/Manage/DatasourceManage/Component/UpdateDatasourceModal.jsx
View file @
05f9d326
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
Modal
,
Select
,
Form
,
Input
,
Divider
,
Space
,
Button
}
from
'antd'
;
import
{
Modal
,
Select
,
Form
,
Input
,
Divider
,
Space
,
Button
,
Upload
}
from
'antd'
;
import
{
UploadOutlined
}
from
'@ant-design/icons'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
dispatch
}
from
'../../../../model'
;
import
{
showMessage
}
from
'../../../../util'
;
import
{
showMessage
}
from
'../../../../util'
;
...
@@ -7,30 +8,69 @@ import { showMessage } from '../../../../util';
...
@@ -7,30 +8,69 @@ import { showMessage } from '../../../../util';
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
const
UpdateDatasourceModal
=
(
props
)
=>
{
const
UpdateDatasourceModal
=
(
props
)
=>
{
const
{
visible
,
onCancel
,
databases
}
=
props
;
const
{
visible
,
onCancel
,
databases
,
action
,
id
}
=
props
;
const
[
selectedDatabaseKey
,
setSelectedDatabaseKey
]
=
useState
(
''
);
const
[
selectedDatabaseKey
,
setSelectedDatabaseKey
]
=
useState
(
''
);
const
[
allSupportedDatasourceTypies
,
setAllSupportedDatasourceTypies
]
=
useState
([]);
const
[
allSupportedDatasourceTypies
,
setAllSupportedDatasourceTypies
]
=
useState
([]);
const
[
currentSupportedDatasourceTypies
,
setCurrentSupportedDatasourceTypies
]
=
useState
({});
const
[
currentSupportedDatasourceTypies
,
setCurrentSupportedDatasourceTypies
]
=
useState
({});
const
[
currentDatasource
,
setCurrentDatasource
]
=
useState
({});
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
validateLoading
,
setValidateLoading
]
=
useState
(
false
);
const
[
validateLoading
,
setValidateLoading
]
=
useState
(
false
);
const
[
fileListBindName
,
setFileListBindName
]
=
useState
([]);
const
[
credentialForm
]
=
Form
.
useForm
();
const
[
credentialForm
]
=
Form
.
useForm
();
const
[
datasourceForm
]
=
Form
.
useForm
();
const
[
datasourceForm
]
=
Form
.
useForm
();
useEffect
(()
=>
{
useEffect
(()
=>
{
getAllSupportedDatasourceTypies
();
if
(
visible
)
{
reset
();
getAllSupportedDatasourceTypies
();
}
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[])
},
[
visible
,
action
,
id
])
const
getAllSupportedDatasourceTypies
=
()
=>
{
const
getAllSupportedDatasourceTypies
=
()
=>
{
dispatch
({
dispatch
({
type
:
'datasource.getAllSupportedDatasourceTypies'
,
type
:
'datasource.getAllSupportedDatasourceTypies'
,
callback
:
data
=>
{
callback
:
data
=>
{
function
compare
(
val1
,
val2
)
{
var
a
=
val1
.
seq
;
var
b
=
val2
.
seq
;
return
(
a
-
b
);
}
(
data
||
[]).
forEach
(
item
=>
{
item
.
credential
&&
(
item
.
credential
.
credentialParameters
||
[]).
sort
(
compare
);
(
item
.
targetParameters
||
[]).
sort
(
compare
);
})
setAllSupportedDatasourceTypies
(
data
||
[]);
setAllSupportedDatasourceTypies
(
data
||
[]);
const
_defaultKey
=
(
data
||
[]).
length
>
0
?
data
[
0
].
type
:
''
;
if
(
action
===
'add'
)
{
const
_defaultKey
=
(
data
||
[]).
length
>
0
?
data
[
0
].
type
:
''
;
setSelectedDatabaseKey
(
_defaultKey
);
getCurrentSupportedDatasourceTypies
(
data
||
[],
_defaultKey
);
}
else
if
(
action
===
'edit'
)
{
getCurrentDatasource
(
data
||
[]);
}
}
})
}
const
getCurrentDatasource
=
(
typies
)
=>
{
dispatch
({
type
:
'datasource.getDatasource'
,
payload
:
{
datasourceId
:
id
},
callback
:
data
=>
{
const
_defaultKey
=
(
data
)?(
data
.
type
||
''
):
''
;
setSelectedDatabaseKey
(
_defaultKey
);
setSelectedDatabaseKey
(
_defaultKey
);
getCurrentSupportedDatasourceTypies
(
data
||
[],
_defaultKey
);
getCurrentSupportedDatasourceTypies
(
typies
||
[],
_defaultKey
);
setCurrentDatasource
(
data
);
setFormFiledsValue
(
data
);
}
}
})
})
}
}
...
@@ -47,7 +87,26 @@ const UpdateDatasourceModal = (props) => {
...
@@ -47,7 +87,26 @@ const UpdateDatasourceModal = (props) => {
setCurrentSupportedDatasourceTypies
(
_currentTypies
);
setCurrentSupportedDatasourceTypies
(
_currentTypies
);
}
}
const
setFormFiledsValue
=
(
data
)
=>
{
let
_credentialFieldsValue
=
{},
_datasourceFieldsValue
=
{};
data
&&
data
.
credential
&&
(
data
.
credential
.
credentialParameters
||
[]).
forEach
(
item
=>
{
_credentialFieldsValue
[
item
.
name
||
''
]
=
item
.
value
||
''
;
});
credentialForm
.
setFieldsValue
(
_credentialFieldsValue
);
data
&&
(
data
.
targetParameters
||
[]).
forEach
(
item
=>
{
_datasourceFieldsValue
[
item
.
name
||
''
]
=
item
.
value
||
''
;
});
datasourceForm
.
setFieldsValue
(
_datasourceFieldsValue
);
}
const
onDatabaseChange
=
(
value
)
=>
{
const
onDatabaseChange
=
(
value
)
=>
{
reset
();
setSelectedDatabaseKey
(
value
);
setSelectedDatabaseKey
(
value
);
getCurrentSupportedDatasourceTypies
(
allSupportedDatasourceTypies
,
value
);
getCurrentSupportedDatasourceTypies
(
allSupportedDatasourceTypies
,
value
);
}
}
...
@@ -57,13 +116,30 @@ const UpdateDatasourceModal = (props) => {
...
@@ -57,13 +116,30 @@ const UpdateDatasourceModal = (props) => {
const
datasourceRow
=
await
datasourceForm
.
validateFields
();
const
datasourceRow
=
await
datasourceForm
.
validateFields
();
const
credentialRow
=
await
credentialForm
.
validateFields
();
const
credentialRow
=
await
credentialForm
.
validateFields
();
const
newDatasource
=
{...
currentSupportedDatasourceTypies
};
//深拷贝
let
newDatasource
=
JSON
.
parse
(
JSON
.
stringify
(
currentSupportedDatasourceTypies
));
if
(
action
===
'edit'
)
{
newDatasource
=
{...
newDatasource
,
...
currentDatasource
};
}
newDatasource
&&
(
newDatasource
.
targetParameters
||
[]).
forEach
(
item
=>
{
newDatasource
&&
(
newDatasource
.
targetParameters
||
[]).
forEach
(
item
=>
{
item
.
value
=
datasourceRow
[
item
.
name
]
||
''
;
item
.
value
=
datasourceRow
[
item
.
name
]
||
''
;
if
(
item
.
selectMode
===
'file'
)
{
const
index
=
(
fileListBindName
||
[]).
findIndex
(
_item
=>
_item
.
name
===
item
.
name
);
if
(
index
!==
-
1
)
{
item
.
value
=
fileListBindName
[
index
].
data
||
''
;
}
}
});
});
newDatasource
&&
newDatasource
.
credential
&&
(
newDatasource
.
credential
.
credentialParameters
||
[]).
forEach
(
item
=>
{
newDatasource
&&
newDatasource
.
credential
&&
(
newDatasource
.
credential
.
credentialParameters
||
[]).
forEach
(
item
=>
{
item
.
value
=
credentialRow
[
item
.
name
];
item
.
value
=
credentialRow
[
item
.
name
]
||
''
;
if
(
item
.
selectMode
===
'file'
)
{
const
index
=
(
fileListBindName
||
[]).
findIndex
(
_item
=>
_item
.
name
===
item
.
name
);
if
(
index
!==
-
1
)
{
item
.
value
=
fileListBindName
[
index
].
data
||
''
;
}
}
})
})
setConfirmLoading
(
true
);
setConfirmLoading
(
true
);
...
@@ -94,10 +170,22 @@ const UpdateDatasourceModal = (props) => {
...
@@ -94,10 +170,22 @@ const UpdateDatasourceModal = (props) => {
const
newDatasource
=
{...
currentSupportedDatasourceTypies
};
const
newDatasource
=
{...
currentSupportedDatasourceTypies
};
newDatasource
&&
(
newDatasource
.
targetParameters
||
[]).
forEach
(
item
=>
{
newDatasource
&&
(
newDatasource
.
targetParameters
||
[]).
forEach
(
item
=>
{
item
.
value
=
datasourceRow
[
item
.
name
];
item
.
value
=
datasourceRow
[
item
.
name
];
if
(
item
.
selectMode
===
'file'
)
{
const
index
=
(
fileListBindName
||
[]).
findIndex
(
_item
=>
_item
.
name
===
item
.
name
);
if
(
index
!==
-
1
)
{
item
.
value
=
fileListBindName
[
index
].
data
||
''
;
}
}
});
});
newDatasource
&&
newDatasource
.
credential
&&
(
newDatasource
.
credential
.
credentialParameters
||
[]).
forEach
(
item
=>
{
newDatasource
&&
newDatasource
.
credential
&&
(
newDatasource
.
credential
.
credentialParameters
||
[]).
forEach
(
item
=>
{
item
.
value
=
credentialRow
[
item
.
name
];
item
.
value
=
credentialRow
[
item
.
name
];
if
(
item
.
selectMode
===
'file'
)
{
const
index
=
(
fileListBindName
||
[]).
findIndex
(
_item
=>
_item
.
name
===
item
.
name
);
if
(
index
!==
-
1
)
{
item
.
value
=
fileListBindName
[
index
].
data
||
''
;
}
}
})
})
setValidateLoading
(
true
);
setValidateLoading
(
true
);
...
@@ -124,6 +212,43 @@ const UpdateDatasourceModal = (props) => {
...
@@ -124,6 +212,43 @@ const UpdateDatasourceModal = (props) => {
}
}
}
}
const
reset
=
()
=>
{
setFileListBindName
([]);
credentialForm
.
resetFields
();
datasourceForm
.
resetFields
();
}
const
onRemoveFile
=
(
name
,
file
)
=>
{
const
index
=
(
fileListBindName
||
[]).
findIndex
(
item
=>
item
.
name
===
name
);
if
(
index
!==
-
1
)
{
const
fileList
=
fileListBindName
[
index
].
fileList
;
const
_index
=
fileList
.
indexOf
(
file
);
fileList
.
splice
(
_index
,
1
);
setFileListBindName
([...
fileListBindName
]);
}
}
const
beforeUpload
=
(
name
,
file
)
=>
{
const
index
=
(
fileListBindName
||
[]).
findIndex
(
item
=>
item
.
name
===
name
);
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
ext
)
{
if
(
index
!==
-
1
)
{
fileListBindName
[
index
].
fileList
=
[
file
];
fileListBindName
[
index
].
data
=
ext
.
target
.
result
.
substring
(
ext
.
target
.
result
.
indexOf
(
','
)
+
1
);
}
else
{
fileListBindName
.
push
({
name
,
fileList
:
[
file
],
data
:
ext
.
target
.
result
.
substring
(
ext
.
target
.
result
.
indexOf
(
','
)
+
1
)
});
}
setFileListBindName
([...
fileListBindName
]);
}
reader
.
readAsDataURL
(
file
);
}
const
formItemLayout
=
{
const
formItemLayout
=
{
labelCol
:
{
labelCol
:
{
xs
:
{
span
:
24
},
xs
:
{
span
:
24
},
...
@@ -138,7 +263,7 @@ const UpdateDatasourceModal = (props) => {
...
@@ -138,7 +263,7 @@ const UpdateDatasourceModal = (props) => {
return
(
return
(
<
Modal
<
Modal
forceRender
forceRender
title=
{
'新增
数据源'
}
title=
{
action
===
'add'
?
'新增数据源'
:
'修改
数据源'
}
visible=
{
visible
}
visible=
{
visible
}
width=
{
600
}
width=
{
600
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
()
}
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
()
}
}
...
@@ -156,6 +281,7 @@ const UpdateDatasourceModal = (props) => {
...
@@ -156,6 +281,7 @@ const UpdateDatasourceModal = (props) => {
value=
{
selectedDatabaseKey
}
value=
{
selectedDatabaseKey
}
style=
{
{
width
:
150
}
}
style=
{
{
width
:
150
}
}
onChange=
{
onDatabaseChange
}
onChange=
{
onDatabaseChange
}
disabled=
{
action
===
'edit'
}
>
>
{
{
databases
&&
databases
.
map
((
item
,
index
)
=>
{
databases
&&
databases
.
map
((
item
,
index
)
=>
{
...
@@ -175,6 +301,7 @@ const UpdateDatasourceModal = (props) => {
...
@@ -175,6 +301,7 @@ const UpdateDatasourceModal = (props) => {
label=
{
item
.
cnName
||
''
}
label=
{
item
.
cnName
||
''
}
name=
{
item
.
name
||
''
}
name=
{
item
.
name
||
''
}
key=
{
index
}
key=
{
index
}
rules=
{
[{
required
:
item
.
required
,
message
:
'必填项'
}]
}
>
>
<
Input
/>
<
Input
/>
</
Form
.
Item
>
</
Form
.
Item
>
...
@@ -186,13 +313,32 @@ const UpdateDatasourceModal = (props) => {
...
@@ -186,13 +313,32 @@ const UpdateDatasourceModal = (props) => {
<
Form
{
...
formItemLayout
}
form=
{
credentialForm
}
>
<
Form
{
...
formItemLayout
}
form=
{
credentialForm
}
>
{
{
currentSupportedDatasourceTypies
&&
currentSupportedDatasourceTypies
.
credential
&&
(
currentSupportedDatasourceTypies
.
credential
.
credentialParameters
||
[]).
map
((
item
,
index
)
=>
{
currentSupportedDatasourceTypies
&&
currentSupportedDatasourceTypies
.
credential
&&
(
currentSupportedDatasourceTypies
.
credential
.
credentialParameters
||
[]).
map
((
item
,
index
)
=>
{
let
_fileList
=
[];
const
_index
=
(
fileListBindName
||
[]).
findIndex
(
_item
=>
_item
.
name
===
item
.
name
);
if
(
_index
!==
-
1
)
{
_fileList
=
fileListBindName
[
_index
].
fileList
||
[];
}
return
(
return
(
<
Form
.
Item
<
Form
.
Item
label=
{
item
.
cnName
||
''
}
label=
{
item
.
cnName
||
''
}
name=
{
item
.
name
||
''
}
name=
{
item
.
name
||
''
}
key=
{
index
}
key=
{
index
}
rules=
{
[{
required
:
item
.
required
,
message
:
'必填项'
}]
}
>
>
<
Input
/>
{
item
.
selectMode
===
'file'
?
(
<
Upload
onRemove=
{
(
file
)
=>
{
onRemoveFile
(
item
.
name
,
file
);
}
}
beforeUpload=
{
(
file
)
=>
{
beforeUpload
(
item
.
name
,
file
);
}
}
fileList=
{
_fileList
}
// accept='.txt'
>
<
Button
icon=
{
<
UploadOutlined
/>
}
>
选择文件上传
</
Button
>
</
Upload
>
)
:
(
item
.
show
?
<
Input
/>
:
<
Input
.
Password
/>
)
}
</
Form
.
Item
>
</
Form
.
Item
>
)
)
})
})
...
...
src/view/Manage/DatasourceManage/Component/UpdateTaskModal.jsx
View file @
05f9d326
...
@@ -5,32 +5,56 @@ import { dispatch } from '../../../../model';
...
@@ -5,32 +5,56 @@ import { dispatch } from '../../../../model';
import
'./UpdateTaskModal.less'
;
import
'./UpdateTaskModal.less'
;
const
UpdateTaskModal
=
(
props
)
=>
{
const
UpdateTaskModal
=
(
props
)
=>
{
const
{
visible
,
onCancel
,
datasourceId
}
=
props
;
const
{
visible
,
onCancel
,
action
,
id
,
datasourceId
}
=
props
;
const
[
schemas
,
setSchemas
]
=
useState
([]);
const
[
schemas
,
setSchemas
]
=
useState
([]);
const
[
filterSchemas
,
setFilterSchemas
]
=
useState
([]);
const
[
filterSchemas
,
setFilterSchemas
]
=
useState
([]);
const
[
selectedSchemas
,
setSelectedSchemas
]
=
useState
([]);
const
[
selectedSchemas
,
setSelectedSchemas
]
=
useState
([]);
const
[
taskSettings
,
setTaskSettings
]
=
useState
({});
const
[
taskSettings
,
setTaskSettings
]
=
useState
({});
const
[
currentTask
,
setCurrentTask
]
=
useState
({});
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
keyword
,
setKeyword
]
=
useState
(
''
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
confirmLoading
,
setConfirmLoading
]
=
useState
(
false
);
const
[
form
]
=
Form
.
useForm
();
const
[
form
]
=
Form
.
useForm
();
useEffect
(()
=>
{
useEffect
(()
=>
{
if
((
datasourceId
||
''
)
!==
''
)
{
getTaskSettings
();
if
(
visible
)
{
setSelectedSchemas
([]);
form
.
resetFields
();
if
(
action
===
'add'
&&
datasourceId
)
{
getTaskSettings
();
}
else
if
(
action
===
'edit'
&&
id
)
{
getTask
();
}
}
}
//eslint-disable-next-line react-hooks/exhaustive-deps
//eslint-disable-next-line react-hooks/exhaustive-deps
},
[
datasourceId
])
},
[
visible
,
action
,
id
,
datasourceId
])
useEffect
(()
=>
{
useEffect
(()
=>
{
setFilterSchemas
((
schemas
||
[]).
filter
(
schema
=>
(
schema
||
''
).
indexOf
(
keyword
)
!==-
1
));
setFilterSchemas
((
schemas
||
[]).
filter
(
schema
=>
(
schema
||
''
).
indexOf
(
keyword
)
!==-
1
));
},
[
keyword
,
schemas
])
},
[
keyword
,
schemas
])
const
getTaskSettings
=
()
=>
{
const
getTask
=
()
=>
{
dispatch
({
type
:
'datasource.getTask'
,
payload
:
{
harvestingTaskId
:
id
},
callback
:
data
=>
{
setCurrentTask
(
data
);
getTaskSettings
(
data
&&
data
.
target
?(
data
.
target
.
id
||
''
):
''
,
data
)
}
})
}
const
getTaskSettings
=
(
sourceId
=
datasourceId
,
task
=
null
)
=>
{
dispatch
({
dispatch
({
type
:
'datasource.getTaskSettingsByDatasource'
,
type
:
'datasource.getTaskSettingsByDatasource'
,
payload
:
{
payload
:
{
datasourceId
datasourceId
:
sourceId
},
},
callback
:
data
=>
{
callback
:
data
=>
{
setTaskSettings
(
data
);
setTaskSettings
(
data
);
...
@@ -39,6 +63,20 @@ const UpdateTaskModal = (props) => {
...
@@ -39,6 +63,20 @@ const UpdateTaskModal = (props) => {
setSchemas
(
item
.
selectItem
||
[]);
setSchemas
(
item
.
selectItem
||
[]);
}
}
})
})
if
(
action
===
'edit'
)
{
let
_fieldsValue
=
{};
task
&&
(
task
.
targetConfParameters
||
[]).
forEach
(
item
=>
{
if
(
item
.
name
===
'schema'
)
{
setSelectedSchemas
((
item
.
value
||
''
).
split
(
','
));
}
else
{
_fieldsValue
[
item
.
name
||
''
]
=
item
.
value
||
''
;
}
})
form
.
setFieldsValue
(
_fieldsValue
);
}
}
}
})
})
}
}
...
@@ -46,7 +84,14 @@ const UpdateTaskModal = (props) => {
...
@@ -46,7 +84,14 @@ const UpdateTaskModal = (props) => {
const
onOk
=
async
()
=>
{
const
onOk
=
async
()
=>
{
try
{
try
{
const
row
=
await
form
.
validateFields
();
const
row
=
await
form
.
validateFields
();
const
newTask
=
{...
taskSettings
};
//深拷贝
let
newTask
=
JSON
.
parse
(
JSON
.
stringify
(
taskSettings
));
if
(
action
===
'edit'
)
{
newTask
=
{...
newTask
,
...
currentTask
};
}
newTask
&&
(
newTask
.
targetConfParameters
||
[]).
forEach
(
item
=>
{
newTask
&&
(
newTask
.
targetConfParameters
||
[]).
forEach
(
item
=>
{
if
(
item
.
name
===
'schema'
)
{
if
(
item
.
name
===
'schema'
)
{
item
.
value
=
selectedSchemas
.
join
(
','
);
item
.
value
=
selectedSchemas
.
join
(
','
);
...
@@ -104,7 +149,7 @@ const UpdateTaskModal = (props) => {
...
@@ -104,7 +149,7 @@ const UpdateTaskModal = (props) => {
<
Modal
<
Modal
className=
'update-task-modal'
className=
'update-task-modal'
forceRender
forceRender
title=
{
'新增
任务'
}
title=
{
action
===
'add'
?
'新增任务'
:
'修改
任务'
}
visible=
{
visible
}
visible=
{
visible
}
width=
{
600
}
width=
{
600
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
()
}
}
onCancel=
{
()
=>
{
onCancel
&&
onCancel
()
}
}
...
...
src/view/Manage/DatasourceManage/index.jsx
View file @
05f9d326
...
@@ -6,7 +6,6 @@ import { dispatch } from '../../../model';
...
@@ -6,7 +6,6 @@ import { dispatch } from '../../../model';
import
UpdateDatasourceModal
from
'./Component/UpdateDatasourceModal'
;
import
UpdateDatasourceModal
from
'./Component/UpdateDatasourceModal'
;
import
UpdateTaskModal
from
'./Component/UpdateTaskModal'
;
import
UpdateTaskModal
from
'./Component/UpdateTaskModal'
;
import
{
showMessage
}
from
'../../../util'
;
import
{
showMessage
}
from
'../../../util'
;
import
{
deleteDatasource
}
from
'../../../model/datasource'
;
const
{
Option
}
=
Select
;
const
{
Option
}
=
Select
;
const
{
Panel
}
=
Collapse
;
const
{
Panel
}
=
Collapse
;
...
@@ -19,8 +18,11 @@ const DatasourceManage = () => {
...
@@ -19,8 +18,11 @@ const DatasourceManage = () => {
const
[
selectedDatabaseKey
,
setSelectedDatabaseKey
]
=
useState
(
''
);
const
[
selectedDatabaseKey
,
setSelectedDatabaseKey
]
=
useState
(
''
);
const
[
loadingDatabases
,
setLoadingDatabases
]
=
useState
(
false
);
const
[
loadingDatabases
,
setLoadingDatabases
]
=
useState
(
false
);
const
[
updateDatasourceModalVisible
,
setUpdateDatasourceModalVisible
]
=
useState
(
false
);
const
[
updateDatasourceModalVisible
,
setUpdateDatasourceModalVisible
]
=
useState
(
false
);
const
[
updateDatasourceModalAction
,
setUpdateDatasourceModalAction
]
=
useState
(
''
);
const
[
updateTaskModalVisible
,
setUpdateTaskModalVisible
]
=
useState
(
false
);
const
[
updateTaskModalVisible
,
setUpdateTaskModalVisible
]
=
useState
(
false
);
const
[
updateTaskModalAction
,
setUpdateTaskModalAction
]
=
useState
(
''
);
const
[
currentDatasourceId
,
setCurrentDatasourceId
]
=
useState
(
''
);
const
[
currentDatasourceId
,
setCurrentDatasourceId
]
=
useState
(
''
);
const
[
currentTaskId
,
setCurrentTaskId
]
=
useState
(
''
);
const
[
tasksBindDatasourceId
,
setTasksBindDatasourceId
]
=
useState
([]);
const
[
tasksBindDatasourceId
,
setTasksBindDatasourceId
]
=
useState
([]);
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
const
[
modal
,
contextHolder
]
=
Modal
.
useModal
();
...
@@ -38,7 +40,7 @@ const DatasourceManage = () => {
...
@@ -38,7 +40,7 @@ const DatasourceManage = () => {
callback
:
data
=>
{
callback
:
data
=>
{
setLoadingDatabases
(
false
);
setLoadingDatabases
(
false
);
setRawSupportDatabases
(
data
||
[]);
setRawSupportDatabases
(
data
||
[]);
setSupportDatabases
([{
targetType
:
'all'
,
targetName
:
'全部'
},
...(
data
||
[])]);
setSupportDatabases
([{
targetType
:
'all'
,
targetName
:
'全部
类型
'
},
...(
data
||
[])]);
setSelectedDatabaseKey
(
'all'
);
setSelectedDatabaseKey
(
'all'
);
getAllDatasources
();
getAllDatasources
();
},
},
...
@@ -90,6 +92,13 @@ const DatasourceManage = () => {
...
@@ -90,6 +92,13 @@ const DatasourceManage = () => {
}
}
const
addDatasource
=
()
=>
{
const
addDatasource
=
()
=>
{
setUpdateDatasourceModalAction
(
'add'
);
setUpdateDatasourceModalVisible
(
true
);
}
const
editDatasource
=
(
datasource
)
=>
{
setCurrentDatasourceId
(
datasource
.
id
);
setUpdateDatasourceModalAction
(
'edit'
);
setUpdateDatasourceModalVisible
(
true
);
setUpdateDatasourceModalVisible
(
true
);
}
}
...
@@ -128,8 +137,9 @@ const DatasourceManage = () => {
...
@@ -128,8 +137,9 @@ const DatasourceManage = () => {
}
}
const
addTask
=
(
datasource
)
=>
{
const
addTask
=
(
datasource
)
=>
{
setUpdateTaskModalVisible
(
true
);
setCurrentDatasourceId
(
datasource
.
id
||
''
);
setCurrentDatasourceId
(
datasource
.
id
||
''
);
setUpdateTaskModalAction
(
'add'
);
setUpdateTaskModalVisible
(
true
);
}
}
const
startTask
=
(
task
)
=>
{
const
startTask
=
(
task
)
=>
{
...
@@ -152,6 +162,12 @@ const DatasourceManage = () => {
...
@@ -152,6 +162,12 @@ const DatasourceManage = () => {
});
});
}
}
const
editTask
=
(
task
)
=>
{
setCurrentTaskId
(
task
.
id
);
setUpdateTaskModalAction
(
'edit'
);
setUpdateTaskModalVisible
(
true
);
}
const
deleteTask
=
(
task
)
=>
{
const
deleteTask
=
(
task
)
=>
{
modal
.
confirm
({
modal
.
confirm
({
title
:
'是否确认删除该任务?'
,
title
:
'是否确认删除该任务?'
,
...
@@ -237,7 +253,7 @@ const DatasourceManage = () => {
...
@@ -237,7 +253,7 @@ const DatasourceManage = () => {
extra=
{
extra=
{
<
Space
>
<
Space
>
<
Tooltip
placement=
'bottom'
title=
{
'修改'
}
>
<
Tooltip
placement=
'bottom'
title=
{
'修改'
}
>
<
Button
icon=
{
<
EditOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
}
}
/>
<
Button
icon=
{
<
EditOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
editDatasource
(
datasource
);
}
}
/>
</
Tooltip
>
</
Tooltip
>
<
Tooltip
placement=
'bottom'
title=
{
'新增任务'
}
>
<
Tooltip
placement=
'bottom'
title=
{
'新增任务'
}
>
<
Button
icon=
{
<
DiffOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
addTask
(
datasource
);
}
}
/>
<
Button
icon=
{
<
DiffOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
addTask
(
datasource
);
}
}
/>
...
@@ -272,7 +288,7 @@ const DatasourceManage = () => {
...
@@ -272,7 +288,7 @@ const DatasourceManage = () => {
<
Button
icon=
{
<
DatabaseOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
startTask
(
task
);
}
}
/>
<
Button
icon=
{
<
DatabaseOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
startTask
(
task
);
}
}
/>
</
Tooltip
>
</
Tooltip
>
<
Tooltip
placement=
'bottom'
title=
'修改'
>
<
Tooltip
placement=
'bottom'
title=
'修改'
>
<
Button
icon=
{
<
EditOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
}
}
/>
<
Button
icon=
{
<
EditOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
editTask
(
task
);
}
}
/>
</
Tooltip
>
</
Tooltip
>
<
Tooltip
placement=
'bottom'
title=
'删除'
>
<
Tooltip
placement=
'bottom'
title=
'删除'
>
<
Button
icon=
{
<
DeleteOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
deleteTask
(
task
);
}
}
/>
<
Button
icon=
{
<
DeleteOutlined
/>
}
size=
'small'
onClick=
{
()
=>
{
deleteTask
(
task
);
}
}
/>
...
@@ -292,13 +308,17 @@ const DatasourceManage = () => {
...
@@ -292,13 +308,17 @@ const DatasourceManage = () => {
<
UpdateDatasourceModal
<
UpdateDatasourceModal
visible=
{
updateDatasourceModalVisible
}
visible=
{
updateDatasourceModalVisible
}
id=
{
currentDatasourceId
}
databases=
{
rawSupportDatabases
}
databases=
{
rawSupportDatabases
}
action=
{
updateDatasourceModalAction
}
onCancel=
{
onUpdateDatasourceModalCancel
}
onCancel=
{
onUpdateDatasourceModalCancel
}
/>
/>
<
UpdateTaskModal
<
UpdateTaskModal
visible=
{
updateTaskModalVisible
}
visible=
{
updateTaskModalVisible
}
id=
{
currentTaskId
}
datasourceId=
{
currentDatasourceId
}
datasourceId=
{
currentDatasourceId
}
action=
{
updateTaskModalAction
}
onCancel=
{
onUpdateTaskModalVisibleCancel
}
onCancel=
{
onUpdateTaskModalVisibleCancel
}
/>
/>
...
...
src/view/Manage/Model/Component/ImportExcel.jsx
View file @
05f9d326
...
@@ -34,6 +34,8 @@ class ImportExcel extends React.Component {
...
@@ -34,6 +34,8 @@ class ImportExcel extends React.Component {
onChange
&&
onChange
([
file
]);
onChange
&&
onChange
([
file
]);
this
.
setState
({
fileList
:
[
file
]
});
this
.
setState
({
fileList
:
[
file
]
});
console
.
log
(
'file'
,
file
);
return
false
;
return
false
;
},
},
accept
:
".xlsx"
,
accept
:
".xlsx"
,
...
...
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