Merge pull request #2450 from loma373/feat/search-infra-moniters
feat: add search functionality to infrastructure monitor
This commit is contained in:
2 files changed
+40
-18
No files matched your search
@@ -1,9 +1,11 @@
|
|||||||
// Components
|
// Components
|
||||||
|
import { Box } from "@mui/material";
|
||||||
import DataTable from "../../../../../Components/Table";
|
import DataTable from "../../../../../Components/Table";
|
||||||
import Host from "../../../../../Components/Host";
|
import Host from "../../../../../Components/Host";
|
||||||
import { StatusLabel } from "../../../../../Components/Label";
|
import { StatusLabel } from "../../../../../Components/Label";
|
||||||
import { Stack } from "@mui/material";
|
import { Stack } from "@mui/material";
|
||||||
import { InfrastructureMenu } from "../MonitorsTableMenu";
|
import { InfrastructureMenu } from "../MonitorsTableMenu";
|
||||||
|
import LoadingSpinner from "../../../../Uptime/Monitors/Components/LoadingSpinner";
|
||||||
// Assets
|
// Assets
|
||||||
import CPUChipIcon from "../../../../../assets/icons/cpu-chip.svg?react";
|
import CPUChipIcon from "../../../../../assets/icons/cpu-chip.svg?react";
|
||||||
import CustomGauge from "../../../../../Components/Charts/CustomGauge";
|
import CustomGauge from "../../../../../Components/Charts/CustomGauge";
|
||||||
@@ -15,7 +17,13 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
const MonitorsTable = ({ isLoading, monitors, isAdmin, handleActionMenuDelete }) => {
|
const MonitorsTable = ({
|
||||||
|
isLoading,
|
||||||
|
monitors,
|
||||||
|
isAdmin,
|
||||||
|
handleActionMenuDelete,
|
||||||
|
isSearching,
|
||||||
|
}) => {
|
||||||
// Utils
|
// Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -120,23 +128,26 @@ const MonitorsTable = ({ isLoading, monitors, isAdmin, handleActionMenuDelete })
|
|||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<DataTable
|
<Box position="relative">
|
||||||
shouldRender={!isLoading}
|
<LoadingSpinner shouldRender={isSearching} />
|
||||||
headers={headers}
|
<DataTable
|
||||||
data={data}
|
shouldRender={!isLoading}
|
||||||
config={{
|
headers={headers}
|
||||||
/* TODO this behavior seems to be repeated. Put it on the root table? */
|
data={data}
|
||||||
rowSX: {
|
config={{
|
||||||
cursor: "pointer",
|
/* TODO this behavior seems to be repeated. Put it on the root table? */
|
||||||
"&:hover td": {
|
rowSX: {
|
||||||
backgroundColor: theme.palette.tertiary.main,
|
cursor: "pointer",
|
||||||
transition: "background-color .3s ease",
|
"&:hover td": {
|
||||||
|
backgroundColor: theme.palette.tertiary.main,
|
||||||
|
transition: "background-color .3s ease",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
onRowClick: (row) => openDetails(row.id),
|
||||||
onRowClick: (row) => openDetails(row.id),
|
emptyView: "No monitors found",
|
||||||
emptyView: "No monitors found",
|
}}
|
||||||
}}
|
/>
|
||||||
/>
|
</Box>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -145,6 +156,7 @@ MonitorsTable.propTypes = {
|
|||||||
monitors: PropTypes.array,
|
monitors: PropTypes.array,
|
||||||
isAdmin: PropTypes.bool,
|
isAdmin: PropTypes.bool,
|
||||||
handleActionMenuDelete: PropTypes.func,
|
handleActionMenuDelete: PropTypes.func,
|
||||||
|
isSearching: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MonitorsTable;
|
export default MonitorsTable;
|
||||||
@@ -8,6 +8,7 @@ import Pagination from "../../..//Components/Table/TablePagination";
|
|||||||
import GenericFallback from "../../../Components/GenericFallback";
|
import GenericFallback from "../../../Components/GenericFallback";
|
||||||
import Fallback from "../../../Components/Fallback";
|
import Fallback from "../../../Components/Fallback";
|
||||||
import Filter from "./Components/Filters";
|
import Filter from "./Components/Filters";
|
||||||
|
import SearchComponent from "../../Uptime/Monitors/Components/SearchComponent";
|
||||||
// Utils
|
// Utils
|
||||||
import { useTheme } from "@emotion/react";
|
import { useTheme } from "@emotion/react";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
@@ -30,6 +31,8 @@ const InfrastructureMonitors = () => {
|
|||||||
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);
|
||||||
|
const [search, setSearch] = useState(undefined);
|
||||||
|
const [isSearching, setIsSearching] = useState(false);
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@@ -67,7 +70,7 @@ const InfrastructureMonitors = () => {
|
|||||||
types: TYPES,
|
types: TYPES,
|
||||||
page,
|
page,
|
||||||
field: field,
|
field: field,
|
||||||
filter: toFilterStatus,
|
filter: toFilterStatus ?? search,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
updateTrigger,
|
updateTrigger,
|
||||||
});
|
});
|
||||||
@@ -122,12 +125,19 @@ const InfrastructureMonitors = () => {
|
|||||||
setToFilterStatus={setToFilterStatus}
|
setToFilterStatus={setToFilterStatus}
|
||||||
handleReset={handleReset}
|
handleReset={handleReset}
|
||||||
/>
|
/>
|
||||||
|
<SearchComponent
|
||||||
|
monitors={monitors}
|
||||||
|
onSearchChange={setSearch}
|
||||||
|
setIsSearching={setIsSearching}
|
||||||
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<MonitorsTable
|
<MonitorsTable
|
||||||
isLoading={isLoading}
|
isLoading={isLoading}
|
||||||
monitors={monitors}
|
monitors={monitors}
|
||||||
isAdmin={isAdmin}
|
isAdmin={isAdmin}
|
||||||
handleActionMenuDelete={handleActionMenuDelete}
|
handleActionMenuDelete={handleActionMenuDelete}
|
||||||
|
isSearching={isSearching}
|
||||||
/>
|
/>
|
||||||
<Pagination
|
<Pagination
|
||||||
itemCount={summary?.totalMonitors}
|
itemCount={summary?.totalMonitors}
|
||||||
|
|||||||
Reference in new issue
Block a user