merged dev with dev_working
This commit is contained in:
parent
e09bddef82
commit
4cea5e51b2
|
@ -41,64 +41,45 @@ exports.uploadPDF = function(files, user, cb) {
|
||||||
console.log(_user.username);
|
console.log(_user.username);
|
||||||
console.log(config.tmpUploadPath);
|
console.log(config.tmpUploadPath);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// console.log(pdfFile);
|
|
||||||
|
|
||||||
var form = Form.findById(req.body.form._id);
|
|
||||||
// console.log(req.files);
|
|
||||||
=======
|
|
||||||
if(files) {
|
if(files) {
|
||||||
|
|
||||||
console.log('inside uploadPDF');
|
console.log('inside uploadPDF');
|
||||||
console.log(files.file[0]);
|
console.log(files.file[0]);
|
||||||
var pdfFile = files.file[0];
|
var pdfFile = files.file[0];
|
||||||
>>>>>>> dev_working
|
|
||||||
|
|
||||||
if (pdfFile.size === 0) {
|
if (pdfFile.size === 0) {
|
||||||
throw new Error('Files uploaded are EMPTY');
|
throw new Error('Files uploaded are EMPTY');
|
||||||
}
|
}
|
||||||
fs.exists(pdfFile.path, function(exists) {
|
|
||||||
<<<<<<< HEAD
|
|
||||||
console.log(pdfFile.path);
|
|
||||||
|
|
||||||
fs.open(pdfFile.path,'r',function(err,fd){
|
//If file exists move to user's tmp directory
|
||||||
if (err && err.code === 'ENOENT') {
|
fs.open(pdfFile.path,'r',function(err,fd){
|
||||||
return res.status(400).send({
|
if (err && err.code === 'ENOENT') {
|
||||||
message: 'Did NOT get your file!'
|
return res.status(400).send({
|
||||||
});
|
message: 'Did NOT get your file!'
|
||||||
}
|
});
|
||||||
return res.status(200);
|
}
|
||||||
});
|
|
||||||
=======
|
|
||||||
//If file exists move to user's tmp directory
|
|
||||||
if(exists) {
|
|
||||||
|
|
||||||
var newDestination = path.join(config.tmpUploadPath, _user.username);
|
var stat = null;
|
||||||
var stat = null;
|
try {
|
||||||
try {
|
stat = fs.statSync(newDestination);
|
||||||
stat = fs.statSync(newDestination);
|
} catch (err) {
|
||||||
} catch (err) {
|
fs.mkdirSync(newDestination);
|
||||||
fs.mkdirSync(newDestination);
|
}
|
||||||
}
|
if (stat && !stat.isDirectory()) {
|
||||||
if (stat && !stat.isDirectory()) {
|
console.log('Directory cannot be created');
|
||||||
console.log('Directory cannot be created');
|
throw new Error('Directory cannot be created because an inode of a different type exists at "' + newDestination + '"');
|
||||||
throw new Error('Directory cannot be created because an inode of a different type exists at "' + newDestination + '"');
|
}
|
||||||
}
|
|
||||||
|
fs.move(pdfFile.path, path.join(newDestination, pdfFile.name), function (err) {
|
||||||
fs.move(pdfFile.path, path.join(newDestination, pdfFile.name), function (err) {
|
if (err) {
|
||||||
if (err) {
|
throw new Error(err.message);
|
||||||
throw new Error(err.message);
|
}
|
||||||
}
|
pdfFile.path = path.join(newDestination, pdfFile.name);
|
||||||
pdfFile.path = path.join(newDestination, pdfFile.name);
|
|
||||||
|
|
||||||
return cb(pdfFile);
|
return cb(pdfFile);
|
||||||
});
|
});
|
||||||
|
return res.status(200);
|
||||||
} else {
|
});
|
||||||
throw new Error('Did NOT get your file!');
|
|
||||||
}
|
|
||||||
>>>>>>> dev_working
|
|
||||||
});
|
|
||||||
}else {
|
}else {
|
||||||
throw new Error('File NOT uploaded');
|
throw new Error('File NOT uploaded');
|
||||||
}
|
}
|
||||||
|
@ -220,12 +201,6 @@ exports.delete = function(req, res) {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
<<<<<<< HEAD
|
|
||||||
* Get List of Forms
|
|
||||||
*/
|
|
||||||
exports.list = function(req, res) {
|
|
||||||
Form.find().sort('-created').populate('admin').exec(function(err, forms) {
|
|
||||||
=======
|
|
||||||
* Get All of Users' Forms
|
* Get All of Users' Forms
|
||||||
*/
|
*/
|
||||||
exports.list = function(req, res) {
|
exports.list = function(req, res) {
|
||||||
|
@ -234,7 +209,6 @@ exports.list = function(req, res) {
|
||||||
if(req.user.isAdmin()) searchObj = {};
|
if(req.user.isAdmin()) searchObj = {};
|
||||||
|
|
||||||
Form.find({}).sort('-created').populate('admin').exec(function(err, forms) {
|
Form.find({}).sort('-created').populate('admin').exec(function(err, forms) {
|
||||||
>>>>>>> dev_working
|
|
||||||
if (err) {
|
if (err) {
|
||||||
res.status(400).send({
|
res.status(400).send({
|
||||||
message: errorHandler.getErrorMessage(err)
|
message: errorHandler.getErrorMessage(err)
|
||||||
|
|
|
@ -73,9 +73,6 @@ var FormSchema = new Schema({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
//Move PDF to permanent location after new PDF is uploaded
|
|
||||||
=======
|
|
||||||
//Update lastModified everytime we save
|
//Update lastModified everytime we save
|
||||||
FormSchema.pre('save', function (next) {
|
FormSchema.pre('save', function (next) {
|
||||||
this.lastModified = Date.now();
|
this.lastModified = Date.now();
|
||||||
|
@ -83,7 +80,6 @@ FormSchema.pre('save', function (next) {
|
||||||
});
|
});
|
||||||
|
|
||||||
//Move PDF to permanent location after new template is uploaded
|
//Move PDF to permanent location after new template is uploaded
|
||||||
>>>>>>> dev_working
|
|
||||||
FormSchema.pre('save', function (next) {
|
FormSchema.pre('save', function (next) {
|
||||||
|
|
||||||
if(this.pdf && this.isModified('pdf')){
|
if(this.pdf && this.isModified('pdf')){
|
||||||
|
@ -167,11 +163,6 @@ FormSchema.pre('save', function (next) {
|
||||||
field.fieldType = _typeConvMap[ field.fieldType+'' ];
|
field.fieldType = _typeConvMap[ field.fieldType+'' ];
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
//Set field defaults
|
|
||||||
field.created = Date.now();
|
|
||||||
=======
|
|
||||||
>>>>>>> dev_working
|
|
||||||
field.fieldValue = '';
|
field.fieldValue = '';
|
||||||
field.created = Date.now();
|
field.created = Date.now();
|
||||||
field.required = true;
|
field.required = true;
|
||||||
|
|
|
@ -22,11 +22,7 @@ module.exports = function(app) {
|
||||||
.get(forms.read)
|
.get(forms.read)
|
||||||
.post(forms.createSubmission)
|
.post(forms.createSubmission)
|
||||||
.put(users.requiresLogin, forms.hasAuthorization, forms.update)
|
.put(users.requiresLogin, forms.hasAuthorization, forms.update)
|
||||||
<<<<<<< HEAD
|
|
||||||
.delete(users.requiresLogin, forms.hasAuthorization,forms.delete);
|
|
||||||
=======
|
|
||||||
.delete(users.requiresLogin, forms.hasAuthorization, forms.delete);
|
.delete(users.requiresLogin, forms.hasAuthorization, forms.delete);
|
||||||
>>>>>>> dev_working
|
|
||||||
|
|
||||||
// Finish by binding the form middleware
|
// Finish by binding the form middleware
|
||||||
app.param('formId', forms.formByID);
|
app.param('formId', forms.formByID);
|
||||||
|
|
|
@ -10,15 +10,9 @@ module.exports = function(app) {
|
||||||
var users = require('../../app/controllers/users.server.controller');
|
var users = require('../../app/controllers/users.server.controller');
|
||||||
|
|
||||||
// Setting up the users profile api
|
// Setting up the users profile api
|
||||||
<<<<<<< HEAD
|
|
||||||
app.route('/users/me').get(users.me);
|
|
||||||
app.route('/users').put(users.requiresLogin, users.update);
|
|
||||||
app.route('/users/accounts').delete(users.removeOAuthProvider);
|
|
||||||
=======
|
|
||||||
app.route('/users/me').get(users.requiresLogin, users.me);
|
app.route('/users/me').get(users.requiresLogin, users.me);
|
||||||
app.route('/users').put(users.requiresLogin, users.update);
|
app.route('/users').put(users.requiresLogin, users.update);
|
||||||
app.route('/users/accounts').delete(users.requiresLogin, users.removeOAuthProvider);
|
app.route('/users/accounts').delete(users.requiresLogin, users.removeOAuthProvider);
|
||||||
>>>>>>> dev_working
|
|
||||||
|
|
||||||
// Setting up the users password api
|
// Setting up the users password api
|
||||||
app.route('/users/password').post(users.requiresLogin, users.changePassword);
|
app.route('/users/password').post(users.requiresLogin, users.changePassword);
|
||||||
|
|
|
@ -106,11 +106,6 @@ module.exports = function(db) {
|
||||||
//Check to make sure we can only upload images and pdfs
|
//Check to make sure we can only upload images and pdfs
|
||||||
console.log(file.originalname + ' is starting ...');
|
console.log(file.originalname + ' is starting ...');
|
||||||
},
|
},
|
||||||
<<<<<<< HEAD
|
|
||||||
onFileUploadComplete: function (file) {
|
|
||||||
console.log(file.fieldname + ' has been uploaded to: ' + file.path);
|
|
||||||
// done=true;
|
|
||||||
=======
|
|
||||||
onFileUploadComplete: function (file, req, res) {
|
onFileUploadComplete: function (file, req, res) {
|
||||||
// console.log('\n\nheadersSent in onFileUploadComplete: ', res.headersSent);
|
// console.log('\n\nheadersSent in onFileUploadComplete: ', res.headersSent);
|
||||||
console.log(req.body.user);
|
console.log(req.body.user);
|
||||||
|
@ -124,7 +119,6 @@ module.exports = function(db) {
|
||||||
message: err.message
|
message: err.message
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
>>>>>>> dev_working
|
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -12,24 +12,12 @@ angular.module('core').config(['$stateProvider', '$urlRouterProvider',
|
||||||
url: '/',
|
url: '/',
|
||||||
templateUrl: 'modules/core/views/home.client.view.html'
|
templateUrl: 'modules/core/views/home.client.view.html'
|
||||||
});
|
});
|
||||||
<<<<<<< HEAD
|
|
||||||
// state('restricted', {
|
|
||||||
// 'abstract': true,
|
|
||||||
// resolve: {
|
|
||||||
// authorize: ['Authorization',
|
|
||||||
// function(Authorization) {
|
|
||||||
// return Authorization.authorize();
|
|
||||||
// }
|
|
||||||
// ]
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
=======
|
|
||||||
|
|
||||||
$urlRouterProvider.otherwise( function($injector) {
|
$urlRouterProvider.otherwise( function($injector) {
|
||||||
var $state = $injector.get('$state');
|
var $state = $injector.get('$state');
|
||||||
$state.go('home');
|
$state.go('home');
|
||||||
});
|
});
|
||||||
|
|
||||||
>>>>>>> dev_working
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
|
@ -74,61 +74,9 @@ angular.module('forms').controller('EditFormController', ['$scope', '$state', '$
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
//PDF Functions
|
|
||||||
|
|
||||||
$scope.cancelUpload = function(){
|
|
||||||
//TBD
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.removePDF = function(){
|
|
||||||
$scope.form.pdf = undefined;
|
|
||||||
$scope.form.isGenerated = false;
|
|
||||||
$scope.form.autofillPDFs = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.uploadPDF = function(files) {
|
|
||||||
|
|
||||||
if (files && files.length) {
|
|
||||||
for (var i = 0; i < files.length; i++) {
|
|
||||||
var file = files[i];
|
|
||||||
Upload.upload({
|
|
||||||
url: '/upload/pdf',
|
|
||||||
fields: {
|
|
||||||
'user': $scope.form.admin,
|
|
||||||
'form': $scope.form
|
|
||||||
},
|
|
||||||
file: file
|
|
||||||
}).progress(function (evt) {
|
|
||||||
var progressPercentage = parseInt(100.0 * evt.loaded / evt.total);
|
|
||||||
$scope.log = 'progress: ' + progressPercentage + '% ' +
|
|
||||||
evt.config.file.name + '\n' + $scope.log;
|
|
||||||
}).success(function (data, status, headers, config) {
|
|
||||||
$scope.log = 'file ' + data.originalname + 'uploaded as '+ data.name +'. JSON: ' + JSON.stringify(data) + '\n' + $scope.log;
|
|
||||||
$scope.form.pdf = data;
|
|
||||||
|
|
||||||
if(!$scope.$$phase) {
|
|
||||||
$scope.$apply();
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log($scope.log);
|
|
||||||
console.log('$scope.pdf: '+$scope.pdf.name);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
$scope.goToWithId = function(route, id) {
|
|
||||||
$state.transitionTo(route, { 'formId' : id }, { reload: true });
|
|
||||||
};
|
|
||||||
|
|
||||||
// Create new Form
|
|
||||||
$scope.createOrUpdate = function() {
|
|
||||||
=======
|
|
||||||
$scope.goToWithId = function(route, id) {
|
$scope.goToWithId = function(route, id) {
|
||||||
$state.go(route, {'formId': id}, {reload: true});
|
$state.go(route, {'formId': id}, {reload: true});
|
||||||
};
|
};
|
||||||
>>>>>>> dev_working
|
|
||||||
|
|
||||||
// Create new Form
|
// Create new Form
|
||||||
$scope.createOrUpdate = function() {
|
$scope.createOrUpdate = function() {
|
||||||
|
@ -136,15 +84,7 @@ angular.module('forms').controller('EditFormController', ['$scope', '$state', '$
|
||||||
if($scope.isNewForm){
|
if($scope.isNewForm){
|
||||||
// Create new Form object
|
// Create new Form object
|
||||||
var form = new Forms($scope.form);
|
var form = new Forms($scope.form);
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
form.$save(function(response) {
|
|
||||||
|
|
||||||
console.log('create form');
|
|
||||||
// console.log(response.pdf);
|
|
||||||
=======
|
|
||||||
form.$save(function(response) {
|
form.$save(function(response) {
|
||||||
>>>>>>> dev_working
|
|
||||||
|
|
||||||
console.log('form created');
|
console.log('form created');
|
||||||
// console.log(response.pdf);
|
// console.log(response.pdf);
|
||||||
|
|
|
@ -1,27 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
// Config HTTP Error Handling
|
// Config HTTP Error Handling
|
||||||
<<<<<<< HEAD
|
|
||||||
angular.module('users').config(['$httpProvider', '$state', 'Principal', '$q',
|
|
||||||
function($httpProvider, $state, Principal, $q) {
|
|
||||||
// Set the httpProvider "not authorized" interceptor
|
|
||||||
$httpProvider.interceptors.push(['$q', '$state', 'Principal',
|
|
||||||
function($q, $state, Principal) {
|
|
||||||
return {
|
|
||||||
responseError: function(rejection) {
|
|
||||||
switch (rejection.status) {
|
|
||||||
case 401:
|
|
||||||
// Deauthenticate the global user
|
|
||||||
// Principal.authenticate(null);
|
|
||||||
|
|
||||||
// Redirect to signin page
|
|
||||||
$state.go('signin');
|
|
||||||
break;
|
|
||||||
case 403:
|
|
||||||
// Add unauthorized behaviour
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
=======
|
|
||||||
angular.module('users').config(['$httpProvider',
|
angular.module('users').config(['$httpProvider',
|
||||||
function($httpProvider) {
|
function($httpProvider) {
|
||||||
$httpProvider.interceptors.push(function($q, $location) {
|
$httpProvider.interceptors.push(function($q, $location) {
|
||||||
|
|
|
@ -4,11 +4,6 @@
|
||||||
angular.module('users').config(['$stateProvider',
|
angular.module('users').config(['$stateProvider',
|
||||||
function($stateProvider) {
|
function($stateProvider) {
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
// Users state routing
|
|
||||||
$stateProvider.
|
|
||||||
=======
|
|
||||||
|
|
||||||
var checkLoggedin = function($q, $timeout, $location, User, Auth) {
|
var checkLoggedin = function($q, $timeout, $location, User, Auth) {
|
||||||
var deferred = $q.defer();
|
var deferred = $q.defer();
|
||||||
|
|
||||||
|
@ -34,7 +29,6 @@ angular.module('users').config(['$stateProvider',
|
||||||
|
|
||||||
// Users state routing
|
// Users state routing
|
||||||
$stateProvider.
|
$stateProvider.
|
||||||
>>>>>>> dev_working
|
|
||||||
state('profile', {
|
state('profile', {
|
||||||
// parent: 'restricted',
|
// parent: 'restricted',
|
||||||
// data: {
|
// data: {
|
||||||
|
|
Loading…
Reference in a new issue