Merge pull request #2453 from Kaotic3/feature/persist-rows-setting
Feature/persist rows setting
This commit is contained in:
2 files changed
+14
-2
No files matched your search
@@ -16,6 +16,9 @@ const initialState = {
|
|||||||
maintenance: {
|
maintenance: {
|
||||||
rowsPerPage: 5,
|
rowsPerPage: 5,
|
||||||
},
|
},
|
||||||
|
infrastructure: {
|
||||||
|
rowsPerPage: 5,
|
||||||
|
},
|
||||||
sidebar: {
|
sidebar: {
|
||||||
collapsed: false,
|
collapsed: false,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -14,16 +14,19 @@ import { useState } from "react";
|
|||||||
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
import { useIsAdmin } from "../../../Hooks/useIsAdmin";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useFetchMonitorsByTeamId } from "../../../Hooks/monitorHooks";
|
import { useFetchMonitorsByTeamId } from "../../../Hooks/monitorHooks";
|
||||||
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
|
import { setRowsPerPage } from "../../../Features/UI/uiSlice";
|
||||||
// Constants
|
// Constants
|
||||||
const TYPES = ["hardware"];
|
const TYPES = ["hardware"];
|
||||||
const BREADCRUMBS = [{ name: `infrastructure`, path: "/infrastructure" }];
|
const BREADCRUMBS = [{ name: `infrastructure`, path: "/infrastructure" }];
|
||||||
|
|
||||||
const InfrastructureMonitors = () => {
|
const InfrastructureMonitors = () => {
|
||||||
// Redux state
|
// Redux state
|
||||||
|
const rowsPerPage = useSelector((state) => state.ui.infrastructure.rowsPerPage);
|
||||||
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
// Local state
|
// Local state
|
||||||
const [page, setPage] = useState(0);
|
const [page, setPage] = useState(0);
|
||||||
const [rowsPerPage, setRowsPerPage] = useState(5);
|
|
||||||
const [updateTrigger, setUpdateTrigger] = useState(false);
|
const [updateTrigger, setUpdateTrigger] = useState(false);
|
||||||
const [selectedStatus, setSelectedStatus] = useState(undefined);
|
const [selectedStatus, setSelectedStatus] = useState(undefined);
|
||||||
const [toFilterStatus, setToFilterStatus] = useState(undefined);
|
const [toFilterStatus, setToFilterStatus] = useState(undefined);
|
||||||
@@ -43,7 +46,13 @@ const InfrastructureMonitors = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleChangeRowsPerPage = (event) => {
|
const handleChangeRowsPerPage = (event) => {
|
||||||
setRowsPerPage(event.target.value);
|
dispatch(
|
||||||
|
setRowsPerPage({
|
||||||
|
value: parseInt(event.target.value, 10),
|
||||||
|
table: "infrastructure",
|
||||||
|
})
|
||||||
|
);
|
||||||
|
setPage(0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleReset = () => {
|
const handleReset = () => {
|
||||||
|
|||||||
Reference in new issue
Block a user