Skip to content

Commit 24150fd

Browse files
committed
initial commit
0 parents  commit 24150fd

39 files changed

+2415
-0
lines changed

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "airbnb"
3+
}

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
.DS_Store
3+
.env

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
react-app
2+
---
3+
4+
Install node dependencies using `npm install`
5+
Run the development server using `npm run start`
6+
7+
The react app is deployed to heroku `https://react-app-drones-spanhawk.herokuapp.com`

package.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"name": "react-app",
3+
"version": "0.1.0",
4+
"private": true,
5+
"devDependencies": {
6+
"react-scripts": "0.7.0"
7+
},
8+
"dependencies": {
9+
"auth0-lock": "^10.5.1",
10+
"json-loader": "^0.5.4",
11+
"lodash": "^4.16.4",
12+
"react": "^15.3.2",
13+
"react-async-script-loader": "^0.2.1",
14+
"react-bootstrap": "^0.30.6",
15+
"react-dom": "^15.3.2",
16+
"react-router": "^3.0.0",
17+
"react-select": "^1.0.0-rc.2",
18+
"react-toastr": "^2.8.1",
19+
"reqwest": "^2.0.5",
20+
"socket.io-client": "^1.5.1"
21+
},
22+
"scripts": {
23+
"start": "react-scripts start",
24+
"build": "react-scripts build",
25+
"test": "react-scripts test --env=jsdom",
26+
"eject": "react-scripts eject"
27+
}
28+
}

public/favicon.ico

24.3 KB
Binary file not shown.

public/i/m1.png

2.93 KB
Loading

public/i/m2.png

3.18 KB
Loading

public/i/m3.png

3.86 KB
Loading

public/i/m4.png

5.57 KB
Loading

public/i/m5.png

6.68 KB
Loading

public/index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1">
6+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
7+
<title>Drones</title>
8+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
9+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.5.2/animate.min.css">
10+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/toastr.js/2.1.3/toastr.min.css">
11+
</head>
12+
<body>
13+
<div id="root"></div>
14+
</body>
15+
</html>

src/App.js

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/**
2+
* Copyright (c) 2016 Topcoder Inc, All rights reserved.
3+
*/
4+
5+
/**
6+
* The main application component.
7+
* This is the main UI entry point for a react application
8+
*
9+
* @author TCSCODER
10+
* @version 1.0.0
11+
*/
12+
13+
import React, { Component } from 'react';
14+
import './styles/App.css';
15+
import scriptLoader from 'react-async-script-loader';
16+
import { Navbar, Nav, NavItem } from 'react-bootstrap';
17+
import { hashHistory } from 'react-router';
18+
19+
class App extends Component {
20+
21+
/**
22+
* Util function to render the children
23+
* Whenever a state change happens in react application, react will render the component again
24+
* and we wish to pass the updated state to the children as props
25+
*/
26+
renderChildren() {
27+
const {children} = this.props;
28+
if (!children) {
29+
return;
30+
}
31+
const sharedProps = {
32+
auth: this.props.auth,
33+
loaded: this.props.isScriptLoaded && this.props.isScriptLoadSucceed
34+
}
35+
return React.Children.map(children, c => {
36+
return React.cloneElement(c, sharedProps, {
37+
38+
});
39+
});
40+
}
41+
42+
logout() {
43+
this.props.auth.logout();
44+
hashHistory.push('/login');
45+
}
46+
47+
48+
/**
49+
* Render the dom
50+
*/
51+
render() {
52+
const isLoggedIn = this.props.auth.loggedIn();
53+
const child = this.renderChildren();
54+
if (isLoggedIn) {
55+
return (
56+
<div className="full-height">
57+
<Navbar fluid className="navbar-wrapper">
58+
<Nav>
59+
<NavItem eventKey={1} href="#/drones">Drones</NavItem>
60+
<NavItem eventKey={2} href="#/planner">Planner</NavItem>
61+
<NavItem eventKey={3} onClick={this.logout.bind(this)} >Logout</NavItem>
62+
</Nav>
63+
</Navbar>
64+
{child}
65+
</div>
66+
);
67+
} else {
68+
return (
69+
<div className="full-height">
70+
<Navbar fluid className="navbar-wrapper">
71+
<Nav>
72+
<NavItem eventKey={1} href="#/login">Login</NavItem>
73+
<NavItem eventKey={2} href="#/drones">Drones</NavItem>
74+
</Nav>
75+
</Navbar>
76+
{child}
77+
</div>
78+
);
79+
}
80+
}
81+
}
82+
83+
export default scriptLoader(
84+
['https://maps.googleapis.com/maps/api/js?key=AIzaSyCR3jfBdv9prCBYBOf-fPUDhjPP4K05YjE', 'https://developers.google.com/maps/documentation/javascript/examples/markerclusterer/markerclusterer.js']
85+
)(App);

src/App.test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
4+
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div');
7+
ReactDOM.render(<App />, div);
8+
});

src/api/Drone.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2016 Topcoder Inc, All rights reserved.
3+
*/
4+
5+
/**
6+
* A simple implementation of /drones API contract
7+
*
8+
* @author TCSCODER
9+
* @version 1.0.0
10+
*/
11+
import reqwest from 'reqwest';
12+
13+
/**
14+
* DroneApi consumer, full implement the rest contract
15+
*/
16+
class DroneApi {
17+
/**
18+
* Default Constructor
19+
* @param {String} basePath the base API path
20+
*/
21+
constructor(basePath) {
22+
this.basePath = basePath;
23+
}
24+
25+
getAll() {
26+
const url = `${this.basePath}/api/v1/drones`;
27+
28+
return reqwest({ url: url });
29+
}
30+
}
31+
32+
export default DroneApi;

src/api/Mission.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* Copyright (c) 2016 Topcoder Inc, All rights reserved.
3+
*/
4+
5+
/**
6+
* A simple implementation of /missions API contract
7+
*
8+
* @author TCSCODER
9+
* @version 1.0.0
10+
*/
11+
import reqwest from 'reqwest';
12+
13+
/**
14+
* MissionApi consumer, full implement the rest contract
15+
*/
16+
class MissionApi {
17+
/**
18+
* Default Constructor
19+
* @param {String} basePath the base API path
20+
*/
21+
constructor(basePath, auth) {
22+
this.basePath = basePath;
23+
this.auth = auth;
24+
}
25+
26+
getAll() {
27+
const url = `${this.basePath}/api/v1/missions`;
28+
29+
return reqwest({ url: url, method: 'get', headers: this.auth.getHeader() });
30+
}
31+
32+
getSingle(id) {
33+
const url = `${this.basePath}/api/v1/missions/${id}`;
34+
35+
return reqwest({ url: url, method: 'get', headers: this.auth.getHeader() });
36+
}
37+
38+
save(name, items, homePosition) {
39+
const url = `${this.basePath}/api/v1/missions`;
40+
41+
return reqwest({ url: url, method: 'post', type: 'json',
42+
contentType: 'application/json',
43+
headers: this.auth.getHeader(),
44+
data: JSON.stringify({
45+
plannedHomePosition: homePosition,
46+
missionItems: items,
47+
missionName: name,
48+
})});
49+
}
50+
51+
update(id, name, items, homePosition) {
52+
const url = `${this.basePath}/api/v1/missions/${id}`;
53+
54+
return reqwest({ url: url, method: 'put', type: 'json',
55+
contentType: 'application/json',
56+
headers: this.auth.getHeader(),
57+
data: JSON.stringify({
58+
plannedHomePosition: homePosition,
59+
missionItems: items,
60+
missionName: name,
61+
})});
62+
}
63+
64+
download(id) {
65+
const url = `${this.basePath}/api/v1/missions/${id}/download`;
66+
67+
return reqwest({ url: url, method: 'get', headers: this.auth.getHeader() });
68+
}
69+
70+
delete(id) {
71+
const url = `${this.basePath}/api/v1/missions/${id}`;
72+
73+
return reqwest({ url: url, headers: this.auth.getHeader(), method: 'delete' });
74+
}
75+
}
76+
77+
export default MissionApi;

src/api/User.js

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright (c) 2016 Topcoder Inc, All rights reserved.
3+
*/
4+
5+
/**
6+
* A simple implementation of /missions API contract
7+
*
8+
* @author TCSCODER
9+
* @version 1.0.0
10+
*/
11+
import reqwest from 'reqwest';
12+
13+
/**
14+
* UserApi consumer, full implement the rest contract
15+
*/
16+
class UserApi {
17+
/**
18+
* Default Constructor
19+
* @param {String} basePath the base API path
20+
*/
21+
constructor(basePath) {
22+
this.basePath = basePath;
23+
}
24+
25+
login(email, password) {
26+
const url = `${this.basePath}/api/v1/users/auth`;
27+
28+
return reqwest({ url: url, method: 'post', type: 'json',
29+
contentType: 'application/json',
30+
data: JSON.stringify({
31+
email: email,
32+
password: password,
33+
})});
34+
}
35+
36+
register(name, email, password) {
37+
const url = `${this.basePath}/api/v1/users`;
38+
39+
return reqwest({ url: url, method: 'post', type: 'json',
40+
contentType: 'application/json',
41+
data: JSON.stringify({
42+
name: name,
43+
email: email,
44+
password: password,
45+
})});
46+
}
47+
}
48+
49+
export default UserApi;

0 commit comments

Comments
 (0)