Skip to content

Commit

Permalink
Merge pull request #92 from NSWC-Crane/CHRIS_DEV
Browse files Browse the repository at this point in the history
Reference pull request for full details.
  • Loading branch information
crodriguez6497 authored Aug 23, 2024
2 parents de32ad1 + e1d7edf commit 13f36e2
Show file tree
Hide file tree
Showing 92 changed files with 2,798 additions and 2,797 deletions.
4 changes: 3 additions & 1 deletion api/Controllers/Collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ module.exports.getCollectionBasicList = async function getCollectionBasicList(re

module.exports.getCollections = async function getCollections(req, res, next) {
try {
const getCollections = await collectionService.getCollections(req.params.userName);
const userId = req.userObject.userId;
const elevate = req.query.elevate;
const getCollections = await collectionService.getCollections(userId, elevate);
if (getCollections.error) {
res.status(500).json({ error: 'Internal Server Error', detail: getCollections.error });
} else {
Expand Down
4 changes: 2 additions & 2 deletions api/Controllers/Marketplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ module.exports.purchaseTheme = async function purchaseTheme(req, res, next) {

module.exports.getUserThemes = async function getUserThemes(req, res, next) {
try {
const userId = req.params.userId;
const userId = req.userObject.userId;
const themes = await marketplaceService.getUserThemes(userId);
res.status(200).json(themes);
} catch (error) {
Expand All @@ -45,7 +45,7 @@ module.exports.getUserThemes = async function getUserThemes(req, res, next) {

module.exports.getUserPoints = async function getUserPoints(req, res, next) {
try {
const userId = req.params.userId;
const userId = req.userObject.userId;
const points = await marketplaceService.getUserPoints(userId);
res.status(200).json(points);
} catch (error) {
Expand Down
42 changes: 28 additions & 14 deletions api/Controllers/Metrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const metricsService = require('../Services/metricsService');

module.exports.getCollectionAssetLabel = async function getCollectionAssetLabel(req, res, next) {
try {
const getMetrics = await metricsService.getCollectionAssetLabel(req, res, next);
const collectionId = req.params.collectionId;
const getMetrics = await metricsService.getCollectionAssetLabel(collectionId);
if (getMetrics) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -25,7 +26,8 @@ module.exports.getCollectionAssetLabel = async function getCollectionAssetLabel(

module.exports.getCollectionPoamLabel = async function getCollectionPoamLabel(req, res, next) {
try {
const getMetrics = await metricsService.getCollectionPoamLabel(req, res, next);
const collectionId = req.params.collectionId;
const getMetrics = await metricsService.getCollectionPoamLabel(collectionId);
if (getMetrics) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -38,7 +40,8 @@ module.exports.getCollectionPoamLabel = async function getCollectionPoamLabel(re

module.exports.getCollectionPoamStatus = async function getCollectionPoamStatus(req, res, next) {
try {
const getMetrics = await metricsService.getCollectionPoamStatus(req, res, next);
const collectionId = req.params.collectionId;
const getMetrics = await metricsService.getCollectionPoamStatus(collectionId);
if (getMetrics && getMetrics.poamStatus) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -51,7 +54,8 @@ module.exports.getCollectionPoamStatus = async function getCollectionPoamStatus(

module.exports.getCollectionPoamSeverity = async function getCollectionPoamSeverity(req, res, next) {
try {
const getMetrics = await metricsService.getCollectionPoamSeverity(req, res, next);
const collectionId = req.params.collectionId;
const getMetrics = await metricsService.getCollectionPoamSeverity(collectionId);
if (getMetrics && getMetrics.poamSeverity) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -64,7 +68,8 @@ module.exports.getCollectionPoamSeverity = async function getCollectionPoamSever

module.exports.getCollectionPoamScheduledCompletion = async function getCollectionPoamScheduledCompletion(req, res, next) {
try {
const getMetrics = await metricsService.getCollectionPoamScheduledCompletion(req, res, next);
const collectionId = req.params.collectionId;
const getMetrics = await metricsService.getCollectionPoamScheduledCompletion(collectionId);
if (getMetrics && getMetrics.poamScheduledCompletion) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -77,7 +82,8 @@ module.exports.getCollectionPoamScheduledCompletion = async function getCollecti

module.exports.getCollectionMonthlyPoamStatus = async function getCollectionMonthlyPoamStatus(req, res, next) {
try {
const getMetrics = await metricsService.getCollectionMonthlyPoamStatus(req, res, next);
const collectionId = req.params.collectionId;
const getMetrics = await metricsService.getCollectionMonthlyPoamStatus(collectionId);
if (getMetrics && getMetrics.poamStatus) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -90,7 +96,8 @@ module.exports.getCollectionMonthlyPoamStatus = async function getCollectionMont

module.exports.getAvailableAssetLabel = async function getAvailableAssetLabel(req, res, next) {
try {
const getMetrics = await metricsService.getAvailableAssetLabel(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailableAssetLabel(userId);
if (getMetrics) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -103,7 +110,8 @@ module.exports.getAvailableAssetLabel = async function getAvailableAssetLabel(re

module.exports.getAvailablePoamLabel = async function getAvailablePoamLabel(req, res, next) {
try {
const getMetrics = await metricsService.getAvailablePoamLabel(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailablePoamLabel(userId);
if (getMetrics) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -116,7 +124,8 @@ module.exports.getAvailablePoamLabel = async function getAvailablePoamLabel(req,

module.exports.getAvailableCollectionPoamCounts = async function getAvailableCollectionPoamCounts(req, res, next) {
try {
const getMetrics = await metricsService.getAvailableCollectionPoamCounts(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailableCollectionPoamCounts(userId);
if (getMetrics) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -129,7 +138,8 @@ module.exports.getAvailableCollectionPoamCounts = async function getAvailableCol

module.exports.getAvailablePoamStatus = async function getAvailablePoamStatus(req, res, next) {
try {
const getMetrics = await metricsService.getAvailablePoamStatus(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailablePoamStatus(userId);
if (getMetrics && getMetrics.poamStatus) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -142,7 +152,8 @@ module.exports.getAvailablePoamStatus = async function getAvailablePoamStatus(re

module.exports.getAvailablePoamSeverity = async function getAvailablePoamSeverity(req, res, next) {
try {
const getMetrics = await metricsService.getAvailablePoamSeverity(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailablePoamSeverity(userId);
if (getMetrics && getMetrics.poamSeverity) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -155,7 +166,8 @@ module.exports.getAvailablePoamSeverity = async function getAvailablePoamSeverit

module.exports.getAvailableMonthlyPoamSeverity = async function getAvailableMonthlyPoamSeverity(req, res, next) {
try {
const getMetrics = await metricsService.getAvailableMonthlyPoamSeverity(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailableMonthlyPoamSeverity(userId);
if (getMetrics && getMetrics.poamSeverity) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -168,7 +180,8 @@ module.exports.getAvailableMonthlyPoamSeverity = async function getAvailableMont

module.exports.getAvailableMonthlyPoamStatus = async function getAvailableMonthlyPoamStatus(req, res, next) {
try {
const getMetrics = await metricsService.getAvailableMonthlyPoamStatus(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailableMonthlyPoamStatus(userId);
if (getMetrics && getMetrics.poamStatus) {
res.status(200).json(getMetrics);
} else {
Expand All @@ -181,7 +194,8 @@ module.exports.getAvailableMonthlyPoamStatus = async function getAvailableMonthl

module.exports.getAvailablePoamScheduledCompletion = async function getAvailablePoamScheduledCompletion(req, res, next) {
try {
const getMetrics = await metricsService.getAvailablePoamScheduledCompletion(req, res, next);
const userId = req.userObject.userId;
const getMetrics = await metricsService.getAvailablePoamScheduledCompletion(userId);
if (getMetrics && getMetrics.poamScheduledCompletion) {
res.status(200).json(getMetrics);
} else {
Expand Down
44 changes: 25 additions & 19 deletions api/Controllers/Notification.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,45 @@

const notificationService = require('../Services/notificationService');

module.exports.getAllNotificationsByUserId = async function getAllNotificationsByUserId(req, res, next) {
module.exports.getAllNotifications = async function getAllNotifications(req, res, next) {
try {
const userId = req.params.userId;
const notifications = await notificationService.getAllNotificationsByUserId(userId);
const userId = req.userObject.userId;
const notifications = await notificationService.getAllNotifications(userId);

res.status(200).json(notifications);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
};

module.exports.getUnreadNotificationsByUserId = async function getUnreadNotificationsByUserId(req, res, next) {
module.exports.getUnreadNotifications = async function getUnreadNotifications(req, res, next) {
try {
const userId = req.params.userId;
const notifications = await notificationService.getUnreadNotificationsByUserId(userId);
const userId = req.userObject.userId;
const notifications = await notificationService.getUnreadNotifications(userId);

res.status(200).json(notifications);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
};

module.exports.getUnreadNotificationCountByUserId = async function getUnreadNotificationCountByUserId(req, res, next) {
module.exports.getUnreadNotificationCount = async function getUnreadNotificationCount(req, res, next) {
try {
const userId = req.params.userId;
const notificationCount = await notificationService.getUnreadNotificationCountByUserId(userId);
const userId = req.userObject.userId;
const notificationCount = await notificationService.getUnreadNotificationCount(userId);

res.status(200).json(notificationCount);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
};

module.exports.dismissNotificationByNotificationId = async function dismissNotificationByNotificationId(req, res, next) {
module.exports.dismissNotification = async function dismissNotification(req, res, next) {
try {
const userId = req.userObject.userId;
const notificationId = req.params.notificationId;
const unreadNotifications = await notificationService.dismissNotificationByNotificationId(notificationId);
const unreadNotifications = await notificationService.dismissNotification(userId, notificationId);

if (unreadNotifications !== null) {
res.status(200).json(unreadNotifications);
} else {
Expand All @@ -54,10 +59,10 @@ module.exports.dismissNotificationByNotificationId = async function dismissNotif
}
};

module.exports.dismissAllNotificationsByUserId = async function dismissAllNotificationsByUserId(req, res, next) {
module.exports.dismissAllNotifications = async function dismissAllNotifications(req, res, next) {
try {
const userId = req.params.userId;
const dismissed = await notificationService.dismissAllNotificationsByUserId(userId);
const userId = req.userObject.userId;
const dismissed = await notificationService.dismissAllNotifications(userId);
if (dismissed) {
res.status(204).json();
} else {
Expand All @@ -68,10 +73,11 @@ module.exports.dismissAllNotificationsByUserId = async function dismissAllNotifi
}
};

module.exports.deleteNotificationByNotificationId = async function deleteNotificationByNotificationId(req, res, next) {
module.exports.deleteNotification = async function deleteNotification(req, res, next) {
try {
const userId = req.userObject.userId;
const notificationId = req.params.notificationId;
const deleted = await notificationService.deleteNotificationByNotificationId(notificationId);
const deleted = await notificationService.deleteNotification(userId, notificationId);

if (deleted) {
res.status(204).send();
Expand All @@ -83,10 +89,10 @@ module.exports.deleteNotificationByNotificationId = async function deleteNotific
}
};

module.exports.deleteAllNotificationsByUserId = async function deleteAllNotificationsByUserId(req, res, next) {
module.exports.deleteAllNotifications = async function deleteAllNotifications(req, res, next) {
try {
const userId = req.params.userId;
const deleted = await notificationService.deleteAllNotificationsByUserId(userId);
const userId = req.userObject.userId;
const deleted = await notificationService.deleteAllNotifications(userId);

if (deleted) {
res.status(204).send();
Expand Down
24 changes: 9 additions & 15 deletions api/Controllers/Permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,6 @@

const permissionService = require('../Services/permissionsService');

module.exports.getCollectionPermission = async function getCollectionPermission(req, res, next) {
try {
const getCollection = await permissionService.getCollectionPermission(req.params.userName, req.params.collectionId, req, res, next);
if (getCollection) {
res.status(200).json(getCollection);
} else {
res.status(204).send();
}
} catch (error) {
res.status(500).json({ error: 'Internal Server Error', detail: error.message });
}
};

module.exports.getCollectionPermissions = async function getCollectionPermissions(req, res, next) {
try {
Expand All @@ -38,7 +26,9 @@ module.exports.getCollectionPermissions = async function getCollectionPermission

module.exports.postPermission = async function postPermission(req, res, next) {
try {
const permission = await permissionService.postPermission(req, res, next);
const userId = req.userObject.userId;
const elevate = req.query.elevate;
const permission = await permissionService.postPermission(userId, elevate, req);
res.status(201).json(permission);
} catch (error) {
if (error.status === 400) {
Expand All @@ -51,7 +41,9 @@ module.exports.postPermission = async function postPermission(req, res, next) {

module.exports.putPermission = async function putPermission(req, res, next) {
try {
const permission = await permissionService.putPermission(req, res, next);
const userId = req.userObject.userId;
const elevate = req.query.elevate;
const permission = await permissionService.putPermission(userId, elevate, req);
res.status(200).json(permission);
} catch (error) {
if (error.status === 400) {
Expand All @@ -64,7 +56,9 @@ module.exports.putPermission = async function putPermission(req, res, next) {

module.exports.deletePermission = async function deletePermission(req, res, next) {
try {
await permissionService.deletePermission(req, res, next);
const userId = req.userObject.userId;
const elevate = req.query.elevate;
await permissionService.deletePermission(userId, elevate, req);
res.status(204).send();
} catch (error) {
if (error.status === 400) {
Expand Down
3 changes: 2 additions & 1 deletion api/Controllers/Poam.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ const poamService = require('../Services/poamService');

module.exports.getAvailablePoams = async function getAvailablePoams(req, res, next) {
try {
const poams = await poamService.getAvailablePoams(req, res, next);
const userId = req.userObject.userId;
const poams = await poamService.getAvailablePoams(userId, req);
res.status(200).json(poams);
} catch (error) {
if (error.status === 400) {
Expand Down
18 changes: 0 additions & 18 deletions api/Controllers/PoamApprover.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,6 @@ module.exports.getPoamApproversByCollection = async function getPoamApproversByC
}
};

module.exports.getPoamApproversByCollectionUser = async function getPoamApproversByCollectionUser(req, res, next) {
try {
const poamApprovers = await poamApproverService.getPoamApproversByCollectionUser(req, res, next);
res.status(200).json(poamApprovers);
} catch (error) {
res.status(400).json({ error: error.message });
}
};

module.exports.getPoamApproversByUserId = async function getPoamApproversByUserId(req, res, next) {
try {
const poamApprovers = await poamApproverService.getPoamApproversByUserId(req, res, next);
res.status(200).json(poamApprovers);
} catch (error) {
res.status(400).json({ error: error.message });
}
};

module.exports.postPoamApprover = async function postPoamApprover(req, res, next) {
try {
const poamApprover = await poamApproverService.postPoamApprover(req, res, next);
Expand Down
19 changes: 0 additions & 19 deletions api/Controllers/PoamAssignees.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,6 @@ exports.getPoamAssigneesByPoamId = async function getPoamAssigneesByPoamId(req,
}
};


exports.getPoamAssigneesByUserId = async function getPoamAssigneesByUserId(req, res, next) {
try {
const result = await poamAssigneeService.getPoamAssigneesByUserId(req, res, next);
return res.status(200).json(result);
} catch (error) {
return res.status(500).json({ error: "An error occurred while retrieving POAM assignees by userId" });
}
};

exports.getPoamAssignee = async function getPoamAssignee(req, res, next) {
try {
const result = await poamAssigneeService.getPoamAssignee(req, res, next);
return res.status(200).json(result);
} catch (error) {
return res.status(500).json({ error: "An error occurred while retrieving the POAM assignee" });
}
};

exports.postPoamAssignee = async function postPoamAssignee(req, res, next) {
try {
const assignee = await poamAssigneeService.postPoamAssignee(req, res, next);
Expand Down
3 changes: 2 additions & 1 deletion api/Controllers/PoamLabel.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ module.exports.getPoamLabels = async function getPoamLabels(req, res, next) {

module.exports.getAvailablePoamLabels = async function getAvailablePoamLabels(req, res, next) {
try {
const poamLabels = await poamLabelService.getAvailablePoamLabels(req, res, next);
const userId = req.userObject.userId;
const poamLabels = await poamLabelService.getAvailablePoamLabels(userId);
res.status(200).json(poamLabels);
} catch (error) {
if (error.message === 'User ID is required') {
Expand Down
Loading

0 comments on commit 13f36e2

Please sign in to comment.