pagination
parent
b6343e55c6
commit
585afb821f
|
@ -226,7 +226,7 @@ export default function Robots() {
|
||||||
"PATCH",
|
"PATCH",
|
||||||
{
|
{
|
||||||
robotId: record.id,
|
robotId: record.id,
|
||||||
name: selectedRobotName,
|
robotName: selectedRobotName,
|
||||||
},
|
},
|
||||||
{},
|
{},
|
||||||
myFetchContentType.JSON,
|
myFetchContentType.JSON,
|
||||||
|
@ -477,6 +477,8 @@ export default function Robots() {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case ReceivedSSECommands.AddUnauthorizedRobot:
|
case ReceivedSSECommands.AddUnauthorizedRobot:
|
||||||
|
console.log("a", unauthorizedRobotsPaginationPageRef.current);
|
||||||
|
|
||||||
if (unauthorizedRobotsPaginationPageRef.current === 1) {
|
if (unauthorizedRobotsPaginationPageRef.current === 1) {
|
||||||
setUnauthorizedRobots((arr) => {
|
setUnauthorizedRobots((arr) => {
|
||||||
const newArr = [...arr];
|
const newArr = [...arr];
|
||||||
|
@ -547,8 +549,9 @@ export default function Robots() {
|
||||||
|
|
||||||
// if user is on the last page and the last item is removed, we need to go back one page
|
// if user is on the last page and the last item is removed, we need to go back one page
|
||||||
if (
|
if (
|
||||||
|
body.UnauthorizedRobotsTotalPages > 0 &&
|
||||||
unauthorizedRobotsPaginationPageRef.current >
|
unauthorizedRobotsPaginationPageRef.current >
|
||||||
body.UnauthorizedRobotsTotalPages
|
body.UnauthorizedRobotsTotalPages
|
||||||
) {
|
) {
|
||||||
unauthorizedRobotsPaginationPageRef.current--;
|
unauthorizedRobotsPaginationPageRef.current--;
|
||||||
setUnauthorizedRobotsPaginationPage(
|
setUnauthorizedRobotsPaginationPage(
|
||||||
|
@ -574,7 +577,10 @@ export default function Robots() {
|
||||||
setUnauthorizedRobotsTotalPages(body.TotalPages);
|
setUnauthorizedRobotsTotalPages(body.TotalPages);
|
||||||
|
|
||||||
// if user is on the last page and the last item is removed, we need to go back one page
|
// if user is on the last page and the last item is removed, we need to go back one page
|
||||||
if (unauthorizedRobotsPaginationPageRef.current > body.TotalPages) {
|
if (
|
||||||
|
body.TotalPages > 0 &&
|
||||||
|
unauthorizedRobotsPaginationPageRef.current > body.TotalPages
|
||||||
|
) {
|
||||||
unauthorizedRobotsPaginationPageRef.current--;
|
unauthorizedRobotsPaginationPageRef.current--;
|
||||||
setUnauthorizedRobotsPaginationPage(
|
setUnauthorizedRobotsPaginationPage(
|
||||||
unauthorizedRobotsPaginationPageRef.current
|
unauthorizedRobotsPaginationPageRef.current
|
||||||
|
@ -597,7 +603,10 @@ export default function Robots() {
|
||||||
setRobotsTotalPages(body.TotalPages);
|
setRobotsTotalPages(body.TotalPages);
|
||||||
|
|
||||||
// if user is on the last page and the last item is removed, we need to go back one page
|
// if user is on the last page and the last item is removed, we need to go back one page
|
||||||
if (robotsPaginationPageRef.current > body.TotalPages) {
|
if (
|
||||||
|
body.TotalPages > 0 &&
|
||||||
|
robotsPaginationPageRef.current > body.TotalPages
|
||||||
|
) {
|
||||||
robotsPaginationPageRef.current--;
|
robotsPaginationPageRef.current--;
|
||||||
setRobotsPaginationPage(robotsPaginationPageRef.current);
|
setRobotsPaginationPage(robotsPaginationPageRef.current);
|
||||||
}
|
}
|
||||||
|
@ -609,7 +618,7 @@ export default function Robots() {
|
||||||
const index = arr.findIndex((x) => x.Id === body.RobotId);
|
const index = arr.findIndex((x) => x.Id === body.RobotId);
|
||||||
|
|
||||||
if (index !== -1) {
|
if (index !== -1) {
|
||||||
newArr[index].Name = body.Name;
|
newArr[index].Name = body.RobotName;
|
||||||
}
|
}
|
||||||
|
|
||||||
return newArr;
|
return newArr;
|
||||||
|
@ -715,29 +724,25 @@ export default function Robots() {
|
||||||
totalPages={robotsTotalPages}
|
totalPages={robotsTotalPages}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{unauthorizedRobots.length > 0 && (
|
<Typography.Title level={4}>
|
||||||
<>
|
{t("robotics.unauthorizedRobots.header")}
|
||||||
<Typography.Title level={4}>
|
</Typography.Title>
|
||||||
{t("robotics.unauthorizedRobots.header")}
|
|
||||||
</Typography.Title>
|
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
scroll={{ x: "max-content" }}
|
scroll={{ x: "max-content" }}
|
||||||
columns={getUnauthorizedTableContent()}
|
columns={getUnauthorizedTableContent()}
|
||||||
dataSource={getUnauthorizedTableItems(unauthorizedRobots)}
|
dataSource={getUnauthorizedTableItems(unauthorizedRobots)}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<MyPagination
|
<MyPagination
|
||||||
paginationPage={unauthorizedRobotsPaginationPage}
|
paginationPage={unauthorizedRobotsPaginationPage}
|
||||||
setPaginationPage={(page) => {
|
setPaginationPage={(page) => {
|
||||||
setUnauthorizedRobotsPaginationPage(page);
|
setUnauthorizedRobotsPaginationPage(page);
|
||||||
unauthorizedRobotsPaginationPageRef.current = page;
|
unauthorizedRobotsPaginationPageRef.current = page;
|
||||||
}}
|
}}
|
||||||
totalPages={unauthorizedRobotsTotalPages}
|
totalPages={unauthorizedRobotsTotalPages}
|
||||||
/>
|
/>
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,8 +111,8 @@ export const Constants = {
|
||||||
MAX_ROBOTICS_ROBOT_NAME_LENGTH: 30,
|
MAX_ROBOTICS_ROBOT_NAME_LENGTH: 30,
|
||||||
MIN_USER_API_KEY_NAME_LENGTH: 2,
|
MIN_USER_API_KEY_NAME_LENGTH: 2,
|
||||||
MAX_USER_API_KEY_NAME_LENGTH: 30,
|
MAX_USER_API_KEY_NAME_LENGTH: 30,
|
||||||
ROBOTICS_ROBOTS_PAGINATION_LIMIT: 10,
|
ROBOTICS_ROBOTS_PAGINATION_LIMIT: 5,
|
||||||
ROBOTICS_UNAUTHORIZED_PAGINATION_LIMIT: 10,
|
ROBOTICS_UNAUTHORIZED_PAGINATION_LIMIT: 5,
|
||||||
},
|
},
|
||||||
MAX_AVATAR_SIZE: 5 * 1024 * 1024,
|
MAX_AVATAR_SIZE: 5 * 1024 * 1024,
|
||||||
ACCEPTED_AVATAR_FILE_TYPES: [
|
ACCEPTED_AVATAR_FILE_TYPES: [
|
||||||
|
|
Loading…
Reference in New Issue