Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f07c61c3b5 | ||
|
|
eb3649547a | ||
|
|
5d339a695e | ||
|
|
c53d7339fb | ||
|
|
587052a509 | ||
|
|
a33ca57d58 |
@@ -6,7 +6,6 @@
|
|||||||
"development": {
|
"development": {
|
||||||
"plugins": [
|
"plugins": [
|
||||||
"transform-react-jsx-source",
|
"transform-react-jsx-source",
|
||||||
"transform-decorators-legacy"
|
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ android {
|
|||||||
applicationId "com.deightonar"
|
applicationId "com.deightonar"
|
||||||
minSdkVersion 24
|
minSdkVersion 24
|
||||||
targetSdkVersion 27
|
targetSdkVersion 27
|
||||||
versionCode 4
|
versionCode 6
|
||||||
versionName "1.0.1"
|
versionName "1.1.0"
|
||||||
ndk {
|
ndk {
|
||||||
abiFilters "armeabi-v7a", "x86"
|
abiFilters "armeabi-v7a", "x86"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.deightonar"
|
package="com.deightonar"
|
||||||
android:versionCode="4"
|
android:versionCode="6"
|
||||||
android:versionName="1.0.1">
|
android:versionName="1.1.0">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
|
||||||
|
|||||||
@@ -19,11 +19,11 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>1.0.1</string>
|
<string>1.1.0</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>????</string>
|
<string>????</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>20180518.0</string>
|
<string>20180525.0</string>
|
||||||
<key>LSRequiresIPhoneOS</key>
|
<key>LSRequiresIPhoneOS</key>
|
||||||
<true/>
|
<true/>
|
||||||
<key>NSAppTransportSecurity</key>
|
<key>NSAppTransportSecurity</key>
|
||||||
|
|||||||
2638
mobile/package-lock.json
generated
2638
mobile/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,6 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"babel-plugin-transform-decorators-legacy": "^1.3.4",
|
|
||||||
"babel-preset-react-native-stage-0": "^1.0.1",
|
"babel-preset-react-native-stage-0": "^1.0.1",
|
||||||
"jest-react-native": "^18.0.0",
|
"jest-react-native": "^18.0.0",
|
||||||
"react-test-renderer": "16.2.0"
|
"react-test-renderer": "16.2.0"
|
||||||
@@ -18,7 +17,7 @@
|
|||||||
"preset": "react-native"
|
"preset": "react-native"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"autobind-decorator": "^2.1.0",
|
"auto-bind2": "^1.0.3",
|
||||||
"eventemitter3": "^3.1.0",
|
"eventemitter3": "^3.1.0",
|
||||||
"moment": "^2.22.1",
|
"moment": "^2.22.1",
|
||||||
"react": "^16.3.2",
|
"react": "^16.3.2",
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import EventEmitter from "eventemitter3"
|
import EventEmitter from "eventemitter3"
|
||||||
import io from "socket.io-client"
|
import io from "socket.io-client"
|
||||||
import { AsyncStorage } from "react-native"
|
import { AsyncStorage } from "react-native"
|
||||||
import autobind from "autobind-decorator"
|
|
||||||
import { config } from "./config"
|
import { config } from "./config"
|
||||||
import RNFS from "react-native-fs"
|
import RNFS from "react-native-fs"
|
||||||
|
import { autoBind } from "auto-bind2"
|
||||||
|
|
||||||
const authTokenKeyName = "AuthToken"
|
const authTokenKeyName = "AuthToken"
|
||||||
const backendKeyName = "Backend"
|
const backendKeyName = "Backend"
|
||||||
@@ -33,7 +33,6 @@ class APIError extends Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
class API extends EventEmitter {
|
class API extends EventEmitter {
|
||||||
static urls = {
|
static urls = {
|
||||||
normal: "https://dar.kss.us.com/api",
|
normal: "https://dar.kss.us.com/api",
|
||||||
@@ -43,6 +42,7 @@ class API extends EventEmitter {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super()
|
super()
|
||||||
|
autoBind(this)
|
||||||
this.user = { pending: true }
|
this.user = { pending: true }
|
||||||
this._apiURL = null
|
this._apiURL = null
|
||||||
|
|
||||||
|
|||||||
@@ -13,16 +13,16 @@ import {
|
|||||||
ViroQuad,
|
ViroQuad,
|
||||||
ViroConstants,
|
ViroConstants,
|
||||||
} from "react-viro"
|
} from "react-viro"
|
||||||
import autobind from "autobind-decorator"
|
|
||||||
import backImage from "./images/back.png"
|
import backImage from "./images/back.png"
|
||||||
import { config } from "../config"
|
import { config } from "../config"
|
||||||
import "url-search-params-polyfill"
|
import "url-search-params-polyfill"
|
||||||
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
const shapes = {
|
const shapes = {
|
||||||
order: {
|
order: {
|
||||||
source: require("./models/hardhat_obj.obj"),
|
source: require("./models/hardhat_obj.obj"),
|
||||||
resources: [require("./models/hardhat.mtl")],
|
resources: [require("./models/hardhat.mtl")],
|
||||||
scale: [0.5, 0.5, 0.5],
|
scale: [0.3, 0.3, 0.3],
|
||||||
},
|
},
|
||||||
complaint: {
|
complaint: {
|
||||||
source: require("./models/question_obj.obj"),
|
source: require("./models/question_obj.obj"),
|
||||||
@@ -47,6 +47,7 @@ const distance = (vectorA, vectorB) => {
|
|||||||
class WorkItemSceneAR extends React.Component {
|
class WorkItemSceneAR extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
position: [0, 0, 0],
|
position: [0, 0, 0],
|
||||||
@@ -57,7 +58,6 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleLoadEnd() {
|
handleLoadEnd() {
|
||||||
this.arScene.getCameraOrientationAsync().then((orientation) => {
|
this.arScene.getCameraOrientationAsync().then((orientation) => {
|
||||||
return this.arScene
|
return this.arScene
|
||||||
@@ -65,8 +65,11 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
.then((results) => {
|
.then((results) => {
|
||||||
const { forward, position } = orientation
|
const { forward, position } = orientation
|
||||||
// Default position is just one meter in front of the user
|
// Default position is just one meter in front of the user
|
||||||
const defaultPosition =
|
const defaultPosition = [
|
||||||
[forward[0] * 1.0, forward[1] * 1.0, forward[2]] * 1.0
|
forward[0] * 1.0,
|
||||||
|
forward[1] * 1.0,
|
||||||
|
forward[2] * 1.0,
|
||||||
|
]
|
||||||
let hitResultPosition = null
|
let hitResultPosition = null
|
||||||
|
|
||||||
// Filter the hit test results based on the position.
|
// Filter the hit test results based on the position.
|
||||||
@@ -102,6 +105,8 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
position: hitResultPosition || defaultPosition,
|
position: hitResultPosition || defaultPosition,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
console.log(hitResultPosition || defaultPosition)
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.updateInitialRotation()
|
this.updateInitialRotation()
|
||||||
}, 200)
|
}, 200)
|
||||||
@@ -110,7 +115,6 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
updateInitialRotation() {
|
updateInitialRotation() {
|
||||||
this.arNode.getTransformAsync().then((retDict) => {
|
this.arNode.getTransformAsync().then((retDict) => {
|
||||||
let rotation = retDict.rotation
|
let rotation = retDict.rotation
|
||||||
@@ -131,7 +135,6 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleTrackingUpdated(state, reason) {
|
handleTrackingUpdated(state, reason) {
|
||||||
if (
|
if (
|
||||||
!this.state.trackingInitialized &&
|
!this.state.trackingInitialized &&
|
||||||
@@ -141,12 +144,10 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleAnchorFound() {
|
handleAnchorFound() {
|
||||||
this.setState({ haveAnchor: true })
|
this.setState({ haveAnchor: true })
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleClick(position, source) {
|
handleClick(position, source) {
|
||||||
const { workItemId } = this.props
|
const { workItemId } = this.props
|
||||||
|
|
||||||
@@ -182,7 +183,7 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
innerAngle={5}
|
innerAngle={5}
|
||||||
outerAngle={20}
|
outerAngle={20}
|
||||||
direction={[0, -1, 0]}
|
direction={[0, -1, 0]}
|
||||||
position={[0, 10, 0]}
|
position={[0, 5, 0]}
|
||||||
color="#ffffff"
|
color="#ffffff"
|
||||||
castsShadow={true}
|
castsShadow={true}
|
||||||
shadowNearZ={0.1}
|
shadowNearZ={0.1}
|
||||||
@@ -193,7 +194,7 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
trackingInitialized &&
|
trackingInitialized &&
|
||||||
haveAnchor && (
|
haveAnchor && (
|
||||||
<Viro3DObject
|
<Viro3DObject
|
||||||
position={[0, 0, -1]}
|
position={[0, 0, 0]}
|
||||||
source={shape.source}
|
source={shape.source}
|
||||||
resources={shape.resources}
|
resources={shape.resources}
|
||||||
scale={shape.scale}
|
scale={shape.scale}
|
||||||
@@ -219,6 +220,7 @@ class WorkItemSceneAR extends React.Component {
|
|||||||
export class ARViewer extends React.Component {
|
export class ARViewer extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
|
||||||
const { search } = this.props.location
|
const { search } = this.props.location
|
||||||
|
|
||||||
@@ -230,7 +232,6 @@ export class ARViewer extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleBackPress() {
|
handleBackPress() {
|
||||||
this.props.history.replace("/")
|
this.props.history.replace("/")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
FormStaticInput,
|
FormStaticInput,
|
||||||
} from "../ui"
|
} from "../ui"
|
||||||
import { MessageModal, WaitModal, ProgressModal } from "../Modal"
|
import { MessageModal, WaitModal, ProgressModal } from "../Modal"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
import KeyboardSpacer from "react-native-keyboard-spacer"
|
import KeyboardSpacer from "react-native-keyboard-spacer"
|
||||||
import { isIphoneX } from "react-native-iphone-x-helper"
|
import { isIphoneX } from "react-native-iphone-x-helper"
|
||||||
import { api } from "../API"
|
import { api } from "../API"
|
||||||
@@ -86,14 +86,17 @@ export class Activity extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = {
|
this.state = {
|
||||||
binder: new FormBinder({}, Activity.bindings),
|
binder: new FormBinder({}, Activity.bindings),
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
messageModal: null,
|
messageModal: null,
|
||||||
progressModal: null,
|
progressModal: null,
|
||||||
uploadPercent: 0,
|
uploadPercent: 0,
|
||||||
region: config.initialRegion,
|
|
||||||
}
|
}
|
||||||
|
this.region = null
|
||||||
|
this.isMapReady = false
|
||||||
|
this.goToRegionWhenReady = false
|
||||||
|
|
||||||
const { search } = this.props.location
|
const { search } = this.props.location
|
||||||
const params = search ? new URLSearchParams(search) : { get: () => null }
|
const params = search ? new URLSearchParams(search) : { get: () => null }
|
||||||
@@ -116,15 +119,22 @@ export class Activity extends React.Component {
|
|||||||
},
|
},
|
||||||
Activity.bindings
|
Activity.bindings
|
||||||
),
|
),
|
||||||
region: {
|
|
||||||
latitude: lat,
|
|
||||||
longitude: lng,
|
|
||||||
latitudeDelta: 0.01,
|
|
||||||
longitudeDelta: 0.01,
|
|
||||||
},
|
|
||||||
location: formatLatLng(lat, lng),
|
location: formatLatLng(lat, lng),
|
||||||
dateTime: moment().format(),
|
dateTime: moment().format(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.region = {
|
||||||
|
latitude: lat,
|
||||||
|
longitude: lng,
|
||||||
|
latitudeDelta: config.activityRegionDelta,
|
||||||
|
longitudeDelta: config.activityRegionDelta,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.isMapReady) {
|
||||||
|
this.mapView.animateToRegion(this.region)
|
||||||
|
} else {
|
||||||
|
this.goToRegionWhenReady = true
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
@@ -170,7 +180,15 @@ export class Activity extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
handleOnMapReady() {
|
||||||
|
if (this.goToRegionWhenReady) {
|
||||||
|
this.mapView.animateToRegion(this.region)
|
||||||
|
this.goToRegionWhenReady = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isMapReady = true
|
||||||
|
}
|
||||||
|
|
||||||
handleMessageDismiss() {
|
handleMessageDismiss() {
|
||||||
const back = this.state.messageModal.back
|
const back = this.state.messageModal.back
|
||||||
this.setState({ messageModal: null })
|
this.setState({ messageModal: null })
|
||||||
@@ -179,7 +197,6 @@ export class Activity extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleBackPress() {
|
handleBackPress() {
|
||||||
const { history } = this.props
|
const { history } = this.props
|
||||||
|
|
||||||
@@ -190,7 +207,6 @@ export class Activity extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleDonePress() {
|
handleDonePress() {
|
||||||
const { binder } = this.state
|
const { binder } = this.state
|
||||||
let obj = binder.getModifiedBindingValues()
|
let obj = binder.getModifiedBindingValues()
|
||||||
@@ -228,7 +244,6 @@ export class Activity extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadStarted() {
|
handleUploadStarted() {
|
||||||
this.setState({
|
this.setState({
|
||||||
progressModal: { message: "Uploading Photo..." },
|
progressModal: { message: "Uploading Photo..." },
|
||||||
@@ -236,7 +251,6 @@ export class Activity extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadProgress(uploadData) {
|
handleUploadProgress(uploadData) {
|
||||||
if (this.state.progressModal) {
|
if (this.state.progressModal) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -250,12 +264,10 @@ export class Activity extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadEnded(successful, uploadData) {
|
handleUploadEnded(successful, uploadData) {
|
||||||
this.setState({ progressModal: null })
|
this.setState({ progressModal: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadCanceled() {
|
handleUploadCanceled() {
|
||||||
this.setState({ progressModal: null })
|
this.setState({ progressModal: null })
|
||||||
}
|
}
|
||||||
@@ -266,7 +278,6 @@ export class Activity extends React.Component {
|
|||||||
messageModal,
|
messageModal,
|
||||||
progressModal,
|
progressModal,
|
||||||
waitModal,
|
waitModal,
|
||||||
region,
|
|
||||||
dateTime,
|
dateTime,
|
||||||
location,
|
location,
|
||||||
uploadPercent,
|
uploadPercent,
|
||||||
@@ -306,6 +317,7 @@ export class Activity extends React.Component {
|
|||||||
<FormStaticInput label="Location:" value={location} />
|
<FormStaticInput label="Location:" value={location} />
|
||||||
<View style={{ flexDirection: "column", justifyContent: "center" }}>
|
<View style={{ flexDirection: "column", justifyContent: "center" }}>
|
||||||
<MapView
|
<MapView
|
||||||
|
ref={(ref) => (this.mapView = ref)}
|
||||||
style={{
|
style={{
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
@@ -324,7 +336,8 @@ export class Activity extends React.Component {
|
|||||||
showsScale={false}
|
showsScale={false}
|
||||||
showsUserLocation
|
showsUserLocation
|
||||||
cacheEnabled
|
cacheEnabled
|
||||||
region={region}
|
initialRegion={config.initialRegion}
|
||||||
|
onMapReady={this.handleOnMapReady}
|
||||||
/>
|
/>
|
||||||
<Icon
|
<Icon
|
||||||
name="target"
|
name="target"
|
||||||
|
|||||||
@@ -56,7 +56,11 @@ export default class App extends React.Component {
|
|||||||
<Route exact path="/login" component={Login} />
|
<Route exact path="/login" component={Login} />
|
||||||
<Route exact path="/logout" component={Logout} />
|
<Route exact path="/logout" component={Logout} />
|
||||||
<ProtectedRoute exact path="/home" component={Home} />
|
<ProtectedRoute exact path="/home" component={Home} />
|
||||||
<ProtectedRoute exact path="/arviewer" component={ARViewer} />
|
<ProtectedRoute
|
||||||
|
exact
|
||||||
|
path="/arviewer"
|
||||||
|
render={(props) => <ARViewer {...props} />}
|
||||||
|
/>
|
||||||
<ProtectedRoute exact path="/activity" component={Activity} />
|
<ProtectedRoute exact path="/activity" component={Activity} />
|
||||||
<ProtectedRoute exact admin path="/workItem" component={WorkItem} />
|
<ProtectedRoute exact admin path="/workItem" component={WorkItem} />
|
||||||
<ProtectedRoute
|
<ProtectedRoute
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { api } from "../API"
|
|||||||
import { BoundSwitch, BoundInput, BoundButton } from "../ui"
|
import { BoundSwitch, BoundInput, BoundButton } from "../ui"
|
||||||
import KeyboardSpacer from "react-native-keyboard-spacer"
|
import KeyboardSpacer from "react-native-keyboard-spacer"
|
||||||
import { versionInfo } from "../version"
|
import { versionInfo } from "../version"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
import { isIphoneX } from "react-native-iphone-x-helper"
|
import { isIphoneX } from "react-native-iphone-x-helper"
|
||||||
import { config } from "../config"
|
import { config } from "../config"
|
||||||
|
|
||||||
@@ -74,6 +74,7 @@ export class Login extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = {
|
this.state = {
|
||||||
binder: new FormBinder(
|
binder: new FormBinder(
|
||||||
{ email: config.defaultUser, rememberMe: true },
|
{ email: config.defaultUser, rememberMe: true },
|
||||||
@@ -92,7 +93,6 @@ export class Login extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleLogin() {
|
handleLogin() {
|
||||||
let obj = this.state.binder.getModifiedBindingValues()
|
let obj = this.state.binder.getModifiedBindingValues()
|
||||||
let { history } = this.props
|
let { history } = this.props
|
||||||
@@ -117,18 +117,15 @@ export class Login extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleMessageDismiss() {
|
handleMessageDismiss() {
|
||||||
this.setState({ messageModal: null })
|
this.setState({ messageModal: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleApiDismiss(backendName) {
|
handleApiDismiss(backendName) {
|
||||||
this.setState({ apiModal: null })
|
this.setState({ apiModal: null })
|
||||||
api.backend = backendName
|
api.backend = backendName
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleApiPress() {
|
handleApiPress() {
|
||||||
this.hiddenTouchCount += 1
|
this.hiddenTouchCount += 1
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,35 @@
|
|||||||
import React from 'react'
|
import React from "react"
|
||||||
import { Route, Redirect } from 'react-router-native'
|
import { Route, Redirect } from "react-router-native"
|
||||||
import { PropTypes } from 'prop-types'
|
import { PropTypes } from "prop-types"
|
||||||
import { api } from '../API'
|
import { api } from "../API"
|
||||||
import autobind from 'autobind-decorator'
|
import { reactAutoBind, autoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class ProtectedRoute extends React.Component {
|
export class ProtectedRoute extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
location: PropTypes.shape({ pathname: PropTypes.string, search: PropTypes.string }),
|
location: PropTypes.shape({
|
||||||
|
pathname: PropTypes.string,
|
||||||
|
search: PropTypes.string,
|
||||||
|
}),
|
||||||
admin: PropTypes.bool,
|
admin: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
}
|
||||||
|
|
||||||
updateComponent() {
|
updateComponent() {
|
||||||
this.forceUpdate()
|
this.forceUpdate()
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
api.addListener('login', this.updateComponent)
|
api.addListener("login", this.updateComponent)
|
||||||
api.addListener('logout', this.updateComponent)
|
api.addListener("logout", this.updateComponent)
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillUnmount() {
|
componentWillUnmount() {
|
||||||
api.removeListener('login', this.updateComponent)
|
api.removeListener("login", this.updateComponent)
|
||||||
api.removeListener('logout', this.updateComponent)
|
api.removeListener("logout", this.updateComponent)
|
||||||
}
|
}
|
||||||
|
|
||||||
render(props) {
|
render(props) {
|
||||||
@@ -32,7 +39,7 @@ export class ProtectedRoute extends React.Component {
|
|||||||
return null
|
return null
|
||||||
} else {
|
} else {
|
||||||
if (!user._id || (this.props.admin && !user.administrator)) {
|
if (!user._id || (this.props.admin && !user.administrator)) {
|
||||||
return <Redirect to='/login' />
|
return <Redirect to="/login" />
|
||||||
} else {
|
} else {
|
||||||
return <Route {...this.props} />
|
return <Route {...this.props} />
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import MapView, { Marker, Callout } from "react-native-maps"
|
|||||||
import { Icon, Header, Geolocation } from "../ui"
|
import { Icon, Header, Geolocation } from "../ui"
|
||||||
import { MessageModal } from "../Modal"
|
import { MessageModal } from "../Modal"
|
||||||
import { api } from "../API"
|
import { api } from "../API"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
import { ifIphoneX } from "react-native-iphone-x-helper"
|
import { ifIphoneX } from "react-native-iphone-x-helper"
|
||||||
import {
|
import {
|
||||||
geoDistance,
|
geoDistance,
|
||||||
@@ -39,14 +39,17 @@ const neverAskForCameraKeyName = "NeverAskForCameraPermission"
|
|||||||
export class Home extends React.Component {
|
export class Home extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = {
|
this.state = {
|
||||||
sections: [],
|
sections: [],
|
||||||
showWorkItems: true,
|
showWorkItems: true,
|
||||||
region: config.initialRegion,
|
|
||||||
haveCameraPermission: false,
|
haveCameraPermission: false,
|
||||||
haveLocationPermission: false,
|
haveLocationPermission: false,
|
||||||
currentPosition: null,
|
currentPosition: null,
|
||||||
}
|
}
|
||||||
|
this.isMapReady = false
|
||||||
|
this.goToRegionWhenReady = false
|
||||||
|
this.region = null
|
||||||
|
|
||||||
if (Platform.OS !== "ios") {
|
if (Platform.OS !== "ios") {
|
||||||
ensurePermissions(
|
ensurePermissions(
|
||||||
@@ -111,12 +114,19 @@ export class Home extends React.Component {
|
|||||||
})
|
})
|
||||||
this.setState({
|
this.setState({
|
||||||
sections: list.items,
|
sections: list.items,
|
||||||
region:
|
|
||||||
regionContainingPoints(
|
|
||||||
list.items.map((item) => item.coordinate),
|
|
||||||
0.02
|
|
||||||
) || this.state.region,
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.region =
|
||||||
|
regionContainingPoints(
|
||||||
|
list.items.map((item) => item.coordinate),
|
||||||
|
config.homeRegionInset
|
||||||
|
) || config.initialRegion
|
||||||
|
|
||||||
|
if (this.isMapReady) {
|
||||||
|
this.mapView.animateToRegion(this.region)
|
||||||
|
} else {
|
||||||
|
this.goToRegionWhenReady = true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -129,12 +139,19 @@ export class Home extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleMessageDismiss() {
|
handleMessageDismiss() {
|
||||||
this.setState({ messageModal: null })
|
this.setState({ messageModal: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
handleOnMapReady() {
|
||||||
|
if (this.goToRegionWhenReady) {
|
||||||
|
this.mapView.animateToRegion(this.region)
|
||||||
|
this.goToRegionWhenReady = false
|
||||||
|
}
|
||||||
|
|
||||||
|
this.isMapReady = true
|
||||||
|
}
|
||||||
|
|
||||||
handleMarkerPress(e, sectionIndex) {
|
handleMarkerPress(e, sectionIndex) {
|
||||||
if (this.sectionList) {
|
if (this.sectionList) {
|
||||||
this.sectionList.scrollToLocation({
|
this.sectionList.scrollToLocation({
|
||||||
@@ -145,7 +162,6 @@ export class Home extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleWorkItemsListPress() {
|
handleWorkItemsListPress() {
|
||||||
if (this.currentPosition) {
|
if (this.currentPosition) {
|
||||||
const { coords } = this.currentPosition
|
const { coords } = this.currentPosition
|
||||||
@@ -156,29 +172,30 @@ export class Home extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleItemSelect(activity) {
|
handleItemSelect(activity) {
|
||||||
this.props.history.push(`/activity?id=${activity._id}`)
|
this.props.history.push(`/activity?id=${activity._id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleSectionSelect(workItem) {
|
handleSectionSelect(workItem) {
|
||||||
|
if (!this.isMapReady) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const { latitude, longitude } = workItem.coordinate
|
const { latitude, longitude } = workItem.coordinate
|
||||||
const region = {
|
|
||||||
|
this.region = {
|
||||||
latitude,
|
latitude,
|
||||||
longitude,
|
longitude,
|
||||||
latitudeDelta: 0.01,
|
latitudeDelta: config.homeRegionDelta,
|
||||||
longitudeDelta: 0.01,
|
longitudeDelta: config.homeRegionDelta,
|
||||||
}
|
}
|
||||||
this.setState({ region })
|
this.mapView.animateToRegion(this.region)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleLogoutPress() {
|
handleLogoutPress() {
|
||||||
this.props.history.replace("/logout")
|
this.props.history.replace("/logout")
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleGlassesPress() {
|
handleGlassesPress() {
|
||||||
const { sections: workItems } = this.state
|
const { sections: workItems } = this.state
|
||||||
|
|
||||||
@@ -217,24 +234,21 @@ export class Home extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleMyLocationPress() {
|
handleMyLocationPress() {
|
||||||
if (this.currentPosition) {
|
if (this.currentPosition && this.isMapReady) {
|
||||||
const coords = this.currentPosition.coords
|
const coords = this.currentPosition.coords
|
||||||
|
|
||||||
this.map.animateToCoordinate({
|
this.mapView.animateToCoordinate({
|
||||||
latitude: coords.latitude,
|
latitude: coords.latitude,
|
||||||
longitude: coords.longitude,
|
longitude: coords.longitude,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleToggleWorkItemsList() {
|
handleToggleWorkItemsList() {
|
||||||
this.setState({ showWorkItems: !this.state.showWorkItems })
|
this.setState({ showWorkItems: !this.state.showWorkItems })
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleCalloutPress(workItem) {
|
handleCalloutPress(workItem) {
|
||||||
if (api.loggedInUser.administrator) {
|
if (api.loggedInUser.administrator) {
|
||||||
this.props.history.push(
|
this.props.history.push(
|
||||||
@@ -245,12 +259,10 @@ export class Home extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handlePositionUpdate(position) {
|
handlePositionUpdate(position) {
|
||||||
this.currentPosition = position
|
this.currentPosition = position
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
getCoordinateDistance(coordinate) {
|
getCoordinateDistance(coordinate) {
|
||||||
if (this.currentPosition) {
|
if (this.currentPosition) {
|
||||||
const coords = this.currentPosition.coords
|
const coords = this.currentPosition.coords
|
||||||
@@ -274,7 +286,6 @@ export class Home extends React.Component {
|
|||||||
const {
|
const {
|
||||||
sections,
|
sections,
|
||||||
showWorkItems,
|
showWorkItems,
|
||||||
region,
|
|
||||||
messageModal,
|
messageModal,
|
||||||
haveCameraPermission,
|
haveCameraPermission,
|
||||||
haveLocationPermission,
|
haveLocationPermission,
|
||||||
@@ -295,7 +306,7 @@ export class Home extends React.Component {
|
|||||||
/>
|
/>
|
||||||
<MapView
|
<MapView
|
||||||
ref={(ref) => {
|
ref={(ref) => {
|
||||||
this.map = ref
|
this.mapView = ref
|
||||||
}}
|
}}
|
||||||
style={[
|
style={[
|
||||||
{
|
{
|
||||||
@@ -310,7 +321,8 @@ export class Home extends React.Component {
|
|||||||
showsIndoors={false}
|
showsIndoors={false}
|
||||||
zoomControlEnabled={false}
|
zoomControlEnabled={false}
|
||||||
showsMyLocationButton={false}
|
showsMyLocationButton={false}
|
||||||
region={region}>
|
initialRegion={config.initialRegion}
|
||||||
|
onMapReady={this.handleOnMapReady}>
|
||||||
{sections.map((workItem, index) => (
|
{sections.map((workItem, index) => (
|
||||||
<Marker
|
<Marker
|
||||||
key={index}
|
key={index}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Modal from "react-native-modal"
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { View, Text, TouchableOpacity } from "react-native"
|
import { View, Text, TouchableOpacity } from "react-native"
|
||||||
import { Icon, OptionStrip } from "../ui"
|
import { Icon, OptionStrip } from "../ui"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
import { api } from "../API"
|
import { api } from "../API"
|
||||||
|
|
||||||
export class ApiModal extends Component {
|
export class ApiModal extends Component {
|
||||||
@@ -14,12 +14,12 @@ export class ApiModal extends Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = {
|
this.state = {
|
||||||
value: api.backend,
|
value: api.backend,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleButtonPress() {
|
handleButtonPress() {
|
||||||
const { onDismiss } = this.props
|
const { onDismiss } = this.props
|
||||||
|
|
||||||
@@ -28,7 +28,6 @@ export class ApiModal extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleValueChanged(newValue) {
|
handleValueChanged(newValue) {
|
||||||
this.setState({ value: newValue })
|
this.setState({ value: newValue })
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Modal from "react-native-modal"
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { View, Image, TouchableOpacity } from "react-native"
|
import { View, Image, TouchableOpacity } from "react-native"
|
||||||
import { Icon } from "../ui"
|
import { Icon } from "../ui"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class ImageViewerModal extends Component {
|
export class ImageViewerModal extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -12,7 +12,11 @@ export class ImageViewerModal extends Component {
|
|||||||
onDismiss: PropTypes.func,
|
onDismiss: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
}
|
||||||
|
|
||||||
handleButtonPress() {
|
handleButtonPress() {
|
||||||
const { onDismiss } = this.props
|
const { onDismiss } = this.props
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import Modal from "react-native-modal"
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { View, Text, TouchableOpacity } from "react-native"
|
import { View, Text, TouchableOpacity } from "react-native"
|
||||||
import { Icon } from "../ui"
|
import { Icon } from "../ui"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class MessageModal extends Component {
|
export class MessageModal extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -14,7 +14,11 @@ export class MessageModal extends Component {
|
|||||||
onDismiss: PropTypes.func,
|
onDismiss: PropTypes.func,
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
constructor(props) {
|
||||||
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
}
|
||||||
|
|
||||||
handleButtonPress() {
|
handleButtonPress() {
|
||||||
if (this.props.onDismiss) {
|
if (this.props.onDismiss) {
|
||||||
this.props.onDismiss()
|
this.props.onDismiss()
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ import Modal from "react-native-modal"
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { View, Text, ActivityIndicator, TouchableOpacity } from "react-native"
|
import { View, Text, ActivityIndicator, TouchableOpacity } from "react-native"
|
||||||
import { ProgressBar } from "../ui"
|
import { ProgressBar } from "../ui"
|
||||||
import autobind from "autobind-decorator"
|
|
||||||
|
|
||||||
export class ProgressModal extends Component {
|
export class ProgressModal extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import {
|
|||||||
Geolocation,
|
Geolocation,
|
||||||
} from "../ui"
|
} from "../ui"
|
||||||
import { MessageModal, ProgressModal, WaitModal } from "../Modal"
|
import { MessageModal, ProgressModal, WaitModal } from "../Modal"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
import { ifIphoneX, isIphoneX } from "react-native-iphone-x-helper"
|
import { ifIphoneX, isIphoneX } from "react-native-iphone-x-helper"
|
||||||
import KeyboardSpacer from "react-native-keyboard-spacer"
|
import KeyboardSpacer from "react-native-keyboard-spacer"
|
||||||
import { api } from "../API"
|
import { api } from "../API"
|
||||||
@@ -93,14 +93,17 @@ export class WorkItem extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
|
||||||
this.state = {
|
this.state = {
|
||||||
binder: new FormBinder({}, WorkItem.bindings),
|
binder: new FormBinder({}, WorkItem.bindings),
|
||||||
messageModal: null,
|
messageModal: null,
|
||||||
waitModal: null,
|
waitModal: null,
|
||||||
progressModal: null,
|
progressModal: null,
|
||||||
region: config.initialRegion,
|
|
||||||
}
|
}
|
||||||
|
this.region = null
|
||||||
|
this.isMapReady = false
|
||||||
|
this.goToRegionWhenReady = false
|
||||||
|
|
||||||
const { search } = this.props.location
|
const { search } = this.props.location
|
||||||
const params = search ? new URLSearchParams(search) : { get: () => null }
|
const params = search ? new URLSearchParams(search) : { get: () => null }
|
||||||
@@ -112,17 +115,18 @@ export class WorkItem extends React.Component {
|
|||||||
.then((workItem) => {
|
.then((workItem) => {
|
||||||
if (workItem) {
|
if (workItem) {
|
||||||
const [longitude, latitude] = workItem.location.coordinates
|
const [longitude, latitude] = workItem.location.coordinates
|
||||||
const region = {
|
|
||||||
|
this.region = {
|
||||||
latitude,
|
latitude,
|
||||||
longitude,
|
longitude,
|
||||||
latitudeDelta: 0.01,
|
latitudeDelta: config.workItemRegionDelta,
|
||||||
longitudeDelta: 0.01,
|
longitudeDelta: config.workItemRegionDelta,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.mapView) {
|
if (this.isMapReady) {
|
||||||
this.mapView.animateToRegion(region)
|
this.mapView.animateToRegion(this.region)
|
||||||
} else {
|
} else {
|
||||||
this.goToRegion = region
|
this.goToRegionWhenReady = true
|
||||||
}
|
}
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -149,7 +153,6 @@ export class WorkItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleBackPress() {
|
handleBackPress() {
|
||||||
const { history } = this.props
|
const { history } = this.props
|
||||||
|
|
||||||
@@ -160,7 +163,6 @@ export class WorkItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleDonePress() {
|
handleDonePress() {
|
||||||
const { binder } = this.state
|
const { binder } = this.state
|
||||||
let obj = binder.getModifiedBindingValues()
|
let obj = binder.getModifiedBindingValues()
|
||||||
@@ -198,7 +200,6 @@ export class WorkItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleMessageDismiss() {
|
handleMessageDismiss() {
|
||||||
const back = this.state.messageModal.back
|
const back = this.state.messageModal.back
|
||||||
this.setState({ messageModal: null })
|
this.setState({ messageModal: null })
|
||||||
@@ -207,10 +208,11 @@ export class WorkItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleRegionChange(region) {
|
handleRegionChange(region) {
|
||||||
const { latitude, longitude } = region
|
const { latitude, longitude } = region
|
||||||
|
|
||||||
|
this.region = region
|
||||||
|
|
||||||
if (this.latLngInput) {
|
if (this.latLngInput) {
|
||||||
this.latLngInput.handleChangeText(formatLatLng(latitude, longitude))
|
this.latLngInput.handleChangeText(formatLatLng(latitude, longitude))
|
||||||
}
|
}
|
||||||
@@ -226,15 +228,15 @@ export class WorkItem extends React.Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleOnMapReady() {
|
handleOnMapReady() {
|
||||||
if (this.goToRegion && this.mapView) {
|
if (this.goToRegionWhenReady) {
|
||||||
this.mapView.animateToRegion(this.goToRegion)
|
this.mapView.animateToRegion(this.region)
|
||||||
this.goToRegion = null
|
this.goToRegionWhenReady = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.isMapReady = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleStartAddressLookup(latLng) {
|
handleStartAddressLookup(latLng) {
|
||||||
api
|
api
|
||||||
.getAddress(latLng)
|
.getAddress(latLng)
|
||||||
@@ -250,7 +252,6 @@ export class WorkItem extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadStarted() {
|
handleUploadStarted() {
|
||||||
this.setState({
|
this.setState({
|
||||||
progressModal: { message: "Uploading Photo..." },
|
progressModal: { message: "Uploading Photo..." },
|
||||||
@@ -258,7 +259,6 @@ export class WorkItem extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadProgress(uploadData) {
|
handleUploadProgress(uploadData) {
|
||||||
if (this.state.progressModal) {
|
if (this.state.progressModal) {
|
||||||
this.setState({
|
this.setState({
|
||||||
@@ -272,35 +272,36 @@ export class WorkItem extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadEnded(successful, uploadData) {
|
handleUploadEnded(successful, uploadData) {
|
||||||
this.setState({ progressModal: null })
|
this.setState({ progressModal: null })
|
||||||
|
this.mapView.animateToRegion(this.region)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleUploadCanceled() {
|
handleUploadCanceled() {
|
||||||
this.setState({ progressModal: null })
|
this.setState({ progressModal: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleAddActivity() {
|
handleAddActivity() {
|
||||||
if (this.props.history) {
|
if (this.props.history) {
|
||||||
this.props.history.push(`/activity?workItemId=${this.state.binder._id}`)
|
this.props.history.push(`/activity?workItemId=${this.state.binder._id}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handlePositionUpdate(position) {
|
handlePositionUpdate(position) {
|
||||||
const { coords } = position
|
const { coords } = position
|
||||||
|
|
||||||
this.setState({
|
this.region = {
|
||||||
region: {
|
latitude: coords.latitude,
|
||||||
latitude: coords.latitude,
|
longitude: coords.longitude,
|
||||||
longitude: coords.longitude,
|
latitudeDelta: config.workItemRegionDelta,
|
||||||
latitudeDelta: 0.02,
|
longitudeDelta: config.workItemRegionDelta,
|
||||||
longitudeDelta: 0.02,
|
}
|
||||||
},
|
|
||||||
})
|
if (this.isMapReady) {
|
||||||
|
this.mapView.animateToRegion(this.region)
|
||||||
|
} else {
|
||||||
|
this.goToRegionWhenReady = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
@@ -310,7 +311,6 @@ export class WorkItem extends React.Component {
|
|||||||
waitModal,
|
waitModal,
|
||||||
progressModal,
|
progressModal,
|
||||||
uploadPercent,
|
uploadPercent,
|
||||||
region,
|
|
||||||
} = this.state
|
} = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -358,10 +358,11 @@ export class WorkItem extends React.Component {
|
|||||||
rotateEnabled={false}
|
rotateEnabled={false}
|
||||||
pitchEnabled={false}
|
pitchEnabled={false}
|
||||||
showsUserLocation
|
showsUserLocation
|
||||||
|
showsMyLocationButton
|
||||||
showsBuildings={false}
|
showsBuildings={false}
|
||||||
showsTraffic={false}
|
showsTraffic={false}
|
||||||
showsIndoors={false}
|
showsIndoors={false}
|
||||||
region={region}
|
initialRegion={config.initialRegion}
|
||||||
onRegionChange={this.handleRegionChange}
|
onRegionChange={this.handleRegionChange}
|
||||||
onMapReady={this.handleOnMapReady}
|
onMapReady={this.handleOnMapReady}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
} from "react-native"
|
} from "react-native"
|
||||||
import { Icon, Header } from "../ui"
|
import { Icon, Header } from "../ui"
|
||||||
import { MessageModal } from "../Modal"
|
import { MessageModal } from "../Modal"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
import { SwipeListView } from "react-native-swipe-list-view"
|
import { SwipeListView } from "react-native-swipe-list-view"
|
||||||
import { api } from "../API"
|
import { api } from "../API"
|
||||||
import {
|
import {
|
||||||
@@ -36,6 +36,7 @@ const styles = StyleSheet.create({
|
|||||||
export class WorkItemList extends React.Component {
|
export class WorkItemList extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = {
|
this.state = {
|
||||||
messageModal: null,
|
messageModal: null,
|
||||||
}
|
}
|
||||||
@@ -74,12 +75,10 @@ export class WorkItemList extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleItemSelect(item, ref) {
|
handleItemSelect(item, ref) {
|
||||||
this.props.history.push(`/workItem?id=${item._id}`)
|
this.props.history.push(`/workItem?id=${item._id}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleItemDelete(item, ref) {
|
handleItemDelete(item, ref) {
|
||||||
api
|
api
|
||||||
.deleteWorkItem(item._id)
|
.deleteWorkItem(item._id)
|
||||||
@@ -110,17 +109,14 @@ export class WorkItemList extends React.Component {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleMessageDismiss() {
|
handleMessageDismiss() {
|
||||||
this.setState({ messageModal: null })
|
this.setState({ messageModal: null })
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleDonePress() {
|
handleDonePress() {
|
||||||
this.props.history.push("/workItem")
|
this.props.history.push("/workItem")
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleBackPress() {
|
handleBackPress() {
|
||||||
const { history } = this.props
|
const { history } = this.props
|
||||||
|
|
||||||
|
|||||||
@@ -10,21 +10,25 @@ export const config = {
|
|||||||
refererURL: "https://dar.kss.us.com",
|
refererURL: "https://dar.kss.us.com",
|
||||||
minDistanceToItem: 20,
|
minDistanceToItem: 20,
|
||||||
geocodeDelayMilliseconds: 500,
|
geocodeDelayMilliseconds: 500,
|
||||||
//defaultUser: "john@lyon-smith.org",
|
defaultUser: "john@lyon-smith.org",
|
||||||
defaultUser: "",
|
//defaultUser: "",
|
||||||
// This region is downtown Toronto
|
// This region is downtown Toronto
|
||||||
initialRegion: {
|
|
||||||
latitude: 43.653908,
|
|
||||||
longitude: -79.384293,
|
|
||||||
latitudeDelta: 0.0922,
|
|
||||||
longitudeDelta: 0.0421,
|
|
||||||
},
|
|
||||||
// This region is Bainbridge Island
|
|
||||||
// initialRegion: {
|
// initialRegion: {
|
||||||
// latitude: 47.629536,
|
// latitude: 43.653908,
|
||||||
// longitude: -122.524162,
|
// longitude: -79.384293,
|
||||||
// latitudeDelta: 0.0922,
|
// latitudeDelta: 0.0922,
|
||||||
// longitudeDelta: 0.0421,
|
// longitudeDelta: 0.0421,
|
||||||
// },
|
// },
|
||||||
// alwaysShowWorkItemInAR: true,
|
// This region is Bainbridge Island
|
||||||
|
initialRegion: {
|
||||||
|
latitude: 47.629536,
|
||||||
|
longitude: -122.524162,
|
||||||
|
latitudeDelta: 0.0922,
|
||||||
|
longitudeDelta: 0.0421,
|
||||||
|
},
|
||||||
|
workItemRegionDelta: 0.005,
|
||||||
|
activityRegionDelta: 0.005,
|
||||||
|
homeRegionInset: 0.02,
|
||||||
|
homeRegionDelta: 0.005,
|
||||||
|
alwaysShowWorkItemInAR: true,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { View, Text, TouchableHighlight } from "react-native"
|
import { View, Text, TouchableHighlight } from "react-native"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class BoundButton extends React.Component {
|
export class BoundButton extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -14,6 +14,7 @@ export class BoundButton extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
|
||||||
const { name, binder } = this.props
|
const { name, binder } = this.props
|
||||||
|
|
||||||
@@ -21,7 +22,6 @@ export class BoundButton extends React.Component {
|
|||||||
this.state = binder.getBindingState(name)
|
this.state = binder.getBindingState(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
updateValue(e) {
|
updateValue(e) {
|
||||||
this.setState(e.state)
|
this.setState(e.state)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { Header } from "."
|
import { Header } from "."
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
const headerButtonShape = {
|
const headerButtonShape = {
|
||||||
icon: PropTypes.string.isRequired,
|
icon: PropTypes.string.isRequired,
|
||||||
@@ -19,6 +19,7 @@ export class BoundHeader extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
|
||||||
const { name, binder } = this.props
|
const { name, binder } = this.props
|
||||||
|
|
||||||
@@ -26,7 +27,6 @@ export class BoundHeader extends React.Component {
|
|||||||
this.state = binder.getBindingState(name)
|
this.state = binder.getBindingState(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
updateValue(e) {
|
updateValue(e) {
|
||||||
this.setState(e.state)
|
this.setState(e.state)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { TextInput, Text, View, Platform } from "react-native"
|
import { TextInput, Text, View, Platform } from "react-native"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class BoundInput extends React.Component {
|
export class BoundInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -20,11 +20,11 @@ export class BoundInput extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
|
|
||||||
const { name, binder } = this.props
|
const { name, binder } = this.props
|
||||||
|
|
||||||
this.state = binder.getBindingState(name)
|
this.state = binder.getBindingState(name)
|
||||||
this.handleChangeText = this.handleChangeText.bind(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
@@ -33,7 +33,6 @@ export class BoundInput extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// @autobind : There seems to be a bug with using this here, so we just do it the old way
|
|
||||||
handleChangeText(newText) {
|
handleChangeText(newText) {
|
||||||
const { binder, name } = this.props
|
const { binder, name } = this.props
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from "react"
|
|||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { View, Text } from "react-native"
|
import { View, Text } from "react-native"
|
||||||
import { OptionStrip } from "."
|
import { OptionStrip } from "."
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class BoundOptionStrip extends React.Component {
|
export class BoundOptionStrip extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -17,10 +17,10 @@ export class BoundOptionStrip extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = props.binder.getBindingState(props.name)
|
this.state = props.binder.getBindingState(props.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleValueChanged(newValue) {
|
handleValueChanged(newValue) {
|
||||||
this.setState(
|
this.setState(
|
||||||
this.props.binder.updateBindingValue(this.props.name, newValue)
|
this.props.binder.updateBindingValue(this.props.name, newValue)
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import {
|
|||||||
import { Icon } from "."
|
import { Icon } from "."
|
||||||
import ImagePicker from "react-native-image-picker"
|
import ImagePicker from "react-native-image-picker"
|
||||||
import ImageResizer from "react-native-image-resizer"
|
import ImageResizer from "react-native-image-resizer"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
import { api } from "../API"
|
import { api } from "../API"
|
||||||
|
|
||||||
const getScreenPortraitDimensions = () => {
|
const getScreenPortraitDimensions = () => {
|
||||||
@@ -35,10 +35,8 @@ export class BoundPhotoPanel extends Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
const { name, binder } = this.props
|
this.state = this.props.binder.getBindingState(this.props.name)
|
||||||
|
|
||||||
this.state = binder.getBindingState(name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
componentWillReceiveProps(nextProps) {
|
componentWillReceiveProps(nextProps) {
|
||||||
@@ -47,7 +45,6 @@ export class BoundPhotoPanel extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handlePhotoPress(index) {
|
handlePhotoPress(index) {
|
||||||
const { onUploadStarted, onUploadEnded, onUploadProgress } = this.props
|
const { onUploadStarted, onUploadEnded, onUploadProgress } = this.props
|
||||||
|
|
||||||
@@ -98,7 +95,6 @@ export class BoundPhotoPanel extends Component {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleLayout(e) {
|
handleLayout(e) {
|
||||||
if (!this.state.photoSize) {
|
if (!this.state.photoSize) {
|
||||||
const { layout } = e.nativeEvent
|
const { layout } = e.nativeEvent
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { View, Switch, Text } from "react-native"
|
import { View, Switch, Text } from "react-native"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class BoundSwitch extends React.Component {
|
export class BoundSwitch extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -12,10 +12,10 @@ export class BoundSwitch extends React.Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = props.binder.getBindingState(props.name)
|
this.state = props.binder.getBindingState(props.name)
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handleValueChange(newValue) {
|
handleValueChange(newValue) {
|
||||||
const { binder, name } = this.props
|
const { binder, name } = this.props
|
||||||
const state = binder.getBindingState(name)
|
const state = binder.getBindingState(name)
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import { TextInput, Text, View, Platform } from "react-native"
|
import { TextInput, Text, View, Platform } from "react-native"
|
||||||
import autobind from "autobind-decorator"
|
|
||||||
|
|
||||||
export class FormStaticInput extends React.Component {
|
export class FormStaticInput extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import React, { Component } from "react"
|
import React, { Component } from "react"
|
||||||
import { Image, View } from "react-native"
|
import { Image, View } from "react-native"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import autobind from "autobind-decorator"
|
|
||||||
|
|
||||||
export class Geolocation extends Component {
|
export class Geolocation extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { Component } from "react"
|
import React, { Component } from "react"
|
||||||
import { View, Text, TouchableHighlight } from "react-native"
|
import { View, Text, TouchableHighlight } from "react-native"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
import autobind from "autobind-decorator"
|
import { reactAutoBind } from "auto-bind2"
|
||||||
|
|
||||||
export class OptionStrip extends Component {
|
export class OptionStrip extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -14,12 +14,12 @@ export class OptionStrip extends Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
reactAutoBind(this)
|
||||||
this.state = {
|
this.state = {
|
||||||
selectedOption: this.getSelectedOption(props.options, props.value),
|
selectedOption: this.getSelectedOption(props.options, props.value),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
getSelectedOption(options, value) {
|
getSelectedOption(options, value) {
|
||||||
return options.find((option) => value === option.value) || null
|
return options.find((option) => value === option.value) || null
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,6 @@ export class OptionStrip extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
handlePress(option) {
|
handlePress(option) {
|
||||||
const { onValueChanged } = this.props
|
const { onValueChanged } = this.props
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const versionInfo = {
|
export const versionInfo = {
|
||||||
version: '1.0.1',
|
version: '1.1.0',
|
||||||
fullVersion: '1.0.1-20180518.0',
|
fullVersion: '1.1.0-20180525.0',
|
||||||
title: 'Deighton AR System',
|
title: 'Deighton AR System',
|
||||||
copyright: '© 2018, Kingston Software Solutions.',
|
copyright: '© 2018, Kingston Software Solutions.',
|
||||||
supportEmail: 'support@kss.us.com',
|
supportEmail: 'support@kss.us.com',
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "deighton-ar",
|
"name": "deighton-ar",
|
||||||
"version": "1.0.1",
|
"version": "1.1.0",
|
||||||
"description": "Deighton AR Training System",
|
"description": "Deighton AR Training System",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"repository": {
|
"repository": {
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
maxPasswordTokenAgeInHours: 3,
|
maxPasswordTokenAgeInHours: 3,
|
||||||
sendEmailDelayInSeconds: 3,
|
sendEmailDelayInSeconds: 3,
|
||||||
supportEmail: 'support@kss.us.com',
|
supportEmail: 'support@kss.us.com',
|
||||||
sendEmail: true
|
sendEmail: true,
|
||||||
|
appName: "Deighton AR Test",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
maxPasswordTokenAgeInHours: 3,
|
maxPasswordTokenAgeInHours: 3,
|
||||||
sendEmailDelayInSeconds: 3,
|
sendEmailDelayInSeconds: 3,
|
||||||
supportEmail: 'support@kss.us.com',
|
supportEmail: 'support@kss.us.com',
|
||||||
sendEmail: true
|
sendEmail: true,
|
||||||
|
appName: "Deighton AR",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
"start": "babel-node src/server.js",
|
"start": "babel-node src/server.js",
|
||||||
"start:prod": "NODE_ENV=production node dist/server.js",
|
"start:prod": "NODE_ENV=production node dist/server.js",
|
||||||
"build": "rm -rf dist && babel src -d dist -s",
|
"build": "rm -rf dist && babel src -d dist -s",
|
||||||
"deploy": "rsync -vr -e ssh --exclude-from .rsync-exclude * $SNAP_DEPLOY_USER@$SNAP_DEPLOY_HOST:deighton-ar-server/ && ssh $SNAP_DEPLOY_USER@$SNAP_DEPLOY_HOST 'cd deighton-ar-server; npm install; sudo ./ops restart; sudo ./ops --test restart'",
|
"deploy": "rsync -vr -e ssh --exclude-from .rsync-exclude * $SNAP_DEPLOY_USER_HOST:deighton-ar-server/ && ssh $SNAP_DEPLOY_USER_HOST 'cd deighton-ar-server; npm install; sudo ./ops restart; sudo ./ops --test restart'",
|
||||||
"test": "jest",
|
"test": "jest",
|
||||||
"actor:api": "monzilla 'src/api/**/*.js:src/database/**/*.js' -- babel-node src/api/index.js",
|
"actor:api": "monzilla 'src/api/**/*.js:src/database/**/*.js' -- babel-node src/api/index.js",
|
||||||
"actor:api:debug": "babel-node --inspect-brk src/api/index.js",
|
"actor:api:debug": "babel-node --inspect-brk src/api/index.js",
|
||||||
|
|||||||
@@ -8,22 +8,7 @@ import config from "config"
|
|||||||
import autobind from "autobind-decorator"
|
import autobind from "autobind-decorator"
|
||||||
import { PassThrough } from "stream"
|
import { PassThrough } from "stream"
|
||||||
import { catchAll } from "."
|
import { catchAll } from "."
|
||||||
|
import { pipeToPromise } from "../../util"
|
||||||
function pipeToGridFS(readable, writeable) {
|
|
||||||
const promise = new Promise((resolve, reject) => {
|
|
||||||
readable.on("error", (error) => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
writeable.on("error", (error) => {
|
|
||||||
reject(error)
|
|
||||||
})
|
|
||||||
writeable.on("finish", (file) => {
|
|
||||||
resolve(file)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
readable.pipe(writeable)
|
|
||||||
return promise
|
|
||||||
}
|
|
||||||
|
|
||||||
@autobind
|
@autobind
|
||||||
export class AssetRoutes {
|
export class AssetRoutes {
|
||||||
@@ -109,7 +94,7 @@ export class AssetRoutes {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async beginAssetUpload(req, res, next) {
|
async beginAssetUpload(req, res, next) {
|
||||||
const uploadId = this.db.newObjectId()
|
const uploadId = this.db.newObjectId().toString()
|
||||||
let {
|
let {
|
||||||
fileName,
|
fileName,
|
||||||
uploadSize,
|
uploadSize,
|
||||||
@@ -224,12 +209,12 @@ export class AssetRoutes {
|
|||||||
if (uploadedChunks >= uploadData.numberOfChunks) {
|
if (uploadedChunks >= uploadData.numberOfChunks) {
|
||||||
let readable = redisReadStream(this.rs.client, uploadDataId)
|
let readable = redisReadStream(this.rs.client, uploadDataId)
|
||||||
let writeable = this.db.gridfs.openUploadStreamWithId(
|
let writeable = this.db.gridfs.openUploadStreamWithId(
|
||||||
uploadId,
|
this.db.newObjectId(uploadId),
|
||||||
uploadData.fileName,
|
uploadData.fileName,
|
||||||
{ contentType: uploadData.contentType }
|
{ contentType: uploadData.contentType }
|
||||||
)
|
)
|
||||||
|
|
||||||
const file = await pipeToGridFS(readable, writeable)
|
const file = await pipeToPromise(readable, writeable)
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.rs.del(uploadId),
|
this.rs.del(uploadId),
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ export class AuthRoutes {
|
|||||||
this.sendEmailDelayInSeconds = config.get("email.sendEmailDelayInSeconds")
|
this.sendEmailDelayInSeconds = config.get("email.sendEmailDelayInSeconds")
|
||||||
this.supportEmail = config.get("email.supportEmail")
|
this.supportEmail = config.get("email.supportEmail")
|
||||||
this.sendEmail = config.get("email.sendEmail")
|
this.sendEmail = config.get("email.sendEmail")
|
||||||
|
this.appName = config.get("email.appName")
|
||||||
|
this.emailServiceName = config.get("serviceName.email")
|
||||||
app
|
app
|
||||||
.route("/auth/login")
|
.route("/auth/login")
|
||||||
// Used to login. Email must be confirmed.
|
// Used to login. Email must be confirmed.
|
||||||
@@ -208,11 +210,12 @@ export class AuthRoutes {
|
|||||||
siteUrl.host
|
siteUrl.host
|
||||||
}/confirm-email?email-token%3D${savedUser.emailToken.value}`,
|
}/confirm-email?email-token%3D${savedUser.emailToken.value}`,
|
||||||
supportEmail: this.supportEmail,
|
supportEmail: this.supportEmail,
|
||||||
|
appName: this.appName,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msgs)
|
await this.mq.request(this.emailServiceName, "sendEmail", msgs)
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({})
|
res.json({})
|
||||||
@@ -393,10 +396,11 @@ export class AuthRoutes {
|
|||||||
siteUrl.host
|
siteUrl.host
|
||||||
}/reset-password?password-token%3D${savedUser.passwordToken.value}`,
|
}/reset-password?password-token%3D${savedUser.passwordToken.value}`,
|
||||||
supportEmail: this.supportEmail,
|
supportEmail: this.supportEmail,
|
||||||
|
appName: this.appName,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msg)
|
await this.mq.request(this.emailServiceName, "sendEmail", msg)
|
||||||
}
|
}
|
||||||
|
|
||||||
res.json({})
|
res.json({})
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ export class TeamRoutes extends BaseRoutes {
|
|||||||
|
|
||||||
res.writeHead(200, {
|
res.writeHead(200, {
|
||||||
"Content-Type": "application/gzip",
|
"Content-Type": "application/gzip",
|
||||||
"Content-Disposition": 'attachment; filename="team-scores.gzip"',
|
"Content-Disposition": 'attachment; filename="team-scores.json.gzip"',
|
||||||
})
|
})
|
||||||
readable.pipe(gzip).pipe(res)
|
readable.pipe(gzip).pipe(res)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ export class UserRoutes {
|
|||||||
this.ws = container.ws
|
this.ws = container.ws
|
||||||
this.maxEmailTokenAgeInHours = config.get("email.maxEmailTokenAgeInHours")
|
this.maxEmailTokenAgeInHours = config.get("email.maxEmailTokenAgeInHours")
|
||||||
this.sendEmail = config.get("email.sendEmail")
|
this.sendEmail = config.get("email.sendEmail")
|
||||||
|
this.emailServiceName = config.get("serviceName.email")
|
||||||
|
|
||||||
app
|
app
|
||||||
.route("/users")
|
.route("/users")
|
||||||
.get(
|
.get(
|
||||||
@@ -164,7 +166,7 @@ export class UserRoutes {
|
|||||||
res.json(savedUser.toClient())
|
res.json(savedUser.toClient())
|
||||||
|
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msg)
|
await this.mq.request(this.emailServiceName, "sendEmail", msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +246,7 @@ export class UserRoutes {
|
|||||||
res.json({})
|
res.json({})
|
||||||
|
|
||||||
if (this.sendEmail) {
|
if (this.sendEmail) {
|
||||||
await this.mq.request("dar-email", "sendEmail", msg)
|
await this.mq.request(this.emailServiceName, "sendEmail", msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,6 +25,15 @@ export class WorkItemRoutes extends BaseRoutes {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async deleteItem(req, res, next) {
|
||||||
|
super.deleteItem(req, res, next)
|
||||||
|
|
||||||
|
const id = req.params._id
|
||||||
|
const Activity = this.db.Activity
|
||||||
|
|
||||||
|
await Activity.remove({ workItem: id })
|
||||||
|
}
|
||||||
|
|
||||||
async listWorkItemActivities(req, res, next) {
|
async listWorkItemActivities(req, res, next) {
|
||||||
const WorkItem = this.db.WorkItem
|
const WorkItem = this.db.WorkItem
|
||||||
const aggregate = WorkItem.aggregate()
|
const aggregate = WorkItem.aggregate()
|
||||||
|
|||||||
39
server/src/util.js
Normal file
39
server/src/util.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import stream from "stream"
|
||||||
|
|
||||||
|
export function streamToBuffer(readable) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
var chunks = []
|
||||||
|
var writeable = new stream.Writable()
|
||||||
|
|
||||||
|
writeable._write = function(chunk, enc, done) {
|
||||||
|
chunks.push(chunk)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
|
||||||
|
readable.on("end", function() {
|
||||||
|
resolve(Buffer.concat(chunks))
|
||||||
|
})
|
||||||
|
|
||||||
|
readable.on("error", (err) => {
|
||||||
|
reject(err)
|
||||||
|
})
|
||||||
|
|
||||||
|
readable.pipe(writeable)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pipeToPromise(readable, writeable) {
|
||||||
|
const promise = new Promise((resolve, reject) => {
|
||||||
|
readable.on("error", (error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
writeable.on("error", (error) => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
writeable.on("finish", (file) => {
|
||||||
|
resolve(file)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
readable.pipe(writeable)
|
||||||
|
return promise
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
export const versionInfo = {
|
export const versionInfo = {
|
||||||
version: '1.0.1',
|
version: '1.1.0',
|
||||||
fullVersion: '1.0.1-20180518.0',
|
fullVersion: '1.1.0-20180525.0',
|
||||||
title: 'Deighton AR System',
|
title: 'Deighton AR System',
|
||||||
copyright: '© 2018, Kingston Software Solutions.',
|
copyright: '© 2018, Kingston Software Solutions.',
|
||||||
supportEmail: 'support@kss.us.com',
|
supportEmail: 'support@kss.us.com',
|
||||||
|
|||||||
@@ -15,11 +15,11 @@
|
|||||||
buildFormat: "full",
|
buildFormat: "full",
|
||||||
tags: {
|
tags: {
|
||||||
major: 1,
|
major: 1,
|
||||||
minor: 0,
|
minor: 1,
|
||||||
patch: 1,
|
patch: 0,
|
||||||
build: 20180518,
|
build: 20180525,
|
||||||
revision: 0,
|
revision: 0,
|
||||||
sequence: 4,
|
sequence: 6,
|
||||||
tz: "America/Los_Angeles",
|
tz: "America/Los_Angeles",
|
||||||
title: "Deighton AR System",
|
title: "Deighton AR System",
|
||||||
copyright: "© 2018, Kingston Software Solutions.",
|
copyright: "© 2018, Kingston Software Solutions.",
|
||||||
|
|||||||
@@ -62,7 +62,7 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node scripts/start.js",
|
"start": "node scripts/start.js",
|
||||||
"build": "node scripts/build.js",
|
"build": "node scripts/build.js",
|
||||||
"deploy": "rsync -vr -e ssh build/* $SNAP_DEPLOY_USER@$SNAP_DEPLOY_HOST:deighton-ar-website/",
|
"deploy": "rsync -vr -e ssh build/* $SNAP_DEPLOY_USER_HOST:deighton-ar-website/",
|
||||||
"lint": "eslint --ext .js --ext .jsx src/",
|
"lint": "eslint --ext .js --ext .jsx src/",
|
||||||
"lint:fix": "eslint --ext .js --ext .jsx --fix src/"
|
"lint:fix": "eslint --ext .js --ext .jsx --fix src/"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -52,12 +52,12 @@ class API extends EventEmitter {
|
|||||||
localStorage.removeItem(authTokenKeyName)
|
localStorage.removeItem(authTokenKeyName)
|
||||||
sessionStorage.removeItem(authTokenKeyName)
|
sessionStorage.removeItem(authTokenKeyName)
|
||||||
this._token = null
|
this._token = null
|
||||||
this._user = {}
|
this._user = { loggedOut: true }
|
||||||
this.socket = null
|
this.socket = null
|
||||||
this.emit("logout")
|
this.emit("logout")
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
this._user = {}
|
this._user = { loggedOut: true }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -229,7 +229,7 @@ class API extends EventEmitter {
|
|||||||
localStorage.removeItem(authTokenKeyName)
|
localStorage.removeItem(authTokenKeyName)
|
||||||
sessionStorage.removeItem(authTokenKeyName)
|
sessionStorage.removeItem(authTokenKeyName)
|
||||||
this._token = null
|
this._token = null
|
||||||
this._user = {}
|
this._user = { loggedOut: true }
|
||||||
this.disconnectSocket()
|
this.disconnectSocket()
|
||||||
this.emit("logout")
|
this.emit("logout")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import React, { Component } from "react"
|
|||||||
import {
|
import {
|
||||||
Login,
|
Login,
|
||||||
Logout,
|
Logout,
|
||||||
|
Parking,
|
||||||
ResetPassword,
|
ResetPassword,
|
||||||
ForgotPassword,
|
ForgotPassword,
|
||||||
ConfirmEmail,
|
ConfirmEmail,
|
||||||
@@ -29,18 +30,38 @@ export class App extends Component {
|
|||||||
<BrowserRouter>
|
<BrowserRouter>
|
||||||
<Column minHeight="100vh">
|
<Column minHeight="100vh">
|
||||||
<Route
|
<Route
|
||||||
path="/app"
|
path="/admin"
|
||||||
render={(props) => (
|
render={(props) => (
|
||||||
<Column.Item height={sizeInfo.headerHeight}>
|
<Column.Item height={sizeInfo.headerHeight}>
|
||||||
<Header
|
<Header
|
||||||
{...props}
|
{...props}
|
||||||
left={[
|
left={[
|
||||||
{ image: require("images/badge.png"), path: "/app/home" },
|
{ image: require("images/badge.png"), path: "/admin/home" },
|
||||||
{ text: "Teams", path: "/app/teams" },
|
{ text: "Teams", path: "/admin/teams" },
|
||||||
{ text: "Users", path: "/app/users" },
|
{ text: "Users", path: "/admin/users" },
|
||||||
]}
|
]}
|
||||||
right={[
|
right={[
|
||||||
{ icon: "profile", path: "/app/profile" },
|
{ icon: "profile", path: "/admin/profile" },
|
||||||
|
{ icon: "logout", path: "/logout" },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Column.Item>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Route
|
||||||
|
path="/user"
|
||||||
|
render={(props) => (
|
||||||
|
<Column.Item height={sizeInfo.headerHeight}>
|
||||||
|
<Header
|
||||||
|
{...props}
|
||||||
|
left={[
|
||||||
|
{
|
||||||
|
image: require("images/badge.png"),
|
||||||
|
path: "/user/profile",
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
right={[
|
||||||
|
{ icon: "profile", path: "/user/profile" },
|
||||||
{ icon: "logout", path: "/logout" },
|
{ icon: "logout", path: "/logout" },
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
@@ -50,18 +71,30 @@ export class App extends Component {
|
|||||||
<Switch>
|
<Switch>
|
||||||
<Route exact path="/login" component={Login} />
|
<Route exact path="/login" component={Login} />
|
||||||
<Route exact path="/logout" component={Logout} />
|
<Route exact path="/logout" component={Logout} />
|
||||||
|
<Route exact path="/parking" component={Parking} />
|
||||||
<Route exact path="/confirm-email" component={ConfirmEmail} />
|
<Route exact path="/confirm-email" component={ConfirmEmail} />
|
||||||
<Route exact path="/reset-password" component={ResetPassword} />
|
<Route exact path="/reset-password" component={ResetPassword} />
|
||||||
<Route exact path="/forgot-password" component={ForgotPassword} />
|
<Route exact path="/forgot-password" component={ForgotPassword} />
|
||||||
<ProtectedRoute exact path="/app/profile" component={Profile} />
|
<ProtectedRoute exact path="/user/profile" component={Profile} />
|
||||||
<ProtectedRoute exact admin path="/app/home" component={Home} />
|
<ProtectedRoute
|
||||||
<ProtectedRoute exact admin path="/app/teams" component={Teams} />
|
exact
|
||||||
<ProtectedRoute exact admin path="/app/system" component={System} />
|
admin
|
||||||
<ProtectedRoute exact admin path="/app/users" component={Users} />
|
path="/admin/profile"
|
||||||
<DefaultRoute redirect="/app/home" />
|
component={Profile}
|
||||||
|
/>
|
||||||
|
<ProtectedRoute exact admin path="/admin/home" component={Home} />
|
||||||
|
<ProtectedRoute exact admin path="/admin/teams" component={Teams} />
|
||||||
|
<ProtectedRoute
|
||||||
|
exact
|
||||||
|
admin
|
||||||
|
path="/admin/system"
|
||||||
|
component={System}
|
||||||
|
/>
|
||||||
|
<ProtectedRoute exact admin path="/admin/users" component={Users} />
|
||||||
|
<DefaultRoute user="/user/profile" admin="/admin/home" />
|
||||||
</Switch>
|
</Switch>
|
||||||
<Route
|
<Route
|
||||||
path="/app"
|
path="/(user|admin)"
|
||||||
render={() => (
|
render={() => (
|
||||||
<Column.Item>
|
<Column.Item>
|
||||||
<Footer
|
<Footer
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export class ConfirmEmail extends React.Component {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,49 @@
|
|||||||
import React, { Component } from "react"
|
import React, { Component } from "react"
|
||||||
import { Route, Redirect } from "react-router-dom"
|
import { Route, Redirect } from "react-router-dom"
|
||||||
import PropTypes from "prop-types"
|
import PropTypes from "prop-types"
|
||||||
|
import { api } from "src/API"
|
||||||
|
|
||||||
export class DefaultRoute extends Component {
|
export class DefaultRoute extends Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
redirect: PropTypes.string,
|
location: PropTypes.shape({
|
||||||
|
pathname: PropTypes.string,
|
||||||
|
search: PropTypes.string,
|
||||||
|
}),
|
||||||
|
user: PropTypes.string.isRequired,
|
||||||
|
admin: PropTypes.string.isRequired,
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
// NOTE: When working on the site, Redirect to the page you are working on
|
const user = api.loggedInUser
|
||||||
return <Route render={() => <Redirect to={this.props.redirect} />} />
|
|
||||||
|
if (user.loggedOut) {
|
||||||
|
return <Route render={() => <Redirect to="/login" />} />
|
||||||
|
} else if (user.pending) {
|
||||||
|
// If login token has not yet been confirmed, park until it is then come back here
|
||||||
|
return (
|
||||||
|
<Route
|
||||||
|
render={() => (
|
||||||
|
<Redirect
|
||||||
|
to={`/parking?redirect=${this.props.location.pathname}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
// Render a redirect to the user or admin default page
|
||||||
|
return (
|
||||||
|
<Route
|
||||||
|
render={() => (
|
||||||
|
<Redirect
|
||||||
|
to={
|
||||||
|
user._id && user.administrator
|
||||||
|
? this.props.admin
|
||||||
|
: this.props.user
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,7 +151,7 @@ export class ForgotPassword extends Component {
|
|||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item grow>
|
<Column.Item grow>
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,9 @@ export class Login extends Component {
|
|||||||
this.setState({ waitModal: false })
|
this.setState({ waitModal: false })
|
||||||
if (this.props.history) {
|
if (this.props.history) {
|
||||||
let url =
|
let url =
|
||||||
new URLSearchParams(window.location.search).get("redirect") || "/"
|
new URLSearchParams(this.props.history.location.search).get(
|
||||||
|
"redirect"
|
||||||
|
) || "/"
|
||||||
|
|
||||||
try {
|
try {
|
||||||
this.props.history.replace(url)
|
this.props.history.replace(url)
|
||||||
@@ -224,7 +226,7 @@ export class Login extends Component {
|
|||||||
</Row>
|
</Row>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
<Column.Item grow>
|
<Column.Item grow>
|
||||||
<WaitModal active={waitModal} message="Logging in..." />
|
<WaitModal open={waitModal} message="Logging in..." />
|
||||||
<MessageModal
|
<MessageModal
|
||||||
error
|
error
|
||||||
open={!!messageModal}
|
open={!!messageModal}
|
||||||
|
|||||||
53
website/src/Auth/Parking.js
Normal file
53
website/src/Auth/Parking.js
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import React, { Component, Fragment } from "react"
|
||||||
|
import PropTypes from "prop-types"
|
||||||
|
import { api } from "src/API"
|
||||||
|
import { WaitModal } from "../Modal"
|
||||||
|
import { Column } from "ui"
|
||||||
|
import autobind from "autobind-decorator"
|
||||||
|
|
||||||
|
export class Parking extends Component {
|
||||||
|
static propTypes = {
|
||||||
|
history: PropTypes.oneOfType([PropTypes.array, PropTypes.object]),
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
api.addListener("login", this.goToRedirect)
|
||||||
|
api.addListener("logout", this.goToLogin)
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
api.removeListener("login", this.goToRedirect)
|
||||||
|
api.removeListener("logout", this.goToLogin)
|
||||||
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
goToRedirect() {
|
||||||
|
if (this.props.history) {
|
||||||
|
let url =
|
||||||
|
new URLSearchParams(this.props.history.location.search).get(
|
||||||
|
"redirect"
|
||||||
|
) || "/"
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.props.history.replace(url)
|
||||||
|
} catch (error) {
|
||||||
|
this.props.history.replace("/")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@autobind
|
||||||
|
goToLogin() {
|
||||||
|
this.props.history.replace("/login")
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Fragment>
|
||||||
|
<Column.Item grow>
|
||||||
|
<WaitModal open loader={false} message="Authenticating..." />
|
||||||
|
</Column.Item>
|
||||||
|
</Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
import React from 'react'
|
import React from "react"
|
||||||
import { Route, Redirect } from 'react-router'
|
import { Route, Redirect } from "react-router"
|
||||||
import { PropTypes } from 'prop-types'
|
import { PropTypes } from "prop-types"
|
||||||
import { api } from 'src/API'
|
import { api } from "src/API"
|
||||||
import autobind from 'autobind-decorator'
|
|
||||||
|
|
||||||
export class ProtectedRoute extends React.Component {
|
export class ProtectedRoute extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
@@ -13,33 +12,32 @@ export class ProtectedRoute extends React.Component {
|
|||||||
admin: PropTypes.bool,
|
admin: PropTypes.bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
@autobind
|
|
||||||
updateComponent() {
|
|
||||||
this.forceUpdate()
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidMount() {
|
|
||||||
api.addListener("login", this.updateComponent)
|
|
||||||
api.addListener("logout", this.updateComponent)
|
|
||||||
}
|
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
api.removeListener("login", this.updateComponent)
|
|
||||||
api.removeListener("logout", this.updateComponent)
|
|
||||||
}
|
|
||||||
|
|
||||||
render(props) {
|
render(props) {
|
||||||
const user = api.loggedInUser
|
const user = api.loggedInUser
|
||||||
|
|
||||||
if (user.pending) {
|
if (user.pending) {
|
||||||
return null
|
// If login token has not yet been confirmed, park until it is and redirect back here
|
||||||
|
return (
|
||||||
|
<Route
|
||||||
|
render={() => (
|
||||||
|
<Redirect
|
||||||
|
to={`/parking?redirect=${this.props.location.pathname}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
)
|
||||||
} else {
|
} else {
|
||||||
|
// If we are not a user or an admin go to the login page
|
||||||
if (!user._id || (this.props.admin && !user.administrator)) {
|
if (!user._id || (this.props.admin && !user.administrator)) {
|
||||||
return (
|
return (
|
||||||
<Redirect
|
<Route
|
||||||
to={`/login?redirect=${this.props.location.pathname}${
|
render={() => (
|
||||||
this.props.location.search
|
<Redirect
|
||||||
}`}
|
to={`/login?redirect=${this.props.location.pathname}${
|
||||||
|
this.props.location.search
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ export class ResetPassword extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
export { Login } from './Login'
|
export { Login } from "./Login"
|
||||||
export { Logout } from './Logout'
|
export { Logout } from "./Logout"
|
||||||
export { ResetPassword } from './ResetPassword'
|
export { Parking } from "./Parking"
|
||||||
export { ForgotPassword } from './ForgotPassword'
|
export { ResetPassword } from "./ResetPassword"
|
||||||
export { ConfirmEmail } from './ConfirmEmail'
|
export { ForgotPassword } from "./ForgotPassword"
|
||||||
export { DefaultRoute } from './DefaultRoute'
|
export { ConfirmEmail } from "./ConfirmEmail"
|
||||||
export { ProtectedRoute } from './ProtectedRoute'
|
export { DefaultRoute } from "./DefaultRoute"
|
||||||
|
export { ProtectedRoute } from "./ProtectedRoute"
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export class Home extends Component {
|
|||||||
<PanelButton
|
<PanelButton
|
||||||
icon="users"
|
icon="users"
|
||||||
text="Users"
|
text="Users"
|
||||||
onClick={() => this.props.history.push("/app/users")}
|
onClick={() => this.props.history.push("/admin/users")}
|
||||||
/>
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
||||||
@@ -27,7 +27,7 @@ export class Home extends Component {
|
|||||||
<PanelButton
|
<PanelButton
|
||||||
icon="teams"
|
icon="teams"
|
||||||
text="Teams"
|
text="Teams"
|
||||||
onClick={() => this.props.history.push("/app/teams")}
|
onClick={() => this.props.history.push("/admin/teams")}
|
||||||
/>
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
<Row.Item width={sizeInfo.panelButtonSpacing} />
|
||||||
@@ -35,7 +35,7 @@ export class Home extends Component {
|
|||||||
<PanelButton
|
<PanelButton
|
||||||
icon="system"
|
icon="system"
|
||||||
text="System"
|
text="System"
|
||||||
onClick={() => this.props.history.push("/app/system")}
|
onClick={() => this.props.history.push("/admin/system")}
|
||||||
/>
|
/>
|
||||||
</Row.Item>
|
</Row.Item>
|
||||||
<Row.Item grow />
|
<Row.Item grow />
|
||||||
|
|||||||
@@ -352,7 +352,7 @@ export class MasterDetail extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export class MasterList extends React.Component {
|
|||||||
<List.Item
|
<List.Item
|
||||||
key={item._id || "0"}
|
key={item._id || "0"}
|
||||||
onClick={(e) => this.props.onItemListClick(e, index)}
|
onClick={(e) => this.props.onItemListClick(e, index)}
|
||||||
active={item === this.props.selectedItem}>
|
open={item === this.props.selectedItem}>
|
||||||
<List.Icon name={data.icon} size={sizeInfo.listIcon} />
|
<List.Icon name={data.icon} size={sizeInfo.listIcon} />
|
||||||
<List.Text>{data.text}</List.Text>
|
<List.Text>{data.text}</List.Text>
|
||||||
{item === selectedItem && selectionModified ? (
|
{item === selectedItem && selectionModified ? (
|
||||||
|
|||||||
@@ -4,17 +4,26 @@ import { Dimmer, Loader, Text } from 'ui'
|
|||||||
|
|
||||||
export class WaitModal extends React.Component {
|
export class WaitModal extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
active: PropTypes.bool.isRequired,
|
open: PropTypes.bool.isRequired,
|
||||||
message: PropTypes.string,
|
message: PropTypes.string,
|
||||||
|
loader: PropTypes.bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
loader: true,
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { active, message } = this.props
|
const { open, message, loader } = this.props
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dimmer active={active}>
|
<Dimmer active={open}>
|
||||||
<Loader />
|
{loader && <Loader />}
|
||||||
{message && <Text size='huge' color='inverse'>{message}</Text>}
|
{message && (
|
||||||
|
<Text size="huge" color="inverse">
|
||||||
|
{message}
|
||||||
|
</Text>
|
||||||
|
)}
|
||||||
</Dimmer>
|
</Dimmer>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ export class Profile extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ export class System extends Component {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<WaitModal
|
<WaitModal
|
||||||
active={!!waitModal}
|
open={!!waitModal}
|
||||||
message={waitModal ? waitModal.message : ""}
|
message={waitModal ? waitModal.message : ""}
|
||||||
/>
|
/>
|
||||||
</Column.Item>
|
</Column.Item>
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
export const versionInfo = {
|
export const versionInfo = {
|
||||||
version: '1.0.1',
|
version: '1.1.0',
|
||||||
fullVersion: '1.0.1-20180518.0',
|
fullVersion: '1.1.0-20180525.0',
|
||||||
title: 'Deighton AR System',
|
title: 'Deighton AR System',
|
||||||
copyright: '© 2018, Kingston Software Solutions.',
|
copyright: '© 2018, Kingston Software Solutions.',
|
||||||
supportEmail: 'support@kss.us.com',
|
supportEmail: 'support@kss.us.com',
|
||||||
|
|||||||
Reference in New Issue
Block a user