Feat/monitor endpoint refactor (#463)

* Moved all methods to modules

* removed old mongoDB file

* Refactored endpoints to take query params, removed duplicate methods, updated routes, updated Client queries

* Added comment

* Add model differentiation

* Add sort order, fix minor bug, add validation for query params
This commit is contained in:
Alexander Holliday authored and GitHub committed 2024-07-26 18:56:39 -07:00
1 parent e47d3685ce
commit 477cad7cc9
11 files changed
+132 -166

No files matched your search

@@ -51,7 +51,7 @@ export const getMonitorsByUserId = createAsyncThunk(
const user = jwtDecode(token);
try {
const res = await axiosInstance.get(
`/monitors/user/${user._id}?limit=25`,
`/monitors/user/${user._id}?limit=25&type=http&type=ping&sortOrder=desc`,
{
headers: {
Authorization: `Bearer ${token}`,
+1 -1
View File
@@ -33,7 +33,7 @@ const Incidents = () => {
useEffect(() => {
const fetchIncidents = async () => {
const res = await axiosInstance.get(
`/monitors/incidents/user/${authState.user._id}`,
`/monitors/user/${authState.user._id}?status=false`,
{
headers: {
Authorization: `Bearer ${authState.authToken}`,
+8 -5
View File
@@ -82,11 +82,14 @@ const DetailsPage = () => {
useEffect(() => {
const fetchMonitor = async () => {
const res = await axiosInstance.get(`/monitors/${monitorId}`, {
headers: {
Authorization: `Bearer ${authToken}`,
},
});
const res = await axiosInstance.get(
`/monitors/${monitorId}?sortOrder=asc`,
{
headers: {
Authorization: `Bearer ${authToken}`,
},
}
);
setMonitor(res.data.data);
const data = {
cols: [
+4 -1
View File
@@ -100,6 +100,9 @@ const Monitors = () => {
: "var(--env-var-color-19)",
};
// Reverse checks so latest check is on the right
const reversedChecks = monitor.checks.slice().reverse();
return {
id: monitor._id,
handleClick: () => navigate(`/monitors/${monitor._id}`),
@@ -117,7 +120,7 @@ const Monitors = () => {
/>
),
},
{ id: idx + 2, data: <ResponseTimeChart checks={monitor.checks} /> },
{ id: idx + 2, data: <ResponseTimeChart checks={reversedChecks} /> },
{ id: idx + 3, data: monitor.type },
{ id: idx + 4, data: "TODO" },
],