Commit 1349567e authored by chenshouchao's avatar chenshouchao

feat: 队列选择器开发完成

parent 4e6dcdf1
...@@ -25,6 +25,9 @@ type IQueueSelectProps = { ...@@ -25,6 +25,9 @@ type IQueueSelectProps = {
onChange: any; onChange: any;
originalCpuList: Array<IQueueLi>; originalCpuList: Array<IQueueLi>;
originalGpuList: Array<IQueueLi>; originalGpuList: Array<IQueueLi>;
error?: boolean;
helperText?: string;
disabled?: boolean;
}; };
type IMemoryLi = { type IMemoryLi = {
...@@ -54,7 +57,15 @@ const queueTypes = [ ...@@ -54,7 +57,15 @@ const queueTypes = [
]; ];
const QueueSelect = (props: IQueueSelectProps) => { const QueueSelect = (props: IQueueSelectProps) => {
const { value, onChange, originalCpuList, originalGpuList } = props; const {
value,
onChange,
originalCpuList,
originalGpuList,
error,
helperText,
disabled,
} = props;
const Message = useMessage(); const Message = useMessage();
const [activeId, setActiveId] = useState(""); const [activeId, setActiveId] = useState("");
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
...@@ -133,6 +144,29 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -133,6 +144,29 @@ const QueueSelect = (props: IQueueSelectProps) => {
}, },
]; ];
const gpuHeadCells = [
{
id: "type",
label: "类型",
width: 510,
},
{
id: "gpuNumRender",
label: "节点卡数",
width: 100,
},
{
id: "coreNumRender",
label: "节点核数",
width: 100,
},
{
id: "gpuMemoryRender",
label: "节点内存容量",
width: 100,
},
];
const renderType = (item: IShowCPULi) => { const renderType = (item: IShowCPULi) => {
return ( return (
<div className={style.cpuType}> <div className={style.cpuType}>
...@@ -149,6 +183,14 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -149,6 +183,14 @@ const QueueSelect = (props: IQueueSelectProps) => {
return item.coreNum + "核"; return item.coreNum + "核";
}; };
const renderGpuNum = (item: IQueueLi) => {
return item.gpuNum + "卡";
};
const renderGpuMemory = (item: IQueueLi) => {
return item.memory + "GB";
};
const setMemory = (id: string) => { const setMemory = (id: string) => {
const copyShowCpuList: Array<IShowCPULi> = cloneDeep(showCpuList); const copyShowCpuList: Array<IShowCPULi> = cloneDeep(showCpuList);
const selectIndex = copyShowCpuList.findIndex((item) => { const selectIndex = copyShowCpuList.findIndex((item) => {
...@@ -162,8 +204,6 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -162,8 +204,6 @@ const QueueSelect = (props: IQueueSelectProps) => {
setActiveId(id); setActiveId(id);
}, 10); }, 10);
setShowCpuList(copyShowCpuList); setShowCpuList(copyShowCpuList);
console.log(id);
console.log(copyShowCpuList);
}; };
const renderMemory = (item: IShowCPULi) => { const renderMemory = (item: IShowCPULi) => {
...@@ -189,7 +229,6 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -189,7 +229,6 @@ const QueueSelect = (props: IQueueSelectProps) => {
}; };
const handleRow = (e: any) => { const handleRow = (e: any) => {
console.log(e);
setActiveId(e.id); setActiveId(e.id);
}; };
...@@ -226,7 +265,14 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -226,7 +265,14 @@ const QueueSelect = (props: IQueueSelectProps) => {
return ( return (
<> <>
<MyInput value={getTitle()} onClick={() => handleOpen()}></MyInput> <MyInput
placeholder="请选择硬件队列"
value={getTitle()}
onClick={() => handleOpen()}
error={error}
helperText={helperText}
disabled={disabled}
></MyInput>
{open && ( {open && (
<MyDialog <MyDialog
open={open} open={open}
...@@ -267,13 +313,14 @@ const QueueSelect = (props: IQueueSelectProps) => { ...@@ -267,13 +313,14 @@ const QueueSelect = (props: IQueueSelectProps) => {
)} )}
{queueType === "GPU" && ( {queueType === "GPU" && (
<MyTable <MyTable
rows={originalGpuList.map((item) => ({ rows={originalGpuList.map((item: any) => ({
...item, ...item,
// type: renderType(item), type: renderType(item),
// coreNumRender: renderCoreNum(item), gpuNumRender: renderGpuNum(item),
// memoryRender: renderMemory(item), coreNumRender: renderCoreNum(item),
gpuMemoryRender: renderGpuMemory(item),
}))} }))}
headCells={cpuHeadCells} headCells={gpuHeadCells}
fixedHead={true} fixedHead={true}
handleRow={(e: any) => handleRow(e)} handleRow={(e: any) => handleRow(e)}
activeId={activeId} activeId={activeId}
......
...@@ -13,6 +13,7 @@ type projectInfo = { ...@@ -13,6 +13,7 @@ type projectInfo = {
desc?: string; desc?: string;
projectRole?: string; projectRole?: string;
filetoken?: string; filetoken?: string;
zoneId?: string;
}; };
type productInfo = { type productInfo = {
......
import moment from "moment"; import moment from "moment";
import classnames from "classnames"; import classnames from "classnames";
import { useState, useMemo, useImperativeHandle } from "react"; import { useState, useMemo, useImperativeHandle, useEffect } from "react";
import QueueSelect from "@/components/BusinessComponents/QueueSelect";
import useMyRequest from "@/hooks/useMyRequest";
import { getHardwreList } from "@/api/project_api";
import { IQueueLi } from "@/components/BusinessComponents/QueueSelect";
import { ITemplateConfig, IRenderTasks } from "../interface"; import { ITemplateConfig, IRenderTasks } from "../interface";
import MyInput from "@/components/mui/MyInput"; import MyInput from "@/components/mui/MyInput";
import FileSelect, { import FileSelect, {
...@@ -24,12 +28,42 @@ type ConfigFormProps = { ...@@ -24,12 +28,42 @@ type ConfigFormProps = {
setParameter: any; setParameter: any;
onRef?: React.Ref<any>; onRef?: React.Ref<any>;
setExternalSelectedNodeId: (val: string) => void; setExternalSelectedNodeId: (val: string) => void;
zoneId: string;
}; };
const ConfigForm = (props: ConfigFormProps) => { const ConfigForm = (props: ConfigFormProps) => {
const { templateConfigInfo, setParameter, setExternalSelectedNodeId } = props; const {
templateConfigInfo,
setParameter,
setExternalSelectedNodeId,
zoneId,
} = props;
const [name, setName] = useState<string>(""); // 任务名称 const [name, setName] = useState<string>(""); // 任务名称
const [fileSelectType, setFileSelectType] = useState<FileSelectType>("path"); const [fileSelectType, setFileSelectType] = useState<FileSelectType>("path");
const [cpuList, setCpuList] = useState<Array<IQueueLi>>([]);
const [gpuList, setGpuList] = useState<Array<IQueueLi>>([]);
const { run: getHardwreListFn } = useMyRequest(getHardwreList, {
onSuccess: (res, params) => {
if (params[0].computeType === "CPU") {
setCpuList(res.data);
} else {
setGpuList(res.data);
}
},
});
useEffect(() => {
getHardwreListFn({
zoneId,
computeType: "CPU",
});
}, [getHardwreListFn, zoneId]);
useEffect(() => {
getHardwreListFn({
zoneId,
computeType: "GPU",
});
}, [getHardwreListFn, zoneId]);
const [nameHelp, setNameHelp] = useState({ const [nameHelp, setNameHelp] = useState({
error: false, error: false,
...@@ -209,10 +243,7 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -209,10 +243,7 @@ const ConfigForm = (props: ConfigFormProps) => {
{parameter.classTypeName} {parameter.classTypeName}
</span> </span>
</div> </div>
<MyTooltip <MyTooltip title={parameter.description} placement="right">
title={parameter.description}
placement="right"
>
<div className={styles.parameterContent}> <div className={styles.parameterContent}>
{(parameter.domType || "").toLowerCase() === "file" && ( {(parameter.domType || "").toLowerCase() === "file" && (
<MyInput <MyInput
...@@ -283,6 +314,26 @@ const ConfigForm = (props: ConfigFormProps) => { ...@@ -283,6 +314,26 @@ const ConfigForm = (props: ConfigFormProps) => {
size="medium" size="medium"
></MyInput> ></MyInput>
)} )}
{(parameter.domType || "").toLowerCase() === "partition" && (
<QueueSelect
value={parameter.value || ""}
onChange={(e: any) =>
handleParameterChange(
{
target: {
value: e,
},
},
taskId,
parameter.name || ""
)
}
originalCpuList={cpuList}
originalGpuList={gpuList}
error={parameter.error || false}
helperText={parameter.helperText}
></QueueSelect>
)}
{(parameter.domType || "").toLowerCase() === "input" && ( {(parameter.domType || "").toLowerCase() === "input" && (
<MyInput <MyInput
onFocus={() => { onFocus={() => {
......
...@@ -34,6 +34,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -34,6 +34,7 @@ const ProjectSubmitWork = observer(() => {
const Message = useMessage(); const Message = useMessage();
const { currentProjectStore } = useStores(); const { currentProjectStore } = useStores();
const projectId = toJS(currentProjectStore.currentProjectInfo.id); const projectId = toJS(currentProjectStore.currentProjectInfo.id);
const zoneId = toJS(currentProjectStore.currentProjectInfo.zoneId);
const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID const productId = toJS(currentProjectStore.currentProductInfo.id); // 产品ID
const [templateConfigInfo, setTemplateConfigInfo] = const [templateConfigInfo, setTemplateConfigInfo] =
useState<ITemplateConfig>(); useState<ITemplateConfig>();
...@@ -319,6 +320,7 @@ const ProjectSubmitWork = observer(() => { ...@@ -319,6 +320,7 @@ const ProjectSubmitWork = observer(() => {
templateConfigInfo={templateConfigInfo} templateConfigInfo={templateConfigInfo}
setParameter={setParameter} setParameter={setParameter}
setExternalSelectedNodeId={setExternalSelectedNodeId} setExternalSelectedNodeId={setExternalSelectedNodeId}
zoneId={zoneId as string}
/> />
</div> </div>
)} )}
......
...@@ -57,7 +57,6 @@ const ProjectListPopper = observer((props: any) => { ...@@ -57,7 +57,6 @@ const ProjectListPopper = observer((props: any) => {
}; };
}); });
}, [projectList, name]); }, [projectList, name]);
console.log(list);
const handleProjectBox = (e: React.SyntheticEvent) => { const handleProjectBox = (e: React.SyntheticEvent) => {
setProjectListOpen(false); setProjectListOpen(false);
......
...@@ -2,6 +2,10 @@ import _ from "lodash"; ...@@ -2,6 +2,10 @@ import _ from "lodash";
import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import classNames from "classnames"; import classNames from "classnames";
import QueueSelect from "@/components/BusinessComponents/QueueSelect";
import useMyRequest from "@/hooks/useMyRequest";
import { getHardwreList } from "@/api/project_api";
import { IQueueLi } from "@/components/BusinessComponents/QueueSelect";
import { import {
ITask, ITask,
IParameter, IParameter,
...@@ -28,9 +32,10 @@ type IParameterSettingProps = { ...@@ -28,9 +32,10 @@ type IParameterSettingProps = {
templateConfigInfo: ITask[]; templateConfigInfo: ITask[];
taskId: string; taskId: string;
setTemplateConfigInfo: any; setTemplateConfigInfo: any;
zoneId: string;
}; };
const ParameterSetting = (props: IParameterSettingProps) => { const ParameterSetting = (props: IParameterSettingProps) => {
const { templateConfigInfo, setTemplateConfigInfo, taskId } = props; // 算子大数组 const { templateConfigInfo, setTemplateConfigInfo, taskId, zoneId } = props; // 算子大数组
const [isShowAllDese, setIsShowAllDese] = useState(false); // 是否展示全部描述 const [isShowAllDese, setIsShowAllDese] = useState(false); // 是否展示全部描述
const [fileSelectOpen, setFileSelectOpen] = useState(false); // 选择输出路径的弹窗显示控制 const [fileSelectOpen, setFileSelectOpen] = useState(false); // 选择输出路径的弹窗显示控制
const [fileSelectType, setFileSelectType] = useState<FileSelectType>("path"); const [fileSelectType, setFileSelectType] = useState<FileSelectType>("path");
...@@ -38,6 +43,31 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -38,6 +43,31 @@ const ParameterSetting = (props: IParameterSettingProps) => {
const resizeRef = useRef<HTMLDivElement>(null); const resizeRef = useRef<HTMLDivElement>(null);
const [activeParamsTab, setActiveParamsTab] = useState<string>(""); const [activeParamsTab, setActiveParamsTab] = useState<string>("");
const [cpuList, setCpuList] = useState<Array<IQueueLi>>([]);
const [gpuList, setGpuList] = useState<Array<IQueueLi>>([]);
const { run: getHardwreListFn } = useMyRequest(getHardwreList, {
onSuccess: (res, params) => {
if (params[0].computeType === "CPU") {
setCpuList(res.data);
} else {
setGpuList(res.data);
}
},
});
useEffect(() => {
getHardwreListFn({
zoneId,
computeType: "CPU",
});
}, [getHardwreListFn, zoneId]);
useEffect(() => {
getHardwreListFn({
zoneId,
computeType: "GPU",
});
}, [getHardwreListFn, zoneId]);
const size = useSize(resizeRef); const size = useSize(resizeRef);
// 文件夹路线选择器弹窗 // 文件夹路线选择器弹窗
...@@ -189,10 +219,7 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -189,10 +219,7 @@ const ParameterSetting = (props: IParameterSettingProps) => {
const renderInput = useCallback( const renderInput = useCallback(
(parameter: IParameter) => { (parameter: IParameter) => {
return ( return (
<MyTooltip <MyTooltip title={parameter.description} placement="right">
title={parameter.description}
placement="right"
>
<div> <div>
{(parameter.domType || "").toLowerCase() === "file" && ( {(parameter.domType || "").toLowerCase() === "file" && (
<MyInput <MyInput
...@@ -269,6 +296,26 @@ const ParameterSetting = (props: IParameterSettingProps) => { ...@@ -269,6 +296,26 @@ const ParameterSetting = (props: IParameterSettingProps) => {
disabled={parameter.parameterGroup === "out"} disabled={parameter.parameterGroup === "out"}
></MyInput> ></MyInput>
)} )}
{(parameter.domType || "").toLowerCase() === "partition" && (
<QueueSelect
value={parameter.value || ""}
onChange={(e: any) =>
handleParameterChange(
{
target: {
value: e,
},
},
parameter.name || ""
)
}
originalCpuList={cpuList}
originalGpuList={gpuList}
error={parameter.error || false}
helperText={parameter.helperText}
disabled={parameter.parameterGroup === "out"}
></QueueSelect>
)}
{(parameter.domType || "").toLowerCase() === "input" && ( {(parameter.domType || "").toLowerCase() === "input" && (
<MyInput <MyInput
value={parameter.defaultValue || ""} value={parameter.defaultValue || ""}
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
*/ */
import React, { useCallback, useEffect, useState, useMemo } from "react"; import React, { useCallback, useEffect, useState, useMemo } from "react";
import _ from "lodash"; import _ from "lodash";
import { useStores } from "@/store";
import { toJS } from "mobx";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import MyPopconfirm from "@/components/mui/MyPopconfirm"; import MyPopconfirm from "@/components/mui/MyPopconfirm";
...@@ -49,6 +51,8 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -49,6 +51,8 @@ const WorkFlowEdit = observer((props: IProps) => {
const Message = useMessage(); const Message = useMessage();
const [templateConfigInfo, setTemplateConfigInfo] = useState<ITask[]>([]); // 算子大数组 const [templateConfigInfo, setTemplateConfigInfo] = useState<ITask[]>([]); // 算子大数组
const [showCustomOperator, setShowCustomOperator] = useState(false); // 是否显示自定义算子 const [showCustomOperator, setShowCustomOperator] = useState(false); // 是否显示自定义算子
const { currentProjectStore } = useStores();
const zoneId = toJS(currentProjectStore.currentProjectInfo.zoneId);
const [saveFormDialog, setSaveFormDialog] = useState(false); // 保存弹窗显示与否控制 const [saveFormDialog, setSaveFormDialog] = useState(false); // 保存弹窗显示与否控制
const [title, setTitle] = useState(""); // 自定义模板名称 const [title, setTitle] = useState(""); // 自定义模板名称
const [version, setVersion] = useState("1.0.0"); // 自定义模板版本 const [version, setVersion] = useState("1.0.0"); // 自定义模板版本
...@@ -243,6 +247,7 @@ const WorkFlowEdit = observer((props: IProps) => { ...@@ -243,6 +247,7 @@ const WorkFlowEdit = observer((props: IProps) => {
templateConfigInfo={templateConfigInfo} templateConfigInfo={templateConfigInfo}
setTemplateConfigInfo={setTemplateConfigInfo} setTemplateConfigInfo={setTemplateConfigInfo}
taskId={selectTaskId || ""} taskId={selectTaskId || ""}
zoneId={zoneId as string}
/> />
)} )}
<div <div
......
...@@ -9,7 +9,6 @@ const QueueSelectDemo = () => { ...@@ -9,7 +9,6 @@ const QueueSelectDemo = () => {
const [cpuList, setCpuList] = useState<Array<IQueueLi>>([]); const [cpuList, setCpuList] = useState<Array<IQueueLi>>([]);
const [gpuList, setGpuList] = useState<Array<IQueueLi>>([]); const [gpuList, setGpuList] = useState<Array<IQueueLi>>([]);
const onChange = (e: any) => { const onChange = (e: any) => {
console.log(e);
setValue(e); setValue(e);
}; };
const { run } = useMyRequest(getHardwreList, { const { run } = useMyRequest(getHardwreList, {
...@@ -21,19 +20,6 @@ const QueueSelectDemo = () => { ...@@ -21,19 +20,6 @@ const QueueSelectDemo = () => {
} }
}, },
}); });
// computeType
// coreNum
// cpuName
// gpuName
// gpuNum
// id
// memory
// name
// originalPrice
// partition
// partitionId
// picUrl
// price
useEffect(() => { useEffect(() => {
run({ run({
zoneId: "CE-Z1", zoneId: "CE-Z1",
......
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