13 Commits

Author SHA1 Message Date
John Lyon-Smith
3e37e835a7 Remove system icon and panel button 2018-06-04 19:06:40 -07:00
John Lyon-Smith
12574fb354 Put system stuff on home page 2018-06-04 19:05:14 -07:00
John Lyon-Smith
e09a8b87de Adding work item details to activity 2018-06-04 19:01:12 -07:00
John Lyon-Smith
cffa0734b8 Added work item details to activity 2018-06-04 16:29:58 -07:00
John Lyon-Smith
4ebb4341b7 Was allowing existing work item location to be updated 2018-06-04 09:28:03 -07:00
John Lyon-Smith
8d70c39dfa Added help message in AR view 2018-06-04 08:09:44 -07:00
John Lyon-Smith
9b34490fbe Manually update version code 2018-05-31 13:40:16 -07:00
John Lyon-Smith
b3a72610e6 Version 1.2.1-20180531.0 2018-05-31 13:39:14 -07:00
John Lyon-Smith
a3b20d8ac1 Reduce sensitivity 2018-05-31 13:38:28 -07:00
John Lyon-Smith
519bc1c50b Version 1.2.0-20180531.0 2018-05-31 11:16:42 -07:00
John Lyon-Smith
71e1816173 Added wait modals everywhere. Reduce required distance to item 2018-05-31 11:15:53 -07:00
John Lyon-Smith
9e55320a21 Fixing base route issues. Fix map scrolling issues on iOS 2018-05-31 07:20:29 -07:00
John Lyon-Smith
62876c94c9 Version 1.1.3-20180529.0 2018-05-29 13:09:48 -07:00
38 changed files with 762 additions and 485 deletions

View File

@@ -8,7 +8,7 @@
</configuration> </configuration>
</facet> </facet>
</component> </component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_7" inherit-compiler-output="true"> <component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output /> <exclude-output />
<content url="file://$MODULE_DIR$"> <content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" /> <excludeFolder url="file://$MODULE_DIR$/.gradle" />

154
mobile/android/app/app.iml Normal file
View File

@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="UTF-8"?>
<module external.linked.project.id=":app" external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="android-gradle" name="Android-Gradle">
<configuration>
<option name="GRADLE_PROJECT_PATH" value=":app" />
</configuration>
</facet>
<facet type="android" name="Android">
<configuration>
<option name="SELECTED_BUILD_VARIANT" value="debug" />
<option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
<option name="COMPILE_JAVA_TASK_NAME" value="compileDebugSources" />
<afterSyncTasks>
<task>generateDebugSources</task>
</afterSyncTasks>
<option name="ALLOW_USER_CONFIGURATION" value="false" />
<option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
<option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
<option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
<option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
</configuration>
</facet>
</component>
<component name="NewModuleRootManager">
<output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
<output-test url="file://$MODULE_DIR$/build/intermediates/classes/test/debug" />
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/androidTest/debug" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/test/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/debug/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/testDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTestDebug/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/assets" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/check-manifest" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/classes" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/javaPrecompile" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jniLibs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/manifests" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/prebuild" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/res" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/rs" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/shaders" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/splits-support" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/symbols" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/transforms" />
<excludeFolder url="file://$MODULE_DIR$/build/outputs" />
<excludeFolder url="file://$MODULE_DIR$/build/reports" />
<excludeFolder url="file://$MODULE_DIR$/build/tmp" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="Gradle: com.android.support:support-fragment-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:fbcore-1.3.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.android.exoplayer:exoplayer-r2.2.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-media-compat-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:drawee-1.3.0" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:imagepipeline-okhttp3-1.3.0" level="project" />
<orderEntry type="library" name="Gradle: artifacts:arcore_client" level="project" />
<orderEntry type="library" name="Gradle: com.parse.bolts:bolts-tasks:1.4.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okio:okio:1.13.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:appcompat-v7-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.amazonaws:aws-android-sdk-ddb:2.2.22@jar" level="project" />
<orderEntry type="library" name="Gradle: com.google.code.gson:gson:2.2.4@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:animated-vector-drawable-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:fresco-1.3.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-compat-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.google.code.findbugs:jsr305:3.0.0@jar" level="project" />
<orderEntry type="library" name="Gradle: org.webkit:android-jsc-r174650" level="project" />
<orderEntry type="library" name="Gradle: com.amazonaws:aws-android-sdk-s3:2.2.22@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-utils-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.amazonaws:aws-android-sdk-core:2.2.22@jar" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.soloader:soloader-0.1.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-core-ui-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-vector-drawable-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fbui.textlayoutbuilder:textlayoutbuilder-1.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:imagepipeline-base-1.3.0" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp:3.6.0@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-v4-25.0.0" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fbui.textlayoutbuilder:staticlayout-proxy:1.0@jar" level="project" />
<orderEntry type="library" name="Gradle: artifacts:react_viro" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.react:react-native-0.55.4" level="project" />
<orderEntry type="library" name="Gradle: com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-7@jar" level="project" />
<orderEntry type="library" name="Gradle: com.android.support:support-annotations:25.0.1@jar" level="project" />
<orderEntry type="library" name="Gradle: com.amazonaws:aws-android-sdk-cognito:2.2.22@jar" level="project" />
<orderEntry type="library" name="Gradle: com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.2.22@jar" level="project" />
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp-urlconnection:3.6.0@jar" level="project" />
<orderEntry type="library" name="Gradle: artifacts:viro_renderer" level="project" />
<orderEntry type="library" name="Gradle: com.amazonaws:aws-android-sdk-ddb-mapper:2.2.22@jar" level="project" />
<orderEntry type="library" name="Gradle: artifacts:gvr_common" level="project" />
<orderEntry type="library" name="Gradle: com.facebook.fresco:imagepipeline-1.3.0" level="project" />
<orderEntry type="module" module-name="react-native-fs" />
<orderEntry type="module" module-name="react-native-maps" />
<orderEntry type="module" module-name="react-native-image-resizer" />
<orderEntry type="module" module-name="react-native-image-picker" />
<orderEntry type="library" name="Gradle: android-android-27" level="project" />
</component>
</module>

View File

@@ -101,8 +101,8 @@ android {
applicationId "com.deightonar" applicationId "com.deightonar"
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 27 targetSdkVersion 27
versionCode 8 versionCode 11
versionName "1.1.2" versionName "1.2.1"
ndk { ndk {
abiFilters "armeabi-v7a", "x86" abiFilters "armeabi-v7a", "x86"
} }

View File

@@ -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="8" android:versionCode="11"
android:versionName="1.1.2"> android:versionName="1.2.1">
<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"/>

View File

@@ -19,11 +19,11 @@
<key>CFBundlePackageType</key> <key>CFBundlePackageType</key>
<string>APPL</string> <string>APPL</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>1.1.2</string> <string>1.2.1</string>
<key>CFBundleSignature</key> <key>CFBundleSignature</key>
<string>????</string> <string>????</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>20180529.0</string> <string>20180531.0</string>
<key>LSRequiresIPhoneOS</key> <key>LSRequiresIPhoneOS</key>
<true/> <true/>
<key>NSAppTransportSecurity</key> <key>NSAppTransportSecurity</key>

View File

@@ -1,5 +1,5 @@
import React from "react" import React from "react"
import { StyleSheet, View, TouchableHighlight, Image } from "react-native" import { StyleSheet, View, TouchableHighlight, Image, Text } from "react-native"
import { import {
ViroARSceneNavigator, ViroARSceneNavigator,
ViroARScene, ViroARScene,
@@ -105,8 +105,6 @@ class WorkItemSceneAR extends React.Component {
position: hitResultPosition || defaultPosition, position: hitResultPosition || defaultPosition,
}) })
console.log(hitResultPosition || defaultPosition)
setTimeout(() => { setTimeout(() => {
this.updateInitialRotation() this.updateInitialRotation()
}, 200) }, 200)
@@ -237,6 +235,10 @@ export class ARViewer extends React.Component {
} }
render() { render() {
const message = this.workItemId
? "Work item nearby. Stand still, point phone at a nearby surface and move it around slowly."
: "No work item detected. Wait for GPS signal to stabilize and move closer to a work item."
return ( return (
<View style={{ width: "100%", height: "100%" }}> <View style={{ width: "100%", height: "100%" }}>
<ViroARSceneNavigator <ViroARSceneNavigator
@@ -263,6 +265,27 @@ export class ARViewer extends React.Component {
<Image source={backImage} /> <Image source={backImage} />
</TouchableHighlight> </TouchableHighlight>
</View> </View>
<View
style={{
flexDirection: "row",
justifyContent: "center",
position: "absolute",
bottom: 30,
left: 0,
right: 0,
backgroundColor: "#99999980",
}}>
<Text
style={{
textAlign: "center",
fontSize: 24,
padding: 10,
color: "#FFFFFF",
}}>
{message}
</Text>
</View>
</View> </View>
) )
} }

View File

@@ -27,10 +27,11 @@ 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"
import { formatLatLng } from "../util" import { formatLatLng, workItemTypeEnum } from "../util"
import moment from "moment" import moment from "moment"
import "url-search-params-polyfill" import "url-search-params-polyfill"
import { config } from "../config" import { config } from "../config"
import { FormStaticOptionStrip, FormStaticPhotoPanel } from "../ui"
const styles = StyleSheet.create({ const styles = StyleSheet.create({
container: { container: {
@@ -97,16 +98,19 @@ export class Activity extends React.Component {
this.region = null this.region = null
this.isMapReady = false this.isMapReady = false
this.goToRegionWhenReady = false this.goToRegionWhenReady = false
}
componentDidMount() {
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 }
const id = params.get("id") const id = params.get("id")
const workItemId = params.get("workItemId") const workItemId = params.get("workItemId")
const getWorkItem = (id) => { const getWorkItem = (id) => {
this.setState({ waitModal: { message: "Loading Work Item Details..." } })
api api
.getWorkItem(id) .getWorkItem(id)
.then((workItem) => { .then((workItem) => {
this.setState({ waitModal: null })
if (workItem) { if (workItem) {
const [lng, lat] = workItem.location.coordinates const [lng, lat] = workItem.location.coordinates
@@ -121,6 +125,9 @@ export class Activity extends React.Component {
), ),
location: formatLatLng(lat, lng), location: formatLatLng(lat, lng),
dateTime: moment().format(), dateTime: moment().format(),
details: workItem.details,
workItemType: workItem.workItemType,
workItemPhotos: workItem.photos,
}) })
this.region = { this.region = {
@@ -139,6 +146,7 @@ export class Activity extends React.Component {
}) })
.catch((err) => { .catch((err) => {
this.setState({ this.setState({
waitModal: null,
messageModal: { messageModal: {
icon: "hand", icon: "hand",
message: "Unable to get work item details", message: "Unable to get work item details",
@@ -150,9 +158,12 @@ export class Activity extends React.Component {
} }
if (id) { if (id) {
this.setState({ waitModal: { message: "Loading Activity..." } })
api api
.getActivity(id) .getActivity(id)
.then((activity) => { .then((activity) => {
this.setState({ waitModal: null })
if (activity) { if (activity) {
this.setState({ this.setState({
binder: new FormBinder(activity, Activity.bindings), binder: new FormBinder(activity, Activity.bindings),
@@ -163,6 +174,7 @@ export class Activity extends React.Component {
}) })
.catch((err) => { .catch((err) => {
this.setState({ this.setState({
waitModal: null,
messageModal: { messageModal: {
icon: "hand", icon: "hand",
message: "Unable to get activity details", message: "Unable to get activity details",
@@ -280,7 +292,10 @@ export class Activity extends React.Component {
waitModal, waitModal,
dateTime, dateTime,
location, location,
details,
workItemType,
uploadPercent, uploadPercent,
workItemPhotos,
} = this.state } = this.state
return ( return (
@@ -293,9 +308,6 @@ export class Activity extends React.Component {
rightButton={{ icon: "done", onPress: this.handleDonePress }} rightButton={{ icon: "done", onPress: this.handleDonePress }}
/> />
<ScrollView style={styles.container}> <ScrollView style={styles.container}>
<View style={styles.panel}>
<BoundInput binder={binder} name="resolution" label="Resolution:" />
</View>
<View style={styles.panel}> <View style={styles.panel}>
<BoundOptionStrip <BoundOptionStrip
binder={binder} binder={binder}
@@ -307,13 +319,40 @@ export class Activity extends React.Component {
]} ]}
label="Status:" label="Status:"
name="status" name="status"
message="You must supply a status for the activity"
/>
<BoundInput
binder={binder}
name="resolution"
label="Resolution:"
message="You must supply a resolution for the activity"
/>
<BoundInput
binder={binder}
name="notes"
label="Notes:"
message="You must supply notes for the activity"
/>
<FormStaticInput label="Date &amp; Time:" value={dateTime} />
<BoundPhotoPanel
name="photos"
binder={binder}
onUploadStarted={this.handleUploadStarted}
onUploadProgress={this.handleUploadProgress}
onUploadEnded={this.handleUploadEnded}
/> />
</View> </View>
<View style={styles.panel}> <View style={styles.panel}>
<BoundInput binder={binder} name="notes" label="Notes:" /> <FormStaticOptionStrip
</View> label="Work Item Type:"
<View style={styles.panel}> options={workItemTypeEnum}
<FormStaticInput label="Date &amp; Time:" value={dateTime} /> value={workItemType}
/>
<FormStaticInput label="Details:" value={details} />
<FormStaticPhotoPanel
label="Work Item Photos:"
value={workItemPhotos}
/>
<FormStaticInput label="Location:" value={location} /> <FormStaticInput label="Location:" value={location} />
<View style={{ flexDirection: "column", justifyContent: "center" }}> <View style={{ flexDirection: "column", justifyContent: "center" }}>
<MapView <MapView
@@ -350,15 +389,6 @@ export class Activity extends React.Component {
/> />
</View> </View>
</View> </View>
<View style={styles.panel}>
<BoundPhotoPanel
name="photos"
binder={binder}
onUploadStarted={this.handleUploadStarted}
onUploadProgress={this.handleUploadProgress}
onUploadEnded={this.handleUploadEnded}
/>
</View>
{isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null} {isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null}
</ScrollView> </ScrollView>
<ProgressModal <ProgressModal

View File

@@ -13,7 +13,7 @@ import {
} from "react-native" } from "react-native"
import MapView, { Marker, Callout } from "react-native-maps" 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, WaitModal } from "../Modal"
import { api } from "../API" import { api } from "../API"
import { reactAutoBind } from "auto-bind2" import { reactAutoBind } from "auto-bind2"
import { ifIphoneX } from "react-native-iphone-x-helper" import { ifIphoneX } from "react-native-iphone-x-helper"
@@ -41,6 +41,8 @@ export class Home extends React.Component {
super(props) super(props)
reactAutoBind(this) reactAutoBind(this)
this.state = { this.state = {
waitModal: null,
messageModal: null,
sections: [], sections: [],
showWorkItems: true, showWorkItems: true,
haveCameraPermission: false, haveCameraPermission: false,
@@ -97,7 +99,14 @@ export class Home extends React.Component {
this.state.haveLocationPermission = true this.state.haveLocationPermission = true
this.state.haveCameraPermission = true this.state.haveCameraPermission = true
} }
}
componentDidMount() {
this.loadWorkItems()
}
loadWorkItems() {
this.setState({ waitModal: { message: "Loading Work Items..." } })
api api
.listTeams() .listTeams()
.then((list) => { .then((list) => {
@@ -105,6 +114,8 @@ export class Home extends React.Component {
return api.listWorkItemActivities() return api.listWorkItemActivities()
}) })
.then((list) => { .then((list) => {
this.setState({ waitModal: null })
list.items.forEach((item) => { list.items.forEach((item) => {
item.data.forEach((datum) => { item.data.forEach((datum) => {
const team = this.teams.find((team) => team._id === datum.team) const team = this.teams.find((team) => team._id === datum.team)
@@ -130,6 +141,7 @@ export class Home extends React.Component {
}) })
.catch((err) => { .catch((err) => {
this.setState({ this.setState({
waitModal: null,
messageModal: { messageModal: {
icon: "hand", icon: "hand",
message: "Unable to get a list of work items, activities and teams", message: "Unable to get a list of work items, activities and teams",
@@ -246,7 +258,13 @@ export class Home extends React.Component {
} }
handleToggleWorkItemsList() { handleToggleWorkItemsList() {
this.setState({ showWorkItems: !this.state.showWorkItems }) const newShowWorkItems = !this.state.showWorkItems
this.setState({ showWorkItems: newShowWorkItems })
if (newShowWorkItems) {
this.loadWorkItems()
}
} }
handleCalloutPress(workItem) { handleCalloutPress(workItem) {
@@ -287,6 +305,7 @@ export class Home extends React.Component {
sections, sections,
showWorkItems, showWorkItems,
messageModal, messageModal,
waitModal,
haveCameraPermission, haveCameraPermission,
haveLocationPermission, haveLocationPermission,
} = this.state } = this.state
@@ -491,6 +510,10 @@ export class Home extends React.Component {
{haveLocationPermission && ( {haveLocationPermission && (
<Geolocation onUpdate={this.handlePositionUpdate} /> <Geolocation onUpdate={this.handlePositionUpdate} />
)} )}
<WaitModal
open={!!waitModal}
message={waitModal ? waitModal.message : ""}
/>
<MessageModal <MessageModal
open={!!messageModal} open={!!messageModal}
icon={messageModal ? messageModal.icon : ""} icon={messageModal ? messageModal.icon : ""}

View File

@@ -100,19 +100,26 @@ export class WorkItem extends React.Component {
messageModal: null, messageModal: null,
waitModal: null, waitModal: null,
progressModal: null, progressModal: null,
allowLocationUpdates: false,
} }
this.region = null this.region = null
this.isMapReady = false this.isMapReady = false
this.goToRegionWhenReady = false this.goToRegionWhenReady = false
}
componentDidMount() {
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 }
const id = params.get("id") const id = params.get("id")
if (id) { if (id) {
this.setState({ waitModal: { message: "Loading Work Item..." } })
api api
.getWorkItem(id) .getWorkItem(id)
.then((workItem) => { .then((workItem) => {
this.setState({ waitModal: null })
if (workItem) { if (workItem) {
const [longitude, latitude] = workItem.location.coordinates const [longitude, latitude] = workItem.location.coordinates
@@ -136,6 +143,7 @@ export class WorkItem extends React.Component {
}) })
.catch((err) => { .catch((err) => {
this.setState({ this.setState({
waitModal: null,
messageModal: { messageModal: {
icon: "hand", icon: "hand",
message: "Unable to get work item details", message: "Unable to get work item details",
@@ -144,6 +152,8 @@ export class WorkItem extends React.Component {
}, },
}) })
}) })
} else {
this.setState({ allowLocationUpdates: true })
} }
} }
@@ -167,14 +177,18 @@ export class WorkItem extends React.Component {
const { binder } = this.state const { binder } = this.state
let obj = binder.getModifiedBindingValues() let obj = binder.getModifiedBindingValues()
this.setState({ waitModal: { message: "Creating Work Item..." } })
if (!obj._id) { if (!obj._id) {
api api
.createWorkItem(obj) .createWorkItem(obj)
.then((workItem) => { .then((workItem) => {
this.setState({ waitModal: null })
this.handleBackPress() this.handleBackPress()
}) })
.catch((error) => { .catch((error) => {
this.setState({ this.setState({
waitModal: null,
messageModal: { messageModal: {
icon: "hand", icon: "hand",
message: "Unable to create work item", message: "Unable to create work item",
@@ -190,6 +204,7 @@ export class WorkItem extends React.Component {
}) })
.catch((error) => { .catch((error) => {
this.setState({ this.setState({
waitModal: null,
messageModal: { messageModal: {
icon: "hand", icon: "hand",
message: "Unable to update work item", message: "Unable to update work item",
@@ -209,6 +224,12 @@ export class WorkItem extends React.Component {
} }
handleRegionChange(region) { handleRegionChange(region) {
if (!this.state.allowLocationUpdates || !this.isMapReady) {
// On iOS we get this after setting the initial region, before the map declared as ready!
// Also, if we are only viewing the work item, then don't allow region changes
return
}
const { latitude, longitude } = region const { latitude, longitude } = region
this.region = region this.region = region
@@ -331,8 +352,6 @@ export class WorkItem extends React.Component {
options={workItemTypeEnum} options={workItemTypeEnum}
message="Select a work item type" message="Select a work item type"
/> />
</View>
<View style={styles.panel}>
<BoundInput <BoundInput
binder={binder} binder={binder}
name="details" name="details"
@@ -340,8 +359,6 @@ export class WorkItem extends React.Component {
label="Details:" label="Details:"
message="You must supply details for the work item" message="You must supply details for the work item"
/> />
</View>
<View style={styles.panel}>
<View style={{ flexDirection: "column", justifyContent: "center" }}> <View style={{ flexDirection: "column", justifyContent: "center" }}>
<MapView <MapView
ref={(ref) => (this.mapView = ref)} ref={(ref) => (this.mapView = ref)}
@@ -388,8 +405,6 @@ export class WorkItem extends React.Component {
name="address" name="address"
label="Address:" label="Address:"
/> />
</View>
<View style={styles.panel}>
<BoundPhotoPanel <BoundPhotoPanel
name="photos" name="photos"
binder={binder} binder={binder}
@@ -411,7 +426,9 @@ export class WorkItem extends React.Component {
)} )}
{isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null} {isIphoneX ? <View style={{ height: 30, width: "100%" }} /> : null}
</ScrollView> </ScrollView>
<Geolocation onUpdate={this.handlePositionUpdate} watch={false} /> {!this.state.allowLocationUpdates && (
<Geolocation onUpdate={this.handlePositionUpdate} watch={false} />
)}
<ProgressModal <ProgressModal
open={!!progressModal} open={!!progressModal}
message={progressModal ? progressModal.message : ""} message={progressModal ? progressModal.message : ""}

View File

@@ -15,7 +15,7 @@ export const config = {
homeRegionDelta: 0.005, homeRegionDelta: 0.005,
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

View File

@@ -85,10 +85,9 @@ export class BoundInput extends React.Component {
<Text <Text
style={{ style={{
fontSize: 12, fontSize: 12,
display: valid ? "none" : "flex",
color: "red", color: "red",
}}> }}>
{message} {valid ? " " : message}
</Text> </Text>
</View> </View>
) )

View File

@@ -55,10 +55,9 @@ export class BoundOptionStrip extends React.Component {
<Text <Text
style={{ style={{
fontSize: 12, fontSize: 12,
display: valid ? "none" : "flex",
color: "red", color: "red",
}}> }}>
{message} {valid ? " " : message}
</Text> </Text>
</View> </View>
) )

View File

@@ -14,17 +14,7 @@ import ImagePicker from "react-native-image-picker"
import ImageResizer from "react-native-image-resizer" import ImageResizer from "react-native-image-resizer"
import { reactAutoBind } from "auto-bind2" import { reactAutoBind } from "auto-bind2"
import { api } from "../API" import { api } from "../API"
import { PhotoPanel } from "."
const getScreenPortraitDimensions = () => {
const { width, height } = Dimensions.get("window")
return {
screenWidth: Math.min(width, height),
screenHeight: Math.max(width, height),
}
}
const photoSpacing = 10
export class BoundPhotoPanel extends Component { export class BoundPhotoPanel extends Component {
static propTypes = { static propTypes = {
@@ -95,56 +85,15 @@ export class BoundPhotoPanel extends Component {
) )
} }
handleLayout(e) {
if (!this.state.photoSize) {
const { layout } = e.nativeEvent
const ratio = 3 / 4
const width = (layout.width - photoSpacing) / 2
const height = width / ratio
this.setState({ photoSize: { width, height } })
}
}
render() { render() {
const { photoSize, value: assetIds } = this.state const { photoSize, value } = this.state
const renderPhoto = (index) => {
const assetId = assetIds[index]
return (
<TouchableOpacity
key={assetId || "blank" + index.toString()}
style={{
width: photoSize.width,
height: photoSize.height,
borderWidth: 2,
borderColor: "gray",
borderRadius: 4,
justifyContent: "center",
}}
onPress={() => this.handlePhotoPress(index)}>
{!assetId && (
<Icon name="add" size={24} style={{ alignSelf: "center" }} />
)}
{assetId && (
<Image
source={{ uri: api.makeImageUrl(assetId) }}
style={{ width: "100%", height: "100%" }}
resizeMode="contain"
/>
)}
</TouchableOpacity>
)
}
return ( return (
<View <View
style={{ style={{
flexDirection: "column", flexDirection: "column",
justifyContent: "space-between", justifyContent: "space-between",
}} }}>
onLayout={this.handleLayout}>
<Text <Text
style={{ style={{
fontSize: 14, fontSize: 14,
@@ -152,18 +101,7 @@ export class BoundPhotoPanel extends Component {
}}> }}>
Pictures: Pictures:
</Text> </Text>
{photoSize && ( <PhotoPanel onPhotoPress={this.handlePhotoPress} value={value} />
<View style={styles.photoRow}>
{renderPhoto(0)}
{renderPhoto(1)}
</View>
)}
{photoSize && (
<View style={styles.photoRow}>
{renderPhoto(2)}
{renderPhoto(3)}
</View>
)}
</View> </View>
) )
} }

View File

@@ -39,6 +39,7 @@ export class FormStaticInput extends React.Component {
underlineColorAndroid="white" underlineColorAndroid="white"
value={value} value={value}
/> />
<Text>&nbsp;</Text>
</View> </View>
) )
} }

View File

@@ -0,0 +1,33 @@
import React from "react"
import PropTypes from "prop-types"
import { Text, View, Platform } from "react-native"
import { OptionStrip } from "."
export class FormStaticOptionStrip extends React.Component {
static propTypes = {
label: PropTypes.string,
options: PropTypes.arrayOf(
PropTypes.shape({ value: PropTypes.string, text: PropTypes.string })
).isRequired,
value: PropTypes.string,
}
render() {
const { label, value, options } = this.props
return (
<View style={{ width: "100%" }}>
<Text
style={{
color: "black",
fontSize: 14,
marginBottom: 5,
}}>
{label}
</Text>
<OptionStrip value={value} readOnly options={options} />
<Text>&nbsp;</Text>
</View>
)
}
}

View File

@@ -0,0 +1,30 @@
import React from "react"
import PropTypes from "prop-types"
import { Text, View, Platform } from "react-native"
import { PhotoPanel } from "."
export class FormStaticPhotoPanel extends React.Component {
static propTypes = {
label: PropTypes.string,
value: PropTypes.arrayOf(PropTypes.string),
}
render() {
const { label, value, options } = this.props
return (
<View style={{ width: "100%" }}>
<Text
style={{
color: "black",
fontSize: 14,
marginBottom: 5,
}}>
{label}
</Text>
<PhotoPanel value={value} readOnly />
<Text>&nbsp;</Text>
</View>
)
}
}

View File

@@ -9,6 +9,7 @@ export class OptionStrip extends Component {
PropTypes.shape({ value: PropTypes.string, text: PropTypes.string }) PropTypes.shape({ value: PropTypes.string, text: PropTypes.string })
).isRequired, ).isRequired,
value: PropTypes.string, value: PropTypes.string,
readOnly: PropTypes.bool,
onValueChanged: PropTypes.func, onValueChanged: PropTypes.func,
} }
@@ -41,14 +42,15 @@ export class OptionStrip extends Component {
handlePress(option) { handlePress(option) {
const { onValueChanged } = this.props const { onValueChanged } = this.props
this.setState({ selectedOption: option })
if (onValueChanged) { if (onValueChanged) {
onValueChanged(option.value) onValueChanged(option.value)
} else if (!this.props.readOnly) {
this.setState({ selectedOption: option })
} }
} }
render() { render() {
const { style, options, value } = this.props const { style, options, value, readOnly } = this.props
const { selectedOption } = this.state const { selectedOption } = this.state
// TODO: Handle visible, disabled & read-only // TODO: Handle visible, disabled & read-only
@@ -58,6 +60,7 @@ export class OptionStrip extends Component {
{options.map((option, index) => ( {options.map((option, index) => (
<TouchableHighlight <TouchableHighlight
key={index} key={index}
disabled={readOnly}
underlayColor="#3BB0FD" underlayColor="#3BB0FD"
style={[ style={[
{ {
@@ -65,7 +68,11 @@ export class OptionStrip extends Component {
flexBasis: 0, flexBasis: 0,
height: 40, height: 40,
backgroundColor: backgroundColor:
option === selectedOption ? "#3BB0FD" : "#EEEEEE", option !== selectedOption
? "#EEEEEE"
: readOnly
? "#AAAAAA"
: "#3BB0FD",
}, },
index === 0 && { index === 0 && {
borderTopLeftRadius: 6, borderTopLeftRadius: 6,

108
mobile/src/ui/PhotoPanel.js Normal file
View File

@@ -0,0 +1,108 @@
import React, { Component } from "react"
import PropTypes from "prop-types"
import {
StyleSheet,
Text,
View,
Image,
TouchableOpacity,
Dimensions,
ActivityIndicator,
} from "react-native"
import { Icon } from "."
import { reactAutoBind } from "auto-bind2"
import { api } from "../API"
const photoSpacing = 10
export class PhotoPanel extends Component {
static propTypes = {
onPhotoPress: PropTypes.func,
readOnly: PropTypes.bool,
value: PropTypes.arrayOf(PropTypes.string),
}
constructor(props) {
super(props)
reactAutoBind(this)
this.state = {
photoSize: null,
}
}
handleLayout(e) {
if (!this.state.photoSize) {
const { layout } = e.nativeEvent
const ratio = 3 / 4
const width = (layout.width - photoSpacing) / 2
const height = width / ratio
this.setState({ photoSize: { width, height } })
}
}
render() {
const { photoSize } = this.state
const { value: assetIds, readOnly, onPhotoPress } = this.props
const renderPhoto = (index) => {
const assetId = assetIds && assetIds[index]
return (
<TouchableOpacity
key={assetId || "blank" + index.toString()}
disabled={readOnly}
style={{
width: photoSize.width,
height: photoSize.height,
borderWidth: 2,
borderColor: "gray",
borderRadius: 4,
justifyContent: "center",
}}
onPress={() => onPhotoPress(index)}>
{!assetId && (
<Icon
name={!readOnly ? "add" : "blank"}
size={24}
style={{ alignSelf: "center" }}
/>
)}
{assetId && (
<Image
source={{ uri: api.makeImageUrl(assetId) }}
style={{ width: "100%", height: "100%" }}
resizeMode="contain"
/>
)}
</TouchableOpacity>
)
}
return (
<View onLayout={this.handleLayout}>
{photoSize && (
<View style={styles.photoRow}>
{renderPhoto(0)}
{renderPhoto(1)}
</View>
)}
{photoSize && (
<View style={styles.photoRow}>
{renderPhoto(2)}
{renderPhoto(3)}
</View>
)}
</View>
)
}
}
const styles = StyleSheet.create({
photoRow: {
flexDirection: "row",
justifyContent: "space-between",
width: "100%",
paddingTop: 5,
paddingBottom: 5,
},
})

View File

@@ -3,10 +3,13 @@ export { Header } from "./Header"
export { OptionStrip } from "./OptionStrip" export { OptionStrip } from "./OptionStrip"
export { BubbleLoader } from "./BubbleLoader" export { BubbleLoader } from "./BubbleLoader"
export { ProgressBar } from "./ProgressBar" export { ProgressBar } from "./ProgressBar"
export { PhotoPanel } from "./PhotoPanel"
export { Geolocation } from "./Geolocation" export { Geolocation } from "./Geolocation"
export { BoundSwitch } from "./BoundSwitch" export { BoundSwitch } from "./BoundSwitch"
export { BoundInput } from "./BoundInput" export { BoundInput } from "./BoundInput"
export { FormStaticInput } from "./FormStaticInput" export { FormStaticInput } from "./FormStaticInput"
export { FormStaticPhotoPanel } from "./FormStaticPhotoPanel"
export { FormStaticOptionStrip } from "./FormStaticOptionStrip"
export { BoundButton } from "./BoundButton" export { BoundButton } from "./BoundButton"
export { BoundOptionStrip } from "./BoundOptionStrip" export { BoundOptionStrip } from "./BoundOptionStrip"
export { BoundHeader } from "./BoundHeader" export { BoundHeader } from "./BoundHeader"

View File

@@ -1,6 +1,6 @@
export const versionInfo = { export const versionInfo = {
version: '1.1.2', version: '1.2.1',
fullVersion: '1.1.2-20180529.0', fullVersion: '1.2.1-20180531.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',

View File

@@ -1,6 +1,6 @@
{ {
"name": "deighton-ar", "name": "deighton-ar",
"version": "1.1.2", "version": "1.2.1",
"description": "Deighton AR Training System", "description": "Deighton AR Training System",
"main": "index.js", "main": "index.js",
"repository": { "repository": {

View File

@@ -12,7 +12,7 @@ server {
# Any route that starts with /api/ is for the backend # Any route that starts with /api/ is for the backend
location /api/ { location /api/ {
error_page 502 503 $scheme://$server_name/500.json; error_page 502 503 504 $scheme://$server_name/500.json;
proxy_pass http://127.0.0.1:3006/; proxy_pass http://127.0.0.1:3006/;
proxy_buffering off; proxy_buffering off;

View File

@@ -6,7 +6,11 @@ import { catchAll, TeamRoutes, BaseRoutes } from "."
@autobind @autobind
export class ActivityRoutes extends BaseRoutes { export class ActivityRoutes extends BaseRoutes {
constructor(container) { constructor(container) {
super(container, container.db.Activity) super({
container,
model: container.db.Activity,
nonAdmin: { listItems: true, createItem: true, getItem: true },
})
const app = container.app const app = container.app
@@ -19,6 +23,12 @@ export class ActivityRoutes extends BaseRoutes {
} }
async deleteAllActivities(req, res, next) { async deleteAllActivities(req, res, next) {
const isAdmin = !!req.user.administrator
if (!isAdmin) {
throw createError.Forbidden()
}
const Activity = this.db.Activity const Activity = this.db.Activity
const Team = this.db.Team const Team = this.db.Team

View File

@@ -3,14 +3,23 @@ import createError from "http-errors"
import autobind from "autobind-decorator" import autobind from "autobind-decorator"
import { catchAll } from "." import { catchAll } from "."
// The list of functions you can list in options.nonAdmin is:
//
// listItems
// createItem
// updateItem
// getItem
// deleteItem
@autobind @autobind
export class BaseRoutes { export class BaseRoutes {
constructor(container, model) { constructor(options) {
this.model = model const { container } = options
this.options = options
this.log = container.log this.log = container.log
this.db = container.db this.db = container.db
const basePath = "/" + model.collection.collectionName const basePath = "/" + options.model.collection.collectionName
const app = container.app const app = container.app
app app
@@ -41,7 +50,13 @@ export class BaseRoutes {
} }
async listItems(req, res, next) { async listItems(req, res, next) {
const ItemModel = this.model const isAdmin = !!req.user.administrator
if (!this.options.nonAdmin.listItems && !isAdmin) {
throw createError.Forbidden()
}
const ItemModel = this.options.model
const limit = req.query.limit || 20 const limit = req.query.limit || 20
const skip = req.query.skip || 0 const skip = req.query.skip || 0
const partial = !!req.query.partial const partial = !!req.query.partial
@@ -74,14 +89,14 @@ export class BaseRoutes {
}) })
} }
async createItem(req, res, next) { async createItem(req, res) {
const isAdmin = req.user.administrator const isAdmin = !!req.user.administrator
if (!isAdmin) { if (!this.options.nonAdmin.createItem && !isAdmin) {
return new createError.Forbidden() throw createError.Forbidden()
} }
const ItemModel = this.model const ItemModel = this.options.model
let item = new ItemModel(req.body) let item = new ItemModel(req.body)
const newItem = await item.save() const newItem = await item.save()
@@ -89,11 +104,11 @@ export class BaseRoutes {
res.json(newItem.toClient()) res.json(newItem.toClient())
} }
async updateItem(req, res, next) { async updateItem(req, res) {
const isAdmin = req.user.administrator const isAdmin = !!req.user.administrator
if (!isAdmin) { if (!this.options.nonAdmin.updateItem && !isAdmin) {
return new createError.Forbidden() throw createError.Forbidden()
} }
// Do this here because Mongoose will add it automatically otherwise // Do this here because Mongoose will add it automatically otherwise
@@ -101,11 +116,11 @@ export class BaseRoutes {
throw createError.BadRequest("No _id given in body") throw createError.BadRequest("No _id given in body")
} }
let ItemModel = this.model let ItemModel = this.options.model
let item = await ItemModel.findById(req.body._id) let item = await ItemModel.findById(req.body._id)
if (!item) { if (!item) {
return next(createError.NotFound(`Item with _id ${_id} was not found`)) throw createError.NotFound(`Item with _id ${_id} was not found`)
} }
item.merge(new ItemModel(req.body)) item.merge(new ItemModel(req.body))
@@ -115,8 +130,14 @@ export class BaseRoutes {
res.json(savedItem.toClient()) res.json(savedItem.toClient())
} }
async getItem(req, res, next) { async getItem(req, res) {
const ItemModel = this.model const isAdmin = !!req.user.administrator
if (!this.options.nonAdmin.getItem && !isAdmin) {
throw createError.Forbidden()
}
const ItemModel = this.options.model
const _id = req.params._id const _id = req.params._id
const item = await ItemModel.findById(_id) const item = await ItemModel.findById(_id)
@@ -127,14 +148,14 @@ export class BaseRoutes {
res.json(item.toClient()) res.json(item.toClient())
} }
async deleteItem(req, res, next) { async deleteItem(req, res) {
const isAdmin = req.user.administrator const isAdmin = !!req.user.administrator
if (!isAdmin) { if (!this.options.nonAdmin.deleteItem && !isAdmin) {
return new createError.Forbidden() throw createError.Forbidden()
} }
const ItemModel = this.model const ItemModel = this.options.model
const _id = req.params._id const _id = req.params._id
const item = await ItemModel.remove({ _id }) const item = await ItemModel.remove({ _id })

View File

@@ -8,7 +8,11 @@ import { catchAll, BaseRoutes } from "."
@autobind @autobind
export class TeamRoutes extends BaseRoutes { export class TeamRoutes extends BaseRoutes {
constructor(container) { constructor(container) {
super(container, container.db.Team) super({
container,
model: container.db.Team,
nonAdmin: { listItems: true, getItem: true },
})
container.app container.app
.route("/teams/status") .route("/teams/status")
@@ -19,6 +23,12 @@ export class TeamRoutes extends BaseRoutes {
} }
async getTeamStatus(req, res, next) { async getTeamStatus(req, res, next) {
const isAdmin = !!req.user.administrator
if (!isAdmin) {
throw createError.Forbidden()
}
const Team = this.db.Team const Team = this.db.Team
const Activity = this.db.Activity const Activity = this.db.Activity
let teams = await Team.find({}).exec() let teams = await Team.find({}).exec()

View File

@@ -7,7 +7,11 @@ import { catchAll, BaseRoutes } from "."
@autobind @autobind
export class WorkItemRoutes extends BaseRoutes { export class WorkItemRoutes extends BaseRoutes {
constructor(container) { constructor(container) {
super(container, container.db.WorkItem) super({
container,
model: container.db.WorkItem,
nonAdmin: { listItems: true, getItem: true },
})
const app = container.app const app = container.app
app app
@@ -63,6 +67,12 @@ export class WorkItemRoutes extends BaseRoutes {
} }
async deleteAllWorkItems(req, res, next) { async deleteAllWorkItems(req, res, next) {
const isAdmin = !!req.user.administrator
if (!isAdmin) {
throw createError.Forbidden()
}
const Activity = this.db.Activity const Activity = this.db.Activity
const WorkItem = this.db.WorkItem const WorkItem = this.db.WorkItem
const Team = this.db.Team const Team = this.db.Team

View File

@@ -1,6 +1,6 @@
export const versionInfo = { export const versionInfo = {
version: '1.1.2', version: '1.2.1',
fullVersion: '1.1.2-20180529.0', fullVersion: '1.2.1-20180531.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',

View File

@@ -15,11 +15,11 @@
buildFormat: "full", buildFormat: "full",
tags: { tags: {
major: 1, major: 1,
minor: 1, minor: 2,
patch: 2, patch: 1,
build: 20180529, build: 20180531,
revision: 0, revision: 0,
sequence: 8, sequence: 11,
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.",

View File

@@ -13,7 +13,6 @@ import { Home } from "./Home"
import { Profile } from "./Profile" import { Profile } from "./Profile"
import { Users } from "./Users" import { Users } from "./Users"
import { Teams } from "./Teams" import { Teams } from "./Teams"
import { System } from "./System"
import { Header, Column, Footer } from "ui" import { Header, Column, Footer } from "ui"
import { BrowserRouter, Route, Switch } from "react-router-dom" import { BrowserRouter, Route, Switch } from "react-router-dom"
import { sizeInfo } from "ui/style" import { sizeInfo } from "ui/style"
@@ -84,12 +83,6 @@ export class App extends Component {
/> />
<ProtectedRoute exact admin path="/admin/home" component={Home} /> <ProtectedRoute exact admin path="/admin/home" component={Home} />
<ProtectedRoute exact admin path="/admin/teams" component={Teams} /> <ProtectedRoute exact admin path="/admin/teams" component={Teams} />
<ProtectedRoute
exact
admin
path="/admin/system"
component={System}
/>
<ProtectedRoute exact admin path="/admin/users" component={Users} /> <ProtectedRoute exact admin path="/admin/users" component={Users} />
<DefaultRoute user="/user/profile" admin="/admin/home" /> <DefaultRoute user="/user/profile" admin="/admin/home" />
</Switch> </Switch>

View File

@@ -1,47 +1,217 @@
import React, { Component, Fragment } from "react" import React, { Component, Fragment } from "react"
import PropTypes from "prop-types" import PropTypes from "prop-types"
import { Row, Column, PanelButton } from "ui" import { Box, Image, Column, Row, Button, Link } from "ui"
import { sizeInfo } from "ui/style" import { MessageModal, WaitModal, YesNoMessageModal } from "../Modal"
import { sizeInfo, colorInfo } from "ui/style"
import headerLogo from "images/logo.png"
import autobind from "autobind-decorator"
import { api } from "../API"
export class Home extends Component { export class Home extends Component {
static propTypes = { static propTypes = {
history: PropTypes.object, changeTitle: PropTypes.func.isRequired,
}
constructor(props) {
super(props)
this.state = {
messageModal: null,
waitModal: null,
yesNoModal: null,
}
}
@autobind
handleDeleteActivities() {
this.setState({
yesNoModal: {
question:
"Are you sure you want to delete all activities in the system?",
onDismiss: this.handleDeleteActivitiesDismiss,
},
})
}
@autobind
handleDeleteActivitiesDismiss(yes) {
if (yes) {
this.setState({ waitModal: { message: "Deleting All Activities..." } })
api
.deleteAllActivities()
.then(() => {
this.setState({
waitModal: null,
messageModal: {
icon: "thumb",
message: "All logged activities have been deleted",
},
})
})
.catch((error) => {
this.setState({
waitModal: null,
messageModal: {
icon: "hand",
message: "Unable to request delete activities.",
detail: error.message,
},
})
})
}
this.setState({
yesNoModal: null,
})
}
@autobind
handleDeleteWorkItems() {
this.setState({
yesNoModal: {
question:
"Are you sure you want to delete all work items & activities in the system?",
onDismiss: this.handleDeleteWorkItemsDismiss,
},
})
}
@autobind
handleDeleteWorkItemsDismiss(yes) {
if (yes) {
this.setState({
waitModal: { message: "Deleting All Work Items & Activities..." },
})
api
.deleteAllWorkItems()
.then(() => {
this.setState({
waitModal: null,
messageModal: {
icon: "thumb",
message: "All work items and logged activities have been deleted",
},
})
})
.catch((error) => {
this.setState({
waitModal: null,
messageModal: {
icon: "hand",
message: "Unable to delete work items and activities.",
detail: error.message,
},
})
})
}
this.setState({
yesNoModal: null,
})
}
@autobind
handleMessageModalDismiss() {
this.setState({ messageModal: null })
} }
render() { render() {
const { messageModal, yesNoModal, waitModal } = this.state
return ( return (
<Fragment> <Fragment>
<Column.Item grow /> <Column.Item grow />
<Column.Item> <Column.Item>
<Row> <Row>
<Row.Item grow /> <Row.Item grow />
<Row.Item> <Row.Item width={sizeInfo.formRowSpacing} />
<PanelButton <Row.Item width={sizeInfo.modalWidth}>
icon="users" <Box
text="Users" border={{
onClick={() => this.props.history.push("/admin/users")} width: sizeInfo.headerBorderWidth,
/> color: colorInfo.headerBorder,
</Row.Item> }}
<Row.Item width={sizeInfo.panelButtonSpacing} /> radius={sizeInfo.formBoxRadius}>
<Row.Item> <Column>
<PanelButton <Column.Item minHeight={sizeInfo.formColumnSpacing} />
icon="teams" <Column.Item>
text="Teams" <Row>
onClick={() => this.props.history.push("/admin/teams")} <Row.Item grow />
/> <Row.Item>
</Row.Item> <Image
<Row.Item width={sizeInfo.panelButtonSpacing} /> source={headerLogo}
<Row.Item> width={sizeInfo.loginLogoWidth}
<PanelButton />
icon="system" </Row.Item>
text="System" <Row.Item grow />
onClick={() => this.props.history.push("/admin/system")} </Row>
/> </Column.Item>
<Column.Item minHeight={sizeInfo.formColumnSpacing} />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item>
<Button
text="Delete All Activities"
width={sizeInfo.buttonWideWidth}
onClick={this.handleDeleteActivities}
/>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item minHeight={sizeInfo.formColumnSpacing} />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item>
<Button
text="Delete All Work Items"
width={sizeInfo.buttonWideWidth}
onClick={this.handleDeleteWorkItems}
/>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item minHeight={sizeInfo.formColumnSpacing} />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item>
<Link to={api.makeTeamStatusUrl()}>
Download Team Data
</Link>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item height={sizeInfo.formColumnSpacing} />
</Column>
</Box>
</Row.Item> </Row.Item>
<Row.Item grow /> <Row.Item grow />
</Row> </Row>
</Column.Item> </Column.Item>
<Column.Item grow /> <Column.Item grow>
<YesNoMessageModal
open={!!yesNoModal}
question={yesNoModal ? yesNoModal.question : ""}
onDismiss={yesNoModal && yesNoModal.onDismiss}
/>
<MessageModal
open={!!messageModal}
icon={messageModal ? messageModal.icon : ""}
message={messageModal ? messageModal.message : ""}
detail={messageModal ? messageModal.title : ""}
onDismiss={this.handleMessageModalDismiss}
/>
<WaitModal
open={!!waitModal}
message={waitModal ? waitModal.message : ""}
/>
</Column.Item>
</Fragment> </Fragment>
) )
} }

View File

@@ -1,218 +0,0 @@
import React, { Component, Fragment } from "react"
import PropTypes from "prop-types"
import { Box, Image, Column, Row, Button, Link } from "ui"
import { MessageModal, WaitModal, YesNoMessageModal } from "../Modal"
import { sizeInfo, colorInfo } from "ui/style"
import headerLogo from "images/logo.png"
import autobind from "autobind-decorator"
import { api } from "../API"
export class System extends Component {
static propTypes = {
changeTitle: PropTypes.func.isRequired,
}
constructor(props) {
super(props)
this.state = {
messageModal: null,
waitModal: null,
yesNoModal: null,
}
}
@autobind
handleDeleteActivities() {
this.setState({
yesNoModal: {
question:
"Are you sure you want to delete all activities in the system?",
onDismiss: this.handleDeleteActivitiesDismiss,
},
})
}
@autobind
handleDeleteActivitiesDismiss(yes) {
if (yes) {
this.setState({ waitModal: { message: "Deleting All Activities..." } })
api
.deleteAllActivities()
.then(() => {
this.setState({
waitModal: null,
messageModal: {
icon: "thumb",
message: "All logged activities have been deleted",
},
})
})
.catch((error) => {
this.setState({
waitModal: null,
messageModal: {
icon: "hand",
message: "Unable to request delete activities.",
detail: error.message,
},
})
})
}
this.setState({
yesNoModal: null,
})
}
@autobind
handleDeleteWorkItems() {
this.setState({
yesNoModal: {
question:
"Are you sure you want to delete all work items & activities in the system?",
onDismiss: this.handleDeleteWorkItemsDismiss,
},
})
}
@autobind
handleDeleteWorkItemsDismiss(yes) {
if (yes) {
this.setState({
waitModal: { message: "Deleting All Work Items & Activities..." },
})
api
.deleteAllWorkItems()
.then(() => {
this.setState({
waitModal: null,
messageModal: {
icon: "thumb",
message: "All work items and logged activities have been deleted",
},
})
})
.catch((error) => {
this.setState({
waitModal: null,
messageModal: {
icon: "hand",
message: "Unable to delete work items and activities.",
detail: error.message,
},
})
})
}
this.setState({
yesNoModal: null,
})
}
@autobind
handleMessageModalDismiss() {
this.setState({ messageModal: null })
}
render() {
const { messageModal, yesNoModal, waitModal } = this.state
return (
<Fragment>
<Column.Item grow />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item width={sizeInfo.formRowSpacing} />
<Row.Item width={sizeInfo.modalWidth}>
<Box
border={{
width: sizeInfo.headerBorderWidth,
color: colorInfo.headerBorder,
}}
radius={sizeInfo.formBoxRadius}>
<Column>
<Column.Item minHeight={sizeInfo.formColumnSpacing} />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item>
<Image
source={headerLogo}
width={sizeInfo.loginLogoWidth}
/>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item minHeight={sizeInfo.formColumnSpacing} />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item>
<Button
text="Delete All Activities"
width={sizeInfo.buttonWideWidth}
onClick={this.handleDeleteActivities}
/>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item minHeight={sizeInfo.formColumnSpacing} />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item>
<Button
text="Delete All Work Items"
width={sizeInfo.buttonWideWidth}
onClick={this.handleDeleteWorkItems}
/>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item minHeight={sizeInfo.formColumnSpacing} />
<Column.Item>
<Row>
<Row.Item grow />
<Row.Item>
<Link to={api.makeTeamStatusUrl()}>
Download Team Data
</Link>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item height={sizeInfo.formColumnSpacing} />
</Column>
</Box>
</Row.Item>
<Row.Item grow />
</Row>
</Column.Item>
<Column.Item grow>
<YesNoMessageModal
open={!!yesNoModal}
question={yesNoModal ? yesNoModal.question : ""}
onDismiss={yesNoModal && yesNoModal.onDismiss}
/>
<MessageModal
open={!!messageModal}
icon={messageModal ? messageModal.icon : ""}
message={messageModal ? messageModal.message : ""}
detail={messageModal ? messageModal.title : ""}
onDismiss={this.handleMessageModalDismiss}
/>
<WaitModal
open={!!waitModal}
message={waitModal ? waitModal.message : ""}
/>
</Column.Item>
</Fragment>
)
}
}

View File

@@ -1 +0,0 @@
export { System } from './System'

View File

@@ -127,6 +127,8 @@ Header.TextButton = Radium(
static style = { static style = {
display: "inline-block", display: "inline-block",
position: "relative",
top: 3,
fontSize: fontInfo.size.header, fontSize: fontInfo.size.header,
fontFamily: fontInfo.family, fontFamily: fontInfo.family,
color: fontInfo.color.normal, color: fontInfo.color.normal,

View File

@@ -31,7 +31,6 @@ export class Icon extends Component {
logout: require("./icons/logout.svg"), logout: require("./icons/logout.svg"),
profile: require("./icons/profile.svg"), profile: require("./icons/profile.svg"),
placeholder: require("./icons/placeholder.svg"), placeholder: require("./icons/placeholder.svg"),
system: require("./icons/system.svg"),
thumb: require("./icons/thumb.svg"), thumb: require("./icons/thumb.svg"),
team: require("./icons/team.svg"), team: require("./icons/team.svg"),
teams: require("./icons/teams.svg"), teams: require("./icons/teams.svg"),

View File

@@ -1,65 +0,0 @@
import Radium from 'radium'
import PropTypes from 'prop-types'
import React, { Component } from 'react'
import { Icon } from '.'
import { sizeInfo, fontInfo, colorInfo } from 'ui/style'
@Radium
export class PanelButton extends Component {
static propTypes = {
onClick: PropTypes.func,
icon: PropTypes.string.isRequired,
text: PropTypes.string.isRequired,
}
static style = {
button: {
borderWidth: sizeInfo.panelButtonBorderWidth,
borderRadius: sizeInfo.panelButtonBorderRadius,
padding: '0 0 0 0',
background: colorInfo.panelButtonBackground,
verticalAlign: 'middle',
outline: 'none',
':hover': {
background: colorInfo.panelButtonBackgroundHover,
},
':disabled': {
background: colorInfo.panelDisabledButtonBackground,
},
':active': {
borderWidth: 0,
background: colorInfo.panelButtonBackgroundActive,
}
}
}
render() {
const { onClick, icon, text } = this.props
return (
<button type='button'
style={[
PanelButton.style.button, { height: sizeInfo.panelButton, width: sizeInfo.panelButton }
]}
onClick={onClick}>
<div style={{ position: 'relative' }}>
<Icon
name={icon} size={sizeInfo.panelButtonIcon}
margin={sizeInfo.panelButtonIconMargin}
style={{ position: 'relative', top: sizeInfo.panelButtonIconOffset }} />
<span style={{
position: 'absolute',
top: sizeInfo.panelButtonTextOffset,
left: 0,
display: 'block',
fontSize: fontInfo.size.huge,
fontFamily: fontInfo.family,
color: fontInfo.color.text,
textAlign: 'center',
width: '100%',
}}>{text}</span>
</div>
</button>
)
}
}

View File

@@ -1,18 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="240px" height="240px" viewBox="0 0 240 240" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Generator: Sketch 49 (51002) - http://www.bohemiancoding.com/sketch -->
<title>system</title>
<desc>Created with Sketch.</desc>
<defs></defs>
<g id="Login" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="Home" transform="translate(-905.000000, -108.000000)" fill="#000000" fill-rule="nonzero">
<g id="System" transform="translate(870.000000, 94.000000)">
<g id="settings" transform="translate(35.000000, 14.000000)">
<path d="M101.074434,139.158895 C101.074434,140.19171 101.889968,141 102.932039,141 C103.97411,141 104.789644,140.19171 104.789644,139.158895 L104.789644,102.696028 C107.779935,101.887737 110,99.193437 110,95.9602763 C110,92.1433506 106.873786,89 102.977346,89 C99.0809061,89 96,92.1433506 96,95.9602763 C96,99.148532 98.1747573,101.842832 101.119741,102.651123 L101.119741,139.158895 L101.074434,139.158895 Z M99.6245955,95.9602763 C99.6245955,94.164076 101.119741,92.6822107 102.932039,92.6822107 C104.744337,92.6822107 106.239482,94.164076 106.239482,95.9602763 C106.239482,97.7564767 104.744337,99.238342 102.932039,99.238342 C101.119741,99.238342 99.6245955,97.7564767 99.6245955,95.9602763 Z" id="Shape"></path>
<path d="M122.954839,89 C121.916129,89 121.103226,89.8075928 121.103226,90.8395168 L121.103226,109.77308 C118.167742,110.580673 116,113.272649 116,116.458154 C116,119.643658 118.167742,122.335634 121.103226,123.143227 L121.103226,139.160483 C121.103226,140.192407 121.916129,141 122.954839,141 C123.993548,141 124.806452,140.192407 124.806452,139.160483 L124.806452,123.143227 C127.787097,122.335634 130,119.643658 130,116.413287 C130,113.182916 127.787097,110.49094 124.806452,109.683348 L124.806452,90.8395168 C124.806452,89.8075928 123.993548,89 122.954839,89 Z M126.341935,116.458154 C126.341935,118.252804 124.851613,119.733391 123.045161,119.733391 C121.23871,119.733391 119.748387,118.252804 119.748387,116.458154 C119.748387,114.663503 121.23871,113.182916 123.045161,113.182916 C124.851613,113.182916 126.341935,114.618637 126.341935,116.458154 Z" id="Shape"></path>
<path d="M142.851184,127.348877 L142.851184,90.8411054 C142.851184,89.8082902 142.03832,89 140.999661,89 C139.961001,89 139.148137,89.8082902 139.148137,90.8411054 L139.148137,127.348877 C136.167637,128.157168 134,130.851468 134,134.039724 C134,137.856649 137.115978,141 140.999661,141 C144.883343,141 147.999321,137.901554 147.999321,134.039724 C148.04448,130.851468 145.831684,128.157168 142.851184,127.348877 Z M141.04482,137.317789 C139.238456,137.317789 137.748205,135.835924 137.748205,134.039724 C137.748205,132.243523 139.238456,130.761658 141.04482,130.761658 C142.851184,130.761658 144.341434,132.243523 144.341434,134.039724 C144.341434,135.835924 142.851184,137.317789 141.04482,137.317789 Z" id="Shape"></path>
</g>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

@@ -4,7 +4,6 @@ export { Button } from "./Button"
export { FormIconButton } from "./FormIconButton" export { FormIconButton } from "./FormIconButton"
export { Header } from "./Header" export { Header } from "./Header"
export { Footer } from "./Footer" export { Footer } from "./Footer"
export { PanelButton } from "./PanelButton"
export { Checkbox } from "./Checkbox" export { Checkbox } from "./Checkbox"
export { Input } from "./Input" export { Input } from "./Input"
export { Image } from "./Image" export { Image } from "./Image"

View File

@@ -1,6 +1,6 @@
export const versionInfo = { export const versionInfo = {
version: '1.1.2', version: '1.2.1',
fullVersion: '1.1.2-20180529.0', fullVersion: '1.2.1-20180531.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',