mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-10-29 17:32:20 +00:00
[WIFI-13257] Fixed configure notification when command is pending
Signed-off-by: Charles <charles.bourque96@gmail.com>
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "3.0.0(4)",
|
"version": "3.0.0(5)",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "3.0.0(4)",
|
"version": "3.0.0(5)",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@chakra-ui/anatomy": "^2.1.1",
|
"@chakra-ui/anatomy": "^2.1.1",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "ucentral-client",
|
"name": "ucentral-client",
|
||||||
"version": "3.0.0(4)",
|
"version": "3.0.0(5)",
|
||||||
"description": "",
|
"description": "",
|
||||||
"private": true,
|
"private": true,
|
||||||
"main": "index.tsx",
|
"main": "index.tsx",
|
||||||
|
|||||||
@@ -59,16 +59,43 @@ const _ConfigureModal = ({ serialNumber, modalProps }: ConfigureModalProps) => {
|
|||||||
try {
|
try {
|
||||||
const config = JSON.parse(newConfig);
|
const config = JSON.parse(newConfig);
|
||||||
configure.mutate(config, {
|
configure.mutate(config, {
|
||||||
onSuccess: () => {
|
onSuccess: (data) => {
|
||||||
toast({
|
if (data.errorCode === 0) {
|
||||||
id: `configure-success-${serialNumber}`,
|
toast({
|
||||||
title: t('common.success'),
|
id: `configure-success-${serialNumber}`,
|
||||||
description: t('controller.configure.success'),
|
title: t('common.success'),
|
||||||
status: 'success',
|
description:
|
||||||
duration: 5000,
|
data.status === 'pending'
|
||||||
isClosable: true,
|
? 'Command is pending! It will execute once the device connects'
|
||||||
position: 'top-right',
|
: t('controller.configure.success'),
|
||||||
});
|
status: 'success',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
modalProps.onClose();
|
||||||
|
} else if (data.errorCode === 1) {
|
||||||
|
toast({
|
||||||
|
id: `configure-warning-${serialNumber}`,
|
||||||
|
title: 'Warning',
|
||||||
|
description: `${data?.errorText ?? 'Unknown Warning'}`,
|
||||||
|
status: 'warning',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
modalProps.onClose();
|
||||||
|
} else {
|
||||||
|
toast({
|
||||||
|
id: `config-error-${serialNumber}`,
|
||||||
|
title: t('common.error'),
|
||||||
|
description: `${data?.errorText ?? 'Unknown Error'} (Code ${data.errorCode})`,
|
||||||
|
status: 'error',
|
||||||
|
duration: 5000,
|
||||||
|
isClosable: true,
|
||||||
|
position: 'top-right',
|
||||||
|
});
|
||||||
|
}
|
||||||
modalProps.onClose();
|
modalProps.onClose();
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -174,12 +174,37 @@ export const useGetEventQueue = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const configureDevice = (serialNumber: string) => async (configuration: Record<string, unknown>) =>
|
const configureDevice = (serialNumber: string) => async (configuration: Record<string, unknown>) =>
|
||||||
axiosGw.post<unknown>(`device/${serialNumber}/configure`, {
|
axiosGw
|
||||||
when: 0,
|
.post<unknown>(`device/${serialNumber}/configure`, {
|
||||||
UUID: 1,
|
when: 0,
|
||||||
serialNumber,
|
UUID: 1,
|
||||||
configuration,
|
serialNumber,
|
||||||
});
|
configuration,
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
(res) =>
|
||||||
|
res.data as Partial<{
|
||||||
|
UUID: string;
|
||||||
|
attachFile: number;
|
||||||
|
command: string;
|
||||||
|
completed: number;
|
||||||
|
custom: number;
|
||||||
|
deferred: boolean;
|
||||||
|
details: Record<string, unknown>;
|
||||||
|
errorCode: number;
|
||||||
|
errorText: string;
|
||||||
|
executed: number;
|
||||||
|
executionTime: number;
|
||||||
|
lastTry: number;
|
||||||
|
results: Record<string, unknown>;
|
||||||
|
serialNumber: string;
|
||||||
|
status: string;
|
||||||
|
submitted: number;
|
||||||
|
submittedBy: string;
|
||||||
|
waitingForFile: number;
|
||||||
|
when: number;
|
||||||
|
}>,
|
||||||
|
);
|
||||||
|
|
||||||
export const useConfigureDevice = ({ serialNumber }: { serialNumber: string }) => {
|
export const useConfigureDevice = ({ serialNumber }: { serialNumber: string }) => {
|
||||||
const queryClient = useQueryClient();
|
const queryClient = useQueryClient();
|
||||||
|
|||||||
Reference in New Issue
Block a user