-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
237 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,8 @@ | |
"esversion": 6, | ||
"strict": true, | ||
"esnext": false, | ||
"node": true | ||
"node": true, | ||
"predef": [ | ||
"app" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
"tests" | ||
], | ||
"dependencies": { | ||
"angular": "^1.5.0" | ||
"angular": "^1.5.0", | ||
"angular-ui-router": "^0.2.18" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
"use strict"; | ||
|
||
const NoteModel = require('../models/notes_model'); | ||
|
||
|
||
module.exports.newNote = (req, res) => { | ||
NoteModel.newNote(req, res); | ||
}; | ||
|
||
module.exports.postNote = (req, res) => { | ||
NoteModel.postNote(req, res); | ||
}; | ||
|
||
module.exports.showNote = (req, res) => { | ||
NoteModel.showNote(req, res); | ||
}; | ||
|
||
module.exports.destroy = (req, res) => { | ||
NoteModel.destroyNote(req, res); | ||
}; | ||
|
||
module.exports.edit = (req, res) => { | ||
NoteModel.edit(req, res); | ||
}; | ||
|
||
module.exports.update = (req, res) => { | ||
NoteModel.update(req, res); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
'use strict'; | ||
|
||
var gulp = require('gulp'); | ||
var electron = require('electron-connect').server.create(); | ||
|
||
gulp.task('serve', function () { | ||
|
||
// Start browser process | ||
electron.start(); | ||
|
||
// Restart browser process | ||
gulp.watch('server.js', 'controllers/*.js', 'models/*.js', electron.restart); | ||
|
||
// Reload renderer process | ||
gulp.watch(['./public/**/*.js', './public/app.js', './public/**/*.html'], electron.reload); | ||
}); | ||
|
||
gulp.task('default', ['serve']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"use strict"; | ||
|
||
// set up sqlite schema | ||
const sqlite3 = require('sqlite3'); | ||
const db = new sqlite3.Database('./db/dashbored.sqlite'); | ||
|
||
// module.exports.model = Note; | ||
|
||
module.exports.index = () => { | ||
db.all(`SELECT Notes.title, Notes.content | ||
FROM Notes JOIN UserData | ||
ON Notes.userid = UserData.userid | ||
WHERE Notes.userid = UserData.userid;`); | ||
}; | ||
|
||
// module.exports.newNote = (req, res) => { | ||
// | ||
// }; | ||
|
||
module.exports.postNote = (req) => { | ||
// console.log("the req is", req); | ||
console.log(req.body); | ||
// add the new note to the database | ||
let title = req.body.title; | ||
let note = req.body.content; | ||
db.run(`INSERT INTO Notes VALUES (NULL, "${title}", "${note}", 1)`, (err) => { | ||
if (err) throw err; | ||
}); | ||
}; | ||
|
||
// module.exports.showNote = (req, res) => { | ||
// // show a specific note | ||
// }; | ||
// | ||
// module.exports.destroyNote = (req, res) => { | ||
// // remove specific note | ||
// }; | ||
// | ||
// module.exports.edit = (req, res) => { | ||
// // edit specific note | ||
// }; | ||
// | ||
// module.exports.update = (req, res) => { | ||
// // update specific note | ||
// }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
"use strict"; | ||
/* eslint-disable */ | ||
const app = angular.module("dashbored", ["ui.router"]); | ||
|
||
app.config(function($stateProvider, $urlRouterProvider) { | ||
|
||
$stateProvider | ||
.state('index', { | ||
url: "/", | ||
templateUrl: "fe_partials/index.html" | ||
}); | ||
$urlRouterProvider.otherwise("/"); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"use strict"; | ||
|
||
app.controller('NotesCtrl', ['$scope', '$http', ($scope, $http) => { | ||
|
||
|
||
|
||
$scope.getStock = (symbol) => { | ||
// $scope.quoteExists = false; // resets ng-shows to hide | ||
// $scope.noQuote = false; | ||
$http.get(`/quotes/${symbol}`) | ||
.then(function(data) { | ||
!data.data.Name || data.status !== 200 // if stock doesn't exist or error occurs | ||
? ($scope.noQuote = true, $scope.noQuoteMessage = data.data.Message || "An error occured. Try again.") | ||
: ($scope.quoteExists = true, $scope.quoteData = data) ; | ||
$scope.symbol = ""; // resets input field to blank | ||
}); | ||
}; | ||
|
||
$scope.buyStock = () => { | ||
// console.log('trying to buy'); | ||
// const totalValue = ($scope.quoteData.data.LastPrice * quantity).toFixed(2); | ||
// $http.post(`/quotes/${quantity}/${$scope.quoteData.data.Symbol}/${$scope.quoteData.data.Name}/${$scope.quoteData.data.LastPrice}/${totalValue}`) | ||
// .then(function(res) { | ||
// console.log(res); | ||
// $state.go('portfolio'); | ||
// }); | ||
}; | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<div> | ||
<h1>Dashbored</h1> | ||
|
||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div ng-controller="NotesCtrl"> | ||
<form method='POST', action='/notes'> | ||
<div class="input-group"> | ||
<label for='title'> Title </label> | ||
<input id="title" type='text', name='title'> | ||
<br> | ||
</div> | ||
<div class="input-group"> | ||
<label for='content'> Note </label> | ||
<input id="note" type='text' name='content'> | ||
<br> | ||
</div> | ||
<div class="input-group"> | ||
<input class="btn" type='submit' value='Save'> | ||
</div> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
"use strict"; | ||
|
||
const express = require('express'); | ||
const router = express.Router(); | ||
|
||
const ctrl = require('../controllers/notes_control'); | ||
|
||
|
||
router.get('/', (req, res) => { | ||
res.render('template'); | ||
}); | ||
// router.get('/notes', (req, res) => { | ||
// | ||
// }); | ||
router.get('/notes/new', ctrl.newNote); | ||
router.post('/notes', ctrl.postNote); | ||
router.get('/notes/:id', ctrl.showNote); | ||
router.delete('/notes/:id', ctrl.destroy); | ||
router.get('/notes/:id/edit', ctrl.edit); | ||
router.put('/notes/:id', ctrl.update); | ||
|
||
module.exports = router; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters