jobs list

main
alex 2023-10-15 15:50:53 +02:00
parent e48ab6ca45
commit dd89432244
5 changed files with 99 additions and 13 deletions

View File

@ -166,6 +166,10 @@
"robotics": {
"robots": {
"header": "Roboter",
"button": {
"permitJoin": "Beitreten erlauben",
"disableJoin": "Beitreten deaktivieren"
},
"column": {
"id": "ID",
"type": "Typ",

View File

@ -166,6 +166,10 @@
"robotics": {
"robots": {
"header": "Robots",
"button": {
"permitJoin": "Permit Join",
"disableJoin": "Disable Join"
},
"column": {
"id": "ID",
"type": "Type",

View File

@ -658,7 +658,7 @@ export default function GroupTasksViewModal({ isOpen }) {
}
content={
<>
<p>
<p style={{ margin: 0 }}>
<span style={{ fontWeight: "bold" }}>ID:</span>{" "}
{paramGroupTaskId} <br />
<span style={{ fontWeight: "bold" }}>

View File

@ -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 ? (
<Popover
title="Jobs waiting"
content={
record._jobsWaitingNameList !== null && (
<ul style={{ paddingLeft: 14 }}>
{record._jobsWaitingNameList.map((jobName, index) => (
<li key={index}>{jobName}</li>
))}
</ul>
)
}
>
{parameter}
</Popover>
) : (
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,10 +566,26 @@ export default function Robots() {
<>
{notificationContextHolder}
<div
style={{
display: "flex",
justifyContent: "space-between",
}}
>
<Typography.Title level={4}>
{t("robotics.robots.header")} ({robotsContext.robots.length})
{t("robotics.robots.header")} ({robotsContext.robots.length}){" "}
<Tooltip title={t("userProfile.icon.viewApiDoc")}>
<Link target="_blank" to={Constants.ROBOTICS_SWAGGER_ADDRESS}>
<FileTextOutlined style={{ fontSize: 16 }} />
</Link>
</Tooltip>
</Typography.Title>
<Button icon={<KeyOutlined />}>
{t("userProfile.button.createApiKey.title")}
</Button>
</div>
<Table
scroll={{ x: "max-content" }}
columns={getRobotsTableContent()}

View File

@ -13,6 +13,7 @@ let staticContentAddress = "";
let wsAddress = "";
let logApiAddress = "";
let roboticsApiAddress = "";
var roboticsSwaggerAddress = "";
if (window.location.hostname === "localhost" && window.location.port === "") {
// for docker container testing on localhost
@ -21,6 +22,7 @@ if (window.location.hostname === "localhost" && window.location.port === "") {
wsAddress = "ws://localhost/ws";
logApiAddress = "http://localhost/lm/v1/log";
roboticsApiAddress = "http://localhost/rcm/v1";
roboticsSwaggerAddress = "http://localhost/rcm/swagger/index.html";
} else if (window.location.hostname === "localhost") {
// programming on localhost
apiAddress = "http://localhost:50050/v1";
@ -28,6 +30,7 @@ if (window.location.hostname === "localhost" && window.location.port === "") {
wsAddress = "ws://localhost:50050/ws";
logApiAddress = "http://127.0.0.1:50110/v1/log";
roboticsApiAddress = "http://localhost:50055/v1";
roboticsSwaggerAddress = "http://localhost:50055/swagger/index.html";
/*} else if (window.location.hostname === "192.168.178.93") {
apiAddress = "http://192.168.178.93:50050/v1";
staticContentAddress = "http://192.168.178.93:50050/";
@ -39,6 +42,7 @@ if (window.location.hostname === "localhost" && window.location.port === "") {
wsAddress = `${wssProtocol}${window.location.hostname}/ws`;
logApiAddress = `${window.location.protocol}${window.location.hostname}/lm/v1/log`;
roboticsApiAddress = `${window.location.protocol}${window.location.hostname}/rcm/v1`;
roboticsSwaggerAddress = `${window.location.protocol}${window.location.hostname}/rcm/swagger/index.html`;
}
export const Constants = {
@ -61,6 +65,7 @@ export const Constants = {
WS_ADDRESS: wsAddress,
LOG_API_ADDRESS: logApiAddress,
ROBOTICS_API_ADDRESS: roboticsApiAddress, // robot-control-manager
ROBOTICS_SWAGGER_ADDRESS: roboticsSwaggerAddress,
ROUTE_PATHS: {
EQUIPMENT_DOCUMENTATION: "/equipment-documentation",
EQUIPMENT_DOCUMENTATION_VIEW: "/equipment-documentation/",