File tree Expand file tree Collapse file tree 5 files changed +13
-19
lines changed
routes/MissionPlanner/components Expand file tree Collapse file tree 5 files changed +13
-19
lines changed Original file line number Diff line number Diff line change @@ -12,4 +12,9 @@ module.exports = {
12
12
AUTH0_CLIENT_ID : process . env . REACT_APP_AUTH0_CLIENT_ID || 'h7p6V93Shau3SSvqGrl6V4xrATlkrVGm' ,
13
13
AUTH0_CLIENT_DOMAIN : process . env . REACT_APP_AUTH0_CLIENT_DOMAIN || 'spanhawk.auth0.com' ,
14
14
AUTH0_CALLBACK : 'http://localhost:3000' ,
15
+ REGION_TYPES : {
16
+ POINT : 'Point' ,
17
+ POLYGON : 'Polygon' ,
18
+ } ,
19
+ USER_LOCATION_KEY : 'ul' ,
15
20
} ;
Original file line number Diff line number Diff line change @@ -7,8 +7,7 @@ import Footer from 'components/Footer';
7
7
import styles from './CoreLayout.scss' ;
8
8
import { userLocationUpdateAction } from '../../store/modules/global' ;
9
9
import _ from 'lodash' ;
10
-
11
- const USER_LOCATION_KEY = 'ul' ;
10
+ import config from '../../config' ;
12
11
13
12
class CoreLayout extends React . Component {
14
13
@@ -32,7 +31,7 @@ class CoreLayout extends React.Component {
32
31
requestUserLocation ( ) {
33
32
const { onUserLocationUpdate} = this . props ;
34
33
// don't request the permission everytime and use caching
35
- const cachedLocation = localStorage . getItem ( USER_LOCATION_KEY ) ;
34
+ const cachedLocation = localStorage . getItem ( config . USER_LOCATION_KEY ) ;
36
35
// just to be extra safe here as a user can manipulate the content of local storage
37
36
if ( cachedLocation && _ . has ( cachedLocation , 'lat' ) && _ . has ( cachedLocation , 'lng' ) ) {
38
37
onUserLocationUpdate ( cachedLocation ) ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import NoFlyZone from 'components/NoFlyZone';
6
6
import Rtfz from '../Rtfz' ;
7
7
import { GOOGLE_MAPS_BOUNDS_TIMEOUT } from 'Const' ;
8
8
import styles from './MissionMap.scss' ;
9
+ import config from '../../../../config' ;
9
10
10
11
// default center location for mission Planner
11
12
const mapConfig = {
@@ -28,11 +29,6 @@ const polylineConfig = {
28
29
} ,
29
30
} ;
30
31
31
- const types = {
32
- point : 'Point' ,
33
- polygon : 'Polygon' ,
34
- } ;
35
-
36
32
export const MissionGoogleMap = withGoogleMap ( ( props ) => (
37
33
< GoogleMap
38
34
{ ... mapConfig }
@@ -122,9 +118,9 @@ export class MissionMap extends Component {
122
118
bounds = new google . maps . LatLngBounds ( ) ;
123
119
// bounds for rtfzs
124
120
rtfzs . forEach ( ( rtfz ) => {
125
- if ( rtfz . location . type === types . point ) {
121
+ if ( rtfz . location . type === config . REGION_TYPES . POINT ) {
126
122
bounds . extend ( { lat : rtfz . location . coordinates [ 1 ] , lng : rtfz . location . coordinates [ 0 ] } ) ;
127
- } else if ( rtfz . location . type === types . polygon ) {
123
+ } else if ( rtfz . location . type === config . REGION_TYPES . POLYGON ) {
128
124
rtfz . location . coordinates . forEach ( ( coor ) => {
129
125
coor . forEach ( ( point ) => {
130
126
bounds . extend ( { lat : point [ 1 ] , lng : point [ 0 ] } ) ;
Original file line number Diff line number Diff line change 1
1
import React , { PropTypes } from 'react' ;
2
2
import { Marker , Polygon } from 'react-google-maps' ;
3
-
4
- // define the type of region to fly zones
5
- const types = {
6
- point : 'Point' ,
7
- polygon : 'Polygon' ,
8
- } ;
3
+ import config from '../../../../config' ;
9
4
10
5
export const Rtfz = ( { zone} ) => {
11
- if ( zone . location . type === types . point ) {
6
+ if ( zone . location . type === config . REGION_TYPES . POINT ) {
12
7
return (
13
8
< Marker
14
9
options = { {
Original file line number Diff line number Diff line change @@ -23,7 +23,6 @@ const LOGIN_REDIRECT = {
23
23
24
24
const LOGOUT_ACTION = 'LOGOUT_ACTION' ;
25
25
const USER_INFO_KEY = 'userInfo' ;
26
- const USER_LOCATION_KEY = 'ul' ;
27
26
28
27
// ------------------------------------
29
28
// Actions
@@ -88,7 +87,7 @@ export const logoutAction = () => (dispatch) => {
88
87
89
88
export const userLocationUpdateAction = ( location ) => ( dispatch ) => {
90
89
// cache the user location in localstorage
91
- localStorage . setItem ( USER_LOCATION_KEY , JSON . stringify ( location ) ) ;
90
+ localStorage . setItem ( config . USER_LOCATION_KEY , JSON . stringify ( location ) ) ;
92
91
dispatch ( { type : USER_LOCATION_UPDATE , payload : { location} } ) ;
93
92
} ;
94
93
You can’t perform that action at this time.
0 commit comments