IO-760 Delete pictures in bulk & other minor fixes
This commit is contained in:
2
App.js
2
App.js
@@ -11,8 +11,6 @@ import { client } from "./graphql/client";
|
||||
import { persistor, store } from "./redux/store";
|
||||
import "./translations/i18n";
|
||||
|
||||
console.log("Environment Variables Set:", env);
|
||||
|
||||
Sentry.init({
|
||||
dsn:
|
||||
"https://8d6c3de1940a4e4f8b81cf4d2150bdea@o492140.ingest.sentry.io/5558869",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import React, { useState, useMemo } from "react";
|
||||
import React, { useMemo, useState } from "react";
|
||||
import {
|
||||
FlatList,
|
||||
Image,
|
||||
@@ -32,6 +32,8 @@ export default function JobDocumentsComponent({ job, loading, refetch }) {
|
||||
[job.documents]
|
||||
);
|
||||
|
||||
console.log("fullphotos", fullphotos);
|
||||
|
||||
return (
|
||||
<View style={{ flex: 1 }}>
|
||||
<FlatList
|
||||
@@ -40,6 +42,7 @@ export default function JobDocumentsComponent({ job, loading, refetch }) {
|
||||
}
|
||||
data={job.documents}
|
||||
numColumns={4}
|
||||
style={{ flex: 1 }}
|
||||
keyExtractor={(item) => item.id}
|
||||
renderItem={(object) => (
|
||||
<View
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import { useNavigation } from "@react-navigation/native";
|
||||
import React, { useRef } from "react";
|
||||
import React from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Animated } from "react-native";
|
||||
import { TouchableOpacity } from "react-native-gesture-handler";
|
||||
import { Button, List, Title } from "react-native-paper";
|
||||
import { connect } from "react-redux";
|
||||
import { createStructuredSelector } from "reselect";
|
||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||
import { setCameraJob, setCameraJobId } from "../../redux/app/app.actions";
|
||||
import styles from "../styles";
|
||||
|
||||
const mapStateToProps = createStructuredSelector({});
|
||||
const mapDispatchToProps = (dispatch) => ({
|
||||
@@ -20,35 +17,35 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
||||
const { t } = useTranslation();
|
||||
const navigation = useNavigation();
|
||||
const _swipeableRow = useRef(null);
|
||||
// const _swipeableRow = useRef(null);
|
||||
|
||||
const RenderRightAction = (progress, dragX) => {
|
||||
const scale = dragX.interpolate({
|
||||
inputRange: [-100, 0],
|
||||
outputRange: [0.7, 0],
|
||||
});
|
||||
// const RenderRightAction = (progress, dragX) => {
|
||||
// const scale = dragX.interpolate({
|
||||
// inputRange: [-100, 0],
|
||||
// outputRange: [0.7, 0],
|
||||
// });
|
||||
|
||||
return (
|
||||
<TouchableOpacity
|
||||
style={[styles.swipe_view, styles.swipe_view_blue]}
|
||||
onPress={() => {
|
||||
logImEXEvent("imexmobile_setcamerajobid_swipe");
|
||||
setCameraJobId(item.id);
|
||||
setCameraJob(item);
|
||||
navigation.navigate("MediaBrowserTab");
|
||||
_swipeableRow.current.close();
|
||||
}}
|
||||
>
|
||||
<Animated.View
|
||||
style={{
|
||||
transform: [{ scale }],
|
||||
}}
|
||||
>
|
||||
<Ionicons name="ios-camera" size={64} color="white" />
|
||||
</Animated.View>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
};
|
||||
// return (
|
||||
// <TouchableOpacity
|
||||
// style={[styles.swipe_view, styles.swipe_view_blue]}
|
||||
// onPress={() => {
|
||||
// logImEXEvent("imexmobile_setcamerajobid_swipe");
|
||||
// setCameraJobId(item.id);
|
||||
// setCameraJob(item);
|
||||
// navigation.navigate("MediaBrowserTab");
|
||||
// _swipeableRow.current.close();
|
||||
// }}
|
||||
// >
|
||||
// <Animated.View
|
||||
// style={{
|
||||
// transform: [{ scale }],
|
||||
// }}
|
||||
// >
|
||||
// <Ionicons name="ios-camera" size={64} color="white" />
|
||||
// </Animated.View>
|
||||
// </TouchableOpacity>
|
||||
// );
|
||||
// };
|
||||
|
||||
const onPress = () => {
|
||||
logImEXEvent("imexmobile_view_job_detail");
|
||||
@@ -59,8 +56,8 @@ export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
||||
};
|
||||
|
||||
return (
|
||||
<TouchableOpacity onPress={onPress}>
|
||||
<List.Item
|
||||
onPress={onPress}
|
||||
title={<Title>{item.ro_number || t("general.labels.na")}</Title>}
|
||||
description={`${item.ownr_fn || ""} ${item.ownr_ln || ""} ${
|
||||
item.ownr_co_nm || ""
|
||||
@@ -69,17 +66,16 @@ export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
||||
}`}
|
||||
right={({ style }) => (
|
||||
<Button
|
||||
style={style}
|
||||
style={[style, { alignSelf: "center" }]}
|
||||
onPress={() => {
|
||||
logImEXEvent("imexmobile_setcamerajobid_swipe");
|
||||
setCameraJobId(item.id);
|
||||
setCameraJob(item);
|
||||
navigation.navigate("MediaBrowserTab");
|
||||
_swipeableRow.current.close();
|
||||
}}
|
||||
>
|
||||
<Ionicons
|
||||
style={style}
|
||||
style={[style, { alignSelf: "center" }]}
|
||||
name="ios-add"
|
||||
size={32}
|
||||
color="dodgerblue"
|
||||
@@ -87,7 +83,6 @@ export function JobListItem({ setCameraJob, setCameraJobId, item }) {
|
||||
</Button>
|
||||
)}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import React from "react";
|
||||
import { Modal } from "react-native";
|
||||
import { Modal, SafeAreaView, TouchableOpacity, View } from "react-native";
|
||||
import Gallery from "react-native-image-gallery";
|
||||
|
||||
export default function MediaCacheOverlay({
|
||||
photos,
|
||||
previewVisible,
|
||||
@@ -9,7 +9,6 @@ export default function MediaCacheOverlay({
|
||||
imgIndex,
|
||||
setImgIndex,
|
||||
}) {
|
||||
console.log("photos :>> ", photos);
|
||||
return (
|
||||
<Modal
|
||||
onDismiss={() => setPreviewVisible(false)}
|
||||
@@ -17,7 +16,20 @@ export default function MediaCacheOverlay({
|
||||
visible={previewVisible}
|
||||
transparent={false}
|
||||
>
|
||||
<Gallery initialPage={imgIndex} style={{ flex: 1 }} images={photos} />
|
||||
<SafeAreaView style={{ flex: 1, backgroundColor: "black" }}>
|
||||
<Gallery initialPage={imgIndex} images={photos} />
|
||||
<TouchableOpacity
|
||||
style={{ position: "absolute" }}
|
||||
onPress={() => setPreviewVisible(false)}
|
||||
>
|
||||
<Ionicons
|
||||
name="ios-close"
|
||||
size={64}
|
||||
color="dodgerblue"
|
||||
style={{ margin: 20 }}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
</SafeAreaView>
|
||||
</Modal>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ import { Ionicons } from "@expo/vector-icons";
|
||||
import { AssetsSelector } from "expo-images-picker";
|
||||
import * as MediaLibrary from "expo-media-library";
|
||||
import _ from "lodash";
|
||||
import plimit from "p-limit";
|
||||
import React, { useCallback, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { StyleSheet, Text, View } from "react-native";
|
||||
@@ -22,7 +21,7 @@ import CameraSelectJob from "../camera-select-job/camera-select-job.component";
|
||||
import UploadDeleteSwitch from "../upload-delete-switch/upload-delete-switch.component";
|
||||
import UploadProgress from "../upload-progress/upload-progress.component";
|
||||
|
||||
const limit = plimit(2);
|
||||
//const limit = plimit(2);
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
currentUser: selectCurrentUser,
|
||||
@@ -52,50 +51,49 @@ export function ImageBrowserScreen({
|
||||
async function handleOnSuccess(uri, id) {
|
||||
console.log("Succesful upload!", uri);
|
||||
logImEXEvent("imexmobile_successful_upload");
|
||||
if (deleteAfterUpload) {
|
||||
try {
|
||||
const result = await MediaLibrary.deleteAssetsAsync([id]);
|
||||
console.log("Delete result :>> ", result);
|
||||
} catch (error) {
|
||||
console.log("Unable to delete picture.", error);
|
||||
}
|
||||
}
|
||||
setUploads((prevUploads) => _.omit(prevUploads, uri));
|
||||
}
|
||||
|
||||
const onDone = async (data) => {
|
||||
logImEXEvent("imexmobile_upload_documents", { count: data.length });
|
||||
const actions = [];
|
||||
data.forEach(function (p) {
|
||||
const ret = await Promise.all(
|
||||
data.map(async (p) => {
|
||||
let filename;
|
||||
//Appears to work for android.
|
||||
//iOS provides the filename, android doe snot.
|
||||
filename = p.filename || p.uri.split("/").pop();
|
||||
actions.push(
|
||||
limit(
|
||||
handleUpload(
|
||||
const result = await handleUpload(
|
||||
{
|
||||
//iOS provides the file name. Android does not.
|
||||
uri: p.uri,
|
||||
filename,
|
||||
mediaId: p.id,
|
||||
onError: handleOnError,
|
||||
onProgress: ({ percent }) => handleOnProgress(filename, percent),
|
||||
onSuccess: () => handleOnSuccess(filename, p.id),
|
||||
},
|
||||
{
|
||||
bodyshop: bodyshop,
|
||||
jobId:
|
||||
selectedCameraJobId !== "temp" ? selectedCameraJobId : null,
|
||||
jobId: selectedCameraJobId !== "temp" ? selectedCameraJobId : null,
|
||||
uploaded_by: currentUser.email,
|
||||
photo: p,
|
||||
}
|
||||
)
|
||||
)
|
||||
);
|
||||
});
|
||||
await Promise.all(actions);
|
||||
return result;
|
||||
})
|
||||
);
|
||||
|
||||
if (deleteAfterUpload) {
|
||||
try {
|
||||
const result = await MediaLibrary.deleteAssetsAsync(
|
||||
ret.map((r) => r.mediaId)
|
||||
);
|
||||
console.log("Delete result :>> ", result);
|
||||
} catch (error) {
|
||||
console.log("Unable to delete picture.", error);
|
||||
}
|
||||
}
|
||||
forceRerender();
|
||||
//navigation.goBack();
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { Ionicons } from "@expo/vector-icons";
|
||||
import _ from "lodash";
|
||||
import React, { useMemo } from "react";
|
||||
import {
|
||||
ScrollView,
|
||||
@@ -8,7 +9,6 @@ import {
|
||||
View,
|
||||
} from "react-native";
|
||||
import * as Progress from "react-native-progress";
|
||||
import _ from "lodash";
|
||||
export default function UploadProgress({ uploads, setUploads }) {
|
||||
const uploadKeys = useMemo(() => {
|
||||
if (uploads) return Object.keys(uploads);
|
||||
@@ -46,7 +46,6 @@ export default function UploadProgress({ uploads, setUploads }) {
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
display: "flex",
|
||||
//flex: 1,
|
||||
},
|
||||
progressItem: {
|
||||
display: "flex",
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
//GQL Imports
|
||||
import {
|
||||
ApolloClient,
|
||||
from,
|
||||
HttpLink,
|
||||
InMemoryCache,
|
||||
split,
|
||||
ApolloLink,
|
||||
HttpLink,
|
||||
from,
|
||||
} from "@apollo/client";
|
||||
import { setContext } from "@apollo/client/link/context";
|
||||
import { onError } from "@apollo/client/link/error";
|
||||
import { RetryLink } from "@apollo/client/link/retry";
|
||||
import { WebSocketLink } from "@apollo/client/link/ws";
|
||||
import { SubscriptionClient } from "subscriptions-transport-ws";
|
||||
import { auth } from "../firebase/firebase.utils";
|
||||
import { onError } from "@apollo/client/link/error";
|
||||
import { getMainDefinition } from "@apollo/client/utilities";
|
||||
import { auth } from "../firebase/firebase.utils";
|
||||
|
||||
const httpLink = new HttpLink({
|
||||
// uri: "https://bodyshop-dev-db.herokuapp.com/v1/graphql",
|
||||
@@ -53,7 +51,6 @@ const errorLink = onError(
|
||||
);
|
||||
if (networkError)
|
||||
console.error(`[Network error]: ${JSON.stringify(networkError)}`);
|
||||
console.log(operation.getContext());
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
11
package-lock.json
generated
11
package-lock.json
generated
@@ -42,7 +42,7 @@
|
||||
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz",
|
||||
"react-native-easy-grid": "^0.2.2",
|
||||
"react-native-gesture-handler": "~1.8.0",
|
||||
"react-native-image-gallery": "^2.1.5",
|
||||
"react-native-image-gallery": "meliorence/react-native-image-gallery#pull/152/head",
|
||||
"react-native-indicators": "^0.17.0",
|
||||
"react-native-pager-view": "^5.1.0",
|
||||
"react-native-paper": "^4.7.2",
|
||||
@@ -13074,8 +13074,8 @@
|
||||
},
|
||||
"node_modules/react-native-image-gallery": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/react-native-image-gallery/-/react-native-image-gallery-2.1.5.tgz",
|
||||
"integrity": "sha512-xC7nuPu4GUH0da6byofQ10LjtqlKj+VaLc0NHBJmeMHVvdvmRvFEO6UOq0Q0m/ePx3OQiPTNwGbf5BSPJEKa0w==",
|
||||
"resolved": "git+ssh://git@github.com/meliorence/react-native-image-gallery.git#06c9564e0f9978b1ed20306c8b1c7131620dcdeb",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"prop-types": "^15.6.0",
|
||||
"react-mixin": "^3.0.5",
|
||||
@@ -25332,9 +25332,8 @@
|
||||
}
|
||||
},
|
||||
"react-native-image-gallery": {
|
||||
"version": "2.1.5",
|
||||
"resolved": "https://registry.npmjs.org/react-native-image-gallery/-/react-native-image-gallery-2.1.5.tgz",
|
||||
"integrity": "sha512-xC7nuPu4GUH0da6byofQ10LjtqlKj+VaLc0NHBJmeMHVvdvmRvFEO6UOq0Q0m/ePx3OQiPTNwGbf5BSPJEKa0w==",
|
||||
"version": "git+ssh://git@github.com/meliorence/react-native-image-gallery.git#06c9564e0f9978b1ed20306c8b1c7131620dcdeb",
|
||||
"from": "react-native-image-gallery@meliorence/react-native-image-gallery#pull/152/head",
|
||||
"requires": {
|
||||
"prop-types": "^15.6.0",
|
||||
"react-mixin": "^3.0.5",
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
"react-native": "https://github.com/expo/react-native/archive/sdk-40.0.0.tar.gz",
|
||||
"react-native-easy-grid": "^0.2.2",
|
||||
"react-native-gesture-handler": "~1.8.0",
|
||||
"react-native-image-gallery": "^2.1.5",
|
||||
"react-native-image-gallery": "meliorence/react-native-image-gallery#pull/152/head",
|
||||
"react-native-indicators": "^0.17.0",
|
||||
"react-native-pager-view": "^5.1.0",
|
||||
"react-native-paper": "^4.7.2",
|
||||
|
||||
@@ -10,7 +10,7 @@ var cleanAxios = axios.create();
|
||||
cleanAxios.interceptors.request.eject(axiosAuthInterceptorId);
|
||||
|
||||
export const handleUpload = async (ev, context) => {
|
||||
const { uri, filename, onError, onSuccess, onProgress } = ev;
|
||||
const { uri, filename, mediaId, onError, onSuccess, onProgress } = ev;
|
||||
const { bodyshop, jobId } = context;
|
||||
|
||||
const newFile = await (await fetch(uri)).blob();
|
||||
@@ -20,8 +20,9 @@ export const handleUpload = async (ev, context) => {
|
||||
/\.[^/.]+$/,
|
||||
""
|
||||
)}`;
|
||||
return uploadToCloudinary(
|
||||
const res = await uploadToCloudinary(
|
||||
key,
|
||||
mediaId,
|
||||
extension,
|
||||
newFile.type,
|
||||
newFile,
|
||||
@@ -30,10 +31,12 @@ export const handleUpload = async (ev, context) => {
|
||||
onProgress,
|
||||
context
|
||||
);
|
||||
return res;
|
||||
};
|
||||
|
||||
export const uploadToCloudinary = async (
|
||||
key,
|
||||
mediaId,
|
||||
extension,
|
||||
fileType,
|
||||
file,
|
||||
@@ -175,9 +178,13 @@ export const uploadToCloudinary = async (
|
||||
// message: JSON.stringify(JSON.stringify(documentInsert.errors)),
|
||||
// }),
|
||||
// });
|
||||
return { success: false, error: JSON.stringify(documentInsert.errors) };
|
||||
return {
|
||||
success: false,
|
||||
error: JSON.stringify(documentInsert.errors),
|
||||
mediaId,
|
||||
};
|
||||
}
|
||||
return { success: true };
|
||||
return { success: true, mediaId };
|
||||
};
|
||||
|
||||
export function DetermineFileType(filetype) {
|
||||
|
||||
@@ -7363,9 +7363,8 @@
|
||||
"invariant" "^2.2.4"
|
||||
"prop-types" "^15.7.2"
|
||||
|
||||
"react-native-image-gallery@^2.1.5":
|
||||
"integrity" "sha512-xC7nuPu4GUH0da6byofQ10LjtqlKj+VaLc0NHBJmeMHVvdvmRvFEO6UOq0Q0m/ePx3OQiPTNwGbf5BSPJEKa0w=="
|
||||
"resolved" "https://registry.npmjs.org/react-native-image-gallery/-/react-native-image-gallery-2.1.5.tgz"
|
||||
"react-native-image-gallery@meliorence/react-native-image-gallery#pull/152/head":
|
||||
"resolved" "git+ssh://git@github.com/meliorence/react-native-image-gallery.git#06c9564e0f9978b1ed20306c8b1c7131620dcdeb"
|
||||
"version" "2.1.5"
|
||||
dependencies:
|
||||
"prop-types" "^15.6.0"
|
||||
|
||||
Reference in New Issue
Block a user