Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotrajano committed Jul 12, 2020
1 parent eb48bef commit 1f0f27d
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 3 deletions.
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const feature = require(`./routes/feature`);
const admin = require(`./routes/admin`);
const bug = require(`./routes/bug`);
const api = require(`./routes/api`);
const account = require(`./routes/account`);

app.use(
session({ secret: "trackpath", resave: false, saveUninitialized: true })
Expand Down Expand Up @@ -64,6 +65,7 @@ app.use(`/feature`, feature);
app.use(`/admin`, admin);
app.use(`/bug`, bug);
app.use(`/api`, api);
app.use(`/account`, account);

app.get(`/`, (req, res) => {
if (req.isAuthenticated()) {
Expand Down
3 changes: 1 addition & 2 deletions helpers/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {
return next();
}
req.flash("error_msg", "User not authorized!");
//res.redirect("/notauthorized");
res.redirect("/notauthorized");
res.redirect("/feature");
},
};
28 changes: 28 additions & 0 deletions routes/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,34 @@ router.get(`/getPriority`, (req, res) => {
router.get(`/getBugsByProject/:id`, (req, res) => {
Bug.getBugsByProject(req.params.id)
.then((results) => {
let listInProgress = [];
let listInTest = [];
let listOpen = [];
let listClosed = [];

results.forEach((bug) => {
if (bug.StatusID === 2) {
listInProgress.push(bug);
}
if (bug.StatusID === 3) {
listInTest.push(bug);
}
if (bug.StatusID === 1) {
listOpen.push(bug);
}
if (bug.StatusID === 4) {
listClosed.push(bug);
}
});

results = [];

results = results
.concat(listInProgress)
.concat(listInTest)
.concat(listOpen)
.concat(listClosed);

res.send(results);
})
.catch((err) => {
Expand Down
7 changes: 7 additions & 0 deletions routes/bug.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ router.get(`/solveIssue/:bugID`, isAuthenticated, (req, res) => {
router.post(`/solveIssue`, isAuthenticated, (req, res) => {
const bug = req.body;

bug.Summary =
bug.Summary +
"\n updated by: " +
req.user.name +
" on " +
moment().format("YYYY-MM-DD HH:mm");

Bug.updateSolveIssue(bug)
.then(() => {
req.flash("success_msg", "Issue successfully updated!");
Expand Down
36 changes: 36 additions & 0 deletions routes/feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const router = express.Router();
const Project = require(`../models/Project`);
const Feature = require(`../models/Feature`);
const StatusProgress = require(`../models/StatusProgress`);
const FeatureStatus = require(`../models/FeatureStatus`);
const moment = require("moment");
const { isAuthenticated, isAdmin } = require(`../helpers/permissions`);

Expand All @@ -13,6 +14,34 @@ router.get(`/`, isAuthenticated, (req, res) => {
router.get(`/getFeaturesByProject/:id`, isAuthenticated, (req, res) => {
Feature.findFeaturesByProjects(req.params.id)
.then((features) => {
let listInProgress = [];
let listInTest = [];
let listOpen = [];
let listClosed = [];

features.forEach((feature) => {
if (feature.FeatureStatusID === 2) {
listInProgress.push(feature);
}
if (feature.FeatureStatusID === 3) {
listInTest.push(feature);
}
if (feature.FeatureStatusID === 1) {
listOpen.push(feature);
}
if (feature.FeatureStatusID === 4) {
listClosed.push(feature);
}
});

features = [];

features = features
.concat(listInProgress)
.concat(listInTest)
.concat(listOpen)
.concat(listClosed);

res.send(features);
})
.catch((e) => {
Expand Down Expand Up @@ -83,6 +112,13 @@ router.post(`/solveIssue`, isAuthenticated, (req, res) => {
StatusProgressID: req.body.Progress,
};

feature.DescriptionFeature =
feature.DescriptionFeature +
"\n updated by: " +
req.user.name +
" on " +
moment().format("YYYY-MM-DD HH:mm");

Feature.updateSolveIssue(feature)
.then(() => {
req.flash("success_msg", "Feature successfully updated!");
Expand Down
2 changes: 1 addition & 1 deletion views/partials/_navbar.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<div>
{{#if user}}
<a class="login-access">
<h4>User: </h4> <span onclick="openLoginMenu()" class="dropbtn">{{user.name}}</span>
<h4>user: </h4> <span onclick="openLoginMenu()" class="dropbtn">{{user.name}}</span>
<div class="dropdown">
<div id="myDropdown" class="dropdown-content">
<a href="/settings">settings</a>
Expand Down

0 comments on commit 1f0f27d

Please sign in to comment.