dynamic machines
parent
2837ec71c7
commit
b16b26ca56
|
@ -10,13 +10,15 @@ import {
|
|||
Tag,
|
||||
notification,
|
||||
} from "antd";
|
||||
import { GetUuid } from "../../../utils";
|
||||
import { GetUuid, myFetch } from "../../../utils";
|
||||
import { InfoCircleOutlined } from "@ant-design/icons";
|
||||
import TextArea from "antd/es/input/TextArea";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useWebSocketContext } from "../../../Contexts/WebSocketContext";
|
||||
import { useGroupTasksContext } from "../../../Contexts/GroupTasksContext";
|
||||
import { SentMessagesCommands } from "../../../Handlers/WebSocketMessageHandler";
|
||||
import { useEffect, useState } from "react";
|
||||
import { MyUserAvatar } from "../../../Components/MyAvatar";
|
||||
|
||||
export default function GroupTypeSelectionModal({
|
||||
isOpen,
|
||||
|
@ -219,6 +221,62 @@ export default function GroupTypeSelectionModal({
|
|||
);
|
||||
}
|
||||
|
||||
function SelectMachineComponent({ t, globalInput }) {
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [options, setOptions] = useState([]);
|
||||
|
||||
useEffect(() => {
|
||||
console.log("useEffect");
|
||||
|
||||
setLoading(true);
|
||||
|
||||
myFetch("/machines", "POST", {}).then((data) => {
|
||||
console.log("data", data);
|
||||
|
||||
const processedOptions = {};
|
||||
|
||||
data.forEach((item, index) => {
|
||||
const partName = item.part_detail.Name;
|
||||
|
||||
if (!processedOptions[partName]) {
|
||||
processedOptions[partName] = [];
|
||||
}
|
||||
|
||||
console.log("item.part_detail.Name", item.part_detail.Name);
|
||||
|
||||
processedOptions[partName].push({
|
||||
key: item.part_detail.Name + "-" + index,
|
||||
label: JSON.parse(item.Notes).displayName,
|
||||
value: index,
|
||||
});
|
||||
});
|
||||
|
||||
const finalOptions = Object.keys(processedOptions).map(
|
||||
(groupName, index) => ({
|
||||
key: groupName + index,
|
||||
label: groupName,
|
||||
options: processedOptions[groupName],
|
||||
})
|
||||
);
|
||||
|
||||
setOptions(finalOptions);
|
||||
|
||||
setLoading(false);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Select
|
||||
loading={loading}
|
||||
placeholder={t("groupTasks.groupTypeSelectionModal.select.placeholder")}
|
||||
style={{ width: "100%" }}
|
||||
id={globalInput.parameterName}
|
||||
options={options}
|
||||
onSelect={(value) => console.log("onSelect", value)}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
function GroupGlobalInputs({
|
||||
categoryGroup,
|
||||
currentSelectedModalGroupType,
|
||||
|
@ -284,6 +342,20 @@ function GroupGlobalInputs({
|
|||
</Form.Item>
|
||||
);
|
||||
break;
|
||||
case "select_machine":
|
||||
console.log("globalInput", globalInput);
|
||||
|
||||
elements.push(
|
||||
<Form.Item
|
||||
key={"fitem-" + globalInput.parameterName}
|
||||
label={getLabel(globalInput.displayName)}
|
||||
required
|
||||
>
|
||||
<SelectMachineComponent t={t} globalInput={globalInput} />
|
||||
</Form.Item>
|
||||
);
|
||||
break;
|
||||
|
||||
default:
|
||||
notificationApi["error"]({
|
||||
message: t(
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { Button, Col, Popconfirm, Result, Row } from "antd";
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useEffect, useState } from "react";
|
||||
import GroupTasksViewModal from "./GroupTasksViewModal";
|
||||
import GroupTypeSelectionModal from "./GroupTypeSelectionModal";
|
||||
import GroupTaskTableList from "./GroupTasksTableList";
|
||||
import { AppStyle, Constants, hasPermission, myFetch } from "../../../utils";
|
||||
import { Constants, hasPermission, myFetch } from "../../../utils";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { ReloadOutlined } from "@ant-design/icons";
|
||||
import { useGroupTasksContext } from "../../../Contexts/GroupTasksContext";
|
||||
|
|
Loading…
Reference in New Issue