permission check
parent
1029e6ebd6
commit
2b199cd15c
|
@ -254,7 +254,7 @@ export default function AppRoutes() {
|
||||||
|
|
||||||
{hasPermission(
|
{hasPermission(
|
||||||
appContext.userPermissions,
|
appContext.userPermissions,
|
||||||
Constants.PERMISSIONS.ROBOTICS.ROBOTS
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.VIEW
|
||||||
) && (
|
) && (
|
||||||
<Route
|
<Route
|
||||||
path={Constants.ROUTE_PATHS.ROBOTICS_ROBOTS}
|
path={Constants.ROUTE_PATHS.ROBOTICS_ROBOTS}
|
||||||
|
|
|
@ -153,7 +153,7 @@ export default function SideMenu({
|
||||||
if (
|
if (
|
||||||
hasPermission(
|
hasPermission(
|
||||||
appContext.userPermissions,
|
appContext.userPermissions,
|
||||||
Constants.PERMISSIONS.ROBOTICS.ROBOTS
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.VIEW
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
let roboticsGroup = {
|
let roboticsGroup = {
|
||||||
|
|
|
@ -15,6 +15,8 @@ import { useEffect, useRef, useState } from "react";
|
||||||
import {
|
import {
|
||||||
Constants,
|
Constants,
|
||||||
FormatDatetime,
|
FormatDatetime,
|
||||||
|
hasOnePermission,
|
||||||
|
hasPermission,
|
||||||
myFetch,
|
myFetch,
|
||||||
myFetchContentType,
|
myFetchContentType,
|
||||||
} from "../../../utils";
|
} from "../../../utils";
|
||||||
|
@ -26,6 +28,7 @@ import {
|
||||||
PlusOutlined,
|
PlusOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { MyCopyIcon, MyShowHiddenIcon } from "../../../Components/MyIcon";
|
import { MyCopyIcon, MyShowHiddenIcon } from "../../../Components/MyIcon";
|
||||||
|
import { useAppContext } from "../../../Contexts/AppContext";
|
||||||
|
|
||||||
const ReceivedSSECommands = {
|
const ReceivedSSECommands = {
|
||||||
UpdateRobotStatus: 1,
|
UpdateRobotStatus: 1,
|
||||||
|
@ -52,6 +55,7 @@ function getRobotTypeString(type) {
|
||||||
|
|
||||||
export default function Robots() {
|
export default function Robots() {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const appContext = useAppContext();
|
||||||
const [notificationApi, notificationContextHolder] =
|
const [notificationApi, notificationContextHolder] =
|
||||||
notification.useNotification();
|
notification.useNotification();
|
||||||
|
|
||||||
|
@ -162,7 +166,15 @@ export default function Robots() {
|
||||||
</>
|
</>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (
|
||||||
|
hasPermission(
|
||||||
|
appContext.userPermissions,
|
||||||
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.VIEW_ROBOTS_ADDRESSES
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
items.push({
|
||||||
title: t("robotics.robots.column.address"),
|
title: t("robotics.robots.column.address"),
|
||||||
dataIndex: "address",
|
dataIndex: "address",
|
||||||
key: "address",
|
key: "address",
|
||||||
|
@ -178,7 +190,10 @@ export default function Robots() {
|
||||||
<MyCopyIcon notificationApi={notificationApi} text={text} />
|
<MyCopyIcon notificationApi={notificationApi} text={text} />
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
items.push(
|
||||||
{
|
{
|
||||||
title: t("robotics.robots.column.connectedAt"),
|
title: t("robotics.robots.column.connectedAt"),
|
||||||
dataIndex: "connectedAt",
|
dataIndex: "connectedAt",
|
||||||
|
@ -193,13 +208,26 @@ export default function Robots() {
|
||||||
title: t("robotics.robots.column.createdAt"),
|
title: t("robotics.robots.column.createdAt"),
|
||||||
dataIndex: "createdAt",
|
dataIndex: "createdAt",
|
||||||
key: "createdAt",
|
key: "createdAt",
|
||||||
},
|
}
|
||||||
{
|
);
|
||||||
|
|
||||||
|
if (
|
||||||
|
hasOnePermission(
|
||||||
|
appContext.userPermissions,
|
||||||
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.EDIT_ROBOT_NAME,
|
||||||
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.DISCONNECT_ROBOT
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
items.push({
|
||||||
title: t("robotics.robots.column.actions"),
|
title: t("robotics.robots.column.actions"),
|
||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
render: (_, record) => (
|
render: (_, record) => (
|
||||||
<Space size="middle">
|
<Space size="middle">
|
||||||
|
{hasPermission(
|
||||||
|
appContext.userPermissions,
|
||||||
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.EDIT_ROBOT_NAME
|
||||||
|
) && (
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
placement="left"
|
placement="left"
|
||||||
title={t("robotics.robots.popconfirmEdit.title")}
|
title={t("robotics.robots.popconfirmEdit.title")}
|
||||||
|
@ -249,7 +277,12 @@ export default function Robots() {
|
||||||
{t("common.text.edit")}
|
{t("common.text.edit")}
|
||||||
</Link>
|
</Link>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{hasPermission(
|
||||||
|
appContext.userPermissions,
|
||||||
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.DISCONNECT_ROBOT
|
||||||
|
) && (
|
||||||
<Popconfirm
|
<Popconfirm
|
||||||
placement="left"
|
placement="left"
|
||||||
title={t("robotics.robots.popconfirmDisconnect.title")}
|
title={t("robotics.robots.popconfirmDisconnect.title")}
|
||||||
|
@ -271,10 +304,11 @@ export default function Robots() {
|
||||||
>
|
>
|
||||||
<Link to="#">{t("common.text.disconnect")}</Link>
|
<Link to="#">{t("common.text.disconnect")}</Link>
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
|
)}
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
@ -335,7 +369,15 @@ export default function Robots() {
|
||||||
dataIndex: "firmwareVersion",
|
dataIndex: "firmwareVersion",
|
||||||
key: "firmwareVersion",
|
key: "firmwareVersion",
|
||||||
},
|
},
|
||||||
{
|
];
|
||||||
|
|
||||||
|
if (
|
||||||
|
hasPermission(
|
||||||
|
appContext.userPermissions,
|
||||||
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.AUTHORIZE_DENY_UNAUTHORIZED_ROBOTS
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
items.push({
|
||||||
title: t("robotics.robots.column.actions"),
|
title: t("robotics.robots.column.actions"),
|
||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
|
@ -386,8 +428,8 @@ export default function Robots() {
|
||||||
</Popconfirm>
|
</Popconfirm>
|
||||||
</Space>
|
</Space>
|
||||||
),
|
),
|
||||||
},
|
});
|
||||||
];
|
}
|
||||||
|
|
||||||
return items;
|
return items;
|
||||||
};
|
};
|
||||||
|
@ -689,6 +731,12 @@ export default function Robots() {
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
|
disabled={
|
||||||
|
!hasPermission(
|
||||||
|
appContext.userPermissions,
|
||||||
|
Constants.PERMISSIONS.ROBOTICS.ROBOTS.ENABLE_PERMIT_JOIN
|
||||||
|
)
|
||||||
|
}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
console.log("click");
|
console.log("click");
|
||||||
myFetch(
|
myFetch(
|
||||||
|
|
10
src/utils.js
10
src/utils.js
|
@ -179,7 +179,15 @@ export const Constants = {
|
||||||
VIEW: "consoles.view",
|
VIEW: "consoles.view",
|
||||||
},
|
},
|
||||||
ROBOTICS: {
|
ROBOTICS: {
|
||||||
ROBOTS: "robotics.view",
|
ROBOTS: {
|
||||||
|
VIEW: "robotics.robots.view",
|
||||||
|
VIEW_ROBOTS_ADDRESSES: "robotics.robots.view_robots_addresses",
|
||||||
|
EDIT_ROBOT_NAME: "robotics.robots.edit_robot_name",
|
||||||
|
DISCONNECT_ROBOT: "robotics.robots.disconnect_robot",
|
||||||
|
ENABLE_PERMIT_JOIN: "robotics.robots.enable_permit_join",
|
||||||
|
AUTHORIZE_DENY_UNAUTHORIZED_ROBOTS:
|
||||||
|
"robotics.robots.authorize_deny_unauthorized_robots",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
SYSTEM_LOG_TYPE: {
|
SYSTEM_LOG_TYPE: {
|
||||||
|
|
Loading…
Reference in New Issue