Merge pull request #1177 from bluewave-labs/feat/infras-monitor-details-request
feat/infra monitor details request
This commit is contained in:
4 files changed
+17
-7
No files matched your search
@@ -9,6 +9,7 @@ import { useSelector } from "react-redux";
|
|||||||
import { networkService } from "../../../main";
|
import { networkService } from "../../../main";
|
||||||
import PulseDot from "../../../Components/Animated/PulseDot";
|
import PulseDot from "../../../Components/Animated/PulseDot";
|
||||||
import useUtils from "../../Monitors/utils";
|
import useUtils from "../../Monitors/utils";
|
||||||
|
import { logger } from "../../../Utils/Logger";
|
||||||
import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils";
|
import { formatDurationRounded, formatDurationSplit } from "../../../Utils/timeUtils";
|
||||||
import {
|
import {
|
||||||
TzTick,
|
TzTick,
|
||||||
@@ -169,7 +170,7 @@ const InfrastructureDetails = () => {
|
|||||||
];
|
];
|
||||||
const [monitor, setMonitor] = useState(null);
|
const [monitor, setMonitor] = useState(null);
|
||||||
const { authToken } = useSelector((state) => state.auth);
|
const { authToken } = useSelector((state) => state.auth);
|
||||||
const [dateRange, setDateRange] = useState("day");
|
const [dateRange, setDateRange] = useState("all");
|
||||||
const { statusColor, determineState } = useUtils();
|
const { statusColor, determineState } = useUtils();
|
||||||
// These calculations are needed because ResponsiveContainer
|
// These calculations are needed because ResponsiveContainer
|
||||||
// doesn't take padding of parent/siblings into account
|
// doesn't take padding of parent/siblings into account
|
||||||
@@ -189,19 +190,19 @@ const InfrastructureDetails = () => {
|
|||||||
const response = await networkService.getStatsByMonitorId({
|
const response = await networkService.getStatsByMonitorId({
|
||||||
authToken: authToken,
|
authToken: authToken,
|
||||||
monitorId: monitorId,
|
monitorId: monitorId,
|
||||||
sortOrder: null,
|
sortOrder: "asc",
|
||||||
limit: null,
|
limit: null,
|
||||||
dateRange: dateRange,
|
dateRange: dateRange,
|
||||||
numToDisplay: 50,
|
numToDisplay: 50,
|
||||||
normalize: true,
|
normalize: false,
|
||||||
});
|
});
|
||||||
setMonitor(response.data.data);
|
setMonitor(response.data.data);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
logger.error(error);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchData();
|
fetchData();
|
||||||
}, []);
|
}, [dateRange, monitorId, authToken]);
|
||||||
|
|
||||||
const statBoxConfigs = [
|
const statBoxConfigs = [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,6 +44,14 @@ class Logger {
|
|||||||
this.log = NO_OP;
|
this.log = NO_OP;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (logLevel === "debug") {
|
||||||
|
this.error = console.error.bind(console);
|
||||||
|
this.warn = console.warn.bind(console);
|
||||||
|
this.info = console.info.bind(console);
|
||||||
|
this.log = console.log.bind(console);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ const getIncidents = (checks) => {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Get date range parameters
|
* Get date range parameters
|
||||||
* @param {string} dateRange - 'day' | 'week' | 'month'
|
* @param {string} dateRange - 'day' | 'week' | 'month' | 'all'
|
||||||
* @returns {Object} Start and end dates
|
* @returns {Object} Start and end dates
|
||||||
*/
|
*/
|
||||||
const getDateRange = (dateRange) => {
|
const getDateRange = (dateRange) => {
|
||||||
@@ -206,6 +206,7 @@ const getDateRange = (dateRange) => {
|
|||||||
day: new Date(new Date().setDate(new Date().getDate() - 1)),
|
day: new Date(new Date().setDate(new Date().getDate() - 1)),
|
||||||
week: new Date(new Date().setDate(new Date().getDate() - 7)),
|
week: new Date(new Date().setDate(new Date().getDate() - 7)),
|
||||||
month: new Date(new Date().setMonth(new Date().getMonth() - 1)),
|
month: new Date(new Date().setMonth(new Date().getMonth() - 1)),
|
||||||
|
all: new Date(0),
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
start: startDates[dateRange],
|
start: startDates[dateRange],
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ const getMonitorStatsByIdQueryValidation = joi.object({
|
|||||||
status: joi.string(),
|
status: joi.string(),
|
||||||
limit: joi.number(),
|
limit: joi.number(),
|
||||||
sortOrder: joi.string().valid("asc", "desc"),
|
sortOrder: joi.string().valid("asc", "desc"),
|
||||||
dateRange: joi.string().valid("day", "week", "month"),
|
dateRange: joi.string().valid("day", "week", "month", "all"),
|
||||||
numToDisplay: joi.number(),
|
numToDisplay: joi.number(),
|
||||||
normalize: joi.boolean(),
|
normalize: joi.boolean(),
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in new issue
Block a user