Merge branch 'master' of github.com:whitef0x0/tellform into HEAD

Conflicts:
	config/env/all.js
	config/env/development.js
This commit is contained in:
David Baldwynn 2017-10-18 20:20:15 -04:00
commit 3835a8aa3a
54 changed files with 482 additions and 1827 deletions

8
.dockerignore Normal file
View File

@ -0,0 +1,8 @@
.git
.idea
.vagrant
coverage
design
e2e_coverage
Vagrantfile
Procfile

View File

@ -1,25 +1,17 @@
# Build:
# docker build -t tellform -f ./Dockerfile .
# docker build -t tellform-prod -f ./Dockerfile-production .
#
# Run:
# docker run -it tellform
# docker run -it tellform-prod
FROM phusion/baseimage:0.9.19
MAINTAINER David Baldwynn <team@tellform.com>
# 3000 = TellForm server, 35729 = livereload, 8080 = node-inspector
EXPOSE 3000 35729 8080
# Set development environment as default
ENV NODE_ENV development
ENV BASE_URL tellform.dev
ENV PORT 3000
# Install Utilities
RUN apt-get update -q \
RUN apt-get update -q \
&& apt-get install -yqq \
curl \
ant \
default-jdk \
git \
gcc \
make \
@ -37,34 +29,31 @@ RUN sudo apt-get install -yq nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install MEAN.JS Prerequisites
RUN npm install --quiet -g grunt bower && npm cache clean
# Install NPM Global Libraries
RUN npm install --quiet -g grunt bower pm2 && npm cache clean
RUN mkdir -p /opt/tellform/public/lib
WORKDIR /opt/tellform
RUN mkdir -p /opt/tellform/public/lib
# Add bower.json
COPY bower.json /opt/tellform/bower.json
COPY .bowerrc /opt/tellform/.bowerrc
COPY ./process.yml /opt/tellform/process.yml
COPY ./app /opt/tellform/app
COPY ./public /opt/tellform/public
COPY ./config /opt/tellform/config
COPY ./gruntfile.js /opt/tellform/gruntfile.js
COPY ./server.js /opt/tellform/server.js
COPY ./scripts/create_admin.js /opt/tellform/scripts/create_admin.js
# Copies the local package.json file to the container
# and utilities docker container cache to not needing to rebuild
# and install node_modules/ everytime we build the docker, but only
# when the local package.json file changes.
# Add npm package.json
COPY package.json /opt/tellform/package.json
RUN npm install
COPY ./package.json /opt/tellform/package.json
RUN npm install --only=production --quiet
# Add bower.json
COPY bower.json /opt/tellform/bower.json
COPY .bowerrc /opt/tellform/.bowerrc
COPY ./app /opt/tellform/app
COPY ./public /opt/tellform/public
COPY ./config /opt/tellform/config
COPY ./gruntfile.js /opt/tellform/gruntfile.js
COPY ./server.js /opt/tellform/server.js
COPY ./.env /opt/tellform/.env
COPY ./scripts/create_admin.js /opt/tellform/scripts/create_admin.js
# Run Development TellForm server
COPY ./dev_entrypoint.sh /dev_entrypoint.sh
RUN chmod +x /dev_entrypoint.sh
ENTRYPOINT ["/dev_entrypoint.sh"]
# Run TellForm server
CMD ["node", "server.js"]

View File

@ -1,71 +0,0 @@
# Build:
# docker build -t tellform-prod -f ./Dockerfile-production .
#
# Run:
# docker run -it tellform-prod
FROM phusion/baseimage:0.9.19
MAINTAINER David Baldwynn <team@tellform.com>
# 4545 = TellForm server
EXPOSE 4545
# Set development environment as default
ENV NODE_ENV production
ENV PORT 4545
ENV BASE_URL tellform.com
# Install Utilities
RUN apt-get update -q \
&& apt-get install -yqq \
curl \
ant \
default-jdk \
git \
gcc \
make \
build-essential \
libkrb5-dev \
python \
sudo \
apt-utils \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install nodejs
RUN curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
RUN sudo apt-get install -yq nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# Install MEAN.JS Prerequisites
RUN npm install --quiet -g grunt bower pm2 && npm cache clean
RUN mkdir -p /opt/tellform/public/lib
WORKDIR /opt/tellform
# Copies the local package.json file to the container
# and utilities docker container cache to not needing to rebuild
# and install node_modules/ everytime we build the docker, but only
# when the local package.json file changes.
# Add npm package.json
COPY package.json /opt/tellform/package.json
RUN npm install --production
RUN mv ./node_modules ./node_modules.tmp && mv ./node_modules.tmp ./node_modules && npm install
# Add bower.json
COPY bower.json /opt/tellform/bower.json
COPY .bowerrc /opt/tellform/.bowerrc
COPY ./app /opt/tellform/app
COPY ./public /opt/tellform/public
COPY ./config /opt/tellform/config
COPY ./gruntfile.js /opt/tellform/gruntfile.js
COPY ./server.js /opt/tellform/server.js
COPY ./.env /opt/tellform/.env
COPY ./scripts/create_admin.js /opt/tellform/scripts/create_admin.js
RUN grunt build
# Run TellForm server
CMD ["pm2-docker","process.yml"]

View File

@ -49,13 +49,11 @@ exports.createSubmission = function(req, res) {
var timeElapsed = 0;
console.log(req.body);
if(typeof req.body.timeElapsed === 'number'){
timeElapsed = req.body.timeElapsed;
}
var submission = new FormSubmission({
form: req.body._id,
title: req.body.title,
form_fields: req.body.form_fields,
timeElapsed: timeElapsed,
percentageComplete: req.body.percentageComplete,
@ -64,7 +62,6 @@ exports.createSubmission = function(req, res) {
device: req.body.device
});
submission.save(function(err, submission){
if (err) {
console.error(err.message);
@ -98,9 +95,10 @@ exports.listSubmissions = function(req, res) {
* Create a new form
*/
exports.create = function(req, res) {
debugger;
if(!req.body.form){
return res.status(400).send({
return res.status(401).send({
message: 'Invalid Input'
});
}
@ -109,13 +107,14 @@ exports.create = function(req, res) {
form.admin = req.user._id;
form.save(function(err) {
debugger;
if (err) {
return res.status(405).send({
return res.status(500).send({
message: errorHandler.getErrorMessage(err)
});
}
res.json(form);
return res.json(form);
});
};
@ -222,7 +221,7 @@ exports.update = function(req, res) {
form.save(function(err, savedForm) {
if (err) {
res.status(405).send({
res.status(500).send({
message: errorHandler.getErrorMessage(err)
});
} else {

View File

@ -0,0 +1,39 @@
'use strict';
// Plugin
module.exports = function timestamp (schema, options) {
options || (options = {})
// Options
var fields = {}
, createdPath = options.createdPath || 'created'
, modifiedPath = options.modifiedPath || 'modified'
, useVirtual = (options.useVirtual !== undefined)
? options.useVirtual
: true
// Add paths to schema if not present
if (!schema.paths[createdPath]) {
fields[modifiedPath] = { type: Date }
}
if (useVirtual) {
// Use the ObjectID for extracting the created time
schema.virtual(createdPath).get(function () {
return new Date(this._id.generationTime * 1000)
})
} else {
if (!schema.paths[createdPath]) {
fields[createdPath] = {
type: Date
, default: Date.now
}
}
}
schema.add(fields)
// Update the modified timestamp on save
schema.pre('save', function (next) {
this[modifiedPath] = new Date
next()
})
}

View File

@ -6,7 +6,7 @@
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
_ = require('lodash'),
mUtilities = require('mongoose-utilities'),
timeStampPlugin = require('../libs/timestamp.server.plugin'),
async = require('async'),
Random = require('random-js'),
mt = Random.engines.mt19937();
@ -283,7 +283,7 @@ FormSchema.virtual('analytics.fields').get(function () {
return fieldDropoffs;
});
FormSchema.plugin(mUtilities.timestamp, {
FormSchema.plugin(timeStampPlugin, {
createdPath: 'created',
modifiedPath: 'lastModified',
useVirtual: false
@ -304,7 +304,6 @@ FormSchema.pre('save', function (next) {
this.language = 'de';
break;
default:
this.language = 'en';
break;
}
next();
@ -336,54 +335,55 @@ FormSchema.pre('save', function (next) {
var that = this;
var _original;
async.series([function(cb) {
that.constructor
.findOne({_id: that._id}).exec(function (err, original) {
if (err) {
return cb(err);
} else if (!original){
return next();
} else {
_original = original;
return cb(null);
}
});
},
function(cb) {
if(that.form_fields && that.isModified('form_fields') && formFieldsAllHaveIds(that.toObject().form_fields)){
async.series([
function(cb) {
that.constructor
.findOne({_id: that._id}).exec(function (err, original) {
if (err) {
return cb(err);
} else if (!original){
return next();
} else {
_original = original;
return cb(null);
}
});
},
function(cb) {
if(that.form_fields && that.isModified('form_fields') && formFieldsAllHaveIds(that.toObject().form_fields)){
var current_form = that.toObject(),
old_form_fields = _original.toObject().form_fields,
new_ids = _.map(_.map(current_form.form_fields, 'globalId'), function(id){ return ''+id;}),
old_ids = _.map(_.map(old_form_fields, 'globalId'), function(id){ return ''+id;}),
deletedIds = getDeletedIndexes(old_ids, new_ids);
var current_form = that.toObject(),
old_form_fields = _original.toObject().form_fields,
new_ids = _.map(_.map(current_form.form_fields, 'globalId'), function(id){ return ''+id;}),
old_ids = _.map(_.map(old_form_fields, 'globalId'), function(id){ return ''+id;}),
deletedIds = getDeletedIndexes(old_ids, new_ids);
//Check if any form_fileds were deleted
if( deletedIds.length > 0 ){
//Check if any form_fileds were deleted
if( deletedIds.length > 0 ){
var modifiedSubmissions = [];
var modifiedSubmissions = [];
async.forEachOfSeries(deletedIds,
function (deletedIdIndex, key, cb_id) {
async.forEachOfSeries(deletedIds,
function (deletedIdIndex, key, cb_id) {
var deleted_id = old_ids[deletedIdIndex];
//Find FormSubmissions that contain field with _id equal to 'deleted_id'
FormSubmission.
find({ form: that, form_fields: {$elemMatch: {globalId: deleted_id} } }).
exec(function(err, submissions){
if(err) {
return cb_id(err);
}
var deleted_id = old_ids[deletedIdIndex];
//Find FormSubmissions that contain field with _id equal to 'deleted_id'
FormSubmission.
find({ form: that, form_fields: {$elemMatch: {globalId: deleted_id} } }).
exec(function(err, submissions){
if(err) {
return cb_id(err);
}
//Preserve fields that have at least one submission
if (submissions.length) {
//Add submissions
modifiedSubmissions.push.apply(modifiedSubmissions, submissions);
}
//Preserve fields that have at least one submission
if (submissions.length) {
//Add submissions
modifiedSubmissions.push.apply(modifiedSubmissions, submissions);
}
return cb_id(null);
});
},
return cb_id(null);
});
},
function (err) {
if(err){
console.error(err.message);
@ -425,17 +425,20 @@ FormSchema.pre('save', function (next) {
}, function (err) {
return cb(err);
});
}
);
});
} else {
return cb(null);
}
} else {
return cb(null);
}
} else {
return cb(null);
}
}],
function(err, results){
next(err);
],
function(err){
if(err){
return next(err);
}
next();
});
});

View File

@ -5,13 +5,11 @@
*/
var mongoose = require('mongoose'),
util = require('util'),
mUtilities = require('mongoose-utilities'),
timeStampPlugin = require('../libs/timestamp.server.plugin'),
_ = require('lodash'),
Schema = mongoose.Schema,
LogicJumpSchema = require('./logic_jump.server.model');
const UIDGenerator = require('uid-generator');
const uidgen3 = new UIDGenerator(256, UIDGenerator.BASE62);
LogicJumpSchema = require('./logic_jump.server.model'),
tokgen = require('../libs/tokenGenerator');
var FieldOptionSchema = new Schema({
option_id: {
@ -132,7 +130,7 @@ function BaseFieldSchema(){
fieldValue: Schema.Types.Mixed
});
this.plugin(mUtilities.timestamp, {
this.plugin(timeStampPlugin, {
createdPath: 'created',
modifiedPath: 'lastModified',
useVirtual: false
@ -198,7 +196,7 @@ FormFieldSchema.pre('save', function(next) {
if(this.logicJump.jumpTo === '') delete this.logicJump.jumpTo;
}
if(!this.globalId){
this.globalId = uidgen3.generateSync();
this.globalId = tokgen();
}
next();
});

View File

@ -5,17 +5,13 @@
*/
var mongoose = require('mongoose'),
Schema = mongoose.Schema,
mUtilities = require('mongoose-utilities'),
timeStampPlugin = require('../libs/timestamp.server.plugin'),
FieldSchema = require('./form_field.server.model.js');
/**
* Form Submission Schema
*/
var FormSubmissionSchema = new Schema({
title: {
type: String
},
form_fields: [FieldSchema],
form: {
@ -58,6 +54,19 @@ FormSubmissionSchema.pre('save', function (next) {
if(this.form_fields[i].fieldType === 'dropdown'){
this.form_fields[i].fieldValue = this.form_fields[i].fieldValue.option_value;
}
delete form_fields[i].validFieldTypes;
delete form_fields[i].disabled;
delete form_fields[i].required;
delete form_fields[i].isSubmission;
delete form_fields[i].title;
delete form_fields[i].fieldOptions;
delete form_fields[i].ratingOptions;
delete form_fields[i].logicJump;
delete form_fields[i].description;
delete form_fields[i].created;
delete form_fields[i].lastModified;
delete form_fields[i].deletePreserved;
}
next();
});
@ -68,6 +77,17 @@ FormSubmissionSchema.path('form_fields', {
form_fields[i].isSubmission = true;
form_fields[i]._id = new mongoose.mongo.ObjectID();
delete form_fields[i].validFieldTypes;
delete form_fields[i].disabled;
delete form_fields[i].required;
delete form_fields[i].isSubmission;
delete form_fields[i].title;
delete form_fields[i].fieldOptions;
delete form_fields[i].ratingOptions;
delete form_fields[i].logicJump;
delete form_fields[i].description;
delete form_fields[i].created;
delete form_fields[i].lastModified;
delete form_fields[i].deletePreserved;
}
@ -75,7 +95,7 @@ FormSubmissionSchema.path('form_fields', {
}
});
FormSubmissionSchema.plugin(mUtilities.timestamp, {
FormSubmissionSchema.plugin(timeStampPlugin, {
createdPath: 'created',
modifiedPath: 'lastModified',
useVirtual: false

View File

@ -7,8 +7,7 @@ var mongoose = require('mongoose'),
Schema = mongoose.Schema,
crypto = require('crypto'),
config = require('../../config/config'),
fs = require('fs-extra'),
mUtilities = require('mongoose-utilities'),
timeStampPlugin = require('../libs/timestamp.server.plugin'),
path = require('path'),
querystring = require('querystring'),
nodemailer = require('nodemailer');
@ -143,7 +142,7 @@ UserSchema.virtual('displayName').get(function () {
return this.firstName + ' ' + this.lastName;
});
UserSchema.plugin(mUtilities.timestamp, {
UserSchema.plugin(timeStampPlugin, {
createdPath: 'created',
modifiedPath: 'lastModified',
useVirtual: false

View File

@ -1,5 +1,7 @@
'use strict';
require('../../server.js');
/**
* Module dependencies.
*/

View File

@ -1,5 +1,4 @@
'use strict';
process.env.NODE_ENV = 'test';
var should = require('should'),
lodash = require('lodash'),
@ -19,8 +18,8 @@ var user, myForm, userSession;
// Create user credentials
var credentials = {
username: 'test1234',
email: 'test1234@test.com',
username: 'aeokjqjqkqaeoaoe',
email: 'aeoaekjqjqqjkoeoa@test.com',
password: 'password'
};
@ -30,18 +29,17 @@ var credentials = {
describe('Form Routes Unit tests', function() {
beforeEach(function(done) {
// Create a new user
user = new User({
firstName: 'Full',
lastName: 'Name',
displayName: 'Full Name',
email: credentials.email,
username: credentials.username,
password: credentials.password,
provider: 'local'
});
// Save a user to the test db and create new Form
user.save(function(err) {
should.not.exist(err);
@ -65,10 +63,12 @@ describe('Form Routes Unit tests', function() {
});
it(' > should not be able to create a Form if not logged in', function(done) {
userSession.post('/forms')
.send({form: myForm})
.expect(401)
.end(function(FormSaveErr, FormSaveRes) {
// Call the assertion callback
done(FormSaveErr);
});
@ -153,7 +153,7 @@ describe('Form Routes Unit tests', function() {
// Save a new Form
authenticatedSession.post('/forms')
.send({form: myForm})
.expect(405)
.expect(500)
.end(function(FormSaveErr, FormSaveRes) {
// Handle Form save error
if (FormSaveErr) {

View File

@ -168,7 +168,7 @@ describe('FormSubmission Model Unit Tests:', function() {
});
it('should be able to find FormSubmission by $elemMatch on form_fields id', function(done){
FormSubmission.findOne({ form: myForm._id, admin: user, form_fields: {$elemMatch: {_id: myForm.form_fields[0]._id} } })
FormSubmission.findOne({ form: myForm._id, form_fields: {$elemMatch: {globalId: myForm.form_fields[0].globalId} } })
.exec(function(err, submission){
should.not.exist(err);
should.exist(submission);

View File

@ -21,7 +21,8 @@ var credentials, user;
* Form routes tests
*/
describe('Form Submission Routes Unit tests', function() {
var FormObj, _Submission, submissionSession;
var FormObj, _Submission, submissionSession, _SubmissionBody
beforeEach(function(done) {
@ -60,15 +61,43 @@ describe('Form Submission Routes Unit tests', function() {
if (formSaveErr) done(formSaveErr);
_Submission = {
form_fields: [
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David'},
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true},
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false}
],
form: form._id,
admin: user._id,
form_fields: [
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David', _id: '', isSubmission: false, deletePreserved: false},
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true, _id: '', isSubmission: false, deletePreserved: true},
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false, _id: '', isSubmission: false, deletePreserved: false}
],
percentageComplete: 100,
timeElapsed: 11.55
timeElapsed: 11.55,
ipAddr: '123.233.232.232',
geoLocation: {
Country: 'Canada',
City: 'Vancouver'
},
device:{
type: 'Mobile',
name: 'iPhone'
}
};
_SubmissionBody ={
_id: form._id,
form_fields: [
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David', _id: '', isSubmission: false, deletePreserved: false},
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true, _id: '', isSubmission: false, deletePreserved: true},
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false, _id: '', isSubmission: false, deletePreserved: false}
],
percentageComplete: 100,
timeElapsed: 11.55,
ipAddr: '123.233.232.232',
geoLocation: {
Country: 'Canada',
City: 'Vancouver'
},
device:{
type: 'Mobile',
name: 'iPhone'
}
};
FormObj = form;
@ -86,12 +115,11 @@ describe('Form Submission Routes Unit tests', function() {
//Create Submission
submissionSession.post('/forms/' + FormObj._id)
.send(_Submission)
.send(_SubmissionBody)
.expect(200)
.end(function(err, res) {
should.not.exist(err);
done();
});
});
@ -99,7 +127,7 @@ describe('Form Submission Routes Unit tests', function() {
it(' > should be able to get Form Submissions if signed in', function(done) {
//Create Submission
submissionSession.post('/forms/' + FormObj._id)
.send(_Submission)
.send(_SubmissionBody)
.expect(200)
.end(function(err, res) {

View File

@ -0,0 +1,70 @@
// Dependencies
var util = require('util')
, assert = require('assert')
, mongoose = require('mongoose')
, timestamp = require('../../libs/timestamp.server.plugin')
, Schema = mongoose.Schema
, ObjectId = Schema.ObjectId
// Run tests
describe('Timestamp', function () {
describe('#default()', function () {
var FooSchema = new Schema()
FooSchema.plugin(timestamp)
var FooModel = mongoose.model('timeFoo', FooSchema)
, bar = new FooModel()
before(function () {
FooModel.remove(function (err) {
assert.strictEqual(err, null)
})
})
it('should have custom properties', function (done) {
assert.strictEqual(typeof FooSchema.virtuals.created, 'object')
assert.strictEqual(typeof FooSchema.paths.modified, 'object')
done()
})
it('should create the default attributes', function (done) {
bar.save(function (err, doc) {
assert.strictEqual(err, null)
assert.strictEqual(util.isDate(doc.created), true)
assert.strictEqual(util.isDate(doc.modified), true)
done()
})
})
})
describe('#custom()', function () {
var FooSchema = new Schema()
FooSchema.plugin(timestamp, {
createdPath: 'oh'
, modifiedPath: 'hai'
, useVirtual: false
})
var BarModel = mongoose.model('timeBar', FooSchema)
, bar = new BarModel()
before(function () {
BarModel.remove(function (err) {
assert.strictEqual(err, null)
})
})
it('should have custom properties', function (done) {
assert.strictEqual(typeof FooSchema.paths.oh, 'object')
assert.strictEqual(typeof FooSchema.paths.hai, 'object')
done()
})
it('should create custom attributes', function (done) {
bar.save(function (err, doc) {
assert.strictEqual(err, null)
assert.strictEqual(util.isDate(doc.oh), true)
assert.strictEqual(util.isDate(doc.hai), true)
done()
})
})
})
})

20
config/env/all.js vendored
View File

@ -9,6 +9,7 @@ module.exports = {
},
db: {
uri: 'mongodb://'+ (process.env.DB_PORT_27017_TCP_ADDR || process.env.MONGODB_URI || 'localhost')+'/mean',
uri: process.env.MONGODB_URI || 'mongodb://'+ (process.env.DB_PORT_27017_TCP_ADDR || '127.0.0.1') + '/mean',
options: {
user: '',
pass: ''
@ -35,6 +36,25 @@ module.exports = {
baseUrl: process.env.BASE_URL || 'localhost:3000',
tempUserCollection: 'temporary_users',
mailer: {
from: process.env.MAILER_FROM || 'testing@'+process.env.SPARKPOST_SANDBOX_DOMAIN || 'no-reply@tellform.com',
options: process.env.MAILER_SMTP_HOST ? { //Uses custom SMTP if MAILER_SMTP_HOST is set
host: process.env.MAILER_SMTP_HOST || '',
port: process.env.MAILER_SMTP_PORT || 465,
secure: process.env.MAILER_SMTP_SECURE || true,
auth: {
user: process.env.MAILER_EMAIL_ID || '',
pass: process.env.MAILER_PASSWORD || ''
}
} : {
service: process.env.MAILER_SERVICE_PROVIDER || '',
auth: {
user: process.env.MAILER_EMAIL_ID || '',
pass: process.env.MAILER_PASSWORD || ''
}
}
},
subdomainsDisabled: (process.env.SUBDOMAINS_DISABLED === 'TRUE'),
//Sentry DSN Client Key

View File

@ -4,7 +4,7 @@ module.exports = {
baseUrl: process.env.BASE_URL || 'http://localhost:5000',
port: process.env.PORT || 5000,
db: {
uri: 'mongodb://'+( process.env.DB_PORT_27017_TCP_ADDR || process.env.MONGODB_URI || '0.0.0.0') +'/mean',
uri: process.env.MONGODB_URI || 'mongodb://'+( process.env.DB_PORT_27017_TCP_ADDR || '127.0.0.1') +'/mean',
options: {
user: '',
pass: ''
@ -16,7 +16,6 @@ module.exports = {
// Stream defaults to process.stdout
// Uncomment to enable logging to a log on the file system
},
mailer: {
from: process.env.MAILER_FROM || 'no-reply@tellform.com',
options: process.env.MAILER_SMTP_HOST ? { //Uses custom SMTP if MAILER_SMTP_HOST is set

View File

@ -3,7 +3,7 @@
module.exports = {
baseUrl: process.env.BASE_URL || process.env.HEROKU_APP_NAME + '.herokuapp.com' || 'tellform.com',
db: {
uri: process.env.MONGODB_URI || process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_1_PORT_27017_TCP_ADDR || '0.0.0.0') + '/mean',
uri: process.env.MONGODB_URI || process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://' + (process.env.DB_PORT_27017_TCP_ADDR || '127.0.0.1') + '/mean',
},
port: process.env.PORT || 5000,
socketUrl: process.env.SOCKET_URL || 'ws.tellform.com',
@ -32,48 +32,5 @@ module.exports = {
css: 'public/dist/application.min.css',
js: 'public/dist/application.min.js',
form_js: 'public/dist/form-application.min.js'
},
facebook: {
clientID: process.env.FACEBOOK_ID || 'APP_ID',
clientSecret: process.env.FACEBOOK_SECRET || 'APP_SECRET',
callbackURL: '/auth/facebook/callback'
},
twitter: {
clientID: process.env.TWITTER_KEY || 'CONSUMER_KEY',
clientSecret: process.env.TWITTER_SECRET || 'CONSUMER_SECRET',
callbackURL: '/auth/twitter/callback'
},
google: {
clientID: process.env.GOOGLE_ID || 'APP_ID',
clientSecret: process.env.GOOGLE_SECRET || 'APP_SECRET',
callbackURL: '/auth/google/callback'
},
linkedin: {
clientID: process.env.LINKEDIN_ID || 'APP_ID',
clientSecret: process.env.LINKEDIN_SECRET || 'APP_SECRET',
callbackURL: '/auth/linkedin/callback'
},
github: {
clientID: process.env.GITHUB_ID || 'APP_ID',
clientSecret: process.env.GITHUB_SECRET || 'APP_SECRET',
callbackURL: '/auth/github/callback'
},
mailer: {
from: process.env.MAILER_FROM || 'testing@'+process.env.SPARKPOST_SANDBOX_DOMAIN || 'no-reply@tellform.com',
options: process.env.MAILER_SMTP_HOST ? { //Uses custom SMTP if MAILER_SMTP_HOST is set
host: process.env.MAILER_SMTP_HOST || '',
port: process.env.MAILER_SMTP_PORT || 465,
secure: process.env.MAILER_SMTP_SECURE || true,
auth: {
user: process.env.MAILER_EMAIL_ID || '',
pass: process.env.MAILER_PASSWORD || ''
}
} : {
service: process.env.MAILER_SERVICE_PROVIDER || '',
auth: {
user: process.env.MAILER_EMAIL_ID || '',
pass: process.env.MAILER_PASSWORD || ''
}
}
}
};

View File

@ -4,7 +4,7 @@ module.exports = {
baseUrl: 'https://forms.polydaic.com',
port: 8443,
db: {
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || 'mongodb://localhost/mean',
uri: process.env.MONGOHQ_URL || process.env.MONGOLAB_URI || process.env.MONGODB_URI || 'mongodb://127.0.0.1/mean',
options: {
user: '',
pass: ''

View File

@ -3,7 +3,7 @@
/**
* Module dependencies.
*/
var fs = require('fs-extra'),
var fs = require('fs'),
https = require('https'),
express = require('express'),
morgan = require('morgan'),
@ -17,22 +17,13 @@ var fs = require('fs-extra'),
passport = require('passport'),
raven = require('raven'),
MongoStore = require('connect-mongo')(session),
flash = require('connect-flash'),
config = require('./config'),
consolidate = require('consolidate'),
path = require('path'),
device = require('express-device'),
client = new raven.Client(config.DSN);
var mongoose = require('mongoose');
var cacheOpts = {
max:100000,
maxAge:1000*60
};
require('mongoose-cache').install(mongoose, cacheOpts);
/**
* Configure Socket.io
*/
@ -246,12 +237,6 @@ module.exports = function(db) {
app.use(passport.initialize());
app.use(passport.session());
// setup express-device
app.use(device.capture({ parseUserAgent: true }));
// connect flash for flash messages
app.use(flash());
// Globbing routing files
config.getGlobbedFiles('./app/routes/**/*.js').forEach(function(routePath) {
require(path.resolve(routePath))(app);
@ -295,16 +280,16 @@ module.exports = function(db) {
// Log it
client.captureError(err);
/*if(process.env.NODE_ENV === 'production'){
if(process.env.NODE_ENV === 'production'){
res.status(500).render('500', {
error: 'Internal Server Error'
});
} else {*/
error: 'Internal Server Error'
});
} else {
// Error page
res.status(500).render('500', {
error: err.stack
});
//}
}
});
// Assume 404 since no middleware responded

View File

@ -1,41 +0,0 @@
'use strict';
/**
* Module dependencies.
*/
var passport = require('passport'),
FacebookStrategy = require('passport-facebook').Strategy,
config = require('../config'),
users = require('../../app/controllers/users.server.controller');
module.exports = function() {
// Use facebook strategy
passport.use(new FacebookStrategy({
clientID: config.facebook.clientID,
clientSecret: config.facebook.clientSecret,
callbackURL: config.facebook.callbackURL,
passReqToCallback: true
},
function(req, accessToken, refreshToken, profile, done) {
// Set the provider data and include tokens
var providerData = profile._json;
providerData.accessToken = accessToken;
providerData.refreshToken = refreshToken;
// Create the user OAuth profile
var providerUserProfile = {
firstName: profile.name.givenName,
lastName: profile.name.familyName,
displayName: profile.displayName,
email: profile.emails[0].value,
username: profile.username,
provider: 'facebook',
providerIdentifierField: 'id',
providerData: providerData
};
// Save the user OAuth profile
users.saveOAuthUserProfile(req, providerUserProfile, done);
}
));
};

View File

@ -1,46 +0,0 @@
'use strict';
/**
* Module dependencies.
*/
var passport = require('passport'),
GithubStrategy = require('passport-github').Strategy,
config = require('../config'),
users = require('../../app/controllers/users.server.controller');
module.exports = function() {
// Use github strategy
passport.use(new GithubStrategy({
clientID: config.github.clientID,
clientSecret: config.github.clientSecret,
callbackURL: config.github.callbackURL,
passReqToCallback: true
},
function(req, accessToken, refreshToken, profile, done) {
// Set the provider data and include tokens
var providerData = profile._json;
providerData.accessToken = accessToken;
providerData.refreshToken = refreshToken;
// Create the user OAuth profile
var displayName = profile.displayName.trim();
var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName
var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName;
var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : '';
var providerUserProfile = {
firstName: firstName,
lastName: lastName,
displayName: displayName,
email: profile.emails[0].value,
username: profile.username,
provider: 'github',
providerIdentifierField: 'id',
providerData: providerData
};
// Save the user OAuth profile
users.saveOAuthUserProfile(req, providerUserProfile, done);
}
));
};

View File

@ -1,41 +0,0 @@
'use strict';
/**
* Module dependencies.
*/
var passport = require('passport'),
GoogleStrategy = require('passport-google-oauth').OAuth2Strategy,
config = require('../config'),
users = require('../../app/controllers/users.server.controller');
module.exports = function() {
// Use google strategy
passport.use(new GoogleStrategy({
clientID: config.google.clientID,
clientSecret: config.google.clientSecret,
callbackURL: config.google.callbackURL,
passReqToCallback: true
},
function(req, accessToken, refreshToken, profile, done) {
// Set the provider data and include tokens
var providerData = profile._json;
providerData.accessToken = accessToken;
providerData.refreshToken = refreshToken;
// Create the user OAuth profile
var providerUserProfile = {
firstName: profile.name.givenName,
lastName: profile.name.familyName,
displayName: profile.displayName,
email: profile.emails[0].value,
username: profile.username,
provider: 'google',
providerIdentifierField: 'id',
providerData: providerData
};
// Save the user OAuth profile
users.saveOAuthUserProfile(req, providerUserProfile, done);
}
));
};

View File

@ -1,42 +0,0 @@
'use strict';
/**
* Module dependencies.
*/
var passport = require('passport'),
LinkedInStrategy = require('passport-linkedin').Strategy,
config = require('../config'),
users = require('../../app/controllers/users.server.controller');
module.exports = function() {
// Use linkedin strategy
passport.use(new LinkedInStrategy({
consumerKey: config.linkedin.clientID,
consumerSecret: config.linkedin.clientSecret,
callbackURL: config.linkedin.callbackURL,
passReqToCallback: true,
profileFields: ['id', 'first-name', 'last-name', 'email-address']
},
function(req, accessToken, refreshToken, profile, done) {
// Set the provider data and include tokens
var providerData = profile._json;
providerData.accessToken = accessToken;
providerData.refreshToken = refreshToken;
// Create the user OAuth profile
var providerUserProfile = {
firstName: profile.name.givenName,
lastName: profile.name.familyName,
displayName: profile.displayName,
email: profile.emails[0].value,
username: profile.username,
provider: 'linkedin',
providerIdentifierField: 'id',
providerData: providerData
};
// Save the user OAuth profile
users.saveOAuthUserProfile(req, providerUserProfile, done);
}
));
};

View File

@ -1,45 +0,0 @@
'use strict';
/**
* Module dependencies.
*/
var passport = require('passport'),
TwitterStrategy = require('passport-twitter').Strategy,
config = require('../config'),
users = require('../../app/controllers/users.server.controller');
module.exports = function() {
// Use twitter strategy
passport.use(new TwitterStrategy({
consumerKey: config.twitter.clientID,
consumerSecret: config.twitter.clientSecret,
callbackURL: config.twitter.callbackURL,
passReqToCallback: true
},
function(req, token, tokenSecret, profile, done) {
// Set the provider data and include tokens
var providerData = profile._json;
providerData.token = token;
providerData.tokenSecret = tokenSecret;
// Create the user OAuth profile
var displayName = profile.displayName.trim();
var iSpace = displayName.indexOf(' '); // index of the whitespace following the firstName
var firstName = iSpace !== -1 ? displayName.substring(0, iSpace) : displayName;
var lastName = iSpace !== -1 ? displayName.substring(iSpace + 1) : '';
var providerUserProfile = {
firstName: firstName,
lastName: lastName,
displayName: displayName,
username: profile.username,
provider: 'twitter',
providerIdentifierField: 'id_str',
providerData: providerData
};
// Save the user OAuth profile
users.saveOAuthUserProfile(req, providerUserProfile, done);
}
));
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

BIN
design/tellform_mascot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

View File

@ -1,22 +0,0 @@
version: "3"
services:
tellform:
build:
context: ./
dockerfile: dockerfile
image: tellform
ports:
- 3000:3000
links:
- tellform-redis:redis-db
- tellform-mongo:db
env_file:
- .env
tellform-redis:
image: redis
ports:
- 6379
tellform-mongo:
image: mongo
ports:
- 27017

View File

@ -1,96 +0,0 @@
[
[{
"fieldType": "textfield",
"fieldValue": "snthsnth",
"_id": "55aec5d284bae1a1996210bd",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Short Text2",
"lastModified": "2015-07-21T22:21:06.653Z",
"created": "2015-07-21T22:21:06.653Z",
"$$hashKey": "02J"
}, {
"fieldType": "textfield",
"fieldValue": "duieedi",
"_id": "55aec5b084bae1a1996210b4",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Last Name",
"lastModified": "2015-07-21T22:20:32.053Z",
"created": "2015-07-21T22:20:32.053Z",
"$$hashKey": "02K"
}],
[{
"fieldType": "textfield",
"fieldValue": "snthsnth",
"_id": "55aec5d284bae1a1996210bd",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Short Text2",
"lastModified": "2015-07-21T22:21:06.653Z",
"created": "2015-07-21T22:21:06.653Z",
"$$hashKey": "02J"
}, {
"fieldType": "textfield",
"fieldValue": "duieedi",
"_id": "55aec5b084bae1a1996210b4",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Last Name",
"lastModified": "2015-07-21T22:20:32.053Z",
"created": "2015-07-21T22:20:32.053Z",
"$$hashKey": "02K"
}],
[{
"fieldType": "textfield",
"fieldValue": "snthsnth",
"_id": "55aec5d284bae1a1996210bd",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Short Text2",
"lastModified": "2015-07-21T22:21:06.653Z",
"created": "2015-07-21T22:21:06.653Z",
"$$hashKey": "02J"
}, {
"fieldType": "textfield",
"fieldValue": "duieedi",
"_id": "55aec5b084bae1a1996210b4",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Last Name",
"lastModified": "2015-07-21T22:20:32.053Z",
"created": "2015-07-21T22:20:32.053Z",
"$$hashKey": "02K"
}],
[{
"fieldType": "textfield",
"fieldValue": "snthsnth",
"_id": "55aec5d284bae1a1996210bd",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Short Text2",
"lastModified": "2015-07-21T22:21:06.653Z",
"created": "2015-07-21T22:21:06.653Z",
"$$hashKey": "02J"
}, {
"fieldType": "textfield",
"fieldValue": "duieedi",
"_id": "55aec5b084bae1a1996210b4",
"disabled": false,
"fieldOptions": [],
"description": "",
"title": "Last Name",
"lastModified": "2015-07-21T22:20:32.053Z",
"created": "2015-07-21T22:20:32.053Z",
"$$hashKey": "02K"
}]
]

View File

@ -1,758 +0,0 @@
[
{
"_id": "56450d120761e9d7d68d3543",
"lastModified": "2015-11-12T22:05:06.380Z",
"fdfData": null,
"admin": "55d270df2749c1ceb47c0f8b",
"form": "5644dde5507b2572635dcd50",
"title": "Sample Form",
"timeElapsed": 11.925,
"percentageComplete": 75,
"__v": 0,
"created": "2015-11-12T22:05:06.378Z",
"form_fields": [
{
"_id": "5644e0d5507b2572635dcd56",
"fieldValue": "",
"fieldType": "statement",
"title": "Statement2",
"lastModified": "2015-11-12T18:56:21.730Z",
"created": "2015-11-12T18:56:21.660Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": true,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.769Z",
"title": "Short Text2",
"fieldType": "textfield",
"fieldValue": "first",
"_id": "5644dde7507b2572635dcd51",
"created": "2015-11-12T18:43:51.290Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.770Z",
"title": "Short Text3",
"fieldType": "textfield",
"fieldValue": "first",
"_id": "5644dde7507b2572635dcd52",
"created": "2015-11-12T18:43:51.977Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Paragraph Text2",
"fieldType": "textarea",
"fieldValue": "first",
"_id": "5644ddea507b2572635dcd54",
"created": "2015-11-12T18:43:54.594Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Rating2",
"fieldType": "rating",
"fieldValue": 1,
"_id": "5644e0d4507b2572635dcd55",
"created": "2015-11-12T18:56:20.324Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
}
]
},
{
"_id": "56450d1d0761e9d7d68d3544",
"lastModified": "2015-11-12T22:05:17.806Z",
"fdfData": null,
"admin": "55d270df2749c1ceb47c0f8b",
"form": "5644dde5507b2572635dcd50",
"title": "Sample Form",
"timeElapsed": 10.301,
"percentageComplete": 75,
"__v": 0,
"created": "2015-11-12T22:05:17.805Z",
"form_fields": [
{
"_id": "5644e0d5507b2572635dcd56",
"fieldValue": "",
"fieldType": "statement",
"title": "Statement2",
"lastModified": "2015-11-12T18:56:21.730Z",
"created": "2015-11-12T18:56:21.660Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": true,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.769Z",
"title": "Short Text2",
"fieldType": "textfield",
"fieldValue": "second",
"_id": "5644dde7507b2572635dcd51",
"created": "2015-11-12T18:43:51.290Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.770Z",
"title": "Short Text3",
"fieldType": "textfield",
"fieldValue": "second",
"_id": "5644dde7507b2572635dcd52",
"created": "2015-11-12T18:43:51.977Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Paragraph Text2",
"fieldType": "textarea",
"fieldValue": "second",
"_id": "5644ddea507b2572635dcd54",
"created": "2015-11-12T18:43:54.594Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Rating2",
"fieldType": "rating",
"fieldValue": 3,
"_id": "5644e0d4507b2572635dcd55",
"created": "2015-11-12T18:56:20.324Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
}
]
},
{
"_id": "56450d260761e9d7d68d3545",
"lastModified": "2015-11-12T22:05:26.874Z",
"fdfData": null,
"admin": "55d270df2749c1ceb47c0f8b",
"form": "5644dde5507b2572635dcd50",
"title": "Sample Form",
"timeElapsed": 7.975,
"percentageComplete": 75,
"__v": 0,
"created": "2015-11-12T22:05:26.874Z",
"form_fields": [
{
"_id": "5644e0d5507b2572635dcd56",
"fieldValue": "",
"fieldType": "statement",
"title": "Statement2",
"lastModified": "2015-11-12T18:56:21.730Z",
"created": "2015-11-12T18:56:21.660Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": true,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.769Z",
"title": "Short Text2",
"fieldType": "textfield",
"fieldValue": "third",
"_id": "5644dde7507b2572635dcd51",
"created": "2015-11-12T18:43:51.290Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.770Z",
"title": "Short Text3",
"fieldType": "textfield",
"fieldValue": "third",
"_id": "5644dde7507b2572635dcd52",
"created": "2015-11-12T18:43:51.977Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Paragraph Text2",
"fieldType": "textarea",
"fieldValue": "third",
"_id": "5644ddea507b2572635dcd54",
"created": "2015-11-12T18:43:54.594Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Rating2",
"fieldType": "rating",
"fieldValue": 2,
"_id": "5644e0d4507b2572635dcd55",
"created": "2015-11-12T18:56:20.324Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
}
]
},
{
"_id": "56450d320761e9d7d68d3546",
"lastModified": "2015-11-12T22:05:38.717Z",
"fdfData": null,
"admin": "55d270df2749c1ceb47c0f8b",
"form": "5644dde5507b2572635dcd50",
"title": "Sample Form",
"timeElapsed": 10.47,
"percentageComplete": 75,
"__v": 0,
"created": "2015-11-12T22:05:38.716Z",
"form_fields": [
{
"_id": "5644e0d5507b2572635dcd56",
"fieldValue": "",
"fieldType": "statement",
"title": "Statement2",
"lastModified": "2015-11-12T18:56:21.730Z",
"created": "2015-11-12T18:56:21.660Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": true,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.769Z",
"title": "Short Text2",
"fieldType": "textfield",
"fieldValue": "fourth",
"_id": "5644dde7507b2572635dcd51",
"created": "2015-11-12T18:43:51.290Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.770Z",
"title": "Short Text3",
"fieldType": "textfield",
"fieldValue": "fourth",
"_id": "5644dde7507b2572635dcd52",
"created": "2015-11-12T18:43:51.977Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Paragraph Text2",
"fieldType": "textarea",
"fieldValue": "fourth",
"_id": "5644ddea507b2572635dcd54",
"created": "2015-11-12T18:43:54.594Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
},
{
"lastModified": "2015-11-12T21:30:20.771Z",
"title": "Rating2",
"fieldType": "rating",
"fieldValue": 2,
"_id": "5644e0d4507b2572635dcd55",
"created": "2015-11-12T18:56:20.324Z",
"validFieldTypes": [
"textfield",
"date",
"email",
"link",
"legal",
"url",
"textarea",
"statement",
"welcome",
"thankyou",
"file",
"dropdown",
"scale",
"rating",
"radio",
"checkbox",
"hidden",
"yes_no",
"natural",
"number"
],
"deletePreserved": false,
"disabled": false,
"required": true,
"fieldOptions": [],
"description": ""
}
]
}
]

View File

@ -1,22 +0,0 @@
##First Form Auto-Update
1. Added field CLIENT
time: 2553
2. Finding form SERVER
time: 2841
3. Update form CLIENT
time: 2870
4.Updated form SERVER
time: 2863
##Second Form Auto-Update
1. Added field CLIENT
time: 2755
2. Finding form SERVER
time: 2898

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

View File

@ -1,249 +0,0 @@
#Installing Sentry Server
### Before You Begin
Make sure you understand what sentry server does. You can view documentation for sentry server [here](https://sentry.readthedocs.org/). This document was written for a server running *Ubuntu 14.04 LTS server* (we used Azure).
### Prerequisites
Make sure you have these installed:
* apt-get
* python2.7
* vim
### Installation Steps
1. Add non-root user.
```
sudo adduser sentry
sudo adduser sentry sudo
```
2. Update all apt-get packages
```
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo apt-get install libxml2-dev libxslt1-dev libffi-dev libpq-dev python-dev
sudo reboot
```
3. Install easy_install and pip
```
wget https://bootstrap.pypa.io/ez_setup.py -O - | sudo python
sudo easy_install pip
```
4. Install virtualenv and lmxl
```
sudo pip install virtualenv
sudo pip install lxml
```
5. Install Sentry and Setup
```
# make server directory
mkdir ~/SentryServer; cd ~/SentryServer;
# make virtualenv
virtualenv ./
#activate virtualenv
source ./bin/activate
# install sentry and its postgresql dependencies
pip install -U sentry[postgres]
```
6. Install postgresql
```
# install postgres
sudo apt-get install postgresql postgresql-contrib libpq-dev
# install postgres adminpack
sudo -u postgres psql
CREATE EXTENSION "adminpack";
\q
```
7. Setup postgresql DB
```
# change postgres password & create database
sudo passwd postgres
sudo su - postgres
psql -d template1 -c "ALTER USER postgres WITH PASSWORD 'changeme';"
createdb sentry
createuser sentry_user --pwprompt
psql -d template1 -U postgres
GRANT ALL PRIVILEGES ON DATABASE sentry to sentry_user;
\q
exit
```
8. Setup Sentry Configuration
```
# initialize conf file
sentry init
#edit sentry configuration
vim ~/.sentry/sentry.conf.py
```
The following are the contents of my sentry.conf.py file (replace name, user and password with your that of your DB)
```
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'sentry',
'USER': 'sentry_user',
'PASSWORD': 'your_password',
'HOST': 'localhost',
}
}
# No trailing slash!
SENTRY_URL_PREFIX = 'http://sentry.example.com'
SENTRY_WEB_HOST = '0.0.0.0'
SENTRY_WEB_PORT = 9000
SENTRY_WEB_OPTIONS = {
'workers': 3, # the number of gunicorn workers
'secure_scheme_headers': {'X-FORWARDED-PROTO': 'https'}, # detect HTTPS mode from X-Forwarded-Proto header
}
#CONFIGURE REDIS
SENTRY_REDIS_OPTIONS = {
'hosts': {
0: {
'host': '127.0.0.1',
'port': 6379,
'timeout': 3,
#'password': 'redis auth password'
}
}
}
#CONFIGURE OUTGOING MAIL
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'your_gmail_username@gmail.com'
EMAIL_HOST_PASSWORD = 'your_gmail_password'
DEFAULT_FROM_EMAIL = 'testing@testing.com
```
9. Setup Database and Start Sentry
```
#install and run redis-server
wget http://download.redis.io/releases/redis-stable.tar.gz
tar xzf redis-stable.tar.gz
cd redis-stable
make
make test
sudo make install
cd utils
sudo ./install_server.sh
#Go back to app directory
cd ~/SentryServer
sudo service redis_6379 start
# set up databse
sentry upgrade
# let's try it out!
sentry start
```
10. Install nginx
```
# install nginx
sudo apt-get install nginx
# remove the default symbolic link
sudo rm /etc/nginx/sites-enabled/default
# create a new blank config, and make a symlink to it
sudo touch /etc/nginx/sites-available/sentry
cd /etc/nginx/sites-enabled
sudo ln -s ../sites-available/sentry
# edit the nginx configuration file
sudo vim /etc/nginx/sites-available/sentry
```
*Here are the contents of my nginx file:*
```
server {
# listen on port 80
listen 80;
# for requests to these domains
server_name yourdomain.com www.yourdomain.com;
# keep logs in these files
access_log /var/log/nginx/sentry.access.log;
error_log /var/log/nginx/sentry.error.log;
# You need this to allow users to upload large files
# See http://wiki.nginx.org/HttpCoreModule#client_max_body_size
# I'm not sure where it goes, so I put it in twice. It works.
client_max_body_size 0;
location / {
proxy_pass http://localhost:9000;
proxy_redirect off;
proxy_read_timeout 5m;
# make sure these HTTP headers are set properly
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
```
11. Start the worker processes
```
# restart nginx
sudo nginx -t
sudo service nginx reload
#start sentry
sentry celery worker -B
```
12. Install and Configure supervisord
```
pip install supervisord
sudo echo_supervisord_conf > ~/SentryServer/etc/supervisord.conf
#Edit yuour supervisord Config
vim /etc/supervisord.conf
```
Configuration file should look like this
```
[program:sentry-web]
directory=~/SentryServer/
command=~/SentryServer/bin/sentry start
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=syslog
stderr_logfile=syslog
[program:sentry-worker]
directory=~/SentryServer/
command=~/SentryServer/bin/sentry celery worker -B
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=syslog
stderr_logfile=syslog
```
13. Run Server (with supervisord)
```
supervisord
```

View File

@ -1,29 +0,0 @@
UX of Updating Forms
====================
##Form Updating
- Action: Update Configuration
1. User clicks on Form from FormList page (visits form admin page)
2. User clicks on "Configure Form" Tab
3. User changes inputs in form page
4. Save Button is Pressed
5. Loading/Busy Indicator fills the screen
6. Loading/Busy Indicator exits the screen
7. Configuration page is shown with updated settings
- Action: Add Form Field
1. User clicks on Form from FormList page
2. User clicks on a Tab in "AddField" column
3. Loading/Busy Indicator fills the screen
4. Loading/Busy Indicator exits the screen
- Action: Edit Form Field Title
1. User clicks on Form from FormList page (visits form admin page)
2. User clicks on a current Form Input accordion (must be either the name or the caret)
3. The clicked accordion (the one interacted with in Step#2) expands
4. User clicks on 'Question Title' text input (aka focuses on said text input)
5. User starts typing in text input
6. User defocuses/clicks off of text input
7. Loading/Busy Indicator fills the screen
8. Loading/Busy Indicator exits the screen
9. Field Accordion heading is updated

View File

@ -28,10 +28,10 @@ module.exports = function(grunt) {
clientViews: ['public/modules/**/*.html', 'public/form_modules/forms/base/**/*.html', '!public/modules/forms/base/**/*.html',],
clientJS: ['public/js/*.js', 'public/form_modules/**/*.js', 'public/modules/**/*.js'],
clientCSS: ['public/modules/**/*.css', 'public/form_modules/**/*.css', '!public/modules/**/demo/**/*.css', '!public/modules/**/dist/**/*.css'],
clientCSS: ['public/modules/**/*.css'],
serverTests: ['app/tests/**/*.js'],
clientTests: ['public/modules/**/tests/*.js', '!public/modules/**/demo/**/*.js', '!public/modules/**/dist/**/*.js', '!public/modules/**/node_modules/**/*.js']
clientTests: ['public/modules/**/tests/*.js']
};
watchFiles.allTests = watchFiles.serverTests.concat(watchFiles.clientTests);
@ -127,19 +127,6 @@ module.exports = function(grunt) {
}
}
},
'closure-compiler': {
vendor_file: {
closurePath: './scripts',
js: 'public/dist/vendor_forms_uglified.js',
jsOutputFile: 'public/dist/vendor.min.js',
maxBuffer: 10000000000,
options: {
warning_level: 'QUIET',
compilation_level: 'SIMPLE_OPTIMIZATIONS',
language_in: 'ECMASCRIPT5'
}
}
},
cssmin: {
combine: {
files: {
@ -157,19 +144,6 @@ module.exports = function(grunt) {
}
}
},
'node-inspector': {
custom: {
options: {
'web-port': 1337,
'web-host': 'localhost',
'debug-port': 5858,
'save-live-edit': true,
'no-preload': true,
'stack-trace-limit': 50,
'hidden': []
}
}
},
ngAnnotate: {
production: {
files: {
@ -180,28 +154,26 @@ module.exports = function(grunt) {
},
concurrent: {
default: ['nodemon', 'watch'],
debug: ['nodemon', 'watch', 'node-inspector'],
debug: ['nodemon', 'watch'],
options: {
logConcurrentOutput: true,
limit: 10
}
},
env: {
src: '.env',
test: {
NODE_ENV: 'test',
src: '.env'
},
secure: {
NODE_ENV: 'secure',
src: '/opt/deploy/.env'
},
production: {
NODE_ENV: 'production',
src: '/opt/deploy/.env'
},
dev: {
NODE_ENV: 'development',
src: '.env'
}
},
mochaTest: {
@ -211,7 +183,7 @@ module.exports = function(grunt) {
quiet: false,
require: 'server.js',
ui: 'bdd',
debug: true
debug: false
}
},
karma: {

View File

@ -22,74 +22,47 @@
"start": "npm run version && grunt",
"test": "npm run version && grunt test",
"postinstall": "bower install --config.interactive=false; grunt build;",
"init": "node scripts/setup.js",
"version": "check-node-version --package"
"init": "node scripts/setup.js"
},
"dependencies": {
"async": "^1.4.2",
"async-boolean-expression-evaluator": "^1.1.1",
"bcrypt": "^0.8.7",
"bcrypt-nodejs": "0.0.3",
"body-parser": "~1.14.1",
"bower": "~1.6.5",
"chalk": "^1.1.3",
"check-node-version": "^2.1.0",
"compression": "~1.6.0",
"connect": "^3.4.1",
"connect-flash": "~0.1.1",
"connect-mongo": "~0.8.2",
"consolidate": "~0.13.1",
"cookie-parser": "~1.4.0",
"deep-diff": "^0.3.4",
"dotenv": "^2.0.0",
"email-verification": "~0.4.1",
"envfile": "^2.0.1",
"express": "~4.13.3",
"express-device": "~0.4.2",
"express-session": "~1.12.1",
"forever": "~0.15.1",
"fs-extra": "~0.26.2",
"glob": "^7.0.3",
"google-cdn": "^1.1.0",
"grunt": "~0.4.1",
"grunt-cli": "~0.1.13",
"grunt-concurrent": "~2.3.0",
"grunt-contrib-csslint": "~1.0.0",
"grunt-contrib-cssmin": "~1.0.1",
"grunt-contrib-jshint": "~1.0.0",
"grunt-contrib-uglify": "~0.11.0",
"grunt-contrib-watch": "~0.6.1",
"grunt-env": "~0.4.1",
"grunt-html2js": "~0.3.5",
"grunt-karma": "~0.12.1",
"grunt-newer": "~1.1.1",
"grunt-ng-annotate": "~1.0.1",
"grunt-node-inspector": "~0.4.1",
"grunt-nodemon": "~0.4.0",
"helmet": "3.5.0",
"inquirer": "^1.0.2",
"jit-grunt": "^0.9.1",
"lodash": "^4.17.4",
"main-bower-files": "~2.9.0",
"method-override": "~2.3.0",
"mkdirp": "^0.5.1",
"mongoose": "~4.4.19",
"mongoose-cache": "^0.1.5",
"mongoose-utilities": "~0.1.1",
"morgan": "~1.8.1",
"multer": "^1.3.0",
"nodemailer": "~4.0.0",
"nodemailer-sendgrid-transport": "^0.2.0",
"nodemailer-sparkpost-transport": "^1.0.0",
"passport": "~0.3.0",
"passport-anonymous": "^1.0.1",
"passport-facebook": "~2.0.0",
"passport-github": "~1.0.0",
"passport-google-oauth": "~0.2.0",
"passport-linkedin": "~1.0.0",
"passport-local": "~1.0.0",
"passport-localapikey-update": "^0.5.0",
"passport-twitter": "~1.0.2",
"path-exists": "^2.1.0",
"prerender-node": "^2.2.1",
"random-js": "^1.0.8",
@ -98,7 +71,6 @@
"socket.io": "^1.4.6",
"socket.io-redis": "^1.0.0",
"swig": "~1.4.1",
"uid-generator": "^0.1.1",
"uuid-token-generator": "^0.5.0",
"wildcard-subdomains": "github:tellform/wildcard-subdomains",
"winston": "^2.3.1",
@ -110,7 +82,7 @@
"coveralls": "^2.11.4",
"cross-spawn": "^5.0.0",
"del": "^2.2.2",
"email-verification": "github:tellform/node-email-verification",
"grunt-cli": "~0.1.13",
"grunt-closure-compiler": "0.0.21",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
@ -118,7 +90,11 @@
"grunt-execute": "^0.2.2",
"grunt-mocha-istanbul": "^3.0.1",
"grunt-mocha-test": "~0.12.1",
"grunt-contrib-watch": "~0.6.1",
"grunt-newer": "~1.1.1",
"grunt-usemin": "^3.1.1",
"grunt-karma": "~0.12.1",
"grunt-nodemon": "~0.4.0",
"grunt-wiredep": "^3.0.1",
"istanbul": "^0.4.0",
"jasmine-core": "^2.4.1",
@ -131,11 +107,9 @@
"karma-mocha-reporter": "^1.1.1",
"karma-ng-html2js-preprocessor": "^0.2.0",
"karma-phantomjs-launcher": "^1.0.4",
"mailosaur": "^1.0.1",
"mocha": "^3.1.2",
"mocha-lcov-reporter": "^1.0.0",
"nightwatch": "^0.9.8",
"node-mandrill": "^1.0.1",
"phantomjs": "^1.9.18",
"selenium-server": "^3.0.1",
"should": "~7.1.1",

View File

@ -1995,6 +1995,14 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
}
};
// Return all user's Forms
$scope.findAll = function() {
GetForms.query(function(_forms){
$scope.myforms = _forms;
});
};
/*
** DeleteModal Functions
*/
@ -2029,13 +2037,6 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
}
};
// Return all user's Forms
$scope.findAll = function() {
GetForms.query(function(_forms){
$scope.myforms = _forms;
});
};
//Modal functions
$scope.openCreateModal = function(){
if(!$scope.showCreateModal){
@ -2513,27 +2514,10 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
rows: []
};
var submissions = $scope.myform.submissions || [];
//Iterate through form's submissions
for(var i = 0; i < submissions.length; i++){
for(var x = 0; x < submissions[i].form_fields.length; x++){
if(submissions[i].form_fields[x].fieldType === 'dropdown'){
submissions[i].form_fields[x].fieldValue = submissions[i].form_fields[x].fieldValue.option_value;
}
//var oldValue = submissions[i].form_fields[x].fieldValue || '';
//submissions[i].form_fields[x] = _.merge(defaultFormFields, submissions[i].form_fields);
//submissions[i].form_fields[x].fieldValue = oldValue;
}
submissions[i].selected = false;
}
$scope.table.rows = submissions;
var initController = function(){
$http({
method: 'GET',
url: '/someUrl'
url: '/forms'+$scope.myform._id+'/submissions'
}).then(function successCallback(response) {
var defaultFormFields = _.cloneDeep($scope.myform.form_fields);
@ -2556,6 +2540,8 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
});
};
initController();
/*
** Analytics Functions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,18 @@
/*Modal overlay (for lightbox effect)*/
.overlay {
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
background-color: rgb(0,0,0);
background-color: rgba(0,0,0,0.5);
z-index: 10;
}
.overlay.submitform {
background-color: rgb(256,256,256);
background-color: rgba(256,256,256,0.8);
}
.form-item .title-row > .list-group-item-heading {
color: #34628a;

View File

@ -1,12 +1,13 @@
'use strict';
// Forms controller
angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope', '$stateParams', '$state', 'GetForms', 'CurrentForm', '$http', '$uibModal',
function($rootScope, $scope, $stateParams, $state, GetForms, CurrentForm, $http, $uibModal) {
angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope', '$stateParams', '$state', 'GetForms', 'CurrentForm', '$http', '$uibModal', 'myForms',
function($rootScope, $scope, $stateParams, $state, GetForms, CurrentForm, $http, $uibModal, myForms) {
$scope = $rootScope;
$scope.forms = {};
$scope.showCreateModal = false;
$scope.myforms = myForms
$rootScope.languageRegExp = {
regExp: /[@!#$%^&*()\-+={}\[\]|\\/'";:`.,~№?<>]+/i,
@ -49,13 +50,6 @@ angular.module('forms').controller('ListFormsController', ['$rootScope', '$scope
}
};
// Return all user's Forms
$scope.findAll = function() {
GetForms.query(function(_forms){
$scope.myforms = _forms;
});
};
//Modal functions
$scope.openCreateModal = function(){
if(!$scope.showCreateModal){

View File

@ -32,7 +32,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
/*
** EditModal Functions
*/
$scope.openEditModal = function(curr_field){
$scope.openEditModal = function(curr_field, isEdit, field_index){
$scope.editFieldModal = $uibModal.open({
animation: true,
templateUrl: 'editFieldModal.html',
@ -41,6 +41,8 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
$scope.field = curr_field;
$scope.showLogicJump = false;
$scope.isEdit = isEdit;
// decides whether field options block will be shown (true for dropdown and radio fields)
$scope.showAddOptions = function (field){
if(field.fieldType === 'dropdown' || field.fieldType === 'checkbox' || field.fieldType === 'radio'){
@ -67,13 +69,13 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
];
// add new option to the field
$scope.addOption = function(currField){
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
if(!currField.fieldOptions){
currField.fieldOptions = [];
$scope.addOption = function(){
if($scope.field.fieldType === 'checkbox' || $scope.field.fieldType === 'dropdown' || $scope.field.fieldType === 'radio'){
if(!$scope.field.fieldOptions){
$scope.field.fieldOptions = [];
}
var lastOptionID = currField.fieldOptions.length+1;
var lastOptionID = $scope.field.fieldOptions.length+1;
// new option's id
@ -84,17 +86,17 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
};
// put new option into fieldOptions array
currField.fieldOptions.push(newOption);
$scope.field.fieldOptions.push(newOption);
}
};
// delete particular option
$scope.deleteOption = function (currField, option){
if(currField.fieldType === 'checkbox' || currField.fieldType === 'dropdown' || currField.fieldType === 'radio'){
for(var i = 0; i < currField.fieldOptions.length; i++){
if(currField.fieldOptions[i].option_id === option.option_id){
$scope.deleteOption = function (option){
if($scope.field.fieldType === 'checkbox' || $scope.field.fieldType === 'dropdown' || $scope.field.fieldType === 'radio'){
for(var i = 0; i < $scope.field.fieldOptions.length; i++){
if($scope.field.fieldOptions[i].option_id === option.option_id){
currField.fieldOptions.splice(i, 1);
$scope.field.fieldOptions.splice(i, 1);
break;
}
}
@ -119,8 +121,8 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
};
// decides whether field options block will be shown (true for dropdown and radio fields)
$scope.showRatingOptions = function (field){
if(field.fieldType === 'rating'){
$scope.showRatingOptions = function (){
if($scope.field.fieldType === 'rating'){
return true;
} else {
return false;
@ -128,11 +130,16 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
};
$scope.saveField = function(){
if($scope.isEdit){
$scope.myform.form_fields[field_index] = $scope.field;
} else {
$scope.myform.form_fields.push(curr_field);
}
$scope.myform.form_fields.push(curr_field);
$scope.$parent.update(false, $scope.$parent.myform, true, true, function(){
$uibModalInstance.close();
});
};
$scope.cancel = function(){
$uibModalInstance.close();
@ -268,7 +275,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
** Field CRUD Methods
*/
// Add a new field
$scope.addNewField = function(modifyForm, fieldType){
$scope.addNewField = function(fieldType){
// increment lastAddedID counter
$scope.addField.lastAddedID++;
var fieldTitle = fieldType;
@ -307,12 +314,7 @@ angular.module('forms').directive('editFormDirective', ['$rootScope', 'FormField
});
}
if(modifyForm){
//Add newField to form_fields array
$scope.myform.form_fields.push(newField);
}
$scope.openEditModal(newField);
$scope.openEditModal(newField, false, $scope.myform.form_fields.length);
};
// decides whether field options block will be shown (true for dropdown and radio fields)

View File

@ -16,27 +16,10 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
rows: []
};
var submissions = $scope.myform.submissions || [];
//Iterate through form's submissions
for(var i = 0; i < submissions.length; i++){
for(var x = 0; x < submissions[i].form_fields.length; x++){
if(submissions[i].form_fields[x].fieldType === 'dropdown'){
submissions[i].form_fields[x].fieldValue = submissions[i].form_fields[x].fieldValue.option_value;
}
//var oldValue = submissions[i].form_fields[x].fieldValue || '';
//submissions[i].form_fields[x] = _.merge(defaultFormFields, submissions[i].form_fields);
//submissions[i].form_fields[x].fieldValue = oldValue;
}
submissions[i].selected = false;
}
$scope.table.rows = submissions;
var initController = function(){
$http({
method: 'GET',
url: '/someUrl'
url: '/forms'+$scope.myform._id+'/submissions'
}).then(function successCallback(response) {
var defaultFormFields = _.cloneDeep($scope.myform.form_fields);
@ -59,6 +42,8 @@ angular.module('forms').directive('editSubmissionsFormDirective', ['$rootScope',
});
};
initController();
/*
** Analytics Functions

View File

@ -146,8 +146,6 @@
</div>
</div>
</script>
<!-- Edit StartPage Modal Dialog Template -->
@ -291,8 +289,6 @@
</div>
</div>
</script>
<!-- Edit Field Modal Dialog Template -->
@ -312,34 +308,34 @@
<div class="row"><br></div>
<div class="row description" ng-hide="showRatingOptions(field)">
<div class="row description" ng-hide="showRatingOptions()">
<div class="col-md-12 bold">{{ 'QUESTION_DESCRIPTION' | translate }}</div>
<div class="col-md-12">
<textarea type="text" class="form-control" ng-model="field.description" name="description{{field._id}}"value="{{field.description}}"></textarea>
</div>
</div>
<div class="row" ng-show="showAddOptions(field)"><br></div>
<div class="row options" ng-if="showAddOptions(field)">
<div class="row" ng-show="showAddOptions()"><br></div>
<div class="row options" ng-if="showAddOptions()">
<div class="col-md-4 col-xs-12">{{ 'OPTIONS' | translate }}</div>
<div class="col-md-8 col-xs-12">
<div ng-repeat="option in field.fieldOptions track by option.option_id" class="row">
<input type="text" name="{{option.option_value}}{{field._id}}" ng-model="option.option_value" class="col-xs-5">
<a class="btn btn-danger btn-mini right" type="button" ng-click="deleteOption(field, option)" class="col-xs-3">
<a class="btn btn-danger btn-mini right" type="button" ng-click="deleteOption(option)" class="col-xs-3">
<i class="fa fa-trash-o"></i>
</a>
</div>
<div class="row">
<button class="btn btn-primary btn-small col-md-offset-0 col-md-6 col-sm-4 col-sm-offset-4 col-xs-6 col-xs-offset-6" type="button" ng-click="addOption(field)">
<button class="btn btn-primary btn-small col-md-offset-0 col-md-6 col-sm-4 col-sm-offset-4 col-xs-6 col-xs-offset-6" type="button" ng-click="addOption()">
<i class="icon-plus icon-white"></i> {{ 'ADD_OPTION' | translate }}
</button>
</div>
</div>
</div>
<div class="row" ng-show="showRatingOptions(field)"><br></div>
<div class="row" ng-if="showRatingOptions(field)">
<div class="row" ng-show="showRatingOptions()"><br></div>
<div class="row" ng-if="showRatingOptions()">
<div class="col-md-9 col-sm-9">{{ 'NUM_OF_STEPS' | translate }}</div>
<div class="col-md-3 col-sm-3">
<input style="width:100%" type="number"
@ -483,7 +479,7 @@
</div>
<div class="preview-field-panel col-md-6 hidden-sm hidden-xs">
<form class="public-form"ss>
<form class="public-form">
<field-directive field="field" validate="false" class="preview-field">
</field-directive>
</form>
@ -545,7 +541,7 @@
<div class="col-xs-12 field-row" ng-repeat="field in myform.form_fields track by $id($index)" ng-if="!field.deletePreserved">
<div class="col-xs-10">
<div class="panel panel-default" ng-click="openEditModal(field)">
<div class="panel panel-default" ng-click="openEditModal(field, true, $index)">
<div class="panel-heading">
<div class="row">
<span class="col-xs-1" ng-switch="field.fieldType">

View File

@ -25,7 +25,7 @@
</div>
</script>
<section data-ng-controller="ListFormsController as ctrl" data-ng-init="findAll()" class="container">
<section class="container">
<br>
<div class="row">
<div ng-click="openCreateModal()" class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item create-new">
@ -71,7 +71,8 @@
<div data-ng-repeat="form in myforms"
class="col-xs-6 col-xs-offset-3 col-sm-4 col-sm-offset-1 col-md-3 col-md-offset-1 form-item container"
ng-class="{'paused': !form.isLive}">
ng-class="{'paused': !form.isLive}"
ng-clkc="goToWithId('viewForm.create', form._id)">
<div class="row">
<span class="pull-right">

View File

@ -8,7 +8,21 @@ angular.module('forms').config(['$stateProvider',
$stateProvider.
state('listForms', {
url: '/forms',
templateUrl: 'modules/forms/admin/views/list-forms.client.view.html'
templateUrl: 'modules/forms/admin/views/list-forms.client.view.html',
resolve: {
Forms: 'GetForms',
myForms: function (GetForms, $q) {
var deferred = $q.defer();
GetForms.query(function(forms){
deferred.resolve(forms);
});
return deferred.promise;
}
},
controller: 'ListFormsController',
controllerAs: 'ctrl'
}).state('submitForm', {
url: '/forms/:formId',
templateUrl: '/static/form_modules/forms/base/views/submit-form.client.view.html',

View File

@ -3,11 +3,12 @@
* Module dependencies.
*/
//Load ENV vars from .env
if ((process.env.NODE_ENV || 'development') === 'development') {
require('dotenv').config();
if(!process.env.NODE_ENV){
process.env.NODE_ENV = 'development';
}
require('dotenv').config()
require('events').EventEmitter.prototype._maxListeners = 0;
var config = require('./config/config'),

4
start.sh Executable file
View File

@ -0,0 +1,4 @@
#!/bin/bash
node server.js
#pm2 start process.yml

View File

@ -0,0 +1,57 @@
Introduction
===========
TellForm is a powerful, open-source form/survey tool that allows you to get data from your users quickly and easily while collecting powerful analytics to improve your surveys. TellForm offers a field by field analytics, custom subdomains per-user, an extendable API, logic-based field jumping, per-device visitor analytics and 11 types of form fields.
By default, TellForm is setup to serve custom subdomains, but you can also configure it to work on a single domain, for those using it in more restricted environments.
Exporters—both the official ones that the Prometheus team maintains as well as the community-contributed ones—provide information about everything from infrastructure, databases, and web servers to messaging systems, APIs, and more.
In this tutorial, you'll install, configure, and secure TellForm to selfhost forms that will make it easy for you and your users to use.
Prerequisites
Before following this tutorial make sure you have:
One Ubuntu 16.x or 14.x Droplet, set up by following the [Initial Server Setup with Ubuntu 16.04 tutorial](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04), including a sudo non-root user and a firewall.
Nginx installed by following the first two steps of the [How To Install Nginx on Ubuntu 16.04 tutorial](https://www.digitalocean.com/community/tutorials/how-to-install-nginx-on-ubuntu-16-04).
Docker installed by following the steps of the [How To Install and Use Docker on Ubuntu 16.04 tutorial](https://www.digitalocean.com/community/tutorials/how-to-install-and-use-docker-on-ubuntu-16-04)
## Step 1 - Fetch Docker-Compose Files
```
$ curl -L github.com/tellform/tellform/stable/blob/docker-compose.yml
$ curl -L github.com/tellform/tellform/stable/blob/.env
```
### Prepare .env file:
Create `.env` file at project root folder. Fill in `MAILER_SERVICE_PROVIDER`, `MAILER_EMAIL_ID`, `MAILER_PASSWORD` and `MAILER_FROM`.
```
APP_NAME=TellForm
BASE_URL=localhost:3000
PORT=3000
DB_PORT_27017_TCP_ADDR=tellform-mongo
REDIS_DB_PORT_6379_TCP_ADDR=tellform-redis
MAILER_SERVICE_PROVIDER=<TO-FILL-IN>
MAILER_EMAIL_ID=<TO-FILL-IN>
MAILER_PASSWORD=<TO-FILL-IN>
MAILER_FROM=<TO-FILL-IN>
SIGNUP_DISABLED=false
SUBDOMAINS_DISABLED=true
DISABLE_CLUSTER_MODE=true
```
### Build docker image
```
$ docker-compose build
```
### Run docker containers with docker-compose
Create and start mongo & redis docker container:
```
$ docker-compose up -d
```
Your application should run at the BASE_URL you specified on port 443.