From 93c49f8be555d6bb89653770e7c970d5271f7df5 Mon Sep 17 00:00:00 2001 From: sipp11 Date: Sun, 8 Jul 2018 00:10:26 +0700 Subject: [PATCH] Updates: move map to current loc * bugfixes: * Map requires auth * Clear polygons to clear fetching stuck at true * reload button * default API endpoint to api.goth.app --- src/App.js | 2 +- src/components/AgencyForm.js | 24 +++++++++--------- src/components/FloatPane.js | 7 +++--- src/components/Footer.js | 3 ++- src/components/RouteForm.js | 44 ++++++++++++++++++++------------- src/components/StopForm.js | 47 +++++++++++++++++++++--------------- src/components/StopList.js | 1 + src/constants/Api.js | 2 +- src/container/Geo.js | 27 +++++++++++++++++++++ src/reducers/stop.js | 7 ++++++ 10 files changed, 110 insertions(+), 54 deletions(-) diff --git a/src/App.js b/src/App.js index 476001e..ae776ac 100644 --- a/src/App.js +++ b/src/App.js @@ -11,8 +11,8 @@ import { LOGIN_PATH } from './constants/path' const App = () => ( {/* both /roster and /roster/:number begin with /roster */} - + ) diff --git a/src/components/AgencyForm.js b/src/components/AgencyForm.js index 2e4c665..94485e8 100644 --- a/src/components/AgencyForm.js +++ b/src/components/AgencyForm.js @@ -20,10 +20,10 @@ class AgencyForm extends Component { agency_id: "", email: "", fare_url: "", - lang: "", + lang: "th", name: "", phone: "", - timezone: "", + timezone: "Asia/Bangkok", url: "", } @@ -98,18 +98,18 @@ class AgencyForm extends Component { handleChange={this.handleChange} /> + label="Timezone" + type="text" + fieldName="timezone" + value={one.timezone || 'Asia/Bangkok'} + handleChange={this.handleChange} /> + label="Phone" + type="text" + fieldName="phone" + value={one.phone || ''} + handleChange={this.handleChange} /> props.hidePane ? 0 : '25vw'}; top: 30px; border-radius: 0 5px 5px 0; diff --git a/src/components/Footer.js b/src/components/Footer.js index cba7f43..3bae82d 100644 --- a/src/components/Footer.js +++ b/src/components/Footer.js @@ -4,7 +4,8 @@ const Footer = () => diff --git a/src/components/RouteForm.js b/src/components/RouteForm.js index 12a85d4..ab7e5dd 100644 --- a/src/components/RouteForm.js +++ b/src/components/RouteForm.js @@ -3,7 +3,8 @@ import styled from 'styled-components' import { connect } from 'react-redux' import { Redirect, Link } from 'react-router-dom' -import HorizontalInput from './parts/HorizontalInput' +import Input from './parts/Input' +import Select from './parts/Select' import { updateRoute, createRoute, deleteRoute } from '../actions/route'; import store from '../store' @@ -23,7 +24,7 @@ class RouteForm extends Component { short_name: "", long_name: "", desc: "", - route_type: "2", + route_type: "3", route_url: "", route_color: "", route_text_color: "", @@ -94,63 +95,72 @@ class RouteForm extends Component {

{one.route_id || 'New Route'}  

- - - - - - - + + - - -

{one.stop_id || 'New Stop'}  

- - - - - - - - + + - - - {/* + + {/* { this.handleStopSearch(e) } } onKeyPress={(e) => { (e.key === 'Enter') && this.handleStopSearch(e) }} /> diff --git a/src/constants/Api.js b/src/constants/Api.js index 2bcae2f..97e3458 100644 --- a/src/constants/Api.js +++ b/src/constants/Api.js @@ -1,5 +1,5 @@ -export const URL = process.env.API_URL || '//localhost:8000' +export const URL = process.env.API_URL || 'https://api.goth.app' export const API_PREFIX = process.env.API_PREFIX || '/v1' export const API_URL = `${URL}${API_PREFIX}` export const LOGIN = '/api-token-auth/' diff --git a/src/container/Geo.js b/src/container/Geo.js index 8fbac93..d72f7ed 100644 --- a/src/container/Geo.js +++ b/src/container/Geo.js @@ -26,6 +26,20 @@ display: flex; flex-direction: column; ` +const FollowMyLocation = styled.div` +width: 40px +height: 40px; +background: #fefefebb; +border-radius: 10px; +color: #209cee; +position: fixed; +text-align: center; +padding-top: 10px; +right: 0; +bottom: 100px; +z-index: 30; +` + // TODO: filter for existing polygons // TODO: update mapCenter to recent active route/trip or current location @@ -142,6 +156,14 @@ class Geo extends Component { }}/> } + forceSetMapCenterToCurrent() { + const { geo } = this.props + const { leafletElement } = this.refs.map + const { zoom } = this.refs.map.viewport // another key is 'center' + const curLoc = [geo.coords.latitude, geo.coords.longitude] + leafletElement.setView(curLoc, zoom < 13 ? 13 : zoom) + } + render() { const { loggedIn, geo } = this.props const myLocationMarker = geo.coords ? ( @@ -190,6 +212,11 @@ class Geo extends Component { {/*