Naming Changes in BE
This commit is contained in:
1 parent
30d85e5712
commit
183c13fe53
7 files changed
+46
-23
No files matched your search
@@ -8,6 +8,7 @@ const useFetchChecksTeam = ({
|
|||||||
limit,
|
limit,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
enabled = true,
|
enabled = true,
|
||||||
@@ -29,6 +30,7 @@ const useFetchChecksTeam = ({
|
|||||||
limit,
|
limit,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
};
|
};
|
||||||
@@ -47,7 +49,7 @@ const useFetchChecksTeam = ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
fetchChecks();
|
fetchChecks();
|
||||||
}, [status, sortOrder, limit, dateRange, filter, page, rowsPerPage, enabled]);
|
}, [status, sortOrder, limit, dateRange, filter, ack, page, rowsPerPage, enabled]);
|
||||||
|
|
||||||
return [checks, checksCount, isLoading, networkError];
|
return [checks, checksCount, isLoading, networkError];
|
||||||
};
|
};
|
||||||
@@ -60,6 +62,7 @@ const useFetchChecksByMonitor = ({
|
|||||||
limit,
|
limit,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
enabled = true,
|
enabled = true,
|
||||||
@@ -83,6 +86,7 @@ const useFetchChecksByMonitor = ({
|
|||||||
limit,
|
limit,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
};
|
};
|
||||||
@@ -109,6 +113,7 @@ const useFetchChecksByMonitor = ({
|
|||||||
limit,
|
limit,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
enabled,
|
enabled,
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ const IncidentTable = ({
|
|||||||
limit: null,
|
limit: null,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter: filter === "resolved" ? "all" : filter,
|
filter: filter === "resolved" ? "all" : filter,
|
||||||
|
ack: filter === "resolved" ? true : false,
|
||||||
page: page,
|
page: page,
|
||||||
rowsPerPage: rowsPerPage,
|
rowsPerPage: rowsPerPage,
|
||||||
enabled: selectedMonitor !== "0",
|
enabled: selectedMonitor !== "0",
|
||||||
@@ -53,6 +54,7 @@ const IncidentTable = ({
|
|||||||
limit: null,
|
limit: null,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter: filter === "resolved" ? "all" : filter,
|
filter: filter === "resolved" ? "all" : filter,
|
||||||
|
ack: filter === "resolved" ? true : false,
|
||||||
page: page,
|
page: page,
|
||||||
rowsPerPage: rowsPerPage,
|
rowsPerPage: rowsPerPage,
|
||||||
enabled: selectedMonitor === "0",
|
enabled: selectedMonitor === "0",
|
||||||
|
|||||||
@@ -549,6 +549,7 @@ class NetworkService {
|
|||||||
* @param {number} config.limit - The maximum number of checks to retrieve.
|
* @param {number} config.limit - The maximum number of checks to retrieve.
|
||||||
* @param {string} config.dateRange - The range of dates for which to retrieve checks.
|
* @param {string} config.dateRange - The range of dates for which to retrieve checks.
|
||||||
* @param {string} config.filter - The filter to apply to the checks.
|
* @param {string} config.filter - The filter to apply to the checks.
|
||||||
|
* @param {boolean} config.ack - The acknowledgment status to apply to the checks.
|
||||||
* @param {number} config.page - The page number to retrieve in a paginated list.
|
* @param {number} config.page - The page number to retrieve in a paginated list.
|
||||||
* @param {number} config.rowsPerPage - The number of rows per page in a paginated list.
|
* @param {number} config.rowsPerPage - The number of rows per page in a paginated list.
|
||||||
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
|
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
|
||||||
@@ -562,6 +563,7 @@ class NetworkService {
|
|||||||
if (config.limit) params.append("limit", config.limit);
|
if (config.limit) params.append("limit", config.limit);
|
||||||
if (config.dateRange) params.append("dateRange", config.dateRange);
|
if (config.dateRange) params.append("dateRange", config.dateRange);
|
||||||
if (config.filter) params.append("filter", config.filter);
|
if (config.filter) params.append("filter", config.filter);
|
||||||
|
if (config.ack !== undefined) params.append("ack", config.ack);
|
||||||
if (config.page) params.append("page", config.page);
|
if (config.page) params.append("page", config.page);
|
||||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||||
if (config.status !== undefined) params.append("status", config.status);
|
if (config.status !== undefined) params.append("status", config.status);
|
||||||
@@ -581,6 +583,7 @@ class NetworkService {
|
|||||||
* @param {number} config.limit - The maximum number of checks to retrieve.
|
* @param {number} config.limit - The maximum number of checks to retrieve.
|
||||||
* @param {string} config.dateRange - The range of dates for which to retrieve checks.
|
* @param {string} config.dateRange - The range of dates for which to retrieve checks.
|
||||||
* @param {string} config.filter - The filter to apply to the checks.
|
* @param {string} config.filter - The filter to apply to the checks.
|
||||||
|
* @param {boolean} config.ack - The acknowledgment status to apply to the checks.
|
||||||
* @param {number} config.page - The page number to retrieve in a paginated list.
|
* @param {number} config.page - The page number to retrieve in a paginated list.
|
||||||
* @param {number} config.rowsPerPage - The number of rows per page in a paginated list.
|
* @param {number} config.rowsPerPage - The number of rows per page in a paginated list.
|
||||||
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
|
* @returns {Promise<AxiosResponse>} The response from the axios GET request.
|
||||||
@@ -592,6 +595,7 @@ class NetworkService {
|
|||||||
if (config.limit) params.append("limit", config.limit);
|
if (config.limit) params.append("limit", config.limit);
|
||||||
if (config.dateRange) params.append("dateRange", config.dateRange);
|
if (config.dateRange) params.append("dateRange", config.dateRange);
|
||||||
if (config.filter) params.append("filter", config.filter);
|
if (config.filter) params.append("filter", config.filter);
|
||||||
|
if (config.ack !== undefined) params.append("ack", config.ack);
|
||||||
if (config.page) params.append("page", config.page);
|
if (config.page) params.append("page", config.page);
|
||||||
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
if (config.rowsPerPage) params.append("rowsPerPage", config.rowsPerPage);
|
||||||
if (config.status !== undefined) params.append("status", config.status);
|
if (config.status !== undefined) params.append("status", config.status);
|
||||||
|
|||||||
@@ -58,13 +58,15 @@ class CheckController {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const { monitorId } = req.params;
|
const { monitorId } = req.params;
|
||||||
let { type, sortOrder, dateRange, filter, page, rowsPerPage, status } = req.query;
|
let { type, sortOrder, dateRange, filter, ack, page, rowsPerPage, status } =
|
||||||
|
req.query;
|
||||||
const result = await this.db.getChecksByMonitor({
|
const result = await this.db.getChecksByMonitor({
|
||||||
monitorId,
|
monitorId,
|
||||||
type,
|
type,
|
||||||
sortOrder,
|
sortOrder,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
status,
|
status,
|
||||||
@@ -88,13 +90,14 @@ class CheckController {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let { sortOrder, dateRange, filter, page, rowsPerPage, status } = req.query;
|
let { sortOrder, dateRange, filter, ack, page, rowsPerPage, status } = req.query;
|
||||||
const { teamId } = req.user;
|
const { teamId } = req.user;
|
||||||
|
|
||||||
const checkData = await this.db.getChecksByTeam({
|
const checkData = await this.db.getChecksByTeam({
|
||||||
sortOrder,
|
sortOrder,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
teamId,
|
teamId,
|
||||||
@@ -109,7 +112,7 @@ class CheckController {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
updateCheckStatus = async (req, res, next) => {
|
ackCheck = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await updateCheckStatusBodyValidation.validateAsync(req.body);
|
await updateCheckStatusBodyValidation.validateAsync(req.body);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@@ -120,19 +123,20 @@ class CheckController {
|
|||||||
try {
|
try {
|
||||||
const { checkId } = req.params;
|
const { checkId } = req.params;
|
||||||
const { ack } = req.body;
|
const { ack } = req.body;
|
||||||
|
const { teamId } = req.user;
|
||||||
|
|
||||||
const updatedCheck = await this.db.updateCheckStatus(checkId, ack);
|
const updatedCheck = await this.db.ackCheck(checkId, teamId, ack);
|
||||||
|
|
||||||
return res.success({
|
return res.success({
|
||||||
msg: this.stringService.checkUpdateStatus,
|
msg: this.stringService.checkUpdateStatus,
|
||||||
data: updatedCheck,
|
data: updatedCheck,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(handleError(error, SERVICE_NAME, "updateCheckStatus"));
|
next(handleError(error, SERVICE_NAME, "ackCheck"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
updateAllChecksStatus = async (req, res, next) => {
|
ackAllChecks = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
await updateCheckStatusParamValidation.validateAsync(req.params);
|
await updateCheckStatusParamValidation.validateAsync(req.params);
|
||||||
await updateAllChecksStatusBodyValidation.validateAsync(req.body);
|
await updateAllChecksStatusBodyValidation.validateAsync(req.body);
|
||||||
@@ -142,17 +146,18 @@ class CheckController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { monitorId, target } = req.params;
|
const { monitorId, path } = req.params;
|
||||||
const { ack } = req.body;
|
const { ack } = req.body;
|
||||||
|
const { teamId } = req.user;
|
||||||
|
|
||||||
const updatedChecks = await this.db.updateAllChecksStatus(monitorId, ack, target);
|
const updatedChecks = await this.db.ackAllChecks(monitorId, teamId, ack, path);
|
||||||
|
|
||||||
return res.success({
|
return res.success({
|
||||||
msg: this.stringService.checkUpdateStatus,
|
msg: this.stringService.checkUpdateStatus,
|
||||||
data: updatedChecks,
|
data: updatedChecks,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(handleError(error, SERVICE_NAME, "updateAllChecksStatus"));
|
next(handleError(error, SERVICE_NAME, "ackAllChecks"));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -63,6 +63,7 @@ const getChecksByMonitor = async ({
|
|||||||
sortOrder,
|
sortOrder,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
status,
|
status,
|
||||||
@@ -75,6 +76,7 @@ const getChecksByMonitor = async ({
|
|||||||
const matchStage = {
|
const matchStage = {
|
||||||
monitorId: ObjectId.createFromHexString(monitorId),
|
monitorId: ObjectId.createFromHexString(monitorId),
|
||||||
...(typeof status !== "undefined" && { status }),
|
...(typeof status !== "undefined" && { status }),
|
||||||
|
...(typeof ack !== "undefined" && { ack: ack === "true" ? true : false }),
|
||||||
...(dateRangeLookup[dateRange] && {
|
...(dateRangeLookup[dateRange] && {
|
||||||
createdAt: {
|
createdAt: {
|
||||||
$gte: dateRangeLookup[dateRange],
|
$gte: dateRangeLookup[dateRange],
|
||||||
@@ -153,6 +155,7 @@ const getChecksByTeam = async ({
|
|||||||
sortOrder,
|
sortOrder,
|
||||||
dateRange,
|
dateRange,
|
||||||
filter,
|
filter,
|
||||||
|
ack,
|
||||||
page,
|
page,
|
||||||
rowsPerPage,
|
rowsPerPage,
|
||||||
teamId,
|
teamId,
|
||||||
@@ -165,6 +168,7 @@ const getChecksByTeam = async ({
|
|||||||
const matchStage = {
|
const matchStage = {
|
||||||
teamId: ObjectId.createFromHexString(teamId),
|
teamId: ObjectId.createFromHexString(teamId),
|
||||||
status: status,
|
status: status,
|
||||||
|
...(typeof ack !== "undefined" && { ack: ack === "true" ? true : false }),
|
||||||
...(dateRangeLookup[dateRange] && {
|
...(dateRangeLookup[dateRange] && {
|
||||||
createdAt: {
|
createdAt: {
|
||||||
$gte: dateRangeLookup[dateRange],
|
$gte: dateRangeLookup[dateRange],
|
||||||
@@ -242,14 +246,15 @@ const getChecksByTeam = async ({
|
|||||||
* Update the acknowledgment status of a check
|
* Update the acknowledgment status of a check
|
||||||
* @async
|
* @async
|
||||||
* @param {string} checkId - The ID of the check to update
|
* @param {string} checkId - The ID of the check to update
|
||||||
|
* @param {string} teamId - The ID of the team
|
||||||
* @param {boolean} ack - The acknowledgment status to set
|
* @param {boolean} ack - The acknowledgment status to set
|
||||||
* @returns {Promise<Check>}
|
* @returns {Promise<Check>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const updateCheckStatus = async (checkId, ack) => {
|
const ackCheck = async (checkId, teamId, ack) => {
|
||||||
try {
|
try {
|
||||||
const updatedCheck = await Check.findOneAndUpdate(
|
const updatedCheck = await Check.findOneAndUpdate(
|
||||||
{ _id: checkId },
|
{ _id: checkId, teamId: teamId },
|
||||||
{ $set: { ack, ackAt: new Date() } },
|
{ $set: { ack, ackAt: new Date() } },
|
||||||
{ new: true }
|
{ new: true }
|
||||||
);
|
);
|
||||||
@@ -261,7 +266,7 @@ const updateCheckStatus = async (checkId, ack) => {
|
|||||||
return updatedCheck;
|
return updatedCheck;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
error.method = "updateCheckStatus";
|
error.method = "ackCheck";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -271,20 +276,20 @@ const updateCheckStatus = async (checkId, ack) => {
|
|||||||
* @async
|
* @async
|
||||||
* @param {string} id - The monitor ID or team ID
|
* @param {string} id - The monitor ID or team ID
|
||||||
* @param {boolean} ack - The acknowledgment status to set
|
* @param {boolean} ack - The acknowledgment status to set
|
||||||
* @param {string} target - The target type ('monitor' or 'team')
|
* @param {string} path - The path type ('monitor' or 'team')
|
||||||
* @returns {Promise<number>}
|
* @returns {Promise<number>}
|
||||||
* @throws {Error}
|
* @throws {Error}
|
||||||
*/
|
*/
|
||||||
const updateAllChecksStatus = async (id, ack, target) => {
|
const ackAllChecks = async (monitorId, teamId, ack, path) => {
|
||||||
try {
|
try {
|
||||||
const updatedChecks = await Check.updateMany(
|
const updatedChecks = await Check.updateMany(
|
||||||
target === "monitor" ? { monitorId: id } : { teamId: id },
|
path === "monitor" ? { monitorId } : { teamId },
|
||||||
{ $set: { ack, ackAt: new Date() } }
|
{ $set: { ack, ackAt: new Date() } }
|
||||||
);
|
);
|
||||||
return updatedChecks.modifiedCount;
|
return updatedChecks.modifiedCount;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
error.service = SERVICE_NAME;
|
error.service = SERVICE_NAME;
|
||||||
error.method = "updateAllChecksStatus";
|
error.method = "ackAllChecks";
|
||||||
throw error;
|
throw error;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -370,8 +375,8 @@ export {
|
|||||||
createChecks,
|
createChecks,
|
||||||
getChecksByMonitor,
|
getChecksByMonitor,
|
||||||
getChecksByTeam,
|
getChecksByTeam,
|
||||||
updateCheckStatus,
|
ackCheck,
|
||||||
updateAllChecksStatus,
|
ackAllChecks,
|
||||||
deleteChecks,
|
deleteChecks,
|
||||||
deleteChecksByTeamId,
|
deleteChecksByTeamId,
|
||||||
updateChecksTTL,
|
updateChecksTTL,
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ class CheckRoutes {
|
|||||||
|
|
||||||
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
|
this.router.get("/:monitorId", this.checkController.getChecksByMonitor);
|
||||||
|
|
||||||
this.router.put("/:checkId", this.checkController.updateCheckStatus);
|
this.router.put("/:checkId", this.checkController.ackCheck);
|
||||||
|
|
||||||
this.router.put("/:monitorId/:target", this.checkController.updateAllChecksStatus);
|
this.router.put("/:path/:monitorId?", this.checkController.ackAllChecks);
|
||||||
|
|
||||||
this.router.post(
|
this.router.post(
|
||||||
"/:monitorId",
|
"/:monitorId",
|
||||||
|
|||||||
@@ -294,8 +294,8 @@ const updateCheckStatusBodyValidation = joi.object({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const updateCheckStatusParamValidation = joi.object({
|
const updateCheckStatusParamValidation = joi.object({
|
||||||
monitorId: joi.string(),
|
monitorId: joi.string().optional(),
|
||||||
target: joi.string().allow("monitor", "team"),
|
path: joi.string().valid("monitor", "team").required(),
|
||||||
});
|
});
|
||||||
|
|
||||||
const updateAllChecksStatusBodyValidation = joi.object({
|
const updateAllChecksStatusBodyValidation = joi.object({
|
||||||
@@ -312,6 +312,7 @@ const getChecksQueryValidation = joi.object({
|
|||||||
limit: joi.number(),
|
limit: joi.number(),
|
||||||
dateRange: joi.string().valid("recent", "hour", "day", "week", "month", "all"),
|
dateRange: joi.string().valid("recent", "hour", "day", "week", "month", "all"),
|
||||||
filter: joi.string().valid("all", "down", "resolve"),
|
filter: joi.string().valid("all", "down", "resolve"),
|
||||||
|
ack: joi.boolean(),
|
||||||
page: joi.number(),
|
page: joi.number(),
|
||||||
rowsPerPage: joi.number(),
|
rowsPerPage: joi.number(),
|
||||||
status: joi.boolean(),
|
status: joi.boolean(),
|
||||||
@@ -324,6 +325,7 @@ const getTeamChecksQueryValidation = joi.object({
|
|||||||
limit: joi.number(),
|
limit: joi.number(),
|
||||||
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
dateRange: joi.string().valid("hour", "day", "week", "month", "all"),
|
||||||
filter: joi.string().valid("all", "down", "resolve"),
|
filter: joi.string().valid("all", "down", "resolve"),
|
||||||
|
ack: joi.boolean(),
|
||||||
page: joi.number(),
|
page: joi.number(),
|
||||||
rowsPerPage: joi.number(),
|
rowsPerPage: joi.number(),
|
||||||
status: joi.boolean(),
|
status: joi.boolean(),
|
||||||
|
|||||||
Reference in new issue
Block a user