forked from sitcomlab/Ethics-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
speckij
committed
Feb 25, 2018
1 parent
4f754de
commit 8861034
Showing
21 changed files
with
745 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,6 @@ REMIND_AFTER=7 | |
REMIND_UNITL=0 | ||
REMIND_ALL=true | ||
JWTSECRET='secret' | ||
|
||
UPLOAD_DIR='uploads/' | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,33 @@ | ||
{ | ||
"name": "ethics-app", | ||
"version": "0.0.1", | ||
"authors": [ | ||
"Nicholas Schiestel <[email protected]>" | ||
], | ||
"description": "Ethics-App for the Institute for Geoinformatics, Münster", | ||
"license": "MIT", | ||
"private": true, | ||
"dependencies": { | ||
"angular": "1.6.4", | ||
"angular-momentjs": "^0.2.2", | ||
"angular-route": "1.6.4", | ||
"angular-sanitize": "1.6.4", | ||
"angular-translate": "^2.11.1", | ||
"bootstrap": "v4.0.0-alpha.6", | ||
"font-awesome": "^4.6.3", | ||
"jquery": "^3.1.0", | ||
"moment": "^2.14.1", | ||
"tether": "^1.3.7", | ||
"flag-icon-css": "^2.0.0", | ||
"underscore": "^1.8.3", | ||
"angular-underscore-module": "^1.0.3", | ||
"angucomplete-alt": "^3.0.0" | ||
}, | ||
"resolutions": { | ||
"angular": "1.6.4", | ||
"angular-route": "1.6.4", | ||
"angular-sanitize": "1.6.4", | ||
"bootstrap": "v4.0.0-alpha.6" | ||
} | ||
"name": "ethics-app", | ||
"version": "0.0.1", | ||
"authors": [ | ||
"Nicholas Schiestel <[email protected]>" | ||
], | ||
"description": "Ethics-App for the Institute for Geoinformatics, Münster", | ||
"license": "MIT", | ||
"private": true, | ||
"dependencies": { | ||
"angular": "1.6.4", | ||
"angular-momentjs": "^0.2.2", | ||
"angular-route": "1.6.4", | ||
"angular-sanitize": "1.6.4", | ||
"angular-translate": "^2.11.1", | ||
"bootstrap": "v4.0.0-alpha.6", | ||
"font-awesome": "^4.6.3", | ||
"jquery": "^3.1.0", | ||
"moment": "^2.14.1", | ||
"tether": "^1.3.7", | ||
"flag-icon-css": "^2.0.0", | ||
"underscore": "^1.8.3", | ||
"angular-underscore-module": "^1.0.3", | ||
"angucomplete-alt": "^3.0.0", | ||
"angular-upload": "^1.0.12" | ||
}, | ||
"resolutions": { | ||
"angular": "1.6.4", | ||
"angular-route": "1.6.4", | ||
"angular-sanitize": "1.6.4", | ||
"bootstrap": "v4.0.0-alpha.6" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
var async = require('async'); | ||
var colors = require('colors'); | ||
var pg = require('pg'); | ||
var types = require('pg').types; | ||
types.setTypeParser(1700, 'text', parseFloat); | ||
var _ = require('underscore'); | ||
var pool = require('../../server.js').pool; | ||
|
||
var fs = require("fs"); | ||
var dir = "/../../sql/queries/concerns/"; | ||
var query_get_concern = fs.readFileSync(__dirname + dir + 'get.sql', 'utf8').toString(); | ||
var query_add_file = fs.readFileSync(__dirname + dir + 'set_uploaded_file.sql', 'utf8').toString(); | ||
|
||
|
||
// EDIT | ||
exports.upload = function(req, res) { | ||
|
||
async.waterfall([ | ||
function(callback){ | ||
// Connect to database | ||
pool.connect(function(err, client, done) { | ||
if(err) { | ||
callback(err, 500); | ||
} else { | ||
callback(null, client, done); | ||
} | ||
}); | ||
}, | ||
function(client, done, callback) { | ||
// Database query | ||
client.query(query_get_concern, [ | ||
req.params.concern_id | ||
], function(err, result) { | ||
done(); | ||
if (err) { | ||
callback(err, 500); | ||
} else { | ||
// Check if Concern exists | ||
if (result.rows.length === 0) { | ||
callback(new Error("Concern not found"), 404); | ||
} else { | ||
callback(null, client, done); | ||
} | ||
} | ||
}); | ||
}, | ||
function(client, done, callback) { | ||
// TODO: Add object/schema validation | ||
var object = { | ||
concern_id: req.params.concern_id, | ||
q14_filename: req.file.originalname, | ||
q14_filepath: req.file.path | ||
}; | ||
var params = _.values(object); | ||
callback(null, client, done, params); | ||
}, | ||
function(client, done, params, callback){ | ||
console.log(req.file); | ||
// Database query | ||
client.query(query_add_file, params, function(err, result) { | ||
done(); | ||
if (err) { | ||
callback(err, 500); | ||
} else { | ||
callback(null, 200, result.rows[0]); | ||
} | ||
}); | ||
} | ||
], function(err, code, result) { | ||
if(err){ | ||
console.error(colors.red(err)); | ||
res.status(code).send(err.message); | ||
} else { | ||
res.status(code).send(result); | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.