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
Hide 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 @@
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-19 17:09:23
* @Date: 2022-10-19 17:09:23
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditors: 吴永生 15770852798@163.com
* @LastEditTime: 2022-10-25
18:23:55
* @LastEditTime: 2022-10-25
20:26:42
* @FilePath: /bkunyun/src/api/resourceCenter.ts
* @FilePath: /bkunyun/src/api/resourceCenter.ts
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @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}) => {
...
@@ -115,9 +115,9 @@ const getWorkflowspecList = (params: {productId?: string, title?: string}) => {
// API_WORKFLOWSPEC_LIST
// API_WORKFLOWSPEC_LIST
// 新增应用环境
// 新增应用环境
const
saveOperator
=
(
params
:
any
)
=>
{
const
saveOperator
=
(
params
:
any
,
isEdit
:
boolean
)
=>
{
return
request
({
return
request
({
url
:
Api
.
API_SAVE_OPERATOR
,
url
:
`
${
Api
.
API_SAVE_OPERATOR
}
?isEdit=
${
isEdit
}
`
,
method
:
"post"
,
method
:
"post"
,
data
:
params
,
data
:
params
,
});
});
...
...
src/components/CommonComponents/Code/index.tsx
View file @
7b01a920
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-20 19:45:32
* @Date: 2022-10-20 19:45:32
* @LastEditors: 吴永生 15770852798@163.com
* @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
* @FilePath: /bkunyun/src/components/CommonComponents/Code/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
...
@@ -36,11 +36,11 @@ const Code = (props: ICodeType) => {
...
@@ -36,11 +36,11 @@ const Code = (props: ICodeType) => {
);
);
};
};
const
handleEqual
=
(
prvProps
:
ICodeType
,
nextProps
:
ICodeType
)
=>
{
//
const handleEqual = (prvProps: ICodeType, nextProps: ICodeType) => {
if
(
isEqual
(
prvProps
,
nextProps
))
{
//
if (isEqual(prvProps, nextProps)) {
return
true
;
//
return true;
}
//
}
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 @@
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-18 16:12:55
* @Date: 2022-10-18 16:12:55
* @LastEditors: 吴永生 15770852798@163.com
* @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
* @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
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
...
@@ -43,12 +43,13 @@ interface IAddOperator {
...
@@ -43,12 +43,13 @@ interface IAddOperator {
pageType
:
string
;
pageType
:
string
;
setPageType
:
(
val
:
string
)
=>
void
;
setPageType
:
(
val
:
string
)
=>
void
;
detailsId
:
string
;
detailsId
:
string
;
getList
:
()
=>
void
;
}
}
type
IBuildType
=
"ENVIRONMENT"
|
"OPERATOR"
;
type
IBuildType
=
"ENVIRONMENT"
|
"OPERATOR"
;
const
AddOperator
=
observer
((
props
:
IAddOperator
)
=>
{
const
AddOperator
=
observer
((
props
:
IAddOperator
)
=>
{
const
{
pageType
,
setPageType
,
detailsId
}
=
props
;
const
{
pageType
,
setPageType
,
detailsId
,
getList
}
=
props
;
const
Message
=
useMessage
();
const
Message
=
useMessage
();
/** 创建类型 BATCH - 批算子; FLOW - 流算子*/
/** 创建类型 BATCH - 批算子; FLOW - 流算子*/
...
@@ -100,8 +101,6 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -100,8 +101,6 @@ const AddOperator = observer((props: IAddOperator) => {
];
];
},
[]);
},
[]);
/** 获取详情数据 */
/** 表单数据 */
/** 表单数据 */
const
changeFormData
=
useCallback
(
const
changeFormData
=
useCallback
(
(
val
:
IOperatorAddFormData
)
=>
{
(
val
:
IOperatorAddFormData
)
=>
{
...
@@ -132,6 +131,7 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -132,6 +131,7 @@ const AddOperator = observer((props: IAddOperator) => {
description
,
description
,
envId
,
envId
,
});
});
setCommand
(
Base64
.
decode
(
command
));
/** 有envId 就是基于应用环境创建的 */
/** 有envId 就是基于应用环境创建的 */
if
(
type
===
"BATCH"
)
{
if
(
type
===
"BATCH"
)
{
...
@@ -151,6 +151,17 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -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
(()
=>
{
useEffect
(()
=>
{
if
(
!
detailsId
)
return
;
if
(
!
detailsId
)
return
;
fetchOperatorDetail
(
detailsId
);
fetchOperatorDetail
(
detailsId
);
...
@@ -161,15 +172,15 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -161,15 +172,15 @@ const AddOperator = observer((props: IAddOperator) => {
console
.
log
(
batchBuildType
,
"batchBuildType"
);
console
.
log
(
batchBuildType
,
"batchBuildType"
);
if
(
batchBuildType
===
"OPERATOR"
)
return
;
if
(
batchBuildType
===
"OPERATOR"
)
return
;
if
(
code
===
""
)
{
if
(
code
===
""
)
{
resultError
=
"
请输入参数配置!"
;
resultError
=
"请输入参数配置!"
;
}
}
try
{
try
{
result
=
JSON
.
stringify
(
JSON
.
parse
(
code
),
null
,
"
\
t"
);
result
=
JSON
.
stringify
(
JSON
.
parse
(
code
),
null
,
"
\
t"
);
if
(
typeof
result
===
"string"
)
{
if
(
typeof
result
===
"string"
)
{
setCode
(
result
);
setCode
(
result
);
const
checkErrorArr
=
checkParamsConfig
(
result
);
const
checkErrorArr
=
checkParamsConfig
(
result
);
console
.
log
(
checkErrorArr
,
"checkErrorArr"
);
if
(
checkErrorArr
.
length
)
{
if
(
checkErrorArr
.
length
)
{
setParametersError
(
"参数配置不正确!"
);
resultError
=
"参数配置不正确!"
;
resultError
=
"参数配置不正确!"
;
const
codeDom
=
document
.
getElementById
(
"paramsConfig"
);
const
codeDom
=
document
.
getElementById
(
"paramsConfig"
);
const
all
=
codeDom
?.
getElementsByClassName
(
"cm-line"
);
const
all
=
codeDom
?.
getElementsByClassName
(
"cm-line"
);
...
@@ -189,11 +200,10 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -189,11 +200,10 @@ const AddOperator = observer((props: IAddOperator) => {
}
}
}
}
} catch (error) {
} catch (error) {
setParametersError("JSON格式不正确!");
resultError = "JSON格式不正确!";
resultError = "JSON格式不正确!";
console.log("JSON格式不正确!");
console.log("JSON格式不正确!");
}
}
setParametersError(resultError || "");
return resultError;
return resultError;
}, [batchBuildType, code]);
}, [batchBuildType, code]);
...
@@ -242,6 +252,7 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -242,6 +252,7 @@ const AddOperator = observer((props: IAddOperator) => {
}
}
const params = {
const params = {
...(detailsId ? detailInfo : {}),
...formData,
...formData,
...(batchBuildType === "ENVIRONMENT" && taskType === "BATCH"
...(batchBuildType === "ENVIRONMENT" && taskType === "BATCH"
? { command: Base64.encode(command) }
? { command: Base64.encode(command) }
...
@@ -259,23 +270,19 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -259,23 +270,19 @@ const AddOperator = observer((props: IAddOperator) => {
}
}
console.log(params, "params");
console.log(params, "params");
saveOperator(params).then((res: any) => {
runSaveOperator(params, detailsId ? true : false);
if (res?.message === "success") {
Message.success("构建成功");
} else {
Message.success(res?.message || "构建失败");
}
});
}, [
}, [
Message,
batchBuildType,
batchBuildType,
checkStatus,
checkStatus,
code,
code,
command,
command,
detailInfo,
detailsId,
formData,
formData,
handleCheck,
handleCheck,
operatorList,
operatorList,
paramsConfigBlur,
paramsConfigBlur,
runSaveOperator,
taskType,
taskType,
]);
]);
...
@@ -334,6 +341,7 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -334,6 +341,7 @@ const AddOperator = observer((props: IAddOperator) => {
helperText={
helperText={
formErrors?.title ? "" : "15字符以内,仅限字母、数字、中文"
formErrors?.title ? "" : "15字符以内,仅限字母、数字、中文"
}
}
disabled={!!detailsId}
placeholder="请输入算子名称"
placeholder="请输入算子名称"
value={formData?.title}
value={formData?.title}
onChange={(e) => {
onChange={(e) => {
...
@@ -370,6 +378,7 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -370,6 +378,7 @@ const AddOperator = observer((props: IAddOperator) => {
>
>
<MySelect
<MySelect
fullWidth
fullWidth
disabled={!!detailsId}
options={productListStore?.productList || []}
options={productListStore?.productList || []}
value={formData?.productId}
value={formData?.productId}
onChange={(e) => {
onChange={(e) => {
...
@@ -450,7 +459,6 @@ const AddOperator = observer((props: IAddOperator) => {
...
@@ -450,7 +459,6 @@ const AddOperator = observer((props: IAddOperator) => {
<Code
<Code
id="paramsConfig"
id="paramsConfig"
value={code}
value={code}
// placeholder="dd"
onChange={(e: string) => {
onChange={(e: string) => {
setCode(e);
setCode(e);
}}
}}
...
...
src/views/ResourceCenter/UserResources/WorkflowOperator/index.tsx
View file @
7b01a920
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
* @Author: 吴永生 15770852798@163.com
* @Author: 吴永生 15770852798@163.com
* @Date: 2022-10-17 14:35:11
* @Date: 2022-10-17 14:35:11
* @LastEditors: 吴永生 15770852798@163.com
* @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
* @FilePath: /bkunyun/src/views/ResourceCenter/UserResources/WorkflowOperator/index.tsx
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/
*/
...
@@ -143,6 +143,7 @@ const WorkflowOperator = observer(() => {
...
@@ -143,6 +143,7 @@ const WorkflowOperator = observer(() => {
</
div
>
</
div
>
{
pageType
&&
(
{
pageType
&&
(
<
AddOperator
<
AddOperator
getList=
{
newGetList
}
detailsId=
{
detailsId
}
detailsId=
{
detailsId
}
setPageType=
{
setPageType
}
setPageType=
{
setPageType
}
pageType=
{
pageType
}
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