Resolve LMS upload.

This commit is contained in:
Patrick Fic
2025-10-31 10:58:53 -07:00
parent beb1145f98
commit ffcaf5d536
5 changed files with 37 additions and 23 deletions

View File

@@ -6,7 +6,7 @@
"scheme": "imex-mobile-scheme", "scheme": "imex-mobile-scheme",
"userInterfaceStyle": "automatic", "userInterfaceStyle": "automatic",
"extra": { "extra": {
"expover": "8", "expover": "15",
"eas": { "eas": {
"projectId": "ffe01f3a-d507-4698-82cd-da1f1cad450b" "projectId": "ffe01f3a-d507-4698-82cd-da1f1cad450b"
} }

View File

@@ -66,7 +66,7 @@ function Tab({ bodyshop, currentUser, signOutStart }) {
}; };
return ( return (
<SafeAreaView style={{ flex: 1 }}> <SafeAreaView style={{ flex: 1, paddingBottom: 48 }}>
<Text variant="headlineMedium" style={styles.title}> <Text variant="headlineMedium" style={styles.title}>
{t("settings.titles.settings")} {t("settings.titles.settings")}
</Text> </Text>

View File

@@ -69,16 +69,20 @@ export function UploadProgress({
<Text variant="titleLarge" style={styles.title}> <Text variant="titleLarge" style={styles.title}>
{t("general.labels.upload")} {t("general.labels.upload")}
</Text> </Text>
<Text variant="labelLarge"> {!photoUploadProgress["Bulk"] && (
{`${t("general.labels.uploadprogress")} ${Math.round( <>
completion * 100 <Text variant="labelLarge">
)}%`} {`${t("general.labels.uploadprogress")} ${Math.round(
</Text> completion * 100
<ProgressBar )}%`}
progress={completion} </Text>
style={styles.progress} <ProgressBar
color={completion === 1 ? "green" : "blue"} progress={completion}
/> style={styles.progress}
color={completion === 1 ? "green" : "blue"}
/>
</>
)}
<Divider style={{ marginVertical: 12 }} /> <Divider style={{ marginVertical: 12 }} />
{Object.keys(photoUploadProgress).map((key) => ( {Object.keys(photoUploadProgress).map((key) => (
<View key={key} style={styles.progressItem}> <View key={key} style={styles.progressItem}>

View File

@@ -45,7 +45,7 @@ const photosReducer = (state = INITIAL_STATE, action) => {
case PhotosActionTypes.MEDIA_UPLOAD_PROGRESS_UPDATE_BULK: case PhotosActionTypes.MEDIA_UPLOAD_PROGRESS_UPDATE_BULK:
return { return {
...state, ...state,
progress: { Upload: action.payload } progress: { Upload: { fileName: "Bulk", ...action.payload } }
}; };
case PhotosActionTypes.MEDIA_UPLOAD_COMPLETED: case PhotosActionTypes.MEDIA_UPLOAD_COMPLETED:
return { return {

View File

@@ -203,15 +203,6 @@ function* uploadSinglePhoto(photo, bodyshop, index, jobid) {
function* uploadToLocalMediaServer(photos, bodyshop, jobid) { function* uploadToLocalMediaServer(photos, bodyshop, jobid) {
try { try {
const options = {
headers: {
"Content-Type": "multipart/form-data",
ims_token: bodyshop.localmediatoken,
},
onUploadProgress: (e) => {
put(mediaUploadProgressBulk({ progress: e.loaded / e.total, loaded: e.loaded, total: e.total }));
},
};
const formData = new FormData(); const formData = new FormData();
formData.append("jobid", jobid); formData.append("jobid", jobid);
@@ -227,11 +218,30 @@ function* uploadToLocalMediaServer(photos, bodyshop, jobid) {
formData.append("skip_thumbnail", true); formData.append("skip_thumbnail", true);
try { try {
const startTime = new Date();
const handleUploadProgress = (e) => {
console.log("progress", e)
store.dispatch(mediaUploadProgressBulk({ progress: e.loaded / e.total, loaded: e.loaded, total: e.total, startTime }));
};
const controller = new AbortController();
yield put(addUploadCancelTask({ assetId: "Bulk", cancelTask: () => controller.abort() }));
const imexMediaServerResponse = yield call(axios.post, const imexMediaServerResponse = yield call(axios.post,
`${bodyshop.localmediaserverhttp}/jobs/upload`, `${bodyshop.localmediaserverhttp}/jobs/upload`,
formData, formData,
options {
headers: {
"Content-Type": "multipart/form-data",
ims_token: bodyshop.localmediatoken,
},
onUploadProgress: handleUploadProgress,
signal: controller.signal
}
); );
if (imexMediaServerResponse.status !== 200) { if (imexMediaServerResponse.status !== 200) {
console.log("Error uploading documents:", JSON.stringify(imexMediaServerResponse, null, 2)); console.log("Error uploading documents:", JSON.stringify(imexMediaServerResponse, null, 2));
} else { } else {