-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
To-Do challenge #157
base: master
Are you sure you want to change the base?
To-Do challenge #157
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bower_components | ||
node_modules |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,7 @@ | ||
# Todo Challenge | ||
LIVE: http://todolistapp-58561.onmodulus.net/ | ||
|
||
* Deadline: submit completed pull request by 9am on Monday | ||
* You may use whatever level of JavaScript you feel comfortable with - pure JS, jQuery, Angular, or whatever weird and wonderful framework you want to try. Extra points for DogeScript | ||
This is a restarted repository because some files got corrupted and atom went crazy. | ||
|
||
Steps | ||
------- | ||
I have used a MEAN stack for this weekend challenge. I used Node.js and Express for my server along with a remotely hosted MongoDB at modulus.io. The todolist runs on angular and is styled using bootstrap. I designed it to be dynamic so as to be viewable on all size screens. | ||
|
||
1. Fill out your learning plan self review for the week: https://github.com/makersacademy/learning_plan | ||
2. Fork this repo, and clone to your local machine | ||
3. Complete the following challenge: | ||
|
||
## Challenge | ||
|
||
 | ||
|
||
Build a Todo list as a mini front-end application. You don't have to use a database, the front-end is more important - you can use an appropriate data structure stored somewhere in your JavaScript (this time only!) | ||
|
||
Here are the core user stories: | ||
|
||
``` | ||
As a forgetful person | ||
I want to store my tasks | ||
So that I don't forget them | ||
|
||
As a person with limited time | ||
I want to instantly be able to update my todo list (adding and changing entries) | ||
So that I have more time to think about other things | ||
|
||
As a person who actually gets stuff done | ||
I want to mark my tasks as done | ||
So that I don't do them twice | ||
``` | ||
|
||
Here are some other user stories you may choose to implement: | ||
|
||
``` | ||
As a person with a lot of tasks | ||
I want to be able to filter my tasks by "All", "Active", "Complete" | ||
So that I only see the relevant tasks | ||
|
||
As a person who doesn't like counting by hand | ||
I want to see a total number of tasks | ||
So that I don't have to count | ||
|
||
As someone who has done lots of stuff | ||
I want to be able to clear my completed tasks | ||
So I never see them again | ||
``` | ||
|
||
As you may imagine, implementing a To-do list is very much a solved problem. However, we are mainly interested in seeing how you approach testing and design. We are looking for: | ||
|
||
* well written, well structured acceptance and unit tests | ||
* clear and expressive JavaScript | ||
* good HTML5 markup | ||
|
||
Don't worry about deployment, and make sure you read the CONTRIBUTING.md when submitting a pull request. | ||
|
||
## Extensions | ||
|
||
* Deploy the app | ||
* Create a persistance layer (e.g. MongoDB), or use LocalStorage or the filesystem through Node | ||
* Make it look purdy (CSS) - try a framework like Bootstrap or Foundation | ||
|
||
## CI | ||
|
||
Read the `.travis.yml` if any of the steps below don't make sense! | ||
|
||
* Make sure you have set up `npm test` in your `package.json` so that it runs your Karma tests | ||
* Make sure you have your Protractor config file at `e2e/conf.js` | ||
* Make sure `npm start` spins up whatever serves up your app - `http-server`, Sinatra or Node | ||
|
||
Good luck! | ||
MORE TESTING COMING SOON. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var mongoose = require('mongoose'); | ||
|
||
module.exports = mongoose.model('Todo', { | ||
text : {type : String, default: ''} | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
var Todo = require('./models/todo'); | ||
|
||
function getTodos(res){ | ||
Todo.find(function(err, todos) { | ||
if (err) { | ||
res.send(err) | ||
} | ||
res.json(todos); | ||
}); | ||
} | ||
|
||
module.exports = function(app) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'module' is not defined. |
||
app.get('/api/todos', function(req, res) { | ||
getTodos(res); | ||
}); | ||
|
||
app.post('/api/todos', function(req, res) { | ||
Todo.create({ | ||
text : req.body.text, | ||
done : false | ||
}, function(err, todo) { | ||
if (err) { | ||
res.send(err); | ||
} | ||
getTodos(res); | ||
}); | ||
|
||
}); | ||
|
||
app.delete('/api/todos/:todo_id', function(req, res) { | ||
Todo.remove({ | ||
_id : req.params.todo_id | ||
}, function(err, todo) { | ||
if (err) { | ||
res.send(err); | ||
} | ||
getTodos(res); | ||
}); | ||
}); | ||
|
||
|
||
app.get('*', function(req, res) { | ||
res.sendfile('./public/index.html'); | ||
}); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"name": "todo", | ||
"description": "* Deadline: submit completed pull request by 9am on Monday * You may use whatever level of JavaScript you feel comfortable with - pure JS, jQuery, Angular, or whatever weird and wonderful framework you want to try. Extra points for DogeScript", | ||
"main": "index.js", | ||
"authors": [ | ||
"Jamie Brown <[email protected]>" | ||
], | ||
"license": "ISC", | ||
"homepage": "https://github.com/jamiebrown201/todo_challenge", | ||
"moduleType": [], | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"jquery": "~2.2.0", | ||
"bootstrap": "~3.3.6", | ||
"angular": "~1.4.9", | ||
"angular-resource": "~1.4.9" | ||
}, | ||
"devDependencies": { | ||
"angular-mocks": "~1.4.9" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
module.exports = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'module' is not defined. |
||
url : 'mongodb://jamie:[email protected]:27017/Tub8evir' | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = function(grunt) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'module' is not defined. |
||
grunt.initConfig({ | ||
karma: { | ||
unit: { | ||
configFile: 'test/karma.conf.js' | ||
} | ||
}, | ||
protractor: { | ||
configFile: 'test/e2e/conf.js' | ||
} | ||
|
||
}) | ||
grunt.loadNpmTasks('grunt-protractor-runner'); | ||
grunt.loadNpmTasks('grunt-karma'); | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{ | ||
"name": "todo", | ||
"version": "1.0.0", | ||
"description": "* Deadline: submit completed pull request by 9am on Monday * You may use whatever level of JavaScript you feel comfortable with - pure JS, jQuery, Angular, or whatever weird and wonderful framework you want to try. Extra points for DogeScript", | ||
"main": "index.js", | ||
"directories": { | ||
"doc": "docs" | ||
}, | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/jamiebrown201/todo_challenge.git" | ||
}, | ||
"author": "", | ||
"dependencies": { | ||
"express": "~4.6.1", | ||
"mongoose": "~3.8.13", | ||
"morgan": "~1.1.1", | ||
"body-parser": "~1.4.3", | ||
"method-override": "~2.1.1" | ||
}, | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/jamiebrown201/todo_challenge/issues" | ||
}, | ||
"homepage": "https://github.com/jamiebrown201/todo_challenge#readme", | ||
"devDependencies": { | ||
"angular-dev-server": "^0.2.0", | ||
"grunt": "^0.4.5", | ||
"grunt-cli": "^0.1.13", | ||
"grunt-karma": "^0.12.1", | ||
"grunt-protractor-runner": "^3.0.0", | ||
"jasmine-core": "^2.4.1", | ||
"karma": "^0.13.19", | ||
"karma-chrome-launcher": "^0.2.2", | ||
"karma-jasmine": "^0.3.6", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
"karma-spec-reporter": "0.0.23", | ||
"phantomjs": "^2.1.3", | ||
"phantomjs-prebuilt": "^2.1.3", | ||
"protractor": "^3.0.0", | ||
"webdriver-manager": "^8.0.0" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#task { | ||
background-color: #F3F4F5; | ||
border-radius: 8px; | ||
padding: 0px 10px 0px 10px; | ||
margin-top: auto; | ||
margin-bottom: auto; | ||
} | ||
|
||
#count { | ||
font-size: 40px; | ||
} | ||
|
||
#title { | ||
font-size: 9.2vw; | ||
text-align: center; | ||
text-shadow: 2px 2px 5px #888888; | ||
} | ||
|
||
h1 { | ||
padding-top: 10px; | ||
padding-bottom: 5px; | ||
/*font-size: 2.2vw;*/ | ||
font-size: 15px | ||
} | ||
|
||
#delete { | ||
float: right; | ||
} | ||
|
||
#taskCount { | ||
position:fixed; bottom:2%; right:2%; | ||
font-size: 50px; | ||
} | ||
|
||
.checkbox { | ||
padding: 0 0 0 0; | ||
} | ||
|
||
|
||
#left { | ||
font-size: 20px | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<!doctype html> | ||
<html ng-app="toDoList"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<title>To Do List app</title> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"> | ||
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.min.css"> | ||
<link rel="stylesheet" href="css/main.css"> | ||
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.min.js"></script> | ||
<script src="js/controllers/main.js"></script> | ||
<script src="js/services/todos.js"></script> | ||
<script src="js/core.js"></script> | ||
</head> | ||
|
||
<body ng-controller="todoController as main"> | ||
<div class="container container-fluid"> | ||
<h1 id="title">To Do List</h1> | ||
<div class="row"> | ||
<form name="searchForm"> | ||
<div class="input-group input-group-lg"> | ||
<input class = "form-control text-center" | ||
placeholder="What would you like to do?" | ||
type="text" | ||
ng-model="main.formData.text" | ||
required> | ||
<span class="input-group-btn"> | ||
<button class="btn btn-success" ng-click="main.createTodo()"><i class="glyphicon glyphicon-plus"></i></button> | ||
</span> | ||
</div> | ||
</form> | ||
</div> | ||
<div id="todo-list" class="row"> | ||
<div > | ||
<div class="checkbox" ng-repeat="todo in main.todos" > | ||
<label > | ||
<div id="task" > | ||
<h1>{{ todo.text }} <i id="delete"class="glyphicon glyphicon-minus" ng-click="main.deleteTodo(todo._id)"></i></h1> | ||
<div> | ||
</label> | ||
</div> | ||
|
||
</div> | ||
</div> | ||
|
||
|
||
|
||
|
||
<div class="container"> | ||
|
||
</div id="count"> | ||
<span id="taskCount" class="label label-info">{{ main.todos.length }} | ||
<p id="left">Left</p> | ||
</span> | ||
</div> | ||
|
||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
angular.module('todoController', []) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'angular' is not defined. |
||
|
||
.controller('todoController', ['$http','Todos', function( $http, Todos) { | ||
|
||
var self = this; | ||
|
||
self.formData = {}; | ||
|
||
Todos.get() | ||
.success(function(data) { | ||
self.todos = data; | ||
}); | ||
|
||
self.createTodo = function() { | ||
if (self.formData.text !== undefined) { | ||
Todos.create(self.formData) | ||
.success(function(data) { | ||
self.formData = {}; | ||
self.todos = data; | ||
}); | ||
} | ||
}; | ||
|
||
self.deleteTodo = function(id) { | ||
Todos.delete(id) | ||
.success(function(data) { | ||
self.todos = data; | ||
}); | ||
}; | ||
|
||
}]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
angular.module('toDoList', ['todoController', 'todoService']); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'angular' is not defined. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
angular.module('todoService', []) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'angular' is not defined. |
||
|
||
.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); | ||
} | ||
} | ||
}]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'require' is not defined.