Commit d149ef25 authored by chenshouchao's avatar chenshouchao

Merge branch 'feat-20221012-environment' into 'release'

cn-feat: 新增流式环境增加字段script、样式调整

See merge request !154
parents 68012927 ff63dd42
...@@ -15,7 +15,8 @@ type addActorenvBuildenvParams = { ...@@ -15,7 +15,8 @@ type addActorenvBuildenvParams = {
baseEnvId: string, baseEnvId: string,
type: "BATCH" | "FLOW", type: "BATCH" | "FLOW",
filePaths: Array<string>, filePaths: Array<string>,
bashScript: string, bashScript?: string,
script?: string,
computeType: string, computeType: string,
publicProjectId: string, publicProjectId: string,
} }
......
...@@ -203,7 +203,7 @@ const SaveOperator = (props: IProps) => { ...@@ -203,7 +203,7 @@ const SaveOperator = (props: IProps) => {
style={{ style={{
position: "absolute", position: "absolute",
fontSize: "14px", fontSize: "14px",
bottom: "7px", top: "96px",
right: "12px", right: "12px",
color: description.length >= 300 ? "#d32f2f" : "#C2C6CC", color: description.length >= 300 ? "#d32f2f" : "#C2C6CC",
}} }}
......
...@@ -358,7 +358,7 @@ const BaseInfo = observer(() => { ...@@ -358,7 +358,7 @@ const BaseInfo = observer(() => {
style={{ style={{
fontSize: "14px", fontSize: "14px",
position: "absolute", position: "absolute",
bottom: "7px", top: "96px",
right: "12px", right: "12px",
color: projectInfo.desc.length >= 100 ? "#d32f2f" : "#C2C6CC", color: projectInfo.desc.length >= 100 ? "#d32f2f" : "#C2C6CC",
}} }}
......
...@@ -224,7 +224,7 @@ const AddProject = observer((props: IAddProjectProps) => { ...@@ -224,7 +224,7 @@ const AddProject = observer((props: IAddProjectProps) => {
style={{ style={{
position: "absolute", position: "absolute",
fontSize: "14px", fontSize: "14px",
bottom: "7px", top: "96px",
right: "12px", right: "12px",
color: desc.length >= 300 ? "#d32f2f" : "#C2C6CC", color: desc.length >= 300 ? "#d32f2f" : "#C2C6CC",
}} }}
......
...@@ -31,7 +31,6 @@ ...@@ -31,7 +31,6 @@
.content { .content {
display: flex; display: flex;
border-radius: 4px; border-radius: 4px;
margin-bottom: 24px;
height: 580px; height: 580px;
} }
.form { .form {
...@@ -51,6 +50,22 @@ ...@@ -51,6 +50,22 @@
border-top-right-radius: 4px; border-top-right-radius: 4px;
border-bottom-right-radius: 4px; border-bottom-right-radius: 4px;
} }
.codeBox2 {
flex: 1;
display: flex;
flex-direction: column;
border-radius: 4px;
margin-top: 20px;
}
.codeBox2 .codeTitle {
border-top-right-radius: 4px;
border-top-left-radius: 4px;
}
.codeBox2 .code {
border-bottom-right-radius: 4px;
border-bottom-left-radius: 4px;
overflow: hidden;
}
.codeTitle { .codeTitle {
background-color: rgba(230, 233, 237, 1); background-color: rgba(230, 233, 237, 1);
padding: 11px 20px; padding: 11px 20px;
...@@ -143,3 +158,6 @@ ...@@ -143,3 +158,6 @@
line-height: 20px; line-height: 20px;
margin-top: 12px; margin-top: 12px;
} }
.button {
margin-top: 24px;
}
...@@ -48,6 +48,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -48,6 +48,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
const [envList, setEnvList] = useState<Array<any>>([]); // 基础环境列表 和taskType环境类型有关 const [envList, setEnvList] = useState<Array<any>>([]); // 基础环境列表 和taskType环境类型有关
const [progress, setProgress] = useState("0%"); // 上传压缩包进度 const [progress, setProgress] = useState("0%"); // 上传压缩包进度
const [code, setCode] = useState(""); // 脚本内容 const [code, setCode] = useState(""); // 脚本内容
const [flowCode, setFlowCode] = useState(""); // 脚本内容
const [codeWidth, setCodeWidth] = useState(0); const [codeWidth, setCodeWidth] = useState(0);
const [upload, setUpload] = useState<any>(() => {}); // 上传压缩包实例 用于暂停(取消上传)upload.abort(true); const [upload, setUpload] = useState<any>(() => {}); // 上传压缩包实例 用于暂停(取消上传)upload.abort(true);
const [nameHelper, setNameHelper] = useState({ const [nameHelper, setNameHelper] = useState({
...@@ -270,6 +271,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -270,6 +271,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
}; };
const handleSubmit = () => { const handleSubmit = () => {
if (taskType === "BATCH") {
if ( if (
!checkName(name) && !checkName(name) &&
!checkDesc(desc) && !checkDesc(desc) &&
...@@ -290,6 +292,29 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -290,6 +292,29 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
} else { } else {
Message.error("请完善环境信息"); Message.error("请完善环境信息");
} }
} else {
if (
!checkName(name) &&
!checkDesc(desc) &&
!checkFile(filePaths) &&
baseEnvId &&
flowCode
) {
addActorenvBuildenvFn({
title: name,
desc,
baseEnvId,
type: taskType,
filePaths,
bashScript: Base64.encode(code),
script: Base64.encode(flowCode),
publicProjectId,
computeType,
});
} else {
Message.error("请完善环境信息");
}
}
}; };
const handleAbort = () => { const handleAbort = () => {
...@@ -358,7 +383,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -358,7 +383,7 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
style={{ style={{
position: "absolute", position: "absolute",
fontSize: "14px", fontSize: "14px",
bottom: "7px", top: "96px",
right: "12px", right: "12px",
color: desc.length >= 300 ? "#d32f2f" : "#C2C6CC", color: desc.length >= 300 ? "#d32f2f" : "#C2C6CC",
}} }}
...@@ -462,7 +487,10 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -462,7 +487,10 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
</div> </div>
<div className={style.codeBox}> <div className={style.codeBox}>
<div className={style.codeTitle}> <div className={style.codeTitle}>
{taskType === "BATCH" ? "Shell脚本" : "Python脚本"} Shell脚本
{taskType === "BATCH" && (
<span className={style.required}>*</span>
)}
</div> </div>
<div className={style.code} id="addEnvironmentCode"> <div className={style.code} id="addEnvironmentCode">
<Code <Code
...@@ -474,6 +502,22 @@ const AddEnvironment = (props: IAddEnvironmentProps) => { ...@@ -474,6 +502,22 @@ const AddEnvironment = (props: IAddEnvironmentProps) => {
</div> </div>
</div> </div>
</div> </div>
{taskType === "FLOW" && (
<div className={style.codeBox2}>
<div className={style.codeTitle}>
Python脚本
<span className={style.required}>*</span>
</div>
<div className={style.code} id="addEnvironmentCode">
<Code
value={flowCode}
onChange={(e: string) => setFlowCode(e)}
height="535px"
width={`${codeWidth + 368}px`}
/>
</div>
</div>
)}
<div className={style.button}> <div className={style.button}>
<MyButton <MyButton
text="开始构建" text="开始构建"
......
...@@ -16,6 +16,7 @@ import WorkFlowEdit from "@/views/WorkFlowEdit"; ...@@ -16,6 +16,7 @@ import WorkFlowEdit from "@/views/WorkFlowEdit";
import { useMessage } from "@/components/MySnackbar"; import { useMessage } from "@/components/MySnackbar";
import TemplateDetail from "./TemplateDetail"; import TemplateDetail from "./TemplateDetail";
import style from "./index.module.css"; import style from "./index.module.css";
import NoData from "@/components/BusinessComponents/NoData";
const UserResourcesTemplate = observer(() => { const UserResourcesTemplate = observer(() => {
const [title, setTitle] = useState(""); const [title, setTitle] = useState("");
...@@ -162,6 +163,7 @@ const UserResourcesTemplate = observer(() => { ...@@ -162,6 +163,7 @@ const UserResourcesTemplate = observer(() => {
</div> </div>
</div> </div>
<div className={style.tableBox}> <div className={style.tableBox}>
{list.length === 0 && <NoData text="暂无相关模板"></NoData>}
<CardTable <CardTable
data={list} data={list}
renderItem={renderItem} renderItem={renderItem}
......
...@@ -253,7 +253,7 @@ const SaveCustomTemplate = (props: IProps) => { ...@@ -253,7 +253,7 @@ const SaveCustomTemplate = (props: IProps) => {
style={{ style={{
position: "absolute", position: "absolute",
fontSize: "14px", fontSize: "14px",
bottom: "7px", top: "96px",
right: "12px", right: "12px",
color: description.length >= 300 ? "#d32f2f" : "#C2C6CC", color: description.length >= 300 ? "#d32f2f" : "#C2C6CC",
}} }}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment