mirror of
https://github.com/optim-enterprises-bv/OptimCloud-gw-ui.git
synced 2025-10-28 17:02:21 +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",
|
||||
"version": "3.0.0(4)",
|
||||
"version": "3.0.0(5)",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ucentral-client",
|
||||
"version": "3.0.0(4)",
|
||||
"version": "3.0.0(5)",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@chakra-ui/anatomy": "^2.1.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "ucentral-client",
|
||||
"version": "3.0.0(4)",
|
||||
"version": "3.0.0(5)",
|
||||
"description": "",
|
||||
"private": true,
|
||||
"main": "index.tsx",
|
||||
|
||||
@@ -59,16 +59,43 @@ const _ConfigureModal = ({ serialNumber, modalProps }: ConfigureModalProps) => {
|
||||
try {
|
||||
const config = JSON.parse(newConfig);
|
||||
configure.mutate(config, {
|
||||
onSuccess: () => {
|
||||
toast({
|
||||
id: `configure-success-${serialNumber}`,
|
||||
title: t('common.success'),
|
||||
description: t('controller.configure.success'),
|
||||
status: 'success',
|
||||
duration: 5000,
|
||||
isClosable: true,
|
||||
position: 'top-right',
|
||||
});
|
||||
onSuccess: (data) => {
|
||||
if (data.errorCode === 0) {
|
||||
toast({
|
||||
id: `configure-success-${serialNumber}`,
|
||||
title: t('common.success'),
|
||||
description:
|
||||
data.status === 'pending'
|
||||
? 'Command is pending! It will execute once the device connects'
|
||||
: 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();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -174,12 +174,37 @@ export const useGetEventQueue = () => {
|
||||
};
|
||||
|
||||
const configureDevice = (serialNumber: string) => async (configuration: Record<string, unknown>) =>
|
||||
axiosGw.post<unknown>(`device/${serialNumber}/configure`, {
|
||||
when: 0,
|
||||
UUID: 1,
|
||||
serialNumber,
|
||||
configuration,
|
||||
});
|
||||
axiosGw
|
||||
.post<unknown>(`device/${serialNumber}/configure`, {
|
||||
when: 0,
|
||||
UUID: 1,
|
||||
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 }) => {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
Reference in New Issue
Block a user