Resolve LMS upload.
This commit is contained in:
2
app.json
2
app.json
@@ -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"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -69,6 +69,8 @@ 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>
|
||||||
|
{!photoUploadProgress["Bulk"] && (
|
||||||
|
<>
|
||||||
<Text variant="labelLarge">
|
<Text variant="labelLarge">
|
||||||
{`${t("general.labels.uploadprogress")} ${Math.round(
|
{`${t("general.labels.uploadprogress")} ${Math.round(
|
||||||
completion * 100
|
completion * 100
|
||||||
@@ -79,6 +81,8 @@ export function UploadProgress({
|
|||||||
style={styles.progress}
|
style={styles.progress}
|
||||||
color={completion === 1 ? "green" : "blue"}
|
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}>
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user