mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
fix for cancel upload
This commit is contained in:
@@ -31,7 +31,7 @@
|
|||||||
"@types/react": "^18.2.14",
|
"@types/react": "^18.2.14",
|
||||||
"@types/react-dom": "^18.2.6",
|
"@types/react-dom": "^18.2.6",
|
||||||
"@types/react-router-dom": "^5.3.3",
|
"@types/react-router-dom": "^5.3.3",
|
||||||
"alova": "^2.8.1",
|
"alova": "^2.9.0",
|
||||||
"async-validator": "^4.2.5",
|
"async-validator": "^4.2.5",
|
||||||
"history": "^5.3.0",
|
"history": "^5.3.0",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ export const alovaInstance = createAlova({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Interceptor for request failure. This interceptor will be entered when the request is wrong.
|
// Interceptor for request failure. This interceptor will be entered when the request is wrong.
|
||||||
// TODO how best to handle http errors like 401 (unauthorized) but I think this is handled correctly in AppRouting?
|
// TODO how best to handle http errors like 401 (unauthorized)
|
||||||
|
// but I think this is handled correctly in AppRouting? See AuthenticatedRouting()
|
||||||
// onError: (error, method) => {
|
// onError: (error, method) => {
|
||||||
// alert(error.message);
|
// alert(error.message);
|
||||||
// }
|
// }
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ const UploadFileForm: FC = () => {
|
|||||||
uploading: progress,
|
uploading: progress,
|
||||||
send: sendUpload,
|
send: sendUpload,
|
||||||
onSuccess: onSuccessUpload,
|
onSuccess: onSuccessUpload,
|
||||||
abort
|
abort: cancelUpload
|
||||||
} = useRequest(SystemApi.uploadFile, {
|
} = useRequest(SystemApi.uploadFile, {
|
||||||
immediate: false,
|
immediate: false,
|
||||||
force: true
|
force: true
|
||||||
@@ -49,14 +49,14 @@ const UploadFileForm: FC = () => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const cancelUpload = () => {
|
|
||||||
console.log('aborting upload...'); // TODO remove debug
|
|
||||||
abort();
|
|
||||||
toast.warning(LL.UPLOAD() + ' ' + LL.ABORTED());
|
|
||||||
};
|
|
||||||
|
|
||||||
const startUpload = async (files: File[]) => {
|
const startUpload = async (files: File[]) => {
|
||||||
await sendUpload(files[0]);
|
await sendUpload(files[0]).catch((err) => {
|
||||||
|
if (err.message === 'The user aborted a request') {
|
||||||
|
toast.warning(LL.UPLOAD() + ' ' + LL.ABORTED());
|
||||||
|
} else {
|
||||||
|
toast.warning(err.message);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const saveFile = (json: any, endpoint: string) => {
|
const saveFile = (json: any, endpoint: string) => {
|
||||||
|
|||||||
@@ -1525,7 +1525,7 @@ __metadata:
|
|||||||
"@typescript-eslint/eslint-plugin": ^5.60.1
|
"@typescript-eslint/eslint-plugin": ^5.60.1
|
||||||
"@typescript-eslint/parser": ^5.60.1
|
"@typescript-eslint/parser": ^5.60.1
|
||||||
"@vitejs/plugin-react-swc": ^3.3.2
|
"@vitejs/plugin-react-swc": ^3.3.2
|
||||||
alova: ^2.8.1
|
alova: ^2.9.0
|
||||||
async-validator: ^4.2.5
|
async-validator: ^4.2.5
|
||||||
eslint: ^8.44.0
|
eslint: ^8.44.0
|
||||||
eslint-config-airbnb: ^19.0.4
|
eslint-config-airbnb: ^19.0.4
|
||||||
@@ -1629,10 +1629,10 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"alova@npm:^2.8.1":
|
"alova@npm:^2.9.0":
|
||||||
version: 2.8.1
|
version: 2.9.0
|
||||||
resolution: "alova@npm:2.8.1"
|
resolution: "alova@npm:2.9.0"
|
||||||
checksum: 28b6ce7f45ac1d9a38b35e92db7886c3ba899cc54109f239dc590f38da9cb0ccbc650c0455b7e3f08bbd0d714e3e4fa19648342536ceae0cd8f4898f1d9f9b64
|
checksum: 397317cbc222cf732b03dc667b7540ccd1be7013d3b4940bc9e9b11657ffbbdf297a056df4203042a8554b4f9deab3e9e6d6af2e6012b69c07b63b65734d2a7e
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function progress_middleware(req, res, next) {
|
|||||||
const percentage = (progress / file_size) * 100;
|
const percentage = (progress / file_size) * 100;
|
||||||
console.log(`Progress: ${Math.round(percentage)}%`);
|
console.log(`Progress: ${Math.round(percentage)}%`);
|
||||||
// await delay(1000); // slow it down
|
// await delay(1000); // slow it down
|
||||||
delay_blocking(100); // slow it down
|
delay_blocking(200); // slow it down
|
||||||
});
|
});
|
||||||
next(); // invoke next middleware which is multer
|
next(); // invoke next middleware which is multer
|
||||||
}
|
}
|
||||||
@@ -2058,7 +2058,6 @@ rest_server.get(LIST_NETWORKS_ENDPOINT, (req, res) => {
|
|||||||
res.sendStatus(200); // waiting....
|
res.sendStatus(200); // waiting....
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// TODO should be a post as its a command?
|
|
||||||
rest_server.get(SCAN_NETWORKS_ENDPOINT, (req, res) => {
|
rest_server.get(SCAN_NETWORKS_ENDPOINT, (req, res) => {
|
||||||
console.log('start scan networks');
|
console.log('start scan networks');
|
||||||
countWifiScanPoll = 0; // stop the poll
|
countWifiScanPoll = 0; // stop the poll
|
||||||
|
|||||||
Reference in New Issue
Block a user