diff --git a/Client/src/App.jsx b/Client/src/App.jsx
index 8fb4bf932..d6fca146f 100644
--- a/Client/src/App.jsx
+++ b/Client/src/App.jsx
@@ -71,7 +71,7 @@ function App() {
element={}
/>
}
/>
diff --git a/Client/src/Components/Charts/BarChart/index.jsx b/Client/src/Components/Charts/BarChart/index.jsx
index 54a9524af..e2d8c7b45 100644
--- a/Client/src/Components/Charts/BarChart/index.jsx
+++ b/Client/src/Components/Charts/BarChart/index.jsx
@@ -1,12 +1,14 @@
import { useTheme } from "@emotion/react";
import { Box, Stack, Tooltip, Typography } from "@mui/material";
-import { formatDate } from "../../../Utils/timeUtils";
+import { formatDateWithTz } from "../../../Utils/timeUtils";
import { useEffect, useState } from "react";
import "./index.css";
+import { useSelector } from "react-redux";
const BarChart = ({ checks = [] }) => {
const theme = useTheme();
const [animate, setAnimate] = useState(false);
+ const uiTimezone = useSelector((state) => state.ui.timezone);
useEffect(() => {
setAnimate(true);
@@ -51,7 +53,11 @@ const BarChart = ({ checks = [] }) => {
title={
<>
- {formatDate(new Date(check.createdAt), { year: undefined })}
+ {formatDateWithTz(
+ check.createdAt,
+ "ddd, MMMM D, YYYY, HH:mm A",
+ uiTimezone
+ )}
{
- const theme = useTheme();
+ const uiTimezone = useSelector((state) => state.ui.timezone);
+ const theme = useTheme();
if (active && payload && payload.length) {
return (
{
fontWeight: 500,
}}
>
- {new Date(label).toLocaleDateString("en-US", {
- weekday: "short", // Mon
- month: "long", // July
- day: "numeric", // 17
- }) +
- ", " +
- new Date(label).toLocaleTimeString("en-US", {
- hour: "numeric", // 12
- minute: "2-digit", // 15
- hour12: true, // AM/PM format
- })}
+ {formatDateWithTz(label, "ddd, MMMM D, YYYY, h:mm A", uiTimezone)}
{
return null;
};
-const MonitorDetailsAreaChart = ({ checks }) => {
- const formatDate = (timestamp) => {
- const date = new Date(timestamp);
- return date.toLocaleTimeString("en-US", {
- hour: "numeric",
- minute: "2-digit",
- hour12: true,
- });
- };
-
- const memoizedChecks = useMemo(() => checks, [checks[0]]);
-
+const CustomTick = ({ x, y, payload, index }) => {
const theme = useTheme();
+ const uiTimezone = useSelector((state) => state.ui.timezone);
+
+ // Render nothing for the first tick
+ if (index === 0) return null;
+ return (
+
+ {formatDateWithTz(payload?.value, "h:mm a", uiTimezone)}
+
+ );
+};
+
+CustomTick.propTypes = {
+ x: PropTypes.number,
+ y: PropTypes.number,
+ payload: PropTypes.object,
+ index: PropTypes.number,
+};
+
+const MonitorDetailsAreaChart = ({ checks }) => {
+ const theme = useTheme();
+ const memoizedChecks = useMemo(() => checks, [checks[0]]);
+ const [isHovered, setIsHovered] = useState(false);
+
return (
{
left: 0,
bottom: 0,
}}
+ onMouseMove={() => setIsHovered(true)}
+ onMouseLeave={() => setIsHovered(false)}
>
{
}
+ minTickGap={0}
+ axisLine={false}
tickLine={false}
- height={18}
+ height={20}
+ interval="equidistantPreserveStart"
/>
}
+ wrapperStyle={{ pointerEvents: "none" }}
/>
diff --git a/Client/src/Components/Charts/PagespeedLineChart/index.css b/Client/src/Components/Charts/PagespeedLineChart/index.css
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Client/src/Components/Charts/PagespeedLineChart/index.jsx b/Client/src/Components/Charts/PagespeedLineChart/index.jsx
deleted file mode 100644
index 270cbaca0..000000000
--- a/Client/src/Components/Charts/PagespeedLineChart/index.jsx
+++ /dev/null
@@ -1,71 +0,0 @@
-import { LineChart } from "@mui/x-charts/LineChart";
-import PropTypes from "prop-types";
-
-const PageSpeedLineChart = ({ pageSpeedChecks = [] }) => {
- const keyToLabel = {
- performance: "Performance",
- seo: "SEO",
- bestPractices: "Best practices",
- accessibility: "Accessibility",
- };
-
- const colors = {
- performance: "#2aa02b",
- seo: "#9467bd",
- bestPractices: "#ff7f0e",
- accessibility: "#1f76b3",
- };
-
- const customize = {
- legend: { position: { vertical: "bottom", horizontal: "middle" } },
- margin: { bottom: 75 },
- };
-
- const xLabels = pageSpeedChecks.map((check) => {
- return check.createdAt;
- });
-
- return (
- ({
- dataKey: key,
- label: keyToLabel[key],
- color: colors[key],
- showMark: false,
- }))}
- yAxis={[{ min: 0, max: 100 }]}
- xAxis={[
- {
- scaleType: "point",
- data: xLabels,
- valueFormatter: (val) => new Date(val).toLocaleDateString(),
- },
- ]}
- dataset={pageSpeedChecks}
- {...customize}
- grid={{ vertical: true, horizontal: true }}
- tooltip={{ trigger: "none" }}
- slotProps={{
- legend: {
- direction: "row",
- position: { vertical: "bottom", horizontal: "middle" },
- padding: 2,
- itemMarkWidth: 8,
- itemMarkHeight: 8,
- markGap: 5,
- itemGap: 15,
- labelStyle: {
- fontSize: 13,
- color: "#344054"
- }
- },
- }}
- />
- );
-};
-
-PageSpeedLineChart.propTypes = {
- pageSpeedChecks: PropTypes.array,
-};
-
-export default PageSpeedLineChart;
diff --git a/Client/src/Components/Inputs/Autocomplete/index.jsx b/Client/src/Components/Inputs/Autocomplete/index.jsx
deleted file mode 100644
index 5256efccc..000000000
--- a/Client/src/Components/Inputs/Autocomplete/index.jsx
+++ /dev/null
@@ -1,116 +0,0 @@
-import { Autocomplete, TextField } from "@mui/material";
-import React from "react";
-import PropTypes from "prop-types";
-import { useTheme } from "@emotion/react";
-
-/**
- * @example
- *
- * const options = [
- * { _id: "66d6119ef959cbc681e034f0", name: "Googler" },
- * { _id: "66d6119ef959cbc681e034f0", name: "CNN" },
- * { _id: "66d61a1bf959cbc681e0353f", name: "X Corp." },
- * ];
- *
- *
- *
- */
-
-/**
- * AutoCompleteField component.
- *
- * @component
- * @param {Object} props - The component props.
- * @param {string} props.id - The ID of the autocomplete field.
- * @param {string} props.type - The type of the input field (text or number).
- * @param {Array} props.options - The options for the autocomplete field.
- * @param {string} props.placeholder - The placeholder text for the input field.
- * @param {boolean} props.disabled - Indicates if the field is disabled.
- * @returns {JSX.Element} The AutoCompleteField component.
- */
-
-const AutoCompleteField = ({
- id,
- type,
- options,
- placeholder = "Type to search",
- disabled,
-}) => {
- const [value, setValue] = React.useState();
- const [inputValue, setInputValue] = React.useState("");
- const theme = useTheme();
-
- return (
- {
- setValue(newValue);
- }}
- inputValue={inputValue}
- onInputChange={(event, newInputValue) => {
- setInputValue(newInputValue);
- }}
- options={options}
- getOptionLabel={(option) => option.name}
- renderInput={(params) => (
-
- )}
- renderOption={(props, option) => {
- const { key, ...optionProps } = props;
- return (
-
- {{option.name}}
-
- );
- }}
- slotProps={{
- popper: {
- sx: {
- "& ul": { p: 0 },
- "& li": { borderRadius: theme.shape.borderRadius },
- },
- },
- paper: {
- sx: {
- p: 2,
- fontSize: 13,
- },
- },
- }}
- />
- );
-};
-
-AutoCompleteField.displayName = "AutoCompleteField";
-
-AutoCompleteField.propTypes = {
- id: PropTypes.string,
- type: PropTypes.oneOf(["text", "number"]),
- options: PropTypes.array,
- placeholder: PropTypes.string,
- disabled: PropTypes.bool,
- setWidth: PropTypes.string,
-};
-
-export default AutoCompleteField;
diff --git a/Client/src/Components/Inputs/Field/index.jsx b/Client/src/Components/Inputs/Field/index.jsx
index 62c50eeff..e7326ec41 100644
--- a/Client/src/Components/Inputs/Field/index.jsx
+++ b/Client/src/Components/Inputs/Field/index.jsx
@@ -121,8 +121,9 @@ const Field = forwardRef(
sx: {
color: theme.palette.text.secondary,
"&:-webkit-autofill": {
- WebkitBoxShadow: `0 0 0 100px ${theme.palette.background.fill} inset`,
+ WebkitBoxShadow: `0 0 0 100px ${theme.palette.other.autofill} inset`,
WebkitTextFillColor: theme.palette.text.secondary,
+ borderRadius: "0 5px 5px 0",
},
},
}}
diff --git a/Client/src/Components/Inputs/Search/index.jsx b/Client/src/Components/Inputs/Search/index.jsx
new file mode 100644
index 000000000..f4d931fd1
--- /dev/null
+++ b/Client/src/Components/Inputs/Search/index.jsx
@@ -0,0 +1,150 @@
+import PropTypes from "prop-types";
+import { Box, ListItem, Autocomplete, TextField } from "@mui/material";
+import { useTheme } from "@emotion/react";
+import SearchIcon from "../../../assets/icons/search.svg?react";
+
+/**
+ * Search component using Material UI's Autocomplete.
+ *
+ * @param {Object} props
+ * @param {string} props.id - Unique identifier for the Autocomplete component
+ * @param {Array
+ ),
+ }}
+ sx={{
+ "& fieldset": {
+ borderColor: theme.palette.border.light,
+ borderRadius: theme.shape.borderRadius,
+ },
+ "& .MuiOutlinedInput-root:hover:not(:has(input:focus)):not(:has(textarea:focus)) fieldset":
+ {
+ borderColor: theme.palette.border.light,
+ },
+ }}
+ />
+ )}
+ filterOptions={(options, { inputValue }) => {
+ const filtered = options.filter((option) =>
+ option[filteredBy].toLowerCase().includes(inputValue.toLowerCase())
+ );
+
+ if (filtered.length === 0) {
+ return [{ [filteredBy]: "No monitors found", noOptions: true }];
+ }
+ return filtered;
+ }}
+ renderOption={(props, option) => {
+ const { key, ...optionProps } = props;
+ return (
+
+ {option[filteredBy]}
+
+ );
+ }}
+ slotProps={{
+ popper: {
+ keepMounted: true,
+ sx: {
+ "& ul": { p: 2 },
+ "& li.MuiAutocomplete-option": {
+ color: theme.palette.text.secondary,
+ px: 4,
+ borderRadius: theme.shape.borderRadius,
+ },
+ "& .MuiAutocomplete-listbox .MuiAutocomplete-option[aria-selected='true'], & .MuiAutocomplete-listbox .MuiAutocomplete-option[aria-selected='true'].Mui-focused, & .MuiAutocomplete-listbox .MuiAutocomplete-option[aria-selected='true']:hover":
+ {
+ backgroundColor: theme.palette.background.fill,
+ },
+ "& .MuiAutocomplete-noOptions": {
+ px: theme.spacing(6),
+ py: theme.spacing(5),
+ },
+ },
+ },
+ }}
+ sx={{
+ height: 34,
+ "&.MuiAutocomplete-root .MuiAutocomplete-input": { p: 0 },
+ ...sx,
+ }}
+ />
+ );
+};
+
+Search.propTypes = {
+ id: PropTypes.string,
+ options: PropTypes.array.isRequired,
+ filteredBy: PropTypes.string.isRequired,
+ value: PropTypes.string.isRequired,
+ handleInputChange: PropTypes.func.isRequired,
+ handleChange: PropTypes.func,
+ sx: PropTypes.object,
+};
+
+export default Search;
diff --git a/Client/src/Components/Search/index.css b/Client/src/Components/Search/index.css
deleted file mode 100644
index e69de29bb..000000000
diff --git a/Client/src/Components/Search/index.jsx b/Client/src/Components/Search/index.jsx
deleted file mode 100644
index 391b95c02..000000000
--- a/Client/src/Components/Search/index.jsx
+++ /dev/null
@@ -1,49 +0,0 @@
-import Autocomplete from '@mui/material/Autocomplete';
-import TextField from '@mui/material/TextField';
-import Chip from '@mui/material/Chip';
-import Box from '@mui/material/Box';
-import { useTheme } from "@mui/material";
-
-const teamMembers = [
- { title: 'John Doe'},
- { title: 'Jane Smith'},
- { title: 'Alex Johnson'},
-];
-
-/**
- * @component
- * @returns {JSX.Element}
- */
-
-export default function Search()
- {
- const theme = useTheme();
- return (
- {/* Add padding to the container */}
- option.title}
- filterSelectedOptions
- renderInput={(params) => (
-
- )}
- renderTags={(value, getTagProps) =>
- value.map((option) => (
-
- ))
- }
- />
-
- );
-}
diff --git a/Client/src/Features/Auth/authSlice.js b/Client/src/Features/Auth/authSlice.js
index f12758715..f6d40c38a 100644
--- a/Client/src/Features/Auth/authSlice.js
+++ b/Client/src/Features/Auth/authSlice.js
@@ -67,7 +67,7 @@ export const update = createAsyncThunk(
fd.append("deleteProfileImage", form.deleteProfileImage);
const res = await networkService.updateUser(token, user._id, fd);
-
+ console.log(res);
return res.data;
} catch (error) {
if (error.response && error.response.data) {
diff --git a/Client/src/Features/UI/uiSlice.js b/Client/src/Features/UI/uiSlice.js
index 947055ddc..2b6a08e8d 100644
--- a/Client/src/Features/UI/uiSlice.js
+++ b/Client/src/Features/UI/uiSlice.js
@@ -14,6 +14,7 @@ const initialState = {
},
mode: "light",
greeting: { index: 0, lastUpdate: null },
+ timezone: "America/Toronto",
};
const uiSlice = createSlice({
@@ -36,9 +37,17 @@ const uiSlice = createSlice({
state.greeting.index = action.payload.index;
state.greeting.lastUpdate = action.payload.lastUpdate;
},
+ setTimezone(state, action) {
+ state.timezone = action.payload.timezone;
+ },
},
});
export default uiSlice.reducer;
-export const { setRowsPerPage, toggleSidebar, setMode, setGreeting } =
- uiSlice.actions;
+export const {
+ setRowsPerPage,
+ toggleSidebar,
+ setMode,
+ setGreeting,
+ setTimezone,
+} = uiSlice.actions;
diff --git a/Client/src/Features/UptimeMonitors/uptimeMonitorsSlice.js b/Client/src/Features/UptimeMonitors/uptimeMonitorsSlice.js
index ac3ce1d6f..a8b1ea737 100644
--- a/Client/src/Features/UptimeMonitors/uptimeMonitorsSlice.js
+++ b/Client/src/Features/UptimeMonitors/uptimeMonitorsSlice.js
@@ -164,6 +164,44 @@ export const deleteMonitorChecksByTeamId = createAsyncThunk(
}
}
);
+export const addDemoMonitors = createAsyncThunk(
+ "monitors/addDemoMonitors",
+ async (data, thunkApi) => {
+ try {
+ const { authToken } = data;
+ const res = await networkService.addDemoMonitors(authToken);
+ return res.data;
+ } catch (error) {
+ if (error.response && error.response.data) {
+ return thunkApi.rejectWithValue(error.response.data);
+ }
+ const payload = {
+ status: false,
+ msg: error.message ? error.message : "Unknown error",
+ };
+ return thunkApi.rejectWithValue(payload);
+ }
+ }
+);
+export const deleteAllMonitors = createAsyncThunk(
+ "monitors/deleteAllMonitors",
+ async (data, thunkApi) => {
+ try {
+ const { authToken } = data;
+ const res = await networkService.deleteAllMonitors(authToken);
+ return res.data;
+ } catch (error) {
+ if (error.response && error.response.data) {
+ return thunkApi.rejectWithValue(error.response.data);
+ }
+ const payload = {
+ status: false,
+ msg: error.message ? error.message : "Unknown error",
+ };
+ return thunkApi.rejectWithValue(payload);
+ }
+ }
+);
const uptimeMonitorsSlice = createSlice({
name: "uptimeMonitors",
@@ -306,6 +344,42 @@ const uptimeMonitorsSlice = createSlice({
state.msg = action.payload
? action.payload.msg
: "Failed to pause uptime monitor";
+ })
+ // *****************************************************
+ // Add Demo Monitors
+ // *****************************************************
+ .addCase(addDemoMonitors.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(addDemoMonitors.fulfilled, (state, action) => {
+ state.isLoading = false;
+ state.success = action.payload.success;
+ state.msg = action.payload.msg;
+ })
+ .addCase(addDemoMonitors.rejected, (state, action) => {
+ state.isLoading = false;
+ state.success = false;
+ state.msg = action.payload
+ ? action.payload.msg
+ : "Failed to add demo uptime monitors";
+ })
+ // *****************************************************
+ // Delete all Monitors
+ // *****************************************************
+ .addCase(deleteAllMonitors.pending, (state) => {
+ state.isLoading = true;
+ })
+ .addCase(deleteAllMonitors.fulfilled, (state, action) => {
+ state.isLoading = false;
+ state.success = action.payload.success;
+ state.msg = action.payload.msg;
+ })
+ .addCase(deleteAllMonitors.rejected, (state, action) => {
+ state.isLoading = false;
+ state.success = false;
+ state.msg = action.payload
+ ? action.payload.msg
+ : "Failed to delete all monitors";
});
},
});
diff --git a/Client/src/Pages/Incidents/IncidentTable/index.jsx b/Client/src/Pages/Incidents/IncidentTable/index.jsx
index d10c79c68..6ca18a1e9 100644
--- a/Client/src/Pages/Incidents/IncidentTable/index.jsx
+++ b/Client/src/Pages/Incidents/IncidentTable/index.jsx
@@ -21,9 +21,16 @@ import { networkService } from "../../../main";
import { StatusLabel } from "../../../Components/Label";
import { logger } from "../../../Utils/Logger";
import { useTheme } from "@emotion/react";
+import { formatDateWithTz } from "../../../Utils/timeUtils";
+import PlaceholderLight from "../../../assets/Images/data_placeholder.svg?react";
+import PlaceholderDark from "../../../assets/Images/data_placeholder_dark.svg?react";
+
const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
+ const uiTimezone = useSelector((state) => state.ui.timezone);
+
const theme = useTheme();
const { authToken, user } = useSelector((state) => state.auth);
+ const mode = useSelector((state) => state.ui.mode);
const [checks, setChecks] = useState([]);
const [checksCount, setChecksCount] = useState(0);
const [paginationController, setPaginationController] = useState({
@@ -109,6 +116,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
{...item}
/>
)}
+ sx={{ mt: "auto" }}
/>
);
}
@@ -125,12 +133,18 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
<>
{checks?.length === 0 && selectedMonitor === "0" ? (
+
+ {mode === "light" ? : }
+
No incidents recorded yet.
) : checks?.length === 0 ? (
+
+ {mode === "light" ? : }
+
The monitor you have selected has no recorded incidents yet.
@@ -151,6 +165,11 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
{checks.map((check) => {
const status = check.status === true ? "up" : "down";
+ const formattedDate = formatDateWithTz(
+ check.createdAt,
+ "YYYY-MM-DD HH:mm:ss A",
+ uiTimezone
+ );
return (
@@ -162,9 +181,7 @@ const IncidentTable = ({ monitors, selectedMonitor, filter }) => {
customStyles={{ textTransform: "capitalize" }}
/>
-
- {new Date(check.createdAt).toLocaleString()}
-
+ {formattedDate}
{check.statusCode ? check.statusCode : "N/A"}
diff --git a/Client/src/Pages/Incidents/index.jsx b/Client/src/Pages/Incidents/index.jsx
index 1fd91c10a..10ab30ad5 100644
--- a/Client/src/Pages/Incidents/index.jsx
+++ b/Client/src/Pages/Incidents/index.jsx
@@ -1,16 +1,19 @@
import { useState, useEffect } from "react";
import { useSelector } from "react-redux";
import { ButtonGroup, Stack, Typography, Button } from "@mui/material";
+import { useParams } from "react-router-dom";
+
import { networkService } from "../../main";
import { useTheme } from "@emotion/react";
import Select from "../../Components/Inputs/Select";
import IncidentTable from "./IncidentTable";
-import "./index.css";
import SkeletonLayout from "./skeleton";
+import "./index.css";
const Incidents = () => {
const theme = useTheme();
const authState = useSelector((state) => state.auth);
+ const { monitorId } = useParams();
const [monitors, setMonitors] = useState({});
const [selectedMonitor, setSelectedMonitor] = useState("0");
@@ -22,17 +25,20 @@ const Incidents = () => {
useEffect(() => {
const fetchMonitors = async () => {
setLoading(true);
- const res = await networkService.getMonitorsByTeamId(
- authState.authToken,
- authState.user.teamId,
- 1,
- null,
- null,
- null,
- null,
- null,
- null
- );
+ const res = await networkService.getMonitorsByTeamId({
+ authToken: authState.authToken,
+ teamId: authState.user.teamId,
+ limit: -1,
+ types: null,
+ status: null,
+ checkOrder: null,
+ normalize: null,
+ page: null,
+ rowsPerPage: null,
+ filter: null,
+ field: null,
+ order: null,
+ });
// Reduce to a lookup object for 0(1) lookup
if (res?.data?.data?.monitors?.length > 0) {
const monitorLookup = res.data.data.monitors.reduce((acc, monitor) => {
@@ -40,6 +46,7 @@ const Incidents = () => {
return acc;
}, {});
setMonitors(monitorLookup);
+ monitorId !== undefined && setSelectedMonitor(monitorId);
}
setLoading(false);
};
@@ -54,7 +61,7 @@ const Incidents = () => {
};
return (
-
+
{loading ? (
) : (
diff --git a/Client/src/Pages/Monitors/Configure/index.css b/Client/src/Pages/Monitors/Configure/index.css
index 032833924..c59936d46 100644
--- a/Client/src/Pages/Monitors/Configure/index.css
+++ b/Client/src/Pages/Monitors/Configure/index.css
@@ -1,6 +1,3 @@
-.configure-monitor h1.MuiTypography-root + span.MuiTypography-root {
- font-size: var(--env-var-font-size-small-plus);
-}
.configure-monitor button.MuiButtonBase-root {
height: var(--env-var-height-2);
}
diff --git a/Client/src/Pages/Monitors/Configure/index.jsx b/Client/src/Pages/Monitors/Configure/index.jsx
index 34076dd89..cd55837a7 100644
--- a/Client/src/Pages/Monitors/Configure/index.jsx
+++ b/Client/src/Pages/Monitors/Configure/index.jsx
@@ -223,12 +223,7 @@ const Configure = () => {
>
-
+
{monitor.name}
{
/>
-
+
{monitor.url?.replace(/^https?:\/\//, "") || "..."}
{
];
return (
-
+
{
gap={theme.spacing(12)}
mt={theme.spacing(6)}
>
-
-
+
+
Create your{" "}
-
+
monitor
@@ -262,7 +256,7 @@ const CreateMonitor = () => {
onChange={(event) => handleChange(event)}
/>
{monitor.type === "http" ? (
-
+
@@ -417,12 +410,11 @@ const DetailsPage = ({ isAdmin }) => {
fontSize={11}
color={theme.palette.text.tertiary}
>
- {formatDate(new Date(hoveredIncidentsData.time), {
- month: "short",
- year: undefined,
- minute: undefined,
- hour: dateRange === "day" ? "numeric" : undefined,
- })}
+ {formatDateWithTz(
+ hoveredIncidentsData.time,
+ dateFormat,
+ uiTimezone
+ )}
)}
@@ -445,14 +437,8 @@ const DetailsPage = ({ isAdmin }) => {
data={[{ response: monitor?.periodAvgResponseTime }]}
/>
-
-
+
+
diff --git a/Client/src/Pages/Monitors/Details/styled.jsx b/Client/src/Pages/Monitors/Details/styled.jsx
index 99112802d..1e34fbbc9 100644
--- a/Client/src/Pages/Monitors/Details/styled.jsx
+++ b/Client/src/Pages/Monitors/Details/styled.jsx
@@ -40,7 +40,7 @@ export const ChartBox = styled(Stack)(({ theme }) => ({
fill: theme.palette.text.tertiary,
},
"& path": {
- transition: "fill 300ms ease",
+ transition: "fill 300ms ease, stroke-width 400ms ease",
},
}));
@@ -76,6 +76,7 @@ export const StatBox = styled(Box)(({ theme }) => ({
borderColor: theme.palette.border.light,
borderRadius: 4,
backgroundColor: theme.palette.background.main,
+ background: `linear-gradient(340deg, ${theme.palette.background.accent} 20%, ${theme.palette.background.main} 45%)`,
"& h2": {
fontSize: 13,
fontWeight: 500,
diff --git a/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx b/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx
index 47c080284..b7e50a499 100644
--- a/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx
+++ b/Client/src/Pages/Monitors/Home/MonitorTable/index.jsx
@@ -14,9 +14,10 @@ import {
Button,
} from "@mui/material";
import ArrowDownwardRoundedIcon from "@mui/icons-material/ArrowDownwardRounded";
+import ArrowUpwardRoundedIcon from "@mui/icons-material/ArrowUpwardRounded";
import { setRowsPerPage } from "../../../../Features/UI/uiSlice";
-import { useState, useEffect } from "react";
+import { useState, useEffect, memo } from "react";
import { useNavigate } from "react-router";
import { logger } from "../../../../Utils/Logger";
import Host from "../host";
@@ -48,6 +49,7 @@ import useUtils from "../../utils";
*/
const TablePaginationActions = (props) => {
const { count, page, rowsPerPage, onPageChange } = props;
+
const handleFirstPageButtonClick = (event) => {
onPageChange(event, 0);
};
@@ -106,7 +108,7 @@ TablePaginationActions.propTypes = {
onPageChange: PropTypes.func.isRequired,
};
-const MonitorTable = ({ isAdmin }) => {
+const MonitorTable = ({ isAdmin, filter }) => {
const theme = useTheme();
const navigate = useNavigate();
const dispatch = useDispatch();
@@ -118,6 +120,7 @@ const MonitorTable = ({ isAdmin }) => {
const [monitorCount, setMonitorCount] = useState(0);
const authState = useSelector((state) => state.auth);
const [updateTrigger, setUpdateTrigger] = useState(false);
+ const [sort, setSort] = useState({});
const handleActionMenuDelete = () => {
setUpdateTrigger((prev) => !prev);
@@ -142,17 +145,20 @@ const MonitorTable = ({ isAdmin }) => {
try {
const { authToken } = authState;
const user = jwtDecode(authToken);
- const res = await networkService.getMonitorsByTeamId(
+ const res = await networkService.getMonitorsByTeamId({
authToken,
- user.teamId,
- 25,
- ["http", "ping"],
- null,
- "desc",
- true,
- page,
- rowsPerPage
- );
+ teamId: user.teamId,
+ limit: 25,
+ types: ["http", "ping"],
+ status: null,
+ checkOrder: "desc",
+ normalize: true,
+ page: page,
+ rowsPerPage: rowsPerPage,
+ filter: filter,
+ field: sort.field,
+ order: sort.order,
+ });
setMonitors(res?.data?.data?.monitors ?? []);
setMonitorCount(res?.data?.data?.monitorCount ?? 0);
} catch (error) {
@@ -160,7 +166,7 @@ const MonitorTable = ({ isAdmin }) => {
}
};
fetchPage();
- }, [updateTrigger, authState, page, rowsPerPage]);
+ }, [updateTrigger, authState, page, rowsPerPage, filter, sort]);
/**
* Helper function to calculate the range of displayed rows.
@@ -172,19 +178,80 @@ const MonitorTable = ({ isAdmin }) => {
return `${start} - ${end}`;
};
+ const handleSort = async (field) => {
+ let order = "";
+ if (sort.field !== field) {
+ order = "desc";
+ } else {
+ order = sort.order === "asc" ? "desc" : "asc";
+ }
+ setSort({ field, order });
+
+ const { authToken } = authState;
+ const user = jwtDecode(authToken);
+
+ const res = await networkService.getMonitorsByTeamId({
+ authToken,
+ teamId: user.teamId,
+ limit: 25,
+ types: ["http", "ping"],
+ status: null,
+ checkOrder: "desc",
+ normalize: true,
+ page: page,
+ rowsPerPage: rowsPerPage,
+ filter: null,
+ field: field,
+ order: order,
+ });
+ setMonitors(res?.data?.data?.monitors ?? []);
+ setMonitorCount(res?.data?.data?.monitorCount ?? 0);
+ };
+
return (
<>
- Host
-
+ handleSort("name")}
+ >
+
+ Host
+
+ {sort.order === "asc" ? (
+
+ ) : (
+
+ )}
+
+
+
+ handleSort("status")}
+ >
{" "}
+ {" "}
Status
-
-
+
+ {sort.order === "asc" ? (
+
+ ) : (
+
+ )}
@@ -272,13 +339,8 @@ const MonitorTable = ({ isAdmin }) => {
alignItems="center"
justifyContent="space-between"
px={theme.spacing(4)}
- sx={{
- "& p": {
- color: theme.palette.text.tertiary,
- },
- }}
>
-
+
Showing {getRange()} of {monitorCount} monitor(s)
{
MonitorTable.propTypes = {
isAdmin: PropTypes.bool,
+ filter: PropTypes.string,
};
-export default MonitorTable;
+const MemoizedMonitorTable = memo(MonitorTable);
+export default MemoizedMonitorTable;
diff --git a/Client/src/Pages/Monitors/Home/actionsMenu.jsx b/Client/src/Pages/Monitors/Home/actionsMenu.jsx
index a271a8a9a..abb1af243 100644
--- a/Client/src/Pages/Monitors/Home/actionsMenu.jsx
+++ b/Client/src/Pages/Monitors/Home/actionsMenu.jsx
@@ -91,6 +91,7 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
anchorEl={anchorEl}
open={Boolean(anchorEl)}
onClose={(e) => closeMenu(e)}
+ disableScrollLock
slotProps={{
paper: {
sx: {
@@ -125,7 +126,14 @@ const ActionsMenu = ({ monitor, isAdmin, updateCallback }) => {
Details
{/* TODO - pass monitor id to Incidents page */}
-
+
{isAdmin && (