Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 34 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,36 @@
node_modules
.DS_Store

# Logs
logs
*.log
.env
/build/*
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
/build
/seeds/*
.DS_Store

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
tmp
.env

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between .env and /.env?

3 changes: 2 additions & 1 deletion db/widget_specifications/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ const clock = require('./clock_specification')
const image = require('./image_specification')
const qrCode = require('./qr_code_specification')
const text = require('./text_specification')
const number = require( './number_specification' )

module.exports = { clock, image, qrCode, text }
module.exports = { clock, image, qrCode, text, number }
54 changes: 54 additions & 0 deletions db/widget_specifications/number_specification.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
const number = {
"category": "Dashboard Tools",
"group": "Number",
"type": "Number",
"title": "Number",
"description": "Display a statistic, goal, completion percentage and progress bar from a csv file.",
"image": "http://placehold.it/140x100?text=Number",
"sections": [{
"type": "Setup",
"fields": [
{
"name": "Title",
"type": "text",
"defaultValue": "Number"
},
{
"name": "Size",
"type": "dropdown",
"defaultValue": "1x1",
"options": [
{ "label": "1x1", "value": "1x1" },
{ "label": "2x2", "value": "2x2" },
{ "label": "3x3", "value": "3x3" }
]
},
{
"name": "CSV URL",
"type": "text",
"help": "Enter the CSV url to set the values of this field.",
"defaultValue": ""
},
{
"name": "Column",
"type": "text",
"help": "This value provides the column for your statistic.",
"defaultValue": ""
},
{
"name": "Row",
"type": "text",
"help": "This value provides the row for your statistic.",
"defaultValue": ""
},
{
"name": "Goal (optional)",
"type": "text",
"help": "Entering a goal will override any other secondary stat.",
"defaultValue": ""
}
]
}]
}

module.exports = number
42 changes: 34 additions & 8 deletions models/dashboards.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,41 @@ const { Schema } = mongoose
const User = require('./users')

const DashboardSchema = new Schema ({
name: { type: String, required: true, default: 'Company Dashboard' },
location: { type: String, required: true, default: 'Oakland' },
width: { type: Number, required: true, default: 2 },
theme: { type: String, required: true, default: 'Dark' },
responsive: { type: Boolean, required: true, default: true },
created_at: { type: Date, required: true, default: Date.now },
users: [{ type: Schema.Types.ObjectId, ref:'User' }],
name: {
type: String,
required: true,
default: 'Company Dashboard'
},
location: {
type: String,
required: true,
default: 'Oakland'
},
width: {
type: Number,
required: true, default: 2
},
theme: {
type: String,
required: true,
default: 'Dark'
},
responsive: {
type: Boolean,
required: true,
default: true
},
created_at: {
type: Date,
required: true,
default: Date.now
},
users: [{
type: Schema.Types.ObjectId,
ref:'User'
}],
})

const Dashboard = mongoose.model('Dashboard', DashboardSchema)
const Dashboard = mongoose.model('Dashboard', DashboardSchema)

module.exports = Dashboard
15 changes: 15 additions & 0 deletions models/number_specifications.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const mongoose = require( 'mongoose' )
const { Schema } = mongoose

const NumberSpecificationSchema = new Schema({
title: String,
size: String,
csvUrl: String,
column: String,
row: String,
goal: String
})

const NumberSpecification = mongoose.model( 'NumberSpecification', NumberSpecificationSchema )

module.exports = NumberSpecification
23 changes: 17 additions & 6 deletions models/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,24 @@ const Schema = mongoose.Schema
const bcrypt = require( 'bcrypt-nodejs' )

const UserSchema = new Schema({
email: { type: String, required: true, unique: true },
password: { type: String, required: true },
token: { type: String },
token_expires: { type: Date },
email: {
type: String,
required: true,
unique: true
},
password: {
type: String,
required: true
},
token: {
type: String
},
token_expires: {
type: Date
},
created_at: Date,
updated_at: Date
})
}) 

UserSchema.pre( 'save', function( next ) {
const user = this
Expand All @@ -24,7 +35,7 @@ UserSchema.pre( 'save', function( next ) {
return next( err )
}

bcrypt.hash( user.password, salt, null, ( err, hash ) => {
bcrypt.hash( user.password, salt, null, ( err, hash ) => {
if( err ){
return next( err )
}
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
"node": "7.0.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test:watch": "mocha -w --recursive",
"test": "mocha --recursive",
"test:coverage": "istanbul cover _mocha -- --recursive ./test",
"seed": "node db/seed_collections.js",
"start": "nf start",
"start:dev": "nf start --procfile Procfile.dev"
Expand All @@ -26,7 +28,6 @@
"bcrypt-nodejs": "0.0.3",
"body-parser": "~1.15.1",
"cookie-parser": "~1.4.3",
"crypto": "0.0.3",
"debug": "~2.2.0",
"ejs": "^2.5.2",
"es6-promise": "^4.0.5",
Expand All @@ -49,8 +50,12 @@
"babel-core": "^6.13.2",
"babel-preset-es2015": "^6.13.2",
"babel-preset-react": "^6.11.1",
"chai": "^3.5.0",
"istanbul": "^0.4.5",
"mocha": "^3.1.2",
"nodemon": "^1.11.0",
"serve-favicon": "~2.3.0"
"serve-favicon": "~2.3.0",
"sinon": "^1.17.6",
"supertest": "^2.0.1"
}
}
4 changes: 2 additions & 2 deletions routes/api/v1/utilities/widget_specification_utilities.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const insertWidgetSpecification = data => {
return new Promise( (resolve, reject) => {
WidgetSpecification.collection.insert( data, (error, item) => {
return new Promise( ( resolve, reject ) => {
WidgetSpecification.collection.insert( data, ( error, item ) => {
if( error === null ) {
resolve( item )
} else {
Expand Down
16 changes: 16 additions & 0 deletions test/models/users.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const expect = require( 'chai' ).expect

const User = require( '../../models/users' );

describe( 'The users model ', () => {
it( 'should return an error if email is empty',
() => {

let user = new User()

user.validate( () => {
expect( err.errors.email ).to.exist
done()
})
})
})
16 changes: 16 additions & 0 deletions test/routes/api/v1/dashboards.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const chai = require( 'chai' )
const request = require( 'supertest' )
const app = require( 'express' ).Router
const expect = chai.expect

describe( 'Dashboard Server Request', () => {
it( 'GET homepage', () => {
request( app )
.get( '/api/dashboards' )
.expect( 200, "ok" )
.expect( 'Content-Type', /json/ )
.end( ( error, response ) => {
if( error ) throw error
})
})
})
Loading