Skip to content

Commit

Permalink
Project details routing, controller (Backend) task
Browse files Browse the repository at this point in the history
In this PR , backend files are created for Project details controller, router and route for Phase 2
  • Loading branch information
Aishwaryak01 committed Nov 6, 2023
1 parent 5aabaaf commit fe6b661
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"moment": "^2.29.4",
"moment-timezone": "^0.5.35",
"mongodb": "^3.7.3",
"mongoose": "^5.13.15",
"mongoose": "^5.13.21",
"mongoose-validator": "^2.1.0",
"node-cache": "^5.1.2",
"node-datetime": "^2.0.3",
Expand Down
20 changes: 20 additions & 0 deletions src/controllers/bmdashboard/bmProjectDetailController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
const bmProjectDetailController = function (ProjectDetail) {
const bmProjectDetails = async function _projDetail(req, res) {
console.log(ProjectDetail);

//projectId from the request parameters object
const { projectId } = req.params;
try {
ProjectDetail
.findById(projectId)
.then(results => res.status(200).send(results))
.catch(error => res.status(500).send(error));
} catch (err) {
res.json(err);
}
};

return { bmProjectDetails };
};

module.exports = bmProjectDetailController;
33 changes: 33 additions & 0 deletions src/models/projectDetail.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const mongoose = require('mongoose');

const { Schema } = mongoose;

const projectDetail = new Schema({
projectName: { type: String, required: true, unique: true },
tools: [{
inventoryItemId: { type: Number, required: true },
title: { type: String, required: true },
image: { type: String, required: true },
rentedOnDate: { type: Date, required: true },
rentDuration: { type: String, required: true },
}],
materials: [{
inventoryItemId: { type: Number, required: true },
title: { type: String, required: true },
image: { type: String, required: true },
amountTotal: { type: Number, required: true },
amountUsed: { type: Number, required: true },
}],
people: [{
personId: { type: Number, required: true },
personName: { type: String, required: true },
personLastName: { type: String, required: true },
role: { type: String, required: true },
team: { type: String, required: true },
currentTask: { type: String, required: true },
totalHrs: { type: Number, required: true },
todayHrs: { type: Number, required: true },
}],
});

module.exports = mongoose.model('projectDetail', projectDetail, 'projectDetail');
15 changes: 15 additions & 0 deletions src/routes/bmdashboard/bmProjectDetailRouter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const express = require('express');

const routes = function (projectDetail) {

const projectRouter = express.Router();
const controller = require('../../controllers/bmdashboard/bmProjectDetailController')(projectDetail);

projectRouter.route('/projects/:projectId')
.get(controller.bmProjectDetails);

return projectRouter;

};

module.exports = routes;
2 changes: 2 additions & 0 deletions src/startup/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ const mouseoverTextRouter = require('../routes/mouseoverTextRouter')(mouseoverTe
// bm dashboard
const bmLoginRouter = require('../routes/bmdashboard/bmLoginRouter')();
const bmMaterialsRouter = require('../routes/bmdashboard/bmMaterialsRouter')(inventoryItemMaterial);
const bmProjectDetailRouter = require('../routes/bmdashboard/bmProjectDetailRouter')(projectDetail);

module.exports = function (app) {
app.use('/api', forgotPwdRouter);
Expand Down Expand Up @@ -93,4 +94,5 @@ module.exports = function (app) {
// bm dashboard
app.use('/api/bm', bmLoginRouter);
app.use('/api/bm', bmMaterialsRouter);
app.use('/api/bm', bmProjectDetailRouter);
};

0 comments on commit fe6b661

Please sign in to comment.