Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
bkunyun
Project
Project
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
Administrator
bkunyun
Commits
7b01a920
Commit
7b01a920
authored
Oct 25, 2022
by
wuyongsheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 编辑算子校验
parent
42e28f8f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
38 additions
and
29 deletions
+38
-29
resourceCenter.ts
src/api/resourceCenter.ts
+3
-3
index.tsx
src/components/CommonComponents/Code/index.tsx
+8
-8
index.tsx
...sources/WorkflowOperator/components/AddOperator/index.tsx
+25
-17
index.tsx
...s/ResourceCenter/UserResources/WorkflowOperator/index.tsx
+2
-1
No files found.
src/api/resourceCenter.ts
View file @
7b01a920
...
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-19 17:09:23
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-10-25
18:23:55
* @LastEditTime: 2022-10-25
20:26:42
* @FilePath: /bkunyun/src/api/resourceCenter.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -115,9 +115,9 @@ const getWorkflowspecList = (params: {productId?: string, title?: string}) => {
// API_WORKFLOWSPEC_LIST
// 新增应用环境
const
saveOperator
=
(
params
:
any
)
=>
{
const
saveOperator
=
(
params
:
any
,
isEdit
:
boolean
)
=>
{
return
request
({
url
:
Api
.
API_SAVE_OPERATOR
,
url
:
`
${
Api
.
API_SAVE_OPERATOR
}
?isEdit=
${
isEdit
}
`
,
method
:
"post"
,
data
:
params
,
});
...
...
src/components/CommonComponents/Code/index.tsx
View file @
7b01a920
...
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-20 19:45:32
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-10-25
17:14:16
* @LastEditTime: 2022-10-25
21:16:13
* @FilePath: /bkunyun/src/components/CommonComponents/Code/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -36,11 +36,11 @@ const Code = (props: ICodeType) => {
);
};
const
handleEqual
=
(
prvProps
:
ICodeType
,
nextProps
:
ICodeType
)
=>
{
if
(
isEqual
(
prvProps
,
nextProps
))
{
return
true
;
}
return
true
;
};
//
const handleEqual = (prvProps: ICodeType, nextProps: ICodeType) => {
//
if (isEqual(prvProps, nextProps)) {
//
return true;
//
}
//
return true;
//
};
export
default
memo
(
Code
,
handleEqual
)
;
export
default
Code
;
src/views/ResourceCenter/UserResources/WorkflowOperator/components/AddOperator/index.tsx
View file @
7b01a920
...
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-18 16:12:55
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-10-25
18:04:16
* @LastEditTime: 2022-10-25
21:16:00
* @FilePath: /bkunyun/src/views/ResourceCenter/UserResources/WorkflowOperator/components/AddOperator/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -43,12 +43,13 @@ interface IAddOperator {
pageType
:
string
;
setPageType
:
(
val
:
string
)
=>
void
;
detailsId
:
string
;
getList
:
()
=>
void
;
}
type
IBuildType
=
"ENVIRONMENT"
|
"OPERATOR"
;
const
AddOperator
=
observer
((
props
:
IAddOperator
)
=>
{
const
{
pageType
,
setPageType
,
detailsId
}
=
props
;
const
{
pageType
,
setPageType
,
detailsId
,
getList
}
=
props
;
const
Message
=
useMessage
();
/** 创建类型 BATCH - 批算子; FLOW - 流算子*/
...
...
@@ -100,8 +101,6 @@ const AddOperator = observer((props: IAddOperator) => {
];
},
[]);
/** 获取详情数据 */
/** 表单数据 */
const
changeFormData
=
useCallback
(
(
val
:
IOperatorAddFormData
)
=>
{
...
...
@@ -132,6 +131,7 @@ const AddOperator = observer((props: IAddOperator) => {
description
,
envId
,
});
setCommand
(
Base64
.
decode
(
command
));
/** 有envId 就是基于应用环境创建的 */
if
(
type
===
"BATCH"
)
{
...
...
@@ -151,6 +151,17 @@ const AddOperator = observer((props: IAddOperator) => {
},
});
/** 保存修改算子 */
const
{
run
:
runSaveOperator
}
=
useMyRequest
(
saveOperator
,
{
onSuccess
:
(
res
:
any
)
=>
{
if
(
res
?.
message
===
"success"
)
{
Message
.
success
(
"构建成功"
);
setPageType
(
""
);
getList
();
}
},
});
useEffect
(()
=>
{
if
(
!
detailsId
)
return
;
fetchOperatorDetail
(
detailsId
);
...
...
@@ -161,15 +172,15 @@ const AddOperator = observer((props: IAddOperator) => {
console
.
log
(
batchBuildType
,
"batchBuildType"
);
if
(
batchBuildType
===
"OPERATOR"
)
return
;
if
(
code
===
""
)
{
resultError
=
"
请输入参数配置!"
;
resultError
=
"请输入参数配置!"
;
}
try
{
result
=
JSON
.
stringify
(
JSON
.
parse
(
code
),
null
,
"
\
t"
);
if
(
typeof
result
===
"string"
)
{
setCode
(
result
);
const
checkErrorArr
=
checkParamsConfig
(
result
);
console
.
log
(
checkErrorArr
,
"checkErrorArr"
);
if
(
checkErrorArr
.
length
)
{
setParametersError
(
"参数配置不正确!"
);
resultError
=
"参数配置不正确!"
;
const
codeDom
=
document
.
getElementById
(
"paramsConfig"
);
const
all
=
codeDom
?.
getElementsByClassName
(
"cm-line"
);
...
...
@@ -189,11 +200,10 @@ const AddOperator = observer((props: IAddOperator) => {
}
}
} catch (error) {
setParametersError("JSON格式不正确!");
resultError = "JSON格式不正确!";
console.log("JSON格式不正确!");
}
setParametersError(resultError || "");
return resultError;
}, [batchBuildType, code]);
...
...
@@ -242,6 +252,7 @@ const AddOperator = observer((props: IAddOperator) => {
}
const params = {
...(detailsId ? detailInfo : {}),
...formData,
...(batchBuildType === "ENVIRONMENT" && taskType === "BATCH"
? { command: Base64.encode(command) }
...
...
@@ -259,23 +270,19 @@ const AddOperator = observer((props: IAddOperator) => {
}
console.log(params, "params");
saveOperator(params).then((res: any) => {
if (res?.message === "success") {
Message.success("构建成功");
} else {
Message.success(res?.message || "构建失败");
}
});
runSaveOperator(params, detailsId ? true : false);
}, [
Message,
batchBuildType,
checkStatus,
code,
command,
detailInfo,
detailsId,
formData,
handleCheck,
operatorList,
paramsConfigBlur,
runSaveOperator,
taskType,
]);
...
...
@@ -334,6 +341,7 @@ const AddOperator = observer((props: IAddOperator) => {
helperText={
formErrors?.title ? "" : "15字符以内,仅限字母、数字、中文"
}
disabled={!!detailsId}
placeholder="请输入算子名称"
value={formData?.title}
onChange={(e) => {
...
...
@@ -370,6 +378,7 @@ const AddOperator = observer((props: IAddOperator) => {
>
<MySelect
fullWidth
disabled={!!detailsId}
options={productListStore?.productList || []}
value={formData?.productId}
onChange={(e) => {
...
...
@@ -450,7 +459,6 @@ const AddOperator = observer((props: IAddOperator) => {
<Code
id="paramsConfig"
value={code}
// placeholder="dd"
onChange={(e: string) => {
setCode(e);
}}
...
...
src/views/ResourceCenter/UserResources/WorkflowOperator/index.tsx
View file @
7b01a920
...
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-17 14:35:11
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-10-2
4 20:40:16
* @LastEditTime: 2022-10-2
5 20:53:24
* @FilePath: /bkunyun/src/views/ResourceCenter/UserResources/WorkflowOperator/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
...
...
@@ -143,6 +143,7 @@ const WorkflowOperator = observer(() => {
</
div
>
{
pageType
&&
(
<
AddOperator
getList=
{
newGetList
}
detailsId=
{
detailsId
}
setPageType=
{
setPageType
}
pageType=
{
pageType
}
...
...
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