-
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
0 parents
commit 91f206e
Showing
18 changed files
with
372 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules/ | ||
bower_components/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,23 @@ | ||
# Code Kata Todo App for Yalamanda, Shireesh, Venkatesh | ||
|
||
This Node app built with MongoDB and Angular. For learning purpose. | ||
|
||
Node provides the RESTful API. Angular provides the frontend and accesses the API. MongoDB stores like a hoarder. | ||
|
||
## Requirements | ||
|
||
- [Node and npm](http://nodejs.org) | ||
|
||
## Installation | ||
|
||
1. Clone the repository: `git clone [email protected]:scotch-io/node-todo` | ||
2. Install the application: `npm install` | ||
3. Start the server: `node server.js` | ||
4. View in browser at `http://localhost:8080` | ||
|
||
Note: Use your own repository by placing the below code into package.json above dependencies: | ||
"repository" :{ | ||
"type" : "git", | ||
"url" : "[email protected]:example.git" | ||
} | ||
|
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 @@ | ||
var app = angular.module('CodeKata',[]); |
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,15 @@ | ||
<!DOCTYPE html> | ||
<html ng-app="CodeKata"> | ||
<head> | ||
<title>Hello World, AngularJs</title> | ||
</head> | ||
<body> | ||
|
||
Write some text in textbox: | ||
<input type="text" ng-model="sometext" /> | ||
|
||
<h1 ng-show="sometext">Hello {{ sometext }}</h1> | ||
<script src="/bower_components/angular/angular.js"></script> | ||
<script src="/app/routes.js"></script> | ||
</body> | ||
</html> |
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,8 @@ | ||
{ | ||
"name": "Codekata", | ||
"version": "0.0.1", | ||
"dependencies": { | ||
"angular" : "~1.3.0" | ||
}, | ||
"analytics": false | ||
} |
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 @@ | ||
module.exports = { | ||
remoteUrl : 'mongodb://node:[email protected]:27017/uwO3mypu', | ||
localUrl: 'mongodb://localhost/meanstacktutorials' | ||
}; |
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,66 @@ | ||
0 info it worked if it ends with ok | ||
1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe', | ||
1 verbose cli 'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', | ||
1 verbose cli 'install' ] | ||
2 info using [email protected] | ||
3 info using [email protected] | ||
4 verbose node symlink C:\Program Files (x86)\nodejs\\node.exe | ||
5 warn package.json [email protected] No repository field. | ||
6 verbose readDependencies using package.json deps | ||
7 verbose install where, deps [ 'D:\\Code_WarRoom', | ||
7 verbose install [ 'mongoose', | ||
7 verbose install 'morgan', | ||
7 verbose install 'body-parser', | ||
7 verbose install 'method-override', | ||
7 verbose install 'karma', | ||
7 verbose install 'karma-jasmine', | ||
7 verbose install 'karma-phantomjs-launcher', | ||
7 verbose install 'bower' ] ] | ||
8 info preinstall [email protected] | ||
9 warn package.json [email protected] No README data | ||
10 verbose readDependencies using package.json deps | ||
11 verbose already installed skipping mongoose@~3.8.13 D:\Code_WarRoom | ||
12 verbose already installed skipping morgan@~1.1.1 D:\Code_WarRoom | ||
13 verbose already installed skipping body-parser@~1.4.3 D:\Code_WarRoom | ||
14 verbose already installed skipping method-override@~2.1.1 D:\Code_WarRoom | ||
15 verbose already installed skipping [email protected] D:\Code_WarRoom | ||
16 verbose already installed skipping [email protected] D:\Code_WarRoom | ||
17 verbose already installed skipping [email protected] D:\Code_WarRoom | ||
18 verbose already installed skipping [email protected] D:\Code_WarRoom | ||
19 silly resolved [] | ||
20 info build D:\Code_WarRoom | ||
21 verbose linkStuff [ false, false, false, 'D:\\' ] | ||
22 info linkStuff [email protected] | ||
23 verbose linkBins [email protected] | ||
24 verbose linkMans [email protected] | ||
25 verbose rebuildBundles [email protected] | ||
26 verbose rebuildBundles [ '.bin', | ||
26 verbose rebuildBundles 'body-parser', | ||
26 verbose rebuildBundles 'bower', | ||
26 verbose rebuildBundles 'karma', | ||
26 verbose rebuildBundles 'karma-jasmine', | ||
26 verbose rebuildBundles 'karma-phantomjs-launcher', | ||
26 verbose rebuildBundles 'method-override', | ||
26 verbose rebuildBundles 'mongoose', | ||
26 verbose rebuildBundles 'morgan' ] | ||
27 info install [email protected] | ||
28 info postinstall [email protected] | ||
29 verbose unsafe-perm in lifecycle true | ||
30 info [email protected] Failed to exec postinstall script | ||
31 error [email protected] postinstall: `node node_modules/bower/bin/bower install` | ||
31 error Exit status 1 | ||
32 error Failed at the [email protected] postinstall script. | ||
32 error This is most likely a problem with the Codekata package, | ||
32 error not with npm itself. | ||
32 error Tell the author that this fails on your system: | ||
32 error node node_modules/bower/bin/bower install | ||
32 error You can get their info via: | ||
32 error npm owner ls Codekata | ||
32 error There is likely additional logging output above. | ||
33 error System Windows_NT 6.1.7601 | ||
34 error command "C:\\Program Files (x86)\\nodejs\\\\node.exe" "C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" | ||
35 error cwd D:\Code_WarRoom | ||
36 error node -v v0.10.36 | ||
37 error npm -v 1.4.28 | ||
38 error code ELIFECYCLE | ||
39 verbose exit [ 1, true ] |
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 @@ | ||
{ | ||
"name" : "Codekata", | ||
"version" : "0.0.1", | ||
"description" : "Learning application.", | ||
"readme" : "README.md", | ||
"main" : "server.js", | ||
"author" : "Venki", | ||
"dependencies" : { | ||
"express" : "~4.13.4", | ||
"mongoose" : "~3.8.13", | ||
"morgan" : "~1.1.1", | ||
"body-parser" : "~1.4.3", | ||
"method-override" : "~2.1.1", | ||
"karma" : "0.12.16", | ||
"karma-jasmine" : "0.1.5", | ||
"karma-phantomjs-launcher": "0.1.4", | ||
"bower": "1.3.8" | ||
}, | ||
"scripts": { | ||
"postinstall": "node node_modules/bower/bin/bower install" | ||
} | ||
} |
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 @@ | ||
//Need to add lines to run the angular app using Node |
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,83 @@ | ||
<!doctype html> | ||
|
||
<!-- ASSIGN OUR ANGULAR MODULE --> | ||
<html ng-app="scotchTodo"> | ||
<head> | ||
<!-- META --> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1"><!-- Optimize mobile viewport --> | ||
|
||
<title>Node/Angular Todo App</title> | ||
|
||
<!-- SCROLLS --> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"><!-- load bootstrap --> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"> | ||
<style> | ||
html { overflow-y:scroll; } | ||
body { padding-top:50px; } | ||
#todo-list { margin-bottom:30px; } | ||
#todo-form { margin-bottom:50px; } | ||
</style> | ||
|
||
<!-- SPELLS --> | ||
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script><!-- load angular --> | ||
|
||
<script src="js/controllers/main.js"></script> <!-- load up our controller --> | ||
<script src="js/services/todos.js"></script> <!-- load our todo service --> | ||
<script src="js/core.js"></script> <!-- load our main application --> | ||
|
||
</head> | ||
<!-- SET THE CONTROLLER --> | ||
<body ng-controller="mainController"> | ||
<div class="container"> | ||
|
||
<!-- HEADER AND TODO COUNT --> | ||
<div class="jumbotron text-center"> | ||
<h1>I'm a Todo-aholic <span class="label label-info">{{ todos.length }}</span></h1> | ||
</div> | ||
|
||
<!-- TODO LIST --> | ||
<div id="todo-list" class="row"> | ||
<div class="col-sm-4 col-sm-offset-4"> | ||
|
||
|
||
|
||
<!-- LOOP OVER THE TODOS IN $scope.todos --> | ||
<div class="checkbox" ng-repeat="todo in todos"> | ||
<label> | ||
<input type="checkbox" ng-click="deleteTodo(todo._id)"> {{ todo.text }} | ||
</label> | ||
</div> | ||
|
||
<p class="text-center" ng-show="loading"> | ||
<span class="fa fa-spinner fa-spin fa-3x"></span> | ||
</p> | ||
|
||
</div> | ||
</div> | ||
|
||
<!-- FORM TO CREATE TODOS --> | ||
<div id="todo-form" class="row"> | ||
<div class="col-sm-8 col-sm-offset-2 text-center"> | ||
<form> | ||
<div class="form-group"> | ||
|
||
<!-- BIND THIS VALUE TO formData.text IN ANGULAR --> | ||
<input type="text" class="form-control input-lg text-center" placeholder="I want to buy a puppy that will love me forever" ng-model="formData.text"> | ||
</div> | ||
|
||
<!-- createToDo() WILL CREATE NEW TODOS --> | ||
<button type="submit" class="btn btn-primary btn-lg" ng-click="createTodo()">Add</button> | ||
</form> | ||
</div> | ||
</div> | ||
|
||
<div class="text-center text-muted"> | ||
<p>A demo by <a href="http://scotch.io">Scotch</a>.</p> | ||
<p>Read the <a href="http://scotch.io/tutorials/javascript/creating-a-single-page-todo-app-with-node-and-angular">tutorial</a>.</p> | ||
</div> | ||
|
||
</div> | ||
|
||
</body> | ||
</html> |
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,50 @@ | ||
angular.module('todoController', []) | ||
|
||
// inject the Todo service factory into our controller | ||
.controller('mainController', ['$scope','$http','Todos', function($scope, $http, Todos) { | ||
$scope.formData = {}; | ||
$scope.loading = true; | ||
|
||
// GET ===================================================================== | ||
// when landing on the page, get all todos and show them | ||
// use the service to get all the todos | ||
Todos.get() | ||
.success(function(data) { | ||
$scope.todos = data; | ||
$scope.loading = false; | ||
}); | ||
|
||
// CREATE ================================================================== | ||
// when submitting the add form, send the text to the node API | ||
$scope.createTodo = function() { | ||
|
||
// validate the formData to make sure that something is there | ||
// if form is empty, nothing will happen | ||
if ($scope.formData.text != undefined) { | ||
$scope.loading = true; | ||
|
||
// call the create function from our service (returns a promise object) | ||
Todos.create($scope.formData) | ||
|
||
// if successful creation, call our get function to get all the new todos | ||
.success(function(data) { | ||
$scope.loading = false; | ||
$scope.formData = {}; // clear the form so our user is ready to enter another | ||
$scope.todos = data; // assign our new list of todos | ||
}); | ||
} | ||
}; | ||
|
||
// DELETE ================================================================== | ||
// delete a todo after checking it | ||
$scope.deleteTodo = function(id) { | ||
$scope.loading = true; | ||
|
||
Todos.delete(id) | ||
// if successful creation, call our get function to get all the new todos | ||
.success(function(data) { | ||
$scope.loading = false; | ||
$scope.todos = data; // assign our new list of todos | ||
}); | ||
}; | ||
}]); |
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 @@ | ||
angular.module('scotchTodo', ['todoController', 'todoService']); |
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 @@ | ||
angular.module('todoService', []) | ||
|
||
// super simple service | ||
// each function returns a promise object | ||
.factory('Todos', ['$http',function($http) { | ||
return { | ||
get : function() { | ||
return $http.get('/api/todos'); | ||
}, | ||
create : function(todoData) { | ||
return $http.post('/api/todos', todoData); | ||
}, | ||
delete : function(id) { | ||
return $http.delete('/api/todos/' + id); | ||
} | ||
} | ||
}]); |