From dd894322442e7bd9958df17471059b7998d3fcc4 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 15 Oct 2023 15:50:53 +0200 Subject: [PATCH] jobs list --- public/locales/de/translation.json | 4 + public/locales/en/translation.json | 4 + .../Overview/GroupTasksViewModal.js | 2 +- src/Pages/Robotics/Robots/index.js | 97 ++++++++++++++++--- src/utils.js | 5 + 5 files changed, 99 insertions(+), 13 deletions(-) diff --git a/public/locales/de/translation.json b/public/locales/de/translation.json index 236dff8..f582a1a 100644 --- a/public/locales/de/translation.json +++ b/public/locales/de/translation.json @@ -166,6 +166,10 @@ "robotics": { "robots": { "header": "Roboter", + "button": { + "permitJoin": "Beitreten erlauben", + "disableJoin": "Beitreten deaktivieren" + }, "column": { "id": "ID", "type": "Typ", diff --git a/public/locales/en/translation.json b/public/locales/en/translation.json index 850740a..e8b8c3d 100644 --- a/public/locales/en/translation.json +++ b/public/locales/en/translation.json @@ -166,6 +166,10 @@ "robotics": { "robots": { "header": "Robots", + "button": { + "permitJoin": "Permit Join", + "disableJoin": "Disable Join" + }, "column": { "id": "ID", "type": "Type", diff --git a/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js b/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js index 12e1ad0..e3e062f 100644 --- a/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js +++ b/src/Pages/GroupTasks/Overview/GroupTasksViewModal.js @@ -658,7 +658,7 @@ export default function GroupTasksViewModal({ isOpen }) { } content={ <> -

+

ID:{" "} {paramGroupTaskId}
diff --git a/src/Pages/Robotics/Robots/index.js b/src/Pages/Robotics/Robots/index.js index 6c32ea1..f7694dc 100644 --- a/src/Pages/Robotics/Robots/index.js +++ b/src/Pages/Robotics/Robots/index.js @@ -1,9 +1,12 @@ import { Badge, + Button, Input, Popconfirm, + Popover, Space, Table, + Tooltip, Typography, notification, } from "antd"; @@ -18,6 +21,7 @@ import { } from "../../../utils"; import MyPagination from "../../../Components/MyPagination"; import { Link } from "react-router-dom"; +import { FileTextOutlined, KeyOutlined } from "@ant-design/icons"; const ReceivedSSECommands = { UpdateRobotStatus: 1, @@ -26,6 +30,8 @@ const ReceivedSSECommands = { RemoveUnauthorizedRobot: 4, RemoveRobot: 5, RobotUpdated: 6, + UpdateRobotCurrentJob: 7, + UpdateRobotJobsWaitingCount: 8, }; function getRobotTypeString(type) { @@ -51,6 +57,7 @@ export default function Robots() { setUnauthorizedRobotsPaginationPage, ] = useState(1); const [selectedRobotName, setSelectedRobotName] = useState(""); + const [permitJoinEnabled, setPermitJoinEnabled] = useState(false); const sseEventSource = useRef(null); @@ -111,13 +118,35 @@ export default function Robots() { }, { title: t("robotics.robots.column.currentJob"), - dataIndex: "currentJob", - key: "currentJob", + dataIndex: "currentJobName", + key: "currentJobName", }, { title: t("robotics.robots.column.jobsWaiting"), - dataIndex: "jobsWaiting", - key: "jobsWaiting", + dataIndex: "jobsWaitingCount", + key: "jobsWaitingCount", + render: (parameter, record) => ( + <> + {parameter > 0 ? ( + + {record._jobsWaitingNameList.map((jobName, index) => ( +

  • {jobName}
  • + ))} + + ) + } + > + {parameter} + + ) : ( + parameter + )} + + ), }, { title: t("robotics.robots.column.address"), @@ -153,7 +182,6 @@ export default function Robots() { placeholder="Name" value={selectedRobotName} onChange={(e) => setSelectedRobotName(e.target.value)} - minLength={Constants.GLOBALS.MIN_ROBOTICS_ROBOT_NAME_LENGTH} maxLength={Constants.GLOBALS.MAX_ROBOTICS_ROBOT_NAME_LENGTH} /> } @@ -237,11 +265,12 @@ export default function Robots() { type: getRobotTypeString(robot.Type), name: robot.Name, status: getRobotStatusBadge(robot.Status), - currentJob: - robot.CurrentJobId === "" + currentJobName: + robot.CurrentJobName === "" ? Constants.TEXT_EMPTY_PLACEHOLDER - : robot.CurrentJobId, - jobsWaiting: robot.JobsWaitingCount, + : robot.CurrentJobName, + jobsWaitingCount: robot.JobsWaitingCount, + _jobsWaitingNameList: robot.JobsWaitingNameList, address: robot.Address, firmwareVersion: robot.FirmwareVersion, connectedAt: FormatDatetime(robot.ConnectedAt), @@ -491,6 +520,34 @@ export default function Robots() { return newArr; }); break; + case ReceivedSSECommands.UpdateRobotCurrentJob: + robotsContext.setRobots((arr) => { + const newArr = [...arr]; + + const index = arr.findIndex((x) => x.Id === body.RobotId); + + if (index !== -1) { + newArr[index].CurrentJobName = body.JobName; + newArr[index].JobsWaitingNameList = body.JobsWaitingNameList; + } + + return newArr; + }); + break; + case ReceivedSSECommands.UpdateRobotJobsWaitingCount: + robotsContext.setRobots((arr) => { + const newArr = [...arr]; + + const index = arr.findIndex((x) => x.Id === body.RobotId); + + if (index !== -1) { + newArr[index].JobsWaitingCount = body.JobsWaitingCount; + newArr[index].JobsWaitingNameList = body.JobsWaitingNameList; + } + + return newArr; + }); + break; default: break; } @@ -509,9 +566,25 @@ export default function Robots() { <> {notificationContextHolder} - - {t("robotics.robots.header")} ({robotsContext.robots.length}) - +
    + + {t("robotics.robots.header")} ({robotsContext.robots.length}){" "} + + + + + + + + +