Merge branch 'develop' into fix/be/monitor-data-pagination
This commit is contained in:
1 file changed
+72
@@ -133,10 +133,82 @@ const DetailsPage = () => {
|
|||||||
}
|
}
|
||||||
}, [authToken, monitorId, navigate, filter]);
|
}, [authToken, monitorId, navigate, filter]);
|
||||||
|
|
||||||
|
const fetchDataForChart = async () => {
|
||||||
|
try {
|
||||||
|
const limit = 0;
|
||||||
|
|
||||||
|
const res = await axiosInstance.get(
|
||||||
|
`/monitors/${monitorId}?sortOrder=asc&limit=${limit}`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
const data = {
|
||||||
|
cols: [
|
||||||
|
{ id: 1, name: "Status" },
|
||||||
|
{ id: 2, name: "Date & Time" },
|
||||||
|
{ id: 3, name: "Message" },
|
||||||
|
],
|
||||||
|
rows: res.data.data.checks.map((check, idx) => {
|
||||||
|
const status = check.status === true ? "up" : "down";
|
||||||
|
|
||||||
|
return {
|
||||||
|
id: check._id,
|
||||||
|
data: [
|
||||||
|
{
|
||||||
|
id: idx,
|
||||||
|
data: (
|
||||||
|
<StatusLabel
|
||||||
|
status={status}
|
||||||
|
text={status}
|
||||||
|
customStyles={{ textTransform: "capitalize" }}
|
||||||
|
/>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: idx + 1,
|
||||||
|
data: new Date(check.createdAt).toLocaleString(),
|
||||||
|
},
|
||||||
|
{ id: idx + 2, data: check.statusCode },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
};
|
||||||
|
|
||||||
|
setData(data);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchMonitor = async () => {
|
||||||
|
try {
|
||||||
|
const res = await axiosInstance.get(
|
||||||
|
`/monitors/${monitorId}?sortOrder=asc`,
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Authorization: `Bearer ${authToken}`,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
);
|
||||||
|
setMonitor(res.data.data);
|
||||||
|
} catch (error) {
|
||||||
|
console.error("Error fetching monitor of id: " + monitorId);
|
||||||
|
navigate("/not-found");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fetchMonitor();
|
fetchMonitor();
|
||||||
}, [fetchMonitor]);
|
}, [fetchMonitor]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
fetchDataForTable();
|
||||||
|
}, [fetchDataForTable]);
|
||||||
|
|
||||||
|
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in new issue
Block a user