Skip to content

Commit

Permalink
modfication
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelotrajano committed Aug 4, 2020
1 parent 1f0f27d commit 8689e96
Show file tree
Hide file tree
Showing 17 changed files with 200 additions and 178 deletions.
2 changes: 2 additions & 0 deletions helpers/permissions.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
module.exports = {
isAuthenticated: (req, res, next) => {
return next();
if (req.isAuthenticated()) {
return next();
}
req.flash("error_msg", "User not authenticated!");
res.redirect("/login");
},
isAdmin: (req, res, next) => {
return next();
if (req.isAuthenticated() && req.user.isAdmin === 1) {
return next();
}
Expand Down
11 changes: 11 additions & 0 deletions models/Bug.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,21 @@ const getBugsByProject = (id) => {
});
};

const remove = (id) => {
return new Promise((resolve, reject) => {
let sql = `delete from bugs where ID = ${mysql.escape(id)}`;

connection.query(sql, (err, data) => {
err ? reject(err) : resolve(data);
});
});
};

module.exports = {
create: create,
findAll: findAll,
getBugsByProject: getBugsByProject,
findByPK: findByPK,
updateSolveIssue: updateSolveIssue,
remove: remove,
};
17 changes: 14 additions & 3 deletions models/Feature.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ const create = (feature) => {
let sql = `insert into Features (TitleFeature, DescriptionFeature, EstimatedTime, DeliveryDate,
CreatedAt, ProjectID, FeatureStatusID, StatusProgressID)
values
("${feature.TitleFeature}", "${feature.DescriptionFeature}", ${feature.EstimatedTime},
STR_TO_DATE('${feature.DeliveryDate}', '%Y-%m-%d'), STR_TO_DATE('${feature.CreatedAt}', '%Y-%m-%d'),
${feature.ProjectID},${feature.FeatureStatusID},${feature.StatusProgressID})`;
("${feature.titleFeature}", "${feature.description}", ${feature.estimatedTime},
STR_TO_DATE('${feature.deliveryDate}', '%Y-%m-%d'), STR_TO_DATE('${feature.CreatedAt}', '%Y-%m-%d'),
${feature.projectID},${feature.featureStatus},${feature.StatusProgressID})`;

connection.query(sql, (err, result) => {
err ? reject(err) : resolve(result);
Expand Down Expand Up @@ -84,10 +84,21 @@ const updateSolveIssue = (feature) => {
});
};

const remove = (id) => {
return new Promise((resolve, reject) => {
let sql = `delete from features where ID = ${mysql.escape(id)}`;

connection.query(sql, (err, data) => {
err ? reject(err) : resolve(data);
});
});
};

module.exports = {
create: create,
findFeaturesByProjects: findFeaturesByProjects,
findByPK: findByPK,
updateSolveIssue: updateSolveIssue,
findAll: findAll,
remove: remove,
};
14 changes: 14 additions & 0 deletions models/FileUpload.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const connection = require("../db/connection");
const mysql = require("mysql");

const create = (file) => {
return new Promise((resolve, reject) => {
sql = `insert into file_upload (name, file_path, feature_id ) values ('${file.name}', '${file.file}', ${file.feature_id})`;

connection.query(sql, (err, result) => {
err ? reject(err) : resolve(result);
});
});
};

module.exports = { create: create };
140 changes: 5 additions & 135 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"express": "^4.17.1",
"express-handlebars": "^4.0.4",
"express-session": "^1.17.1",
"formidable": "^1.2.2",
"moment": "^2.26.0",
"mysql": "^2.18.1",
"mysql2": "^2.1.0",
"passport": "^0.4.1",
"passport-local": "^1.0.0",
"pg": "^8.2.1",
"pg-hstore": "^2.3.3",
"sequelize": "^5.21.11"
"pg-hstore": "^2.3.3"
},
"devDependencies": {},
"scripts": {
Expand Down
20 changes: 20 additions & 0 deletions public/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ h5 {

input[type="text"],
input[type="date"],
input[type="file"],
select,
textarea {
width: 100%;
Expand Down Expand Up @@ -440,3 +441,22 @@ span.psw {
.show {
display: block;
}

.file-upload {
padding: 10px;
color: white;
background-color: #009578;
border: 1px solid white;
border-radius: 5px;
cursor: pointer;
}

.file-upload:hover {
background-color: #00b28f;
}

.file-upload-custom-text {
margin-left: 10px;
font-family: "Raleway";
color: rgb(124, 122, 122);
}
Loading

0 comments on commit 8689e96

Please sign in to comment.