diff --git a/models/information.js b/models/information.js index 25fc8b5..3f2c2e5 100644 --- a/models/information.js +++ b/models/information.js @@ -1,10 +1,11 @@ var mongoose = require('mongoose'); var infoSchema = new mongoose.Schema({ - number: Number, - date: Number, - time: Number, - message: String + number: String, + date: Date, + time: String, + message: String, + updated: {type: Date, default: Date.now} }); diff --git a/npm-debug.log b/npm-debug.log index 40531b7..4c4663b 100644 --- a/npm-debug.log +++ b/npm-debug.log @@ -7,7 +7,7 @@ 6 info start myapp@0.0.0 7 verbose unsafe-perm in lifecycle true 8 info myapp@0.0.0 Failed to exec start script -9 verbose stack Error: myapp@0.0.0 start: `node ./bin/www` +9 verbose stack Error: myapp@0.0.0 start: `node ./bin/www && node ./mongoui/mongoui-master/index.js` 9 verbose stack Exit status 1 9 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16) 9 verbose stack at EventEmitter.emit (events.js:110:17) @@ -22,13 +22,13 @@ 14 error node v0.12.4 15 error npm v2.10.1 16 error code ELIFECYCLE -17 error myapp@0.0.0 start: `node ./bin/www` +17 error myapp@0.0.0 start: `node ./bin/www && node ./mongoui/mongoui-master/index.js` 17 error Exit status 1 -18 error Failed at the myapp@0.0.0 start script 'node ./bin/www'. +18 error Failed at the myapp@0.0.0 start script 'node ./bin/www && node ./mongoui/mongoui-master/index.js'. 18 error This is most likely a problem with the myapp package, 18 error not with npm itself. 18 error Tell the author that this fails on your system: -18 error node ./bin/www +18 error node ./bin/www && node ./mongoui/mongoui-master/index.js 18 error You can get their info via: 18 error npm owner ls myapp 18 error There is likely additional logging output above. diff --git a/package.json b/package.json index 5042b4b..e9fb13c 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.0", "private": true, "scripts": { - "start": "node ./bin/www" + "start": "node ./bin/www && node ./mongoui/mongoui-master/index.js" }, "dependencies": { "body-parser": "~1.12.4", @@ -14,4 +14,4 @@ "morgan": "~1.5.3", "serve-favicon": "~2.2.1" } -} \ No newline at end of file +} diff --git a/routes/index.js b/routes/index.js index 70e56fb..9c67218 100644 --- a/routes/index.js +++ b/routes/index.js @@ -7,20 +7,21 @@ var info = mongoose.model('info'); /* GET home page. */ router.get('/', function(req, res, next) { var getString = req.param("test"); - res.render('index'); + var find = {number : "555-555-5555"}; + res.render('index', {findParams : find}); }); -router.post('/', function(req, res,next) { +router.post('/information', function(req, res,next) { var number = req.param("number"); var date = req.param("date"); var time = req.param("time"); var message = req.param("message"); var entry = new info({ - number: 234, - date: 234, - time: 234, - message: "test" + number: number, + date: date, + time: time, + message: message }); entry.save(function(err, entry) { @@ -32,4 +33,15 @@ router.post('/', function(req, res,next) { res.render('index'); }); +router.post('/search', function(req, res, next) { + var searchNumber = req.param("searchNumber"); + + info.findOne({'number' : searchNumber}, "number date time message updated", function(err, seach) { + if (err) return handleError(err); + }); + + res.render('index', {findParams : search}); + +}); + module.exports = router; diff --git a/views/index.jade b/views/index.jade index 4685c89..63bf03e 100644 --- a/views/index.jade +++ b/views/index.jade @@ -9,7 +9,7 @@ block content div.row div.col-lg-4 h1 Submit Form - form(action="/", method="post") + form(action="/information", method="post") div.form-group Span Phone Number: br @@ -17,13 +17,27 @@ block content br Span Date: br - input.form-control(type="text", name="date", placeholder="mm/dd/yy") + input.form-control(type="text", name="date", id="datepicker" placeholder="mm/dd/yy") br Span Time: br - input.form-control(type="text", name="time", placeholder="12:00 am") + input.form-control(type="text", name="time", id="timepicker" placeholder="12:00 am") br Span Message: input.form-control(type="textarea", name="message") br - input(type="submit", value="submit").btn \ No newline at end of file + input(type="submit", value="submit").btn + div.col-lg-4 + h1 Search by number + form(action="/search", method="post") + div.form-group + Span Phone Number: + br + input.form-control(type="text", name="searchNumber", placeholder="555-555-5555") + br + input(type="submit", value="submit").btn + br + ul + each val, index in findParams + li= index + " " + val + br \ No newline at end of file diff --git a/views/layout.jade b/views/layout.jade index 52fbd9b..c49b671 100644 --- a/views/layout.jade +++ b/views/layout.jade @@ -4,7 +4,12 @@ html title= "Mithell's Node.js Project" link(rel='stylesheet', href='bootstrap/css/bootstrap.css') link(rel='stylesheet', href='/stylesheets/style.css') + link(rel='stylesheet', href='jquery-ui-1.11.4/jquery-ui.css') + link(rel='stylesheet', href='jquery-timepicker/jquery.timepicker.css') body block content script(src="http://code.jquery.com/jquery-latest.min.js") - script(src="bootstrap/js/bootstrap.js") \ No newline at end of file + script(src="bootstrap/js/bootstrap.js") + script(src="jquery-ui-1.11.4/jquery-ui.js") + script(src="jquery-timepicker/jquery.timepicker.js") + script(src="javascripts/custom.js") \ No newline at end of file