mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-10-29 09:22:21 +00:00
[WIFI-11925] Fixed firmware upgrade result handling
Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
10
package-lock.json
generated
10
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "3.0.0(2)",
|
"version": "3.0.0(4)",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "3.0.0(2)",
|
"version": "3.0.0(4)",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chakra-ui/anatomy": "^2.1.1",
|
"@chakra-ui/anatomy": "^2.1.1",
|
||||||
@@ -10132,9 +10132,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/vite": {
|
"node_modules/vite": {
|
||||||
"version": "4.4.9",
|
"version": "4.5.1",
|
||||||
"resolved": "https://registry.npmjs.org/vite/-/vite-4.4.9.tgz",
|
"resolved": "https://registry.npmjs.org/vite/-/vite-4.5.1.tgz",
|
||||||
"integrity": "sha512-2mbUn2LlUmNASWwSCNSJ/EG2HuSRTnVNaydp6vMCm5VIqJsjMfbIWtbH2kDuwUVW5mMUKKZvGPX/rqeqVvv1XA==",
|
"integrity": "sha512-AXXFaAJ8yebyqzoNB9fu2pHoo/nWX+xZlaRwoeYUxEqBO+Zj4msE5G+BhGBll9lYEKv9Hfks52PAF2X7qDYXQA==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"esbuild": "^0.18.10",
|
"esbuild": "^0.18.10",
|
||||||
"postcss": "^8.4.27",
|
"postcss": "^8.4.27",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "3.0.0(2)",
|
"version": "3.0.0(4)",
|
||||||
"description": "",
|
"description": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "index.tsx",
|
"main": "index.tsx",
|
||||||
|
|||||||
@@ -70,25 +70,66 @@ export const useUpdateDeviceFirmware = ({ serialNumber, onClose }: { serialNumbe
|
|||||||
|
|
||||||
return useMutation(
|
return useMutation(
|
||||||
({ keepRedirector, uri, signature }: { keepRedirector: boolean; uri: string; signature?: string }) =>
|
({ keepRedirector, uri, signature }: { keepRedirector: boolean; uri: string; signature?: string }) =>
|
||||||
axiosGw.post(`device/${serialNumber}/upgrade${signature ? `?FWsignature=${signature}` : ''}`, {
|
axiosGw
|
||||||
serialNumber,
|
.post(`device/${serialNumber}/upgrade${signature ? `?FWsignature=${signature}` : ''}`, {
|
||||||
when: 0,
|
serialNumber,
|
||||||
keepRedirector,
|
when: 0,
|
||||||
uri,
|
keepRedirector,
|
||||||
signature,
|
uri,
|
||||||
}),
|
signature,
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
(response) =>
|
||||||
|
response as {
|
||||||
|
data: {
|
||||||
|
errorCode: number;
|
||||||
|
errorText: string;
|
||||||
|
status: string;
|
||||||
|
results?: {
|
||||||
|
status?: {
|
||||||
|
error?: number;
|
||||||
|
resultCode?: number;
|
||||||
|
text?: string;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
},
|
||||||
|
),
|
||||||
{
|
{
|
||||||
onSuccess: () => {
|
onSuccess: ({ data }) => {
|
||||||
toast({
|
if (data.errorCode === 0) {
|
||||||
id: `device-upgrade-success-${uuid()}`,
|
toast({
|
||||||
title: t('common.success'),
|
id: `device-upgrade-success-${uuid()}`,
|
||||||
description: t('commands.firmware_upgrade_success'),
|
title: t('common.success'),
|
||||||
status: 'success',
|
description: t('commands.firmware_upgrade_success'),
|
||||||
duration: 5000,
|
status: 'success',
|
||||||
isClosable: true,
|
duration: 5000,
|
||||||
position: 'top-right',
|
isClosable: true,
|
||||||
});
|
position: 'top-right',
|
||||||
onClose();
|
});
|
||||||
|
onClose();
|
||||||
|
} else if (data.errorCode === 1) {
|
||||||
|
toast({
|
||||||
|
id: `device-upgrade-warning-${uuid()}`,
|
||||||
|
title: 'Warning',
|
||||||
|
description: `${data?.errorText ?? 'Unknown Warning'}`,
|
||||||
|
status: 'warning',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
onClose();
|
||||||
|
} else {
|
||||||
|
toast({
|
||||||
|
id: `device-upgrade-error-${uuid()}`,
|
||||||
|
title: t('common.error'),
|
||||||
|
description: `${data?.errorText ?? 'Unknown Error'} (Code ${data.errorCode})`,
|
||||||
|
status: 'error',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
onError: (e: AxiosError) => {
|
onError: (e: AxiosError) => {
|
||||||
toast({
|
toast({
|
||||||
|
|||||||
Reference in New Issue
Block a user