Skip to content

Commit 7303b66

Browse files
authored
Merge pull request #52 from opentripplanner/dev
New release
2 parents 5cb4080 + 2187417 commit 7303b66

File tree

127 files changed

+19130
-4260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+19130
-4260
lines changed

Diff for: .travis.yml

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ cache:
33
yarn: true
44
notifications:
55
email: false
6+
webhooks: https://outlook.office.com/webhook/03fa4a79-572f-4c68-b756-e4e851d0215a@9093f1a3-8771-4fb7-8596-d51eeef18cda/TravisCI/449087910d3647598cf3d7c6387fb8fc/286c079f-6085-4aa0-8f8d-e2a3e8d1f568
67
node_js:
7-
- '6'
8+
- '8'
89
before_install:
910
- npm i -g yarn codecov
1011
after_success:
11-
- yarn run semantic-release
12+
- semantic-release
1213
before_script:
1314
- yarn global add codecov
1415
script:

Diff for: __tests__/actions/__snapshots__/api.js.snap

+4-24
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`OTP Query Path 1`] = `"/api/plan?fromPlace=12%2C34&toPlace=34%2C12"`;
4-
5-
exports[`actions > api > routingQuery should gracefully handle bad response 1`] = `
3+
exports[`actions > api routingQuery should gracefully handle bad response 1`] = `
64
Array [
75
Array [
86
Object {
@@ -13,19 +11,10 @@ Array [
1311
"type": "ROUTING_REQUEST",
1412
},
1513
],
16-
Array [
17-
Object {
18-
"payload": Object {
19-
"error": [Error: Received error from server],
20-
"searchId": 2,
21-
},
22-
"type": "ROUTING_ERROR",
23-
},
24-
],
2514
]
2615
`;
2716

28-
exports[`actions > api > routingQuery should make a query to OTP 1`] = `
17+
exports[`actions > api routingQuery should make a query to OTP 1`] = `
2918
Array [
3019
Array [
3120
Object {
@@ -36,16 +25,7 @@ Array [
3625
"type": "ROUTING_REQUEST",
3726
},
3827
],
39-
Array [
40-
Object {
41-
"payload": Object {
42-
"response": Object {
43-
"fake": "response",
44-
},
45-
"searchId": 1,
46-
},
47-
"type": "ROUTING_RESPONSE",
48-
},
49-
],
5028
]
5129
`;
30+
31+
exports[`actions > api routingQuery should make a query to OTP: OTP Query Path 1`] = `"/api/plan?fromPlace=Origin%20%2812%2C34%29%3A%3A12%2C34&toPlace=Destination%20%2834%2C12%29%3A%3A34%2C12&mode=WALK%2CTRANSIT"`;

Diff for: __tests__/actions/__snapshots__/form.js.snap

-59
This file was deleted.

Diff for: __tests__/actions/api.js

+7-16
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22

33
import nock from 'nock'
44

5-
import {timeoutPromise} from '../test-utils'
6-
75
import {routingQuery} from '../../lib/actions/api'
86

97
describe('actions > api', () => {
10-
describe('> routingQuery', () => {
8+
describe('routingQuery', () => {
119
const defaultState = {
1210
otp: {
1311
config: {
@@ -19,6 +17,7 @@ describe('actions > api', () => {
1917
},
2018
currentQuery: {
2119
from: { lat: 12, lon: 34 },
20+
mode: 'WALK,TRANSIT',
2221
routingType: 'ITINERARY',
2322
to: { lat: 34, lon: 12 }
2423
},
@@ -31,21 +30,16 @@ describe('actions > api', () => {
3130

3231
nock('http://mock-host.com')
3332
.get(/api\/plan/)
34-
.reply(200, {
35-
fake: 'response'
36-
})
37-
.on('request', (req, interceptor) => {
38-
expect(req.path).toMatchSnapshot('OTP Query Path')
33+
.reply(200, (uri, requestBody) => {
34+
expect(uri).toMatchSnapshot('OTP Query Path')
35+
return { fake: 'response' }
3936
})
4037

4138
const mockDispatch = jest.fn()
42-
routingQueryAction(mockDispatch, () => {
39+
await routingQueryAction(mockDispatch, () => {
4340
return defaultState
4441
})
4542

46-
// wait for request to complete
47-
await timeoutPromise(100)
48-
4943
expect(mockDispatch.mock.calls).toMatchSnapshot()
5044
})
5145

@@ -59,13 +53,10 @@ describe('actions > api', () => {
5953
})
6054

6155
const mockDispatch = jest.fn()
62-
routingQueryAction(mockDispatch, () => {
56+
await routingQueryAction(mockDispatch, () => {
6357
return defaultState
6458
})
6559

66-
// wait for request to complete
67-
await timeoutPromise(100)
68-
6960
expect(mockDispatch.mock.calls).toMatchSnapshot()
7061
})
7162
})

Diff for: __tests__/actions/form.js renamed to __tests__/actions/form.js_old

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// Test file renamed because it is no longer valid
2+
// TODO: write tests for form actions
3+
14
/* globals describe, expect, it, jest */
25

36
import {timeoutPromise} from '../test-utils'

Diff for: __tests__/test-utils/setup.js

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
window.localStorage = {
2+
getItem: () => null
3+
}

Diff for: example.css

+23-4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
.otp .navbar {
2+
border-radius: 0;
3+
background-color: #444;
4+
}
5+
6+
.otp .navbar .container {
7+
margin-left: 0;
8+
}
9+
10+
.otp .navbar-brand {
11+
padding: 7px 10px;
12+
}
13+
14+
.otp .navbar-title {
15+
color: #fff;
16+
font-size: 24px;
17+
padding-top: 7px;
18+
}
19+
20+
.otp.mobile .navbar-title {
21+
padding-top: 2px;
22+
}
23+
124
.main-row {
225
position: fixed;
326
top: 52px;
@@ -18,7 +41,3 @@
1841
margin: 0px;
1942
padding: 0px;
2043
}
21-
22-
.date-time-selector {
23-
margin-top: 20px;
24-
}

Diff for: example.js

+67-50
Original file line numberDiff line numberDiff line change
@@ -11,39 +11,32 @@ import { Navbar, Grid, Row, Col } from 'react-bootstrap'
1111

1212
// import OTP-RR components
1313
import {
14-
BaseLayers,
15-
BaseMap,
16-
BikeRentalOverlay,
17-
DateTimeSelector,
18-
EndpointsOverlay,
14+
DefaultSearchForm,
1915
ErrorMessage,
20-
ItineraryOverlay,
21-
LocationField,
22-
NarrativeItineraries,
23-
PlanTripButton,
24-
TransitiveOverlay,
25-
SettingsSelectorPanel,
26-
SwitchButton,
27-
16+
MobileMain,
17+
NarrativeRoutingResults,
18+
ResponsiveWebapp,
19+
Map,
20+
ViewerContainer,
21+
AppMenu,
2822
createOtpReducer
2923
} from './lib'
3024

3125
// load the OTP configuration
3226
import otpConfig from './config.yml'
3327

3428
// create an initial query for demo/testing purposes
35-
/* const initialQuery = {
29+
const initialQuery = {
3630
from: {
37-
name: 'PDX',
38-
lat: 45.589180,
39-
lon: -122.593460
31+
lat: 45.5246,
32+
lon: -122.6710
4033
},
4134
to: {
42-
name: 'TTO',
43-
lat: 45.518950,
44-
lon: -122.679565
45-
}
46-
} */
35+
lat: 45.5307,
36+
lon: -122.6647
37+
},
38+
type: 'ITINERARY'
39+
}
4740

4841
// set up the Redux store
4942
const store = createStore(
@@ -57,42 +50,66 @@ const store = createStore(
5750
// define a simple responsive UI using Bootstrap and OTP-RR
5851
class OtpRRExample extends Component {
5952
render () {
60-
return (<div className='otp'>
61-
<Navbar fluid>
62-
<Navbar.Brand>OpenTripPlanner</Navbar.Brand>
63-
</Navbar>
64-
<Grid fluid>
65-
<Row className='main-row'>
66-
<Col xs={12} md={4} className='sidebar'>
67-
<LocationField type='from' label='Enter start location or click on map...' />
68-
<LocationField type='to' label='Enter destination or click on map...' />
69-
<SwitchButton />
70-
<DateTimeSelector />
71-
<SettingsSelectorPanel />
72-
<ErrorMessage />
73-
<PlanTripButton />
74-
<NarrativeItineraries />
75-
</Col>
7653

77-
<Col xsHidden md={8} className='map-container'>
78-
<BaseMap>
79-
<BaseLayers />
80-
<BikeRentalOverlay />
81-
<ItineraryOverlay />
82-
<TransitiveOverlay />
83-
<EndpointsOverlay />
84-
</BaseMap>
85-
</Col>
86-
</Row>
87-
</Grid>
88-
</div>)
54+
/** desktop view **/
55+
const desktopView = (
56+
<div className='otp'>
57+
<Navbar>
58+
<Navbar.Header>
59+
<Navbar.Brand>
60+
<div style={{ float: 'left', color: 'white', fontSize: 28 }}>
61+
<AppMenu />
62+
</div>
63+
<div className='navbar-title' style={{ marginLeft: 50 }}>OpenTripPlanner</div>
64+
</Navbar.Brand>
65+
</Navbar.Header>
66+
</Navbar>
67+
<Grid>
68+
<Row className='main-row'>
69+
<Col sm={6} md={4} className='sidebar'>
70+
<ViewerContainer>
71+
<DefaultSearchForm />
72+
<ErrorMessage />
73+
<div className='desktop-narrative-container'>
74+
<NarrativeRoutingResults />
75+
</div>
76+
</ViewerContainer>
77+
</Col>
78+
79+
<Col sm={6} md={8} className='map-container'>
80+
<Map />
81+
</Col>
82+
</Row>
83+
</Grid>
84+
</div>
85+
)
86+
87+
/** mobile view **/
88+
const mobileView = (
89+
<MobileMain map={(<Map />)} title={(<div className='navbar-title'>OpenTripPlanner</div>)} />
90+
)
91+
92+
/** the main webapp **/
93+
return (
94+
<ResponsiveWebapp
95+
desktopView={desktopView}
96+
mobileView={mobileView}
97+
/>
98+
)
8999
}
90100
}
91101

92102
// render the app
93103
render(
94104
<Provider store={store}>
105+
{ /**
106+
* If not using router history, simply include OtpRRExample here:
107+
* e.g.
108+
* <OtpRRExample />
109+
*/
110+
}
95111
<OtpRRExample />
112+
96113
</Provider>,
97114
document.getElementById('root')
98115
)

Diff for: index.html

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@
55
<title>OTP R.R.</title>
66

77
<link rel="stylesheet" href="dist/index.css">
8+
<link rel="stylesheet" href="node_modules/transitive-js/lib/transitive.css">
89
<link rel="stylesheet" href="example.css">
10+
<link rel="stylesheet" href="node_modules/leaflet.polylinemeasure/Leaflet.PolylineMeasure.css" />
11+
912
</head>
1013
<body>
1114
<div id="root"></div>
12-
<script src="example.js"></script>
15+
<script src="/example.js"></script>
1316
</body>
1417
</html>

0 commit comments

Comments
 (0)