Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

Feature/refactor get all #8

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
8 changes: 8 additions & 0 deletions .idea/jsLibraryMappings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/vscode-react-sample.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

237 changes: 237 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .jsbeautifyrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"js": {
"space_around_selector_separator": true
}
}
2 changes: 2 additions & 0 deletions app/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import getMuiTheme from 'material-ui/lib/styles/getMuiTheme';
import IconButton from 'material-ui/lib/icon-button';
import StarIcon from 'material-ui/lib/svg-icons/toggle/star';



import Viewport from './Viewport';


Expand Down
2 changes: 1 addition & 1 deletion app/components/NewTodo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NewTodo extends React.Component {
this.styles = {
spacing: {
float: 'left',
width: '30%',
width '30%',
margin: '3%'
},
prompt: {
Expand Down
14 changes: 11 additions & 3 deletions app/components/Todos.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ class Todos extends React.Component {
render() {
const todos = this.state.todos.map(this.create.bind(this));
return (
<List style={this.styles}>
{todos}
</List>
<div>
<List style={this.styles}>
{todos}
</List>
<select>
<option value="1">Q1. Jan - Mar</option>
<option value="2">Q2. Apr - Jun</option>
<option value="3">Q3. Jul - Sep</option>
<option value="4">Q4. Oct - Dec</option>
</select>
</div>
);
}
}
Expand Down
File renamed without changes.
File renamed without changes.
9 changes: 6 additions & 3 deletions server/database.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
var fs = require('fs');
var _ = require('lodash');
var promise = require('promise');

var DATA = 'data/todos.json';
var PRETTIFY_WS = 4;

function getAll(resolve) {
fs.readFile(DATA, function(err, data) {
resolve(JSON.parse(data));
function getAll() {
return new Promise((resolve, reject) => {
fs.readFile(DATA, function(err, data) {
resolve(JSON.parse(data));
});
});
}

Expand Down
8 changes: 3 additions & 5 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ var _ = require('lodash');

var database = require('./database');

// Create server
var server = express();
server.use(bodyParser.json());

// Middleware
server.use(function (req, res, next) {
// allow origin for demo purposes
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:8080');
Expand All @@ -18,9 +16,9 @@ server.use(function (req, res, next) {
});

// Routes
server.get('/todos', function(req, res, next) {
database.getAll(function(todos) {
res.send(todos);
server.get('/todos', function (req, res, next) {
database.getAll(function (todos) {
res.send(todos);
next();
});
});
Expand Down
1 change: 1 addition & 0 deletions server/typings/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/// <reference path="modules/lodash/index.d.ts" />
Loading